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

217 lines
12 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<html><head><title>Macro Mouse Cross/fr</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/fr</h1></div>
<div id="mw-content-text" lang="fr" 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">Description
</th></tr>
<tr>
<td class="ctEven left">Cette macro change la forme de la souris en une croix de précision.
</td></tr>
<tr>
<th class="ctOdd">Auteur
</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">Liens
</th></tr>
<tr>
<td class="ctEven"><a href="https://www.freecadweb.org/wiki/index.php?title=Macros_recipes/fr" title="Macros recipes/fr">Recettes macros</a><br /><a href="https://www.freecadweb.org/wiki/index.php?title=How_to_install_macros/fr" title="How to install macros/fr">Comment installer une macro</a><br /><a href="https://www.freecadweb.org/wiki/index.php?title=Customize_Toolbars/fr" title="Customize Toolbars/fr">Comment ajouter une barre d'outils</a>
</td></tr>
<tr>
<th class="ctOdd">Version
</th></tr>
<tr>
<td class="ctEven macro-version">00.03
</td></tr>
<tr>
<th class="ctOdd">Date dernière modification
</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="#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="#Utilisation"><span class="tocnumber">3</span> <span class="toctext">Utilisation</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="#Les_curseurs_pouvant_.C3.AAtre_utilis.C3.A9s"><span class="tocnumber">4.1</span> <span class="toctext">Les curseurs pouvant être utilisés</span></a></li>
</ul>
</li>
<li class="toclevel-1 tocsection-5"><a href="#Limitations"><span class="tocnumber">5</span> <span class="toctext">Limitations</span></a></li>
</ul>
</div>
</td></tr>
</table>
<p><br />
</p>
<h2><span class="mw-headline" id="Description">Description</span></h2>
<p>Cette macro change la forme de la souris en une croix de précision..<br />
Petit exemple d'utilisation de la class <b>ViewObserver()</b> et de l'utilisation du clavier avec <b><a href="/wiki/Code_snippets/fr#Observation_des_.C3.A9v.C3.A8nements_de_la_souris_dans_la_vue_3D_via_Python" title="Code snippets/fr">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="Utilisation">Utilisation</span></h2>
<ol><li> Pressez la touche <span style="background: #DDDDDD; border: 1px solid #888888; padding: 0px 5px 1px 5px;">C</span> pour activer la croix.</li>
<li> Pressez la touche <span style="background: #DDDDDD; border: 1px solid #888888; padding: 0px 5px 1px 5px;">A</span> pour activer la flèche.</li>
<li> Pressez la touche <span style="background: #DDDDDD; border: 1px solid #888888; padding: 0px 5px 1px 5px;">G</span> pour activer la grille.</li>
<li> Pressez la touche <span style="background: #DDDDDD; border: 1px solid #888888; padding: 0px 5px 1px 5px;">X</span> pour visualiser tous les curseurs.</li>
<li> Pressez la touche <span style="background: #DDDDDD; border: 1px solid #888888; padding: 0px 5px 1px 5px;">Q</span> pour quitter la 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="Les_curseurs_pouvant_.C3.AAtre_utilis.C3.A9s">Les curseurs pouvant être utilisés</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="Limitations">Limitations</span></h2>
<p>Le curseur peut changer d'apparence suivant l'établi utilisé, il faut alors répéter lopération.<br />
Le curseur peut se substituer aux autre curseurs (ex: lors de l'agrandissement d'une fenêtre, coins...).<br />
La grille est permanente.<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/fr&amp;oldid=239838">http://www.freecadweb.org/wiki/index.php?title=Macro_Mouse_Cross/fr&amp;oldid=239838</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>