FreeCAD-Doc/localwiki/Macro_Mouse_Cross-it.html
2018-07-19 18:47:02 -05:00

217 lines
11 KiB
HTML

<html><head><title>Macro Mouse Cross/it</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/it</h1></div>
<div id="mw-content-text" lang="it" 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="Mouse_di_precisione"><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> Mouse di precisione</span></h3>
</td></tr>
<tr>
<th class="ctOdd">Descrizione
</th></tr>
<tr>
<td class="ctEven left">Questa macro cambia la forma del mouse in una croce di precisione.
</td></tr>
<tr>
<th class="ctOdd">Autore
</th></tr>
<tr>
<td class="ctEven"><a href="https://www.freecadweb.org/wiki/index.php?title=User:Mario52" title="User:Mario52">Mario52</a>
</td></tr>
<tr>
<th class="ctOdd">Link
</th></tr>
<tr>
<td class="ctEven"><a href="https://www.freecadweb.org/wiki/index.php?title=Macros_recipes/it" title="Macros recipes/it">Esempi di macro</a><br /><a href="https://www.freecadweb.org/wiki/index.php?title=How_to_install_macros/it" title="How to install macros/it">Come installare le Macro</a><br /><a href="https://www.freecadweb.org/wiki/index.php?title=Customize_Toolbars/it" title="Customize Toolbars/it">Personalizzare la barra degli strumenti</a>
</td></tr>
<tr>
<th class="ctOdd">Versione
</th></tr>
<tr>
<td class="ctEven macro-version">00.03
</td></tr>
<tr>
<th class="ctOdd">Data ultima modifica
</th></tr>
<tr>
<td class="ctEven macro-date">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="#Mouse_di_precisione"><span class="tocnumber">1</span> <span class="toctext">Mouse di precisione</span></a></li>
<li class="toclevel-1 tocsection-1"><a href="#Descrizione"><span class="tocnumber">2</span> <span class="toctext">Descrizione</span></a></li>
<li class="toclevel-1 tocsection-2"><a href="#Utilizzo"><span class="tocnumber">3</span> <span class="toctext">Utilizzo</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="#Cursori_che_.C3.A8_possibile_usare"><span class="tocnumber">4.1</span> <span class="toctext">Cursori che è possibile usare</span></a></li>
</ul>
</li>
<li class="toclevel-1 tocsection-5"><a href="#Limiti"><span class="tocnumber">5</span> <span class="toctext">Limiti</span></a></li>
</ul>
</div>
</td></tr>
</table>
<p><br />
</p>
<h2><span class="mw-headline" id="Descrizione">Descrizione</span></h2>
<p>Questa macro cambia la forma del mouse in una croce di precisione <br />
Breve esempio di utilizzo della classe <b>ViewObserver()</b> e della procedura d'uso. <b><a href="/wiki/Code_snippets/it#Controllare_gli_eventi_del_mouse_nel_visualizzatore_3D_tramite_Python" title="Code snippets/it">SoKeyboardEvent</a></b>
</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> <div style="clear:both"></div>
<p><br />
</p>
<h2><span class="mw-headline" id="Utilizzo">Utilizzo</span></h2>
<ol><li> Premere <span style="background: #DDDDDD; border: 1px solid #888888; padding: 0px 5px 1px 5px;">C</span> per attivare la croce.</li>
<li> Premere <span style="background: #DDDDDD; border: 1px solid #888888; padding: 0px 5px 1px 5px;">A</span> per attivare la freccia.</li>
<li> Premere <span style="background: #DDDDDD; border: 1px solid #888888; padding: 0px 5px 1px 5px;">G</span> per attivare la griglia.</li>
<li> Premere <span style="background: #DDDDDD; border: 1px solid #888888; padding: 0px 5px 1px 5px;">X</span> per scorrere tutti i cursori.</li>
<li> Premere <span style="background: #DDDDDD; border: 1px solid #888888; padding: 0px 5px 1px 5px;">Q</span> per uscire dalla 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&#160;;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&amp;t=1065&amp;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="Cursori_che_.C3.A8_possibile_usare">Cursori che è possibile usare</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="Limiti">Limiti</span></h2>
<p>Il cursore può cambiare aspetto a seconda dell'ambiente di lavoro usato, quindi ripetere l'operazione. <br />
Il cursore può essere sostituito con altri cursori (es: durante l'espansione di una finestra, gli angoli...). <br />
La griglia resta permanante. <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/it&amp;oldid=239843">http://www.freecadweb.org/wiki/index.php?title=Macro_Mouse_Cross/it&amp;oldid=239843</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>