218 lines
11 KiB
HTML
218 lines
11 KiB
HTML
<html><head><title>Macro Mouse Cross/es</title><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><link type='text/css' href='wiki.css' rel='stylesheet'></head><body><h1>Macro Mouse Cross/es</h1></div>
|
|
|
|
<div id="mw-content-text" lang="es" dir="ltr" class="mw-content-ltr"><hr/><div class="mw-parser-output"><table class="fcinfobox wikitable ct" width="100%" style="float: right; width: 230px; margin-left: 10px;">
|
|
<tr>
|
|
<td class="ctTitle">
|
|
<h3><span class="mw-headline" id="Macro_Mouse_Cross"><a href="https://www.freecadweb.org/wiki/index.php?title=File:Text-x-python.png" class="image"><img alt="Text-x-python.png" src="32px-Text-x-python.png" width="32" height="32" srcset="/wiki/images/2/2c/Text-x-python.png 1.5x" /></a> Macro_Mouse_Cross</span></h3>
|
|
</td></tr>
|
|
<tr>
|
|
<th class="ctOdd">Descripción
|
|
</th></tr>
|
|
<tr>
|
|
<td class="ctEven left macro-description">This macro turns the arrow of the mouse in a precision cross.
|
|
</td></tr>
|
|
<tr>
|
|
<th class="ctOdd">Autor
|
|
</th></tr>
|
|
<tr>
|
|
<td class="ctEven macro-author"><a href="https://www.freecadweb.org/wiki/index.php?title=User:Mario52" title="User:Mario52">Mario52</a>
|
|
</td></tr>
|
|
<tr>
|
|
<th class="ctOdd">Vista
|
|
</th></tr>
|
|
<tr>
|
|
<td class="ctEven"><a href="https://www.freecadweb.org/wiki/index.php?title=Macros_recipes/es" title="Macros recipes/es">Macros recipes</a><br /><a href="https://www.freecadweb.org/wiki/index.php?title=How_to_install_macros/es" title="How to install macros/es">How to install macros</a><br /><a href="https://www.freecadweb.org/wiki/index.php?title=Customize_Toolbars/es" title="Customize Toolbars/es">How to customize toolbars</a>
|
|
</td></tr>
|
|
<tr>
|
|
<th class="ctOdd">Version
|
|
</th></tr>
|
|
<tr>
|
|
<td class="ctEven macro-version">00.03
|
|
</td></tr>
|
|
<tr>
|
|
<th class="ctOdd">Fecha de la última modificación
|
|
</th></tr>
|
|
<tr>
|
|
<td class="ctEven macro-version">2016-01-25
|
|
</td></tr>
|
|
<tr>
|
|
<th class="ctOdd">
|
|
</th></tr>
|
|
<tr>
|
|
<td class="ctToc"><br /><div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
|
|
<ul>
|
|
<li class="toclevel-1"><a href="#Macro_Mouse_Cross"><span class="tocnumber">1</span> <span class="toctext">Macro_Mouse_Cross</span></a></li>
|
|
<li class="toclevel-1 tocsection-1"><a href="#Description"><span class="tocnumber">2</span> <span class="toctext">Description</span></a></li>
|
|
<li class="toclevel-1 tocsection-2"><a href="#How_to_use"><span class="tocnumber">3</span> <span class="toctext">How to use</span></a></li>
|
|
<li class="toclevel-1 tocsection-3"><a href="#Script"><span class="tocnumber">4</span> <span class="toctext">Script</span></a>
|
|
<ul>
|
|
<li class="toclevel-2 tocsection-4"><a href="#Cursors_that_can_be_used"><span class="tocnumber">4.1</span> <span class="toctext">Cursors that can be used</span></a></li>
|
|
</ul>
|
|
</li>
|
|
<li class="toclevel-1 tocsection-5"><a href="#Limitation"><span class="tocnumber">5</span> <span class="toctext">Limitation</span></a></li>
|
|
</ul>
|
|
</div>
|
|
|
|
</td></tr>
|
|
</table>
|
|
<p><br />
|
|
</p>
|
|
<h2><span class="mw-headline" id="Description">Description</span></h2>
|
|
<p>This small macro turns the arrow of the mouse in a precision cross.<br />
|
|
Small example of using the class <b>ViewObserver()</b> and the use of the keyboard with <b><a href="/wiki/Code_snippets#Observing_mouse_events_in_the_3D_viewer_via_Python" title="Code snippets">SoKeyboardEvent</a></b>
|
|
</p><p><a href="https://www.freecadweb.org/wiki/index.php?title=File:Macro_Mouse_Cross_00.png" class="image" title="Macro_Mouse_Cross"><img alt="Macro_Mouse_Cross" src="480px-Macro_Mouse_Cross_00.png" width="480" height="360" srcset="/wiki/images/8/82/Macro_Mouse_Cross_00.png 1.5x" /></a>
|
|
</p>
|
|
<div style="clear:both"></div>
|
|
<p><br />
|
|
</p>
|
|
<h2><span class="mw-headline" id="How_to_use">How to use</span></h2>
|
|
<ol><li> Press the <span style="background: #DDDDDD; border: 1px solid #888888; padding: 0px 5px 1px 5px;">C</span> button to activate the cross.</li>
|
|
<li> Press the <span style="background: #DDDDDD; border: 1px solid #888888; padding: 0px 5px 1px 5px;">A</span> button to activate the arrow.</li>
|
|
<li> Press the <span style="background: #DDDDDD; border: 1px solid #888888; padding: 0px 5px 1px 5px;">G</span> button to activate the grid.</li>
|
|
<li> Press the <span style="background: #DDDDDD; border: 1px solid #888888; padding: 0px 5px 1px 5px;">X</span> button for visualise all cursor.</li>
|
|
<li> Press the <span style="background: #DDDDDD; border: 1px solid #888888; padding: 0px 5px 1px 5px;">Q</span> button to quit the macro.</li></ol>
|
|
<h2><span class="mw-headline" id="Script">Script</span></h2>
|
|
<p>Macro_Mouse_Cross.FCMacro
|
|
</p>
|
|
<pre># -*- coding: utf-8 -*-
|
|
# mouse cursor to Cross or Arrow + Grig
|
|
# ver 0.2 08/08/2014 PyQt4 and PySide
|
|
__title__ = "Macro_Mouse_Cross"
|
|
__author__ = "Mario52"
|
|
__url__ = "http://www.freecadweb.org/index-fr.html"
|
|
__version__ = "00.03"
|
|
__date__ = "25/01/2016"
|
|
|
|
try:
|
|
from PyQt4 import QtCore, QtGui
|
|
except Exception:
|
|
from PySide import QtCore, QtGui
|
|
from pivy import coin
|
|
|
|
global xx ;xx = -1
|
|
|
|
#################### create document if not exist #######################
|
|
doc = FreeCAD.ActiveDocument ####
|
|
if doc == None: ####
|
|
doc = FreeCAD.newDocument() ####
|
|
#########################################################################
|
|
class ViewObserver:
|
|
def logPosition(self, info):
|
|
global xx
|
|
self.pos = info["Key"]
|
|
if (self.pos.upper() == "Q"):
|
|
v.removeEventCallback("SoKeyboardEvent",c)
|
|
print "End Macro_Mouse_Cross"
|
|
if (self.pos.upper() == "C"):
|
|
# change the cursor cross ( + )
|
|
QtGui.QApplication.setOverrideCursor(QtGui.QCursor(QtCore.Qt.CrossCursor))
|
|
elif (self.pos.upper() == "A"):
|
|
# change the cursor in Arrow
|
|
QtGui.QApplication.setOverrideCursor(QtGui.QCursor(QtCore.Qt.ArrowCursor))
|
|
elif (self.pos.upper() == "X") and (info["State"] == "DOWN"):
|
|
# change the cursor and visualise all model
|
|
xx += 1
|
|
if xx == 0:
|
|
QtGui.QApplication.setOverrideCursor(QtGui.QCursor(QtCore.Qt.ArrowCursor))
|
|
FreeCAD.Console.PrintMessage("ArrowCursor"+"\n")
|
|
if xx == 1:
|
|
QtGui.QApplication.setOverrideCursor(QtGui.QCursor(QtCore.Qt.UpArrowCursor))
|
|
FreeCAD.Console.PrintMessage("UpArrowCursor"+"\n")
|
|
if xx == 2:
|
|
QtGui.QApplication.setOverrideCursor(QtGui.QCursor(QtCore.Qt.CrossCursor))
|
|
FreeCAD.Console.PrintMessage("CrossCursor"+"\n")
|
|
if xx == 3:
|
|
QtGui.QApplication.setOverrideCursor(QtGui.QCursor(QtCore.Qt.WaitCursor))
|
|
FreeCAD.Console.PrintMessage("WaitCursor"+"\n")
|
|
if xx == 4:
|
|
QtGui.QApplication.setOverrideCursor(QtGui.QCursor(QtCore.Qt.IBeamCursor))
|
|
FreeCAD.Console.PrintMessage("IBeamCursor"+"\n")
|
|
if xx == 5:
|
|
QtGui.QApplication.setOverrideCursor(QtGui.QCursor(QtCore.Qt.SizeVerCursor))
|
|
FreeCAD.Console.PrintMessage("SizeVerCursor"+"\n")
|
|
if xx == 6:
|
|
QtGui.QApplication.setOverrideCursor(QtGui.QCursor(QtCore.Qt.SizeHorCursor))
|
|
FreeCAD.Console.PrintMessage("SizeHorCursor"+"\n")
|
|
if xx == 7:
|
|
QtGui.QApplication.setOverrideCursor(QtGui.QCursor(QtCore.Qt.SizeBDiagCursor))
|
|
FreeCAD.Console.PrintMessage("SizeBDiagCursor"+"\n")
|
|
if xx == 8:
|
|
QtGui.QApplication.setOverrideCursor(QtGui.QCursor(QtCore.Qt.SizeFDiagCursor))
|
|
FreeCAD.Console.PrintMessage("SizeFDiagCursor"+"\n")
|
|
if xx == 9:
|
|
QtGui.QApplication.setOverrideCursor(QtGui.QCursor(QtCore.Qt.SizeAllCursor))
|
|
FreeCAD.Console.PrintMessage("SizeAllCursor"+"\n")
|
|
if xx == 10:
|
|
QtGui.QApplication.setOverrideCursor(QtGui.QCursor(QtCore.Qt.BlankCursor))
|
|
FreeCAD.Console.PrintMessage("BlankCursor"+"\n")
|
|
if xx == 11:
|
|
QtGui.QApplication.setOverrideCursor(QtGui.QCursor(QtCore.Qt.SplitVCursor))
|
|
FreeCAD.Console.PrintMessage("SplitVCursor"+"\n")
|
|
if xx == 12:
|
|
QtGui.QApplication.setOverrideCursor(QtGui.QCursor(QtCore.Qt.SplitHCursor))
|
|
FreeCAD.Console.PrintMessage("SplitHCursor"+"\n")
|
|
if xx == 13:
|
|
QtGui.QApplication.setOverrideCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
|
|
FreeCAD.Console.PrintMessage("PointingHandCursor"+"\n")
|
|
if xx == 14:
|
|
QtGui.QApplication.setOverrideCursor(QtGui.QCursor(QtCore.Qt.ForbiddenCursor))
|
|
FreeCAD.Console.PrintMessage("ForbiddenCursor"+"\n")
|
|
if xx == 15:
|
|
QtGui.QApplication.setOverrideCursor(QtGui.QCursor(QtCore.Qt.OpenHandCursor))
|
|
FreeCAD.Console.PrintMessage("OpenHandCursor"+"\n")
|
|
if xx == 16:
|
|
QtGui.QApplication.setOverrideCursor(QtGui.QCursor(QtCore.Qt.ClosedHandCursor))
|
|
FreeCAD.Console.PrintMessage("ClosedHandCursor"+"\n")
|
|
if xx == 17:
|
|
QtGui.QApplication.setOverrideCursor(QtGui.QCursor(QtCore.Qt.WhatsThisCursor))
|
|
FreeCAD.Console.PrintMessage("WhatsThisCursor"+"\n")
|
|
if xx == 18:
|
|
QtGui.QApplication.setOverrideCursor(QtGui.QCursor(QtCore.Qt.BusyCursor))
|
|
FreeCAD.Console.PrintMessage("BusyCursor"+"\n")
|
|
if xx == 19:
|
|
QtGui.QApplication.setOverrideCursor(QtGui.QCursor(QtCore.Qt.BitmapCursor))
|
|
FreeCAD.Console.PrintMessage("BitmapCursor"+"\n")
|
|
xx = -1
|
|
elif (self.pos.upper() == "G"):
|
|
# "wmayer" http://forum.freecadweb.org/viewtopic.php?f=3&t=1065&hilit=cross#p8818
|
|
# Create Grida
|
|
grid=coin.SoType.fromName("SoDrawingGrid").createInstance()
|
|
Gui.ActiveDocument.ActiveView.getSceneGraph().addChild(grid)
|
|
xx = -1
|
|
|
|
try:
|
|
v=Gui.activeDocument().activeView()
|
|
o = ViewObserver()
|
|
c = v.addEventCallback("SoKeyboardEvent",o.logPosition)
|
|
App.Console.PrintMessage("Type Key C to Cross"+"\n")
|
|
App.Console.PrintMessage("Type Key A to Arrow"+"\n")
|
|
App.Console.PrintMessage("Type Key X to Visualise all cursor"+"\n")
|
|
App.Console.PrintMessage("Type Key G to Grid (not editable)"+"\n")
|
|
App.Console.PrintMessage("Type Key Q to Quit"+"\n")
|
|
except Exception:
|
|
FreeCAD.Console.PrintError("\n"+"Not document open"+"\n") </pre>
|
|
<h3><span class="mw-headline" id="Cursors_that_can_be_used">Cursors that can be used</span></h3>
|
|
<p>ArrowCursor, UpArrowCursor, CrossCursor, WaitCursor, IBeamCursor, SizeVerCursor, SizeHorCursor
|
|
SizeBDiagCursor, SizeFDiagCursor, SizeAllCursor, BlankCursor, SplitVCursor, SplitHCursor
|
|
PointingHandCursor, ForbiddenCursor, OpenHandCursor, ClosedHandCursor, WhatsThisCursor, BusyCursor, BitmapCursor
|
|
</p>
|
|
<h2><span class="mw-headline" id="Limitation">Limitation</span></h2>
|
|
<p>The cursor can change appearance depending on the used Workbench, he must repeat the operation.<br />
|
|
The cursor can be subtituer to the other sliders (ex: expansion of a window, corner...).<br />
|
|
The grid is permanent.<br />
|
|
</p>
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div><div class="printfooter">
|
|
Online version: "<a dir="ltr" href="https://www.freecadweb.org/wiki/index.php?title=Macro_Mouse_Cross/es&oldid=239840">http://www.freecadweb.org/wiki/index.php?title=Macro_Mouse_Cross/es&oldid=239840</a>"</div>
|
|
<div id="catlinks" class="catlinks" data-mw="interface"></div><div class="visualClear"></div>
|
|
</div>
|
|
</div>
|
|
<div id="mw-navigation">
|
|
<h2>Navigation menu</h2>
|
|
|
|
</body></html> |