Draft: add base class for Snap commands
This commit is contained in:
@@ -5251,6 +5251,21 @@ class Draft_Arc_3Points:
|
||||
#---------------------------------------------------------------------------
|
||||
# Snap tools
|
||||
#---------------------------------------------------------------------------
|
||||
from draftguitools.gui_snaps import Draft_Snap_Lock
|
||||
from draftguitools.gui_snaps import Draft_Snap_Midpoint
|
||||
from draftguitools.gui_snaps import Draft_Snap_Perpendicular
|
||||
from draftguitools.gui_snaps import Draft_Snap_Grid
|
||||
from draftguitools.gui_snaps import Draft_Snap_Intersection
|
||||
from draftguitools.gui_snaps import Draft_Snap_Parallel
|
||||
from draftguitools.gui_snaps import Draft_Snap_Endpoint
|
||||
from draftguitools.gui_snaps import Draft_Snap_Angle
|
||||
from draftguitools.gui_snaps import Draft_Snap_Center
|
||||
from draftguitools.gui_snaps import Draft_Snap_Extension
|
||||
from draftguitools.gui_snaps import Draft_Snap_Near
|
||||
from draftguitools.gui_snaps import Draft_Snap_Ortho
|
||||
from draftguitools.gui_snaps import Draft_Snap_Special
|
||||
from draftguitools.gui_snaps import Draft_Snap_Dimensions
|
||||
from draftguitools.gui_snaps import Draft_Snap_WorkingPlane
|
||||
from draftguitools.gui_snaps import ShowSnapBar
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
@@ -31,23 +31,34 @@
|
||||
from PySide.QtCore import QT_TRANSLATE_NOOP
|
||||
|
||||
import FreeCADGui as Gui
|
||||
import draftguitools.gui_base as gui_base
|
||||
from draftutils.translate import _tr
|
||||
|
||||
|
||||
class Draft_Snap_Lock:
|
||||
"""Command to activate or deactivate all snap commands."""
|
||||
class Draft_Snap_Lock(gui_base.GuiCommandSimplest):
|
||||
"""GuiCommand for the Draft_Snap_Lock tool.
|
||||
|
||||
Activate or deactivate all snap methods at once.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
super().__init__(name=_tr("Main toggle snap"))
|
||||
|
||||
def GetResources(self):
|
||||
"""Set icon, menu and tooltip."""
|
||||
_menu = "Toggle On/Off"
|
||||
_menu = "Main snapping toggle On/Off"
|
||||
_tip = ("Activates or deactivates "
|
||||
"all snap tools at once")
|
||||
"all snap methods at once.")
|
||||
|
||||
return {'Pixmap': 'Snap_Lock',
|
||||
'Accel': "Shift+S",
|
||||
'MenuText': QT_TRANSLATE_NOOP("Draft_Snap_Lock", _menu),
|
||||
'ToolTip': QT_TRANSLATE_NOOP("Draft_Snap_Lock", _tip)}
|
||||
|
||||
def Activated(self):
|
||||
"""Execute this when the command is called."""
|
||||
"""Execute when the command is called."""
|
||||
super().Activated()
|
||||
|
||||
if hasattr(Gui, "Snapper"):
|
||||
if hasattr(Gui.Snapper, "masterbutton"):
|
||||
Gui.Snapper.masterbutton.toggle()
|
||||
@@ -56,19 +67,28 @@ class Draft_Snap_Lock:
|
||||
Gui.addCommand('Draft_Snap_Lock', Draft_Snap_Lock())
|
||||
|
||||
|
||||
class Draft_Snap_Midpoint:
|
||||
"""Command to snap to the midpoint of an edge."""
|
||||
class Draft_Snap_Midpoint(gui_base.GuiCommandSimplest):
|
||||
"""GuiCommand for the Draft_Snap_Midpoint tool.
|
||||
|
||||
Set snapping to the midpoint of an edge.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
super().__init__(name=_tr("Midpoint snap"))
|
||||
|
||||
def GetResources(self):
|
||||
"""Set icon, menu and tooltip."""
|
||||
_menu = "Midpoint"
|
||||
_tip = "Snaps to midpoints of edges"
|
||||
_tip = "Set snapping to the midpoint of an edge."
|
||||
|
||||
return {'Pixmap': 'Snap_Midpoint',
|
||||
'MenuText': QT_TRANSLATE_NOOP("Draft_Snap_Midpoint", _menu),
|
||||
'ToolTip': QT_TRANSLATE_NOOP("Draft_Snap_Midpoint", _tip)}
|
||||
|
||||
def Activated(self):
|
||||
"""Execute this when the command is called."""
|
||||
"""Execute when the command is called."""
|
||||
super().Activated()
|
||||
|
||||
if hasattr(Gui, "Snapper"):
|
||||
if hasattr(Gui.Snapper, "toolbarButtons"):
|
||||
for b in Gui.Snapper.toolbarButtons:
|
||||
@@ -79,13 +99,20 @@ class Draft_Snap_Midpoint:
|
||||
Gui.addCommand('Draft_Snap_Midpoint', Draft_Snap_Midpoint())
|
||||
|
||||
|
||||
class Draft_Snap_Perpendicular:
|
||||
"""Command to snap to perdendicular of an edge."""
|
||||
class Draft_Snap_Perpendicular(gui_base.GuiCommandSimplest):
|
||||
"""GuiCommand for the Draft_Snap_Perpendicular tool.
|
||||
|
||||
Set snapping to a direction that is perpendicular to an edge.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
super().__init__(name=_tr("Perpendicular snap"))
|
||||
|
||||
def GetResources(self):
|
||||
"""Set icon, menu and tooltip."""
|
||||
_menu = "Perpendicular"
|
||||
_tip = "Snaps to perpendicular points on edges"
|
||||
_tip = "Set snapping to a direction that is perpendicular to an edge."
|
||||
|
||||
return {'Pixmap': 'Snap_Perpendicular',
|
||||
'MenuText': QT_TRANSLATE_NOOP("Draft_Snap_Perpendicular",
|
||||
_menu),
|
||||
@@ -93,7 +120,9 @@ class Draft_Snap_Perpendicular:
|
||||
_tip)}
|
||||
|
||||
def Activated(self):
|
||||
"""Execute this when the command is called."""
|
||||
"""Execute when the command is called."""
|
||||
super().Activated()
|
||||
|
||||
if hasattr(Gui, "Snapper"):
|
||||
if hasattr(Gui.Snapper, "toolbarButtons"):
|
||||
for b in Gui.Snapper.toolbarButtons:
|
||||
@@ -104,18 +133,27 @@ class Draft_Snap_Perpendicular:
|
||||
Gui.addCommand('Draft_Snap_Perpendicular', Draft_Snap_Perpendicular())
|
||||
|
||||
|
||||
class Draft_Snap_Grid:
|
||||
"""Command to snap to the intersection of grid lines."""
|
||||
class Draft_Snap_Grid(gui_base.GuiCommandSimplest):
|
||||
"""GuiCommand for the Draft_Snap_Grid tool.
|
||||
|
||||
Set snapping to the intersection of grid lines.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
super().__init__(name=_tr("Grid snap"))
|
||||
|
||||
def GetResources(self):
|
||||
"""Set icon, menu and tooltip."""
|
||||
_tip = "Snaps to grid points"
|
||||
_tip = "Set snapping to the intersection of grid lines."
|
||||
|
||||
return {'Pixmap': 'Snap_Grid',
|
||||
'MenuText': QT_TRANSLATE_NOOP("Draft_Snap_Grid", "Grid"),
|
||||
'ToolTip': QT_TRANSLATE_NOOP("Draft_Snap_Grid", _tip)}
|
||||
|
||||
def Activated(self):
|
||||
"""Execute this when the command is called."""
|
||||
"""Execute when the command is called."""
|
||||
super().Activated()
|
||||
|
||||
if hasattr(Gui, "Snapper"):
|
||||
if hasattr(Gui.Snapper, "toolbarButtons"):
|
||||
for b in Gui.Snapper.toolbarButtons:
|
||||
@@ -126,13 +164,20 @@ class Draft_Snap_Grid:
|
||||
Gui.addCommand('Draft_Snap_Grid', Draft_Snap_Grid())
|
||||
|
||||
|
||||
class Draft_Snap_Intersection:
|
||||
"""Command to snap to the intersection of two edges."""
|
||||
class Draft_Snap_Intersection(gui_base.GuiCommandSimplest):
|
||||
"""GuiCommand for the Draft_Snap_Intersection tool.
|
||||
|
||||
Set snapping to the intersection of edges.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
super().__init__(name=_tr("Intersection snap"))
|
||||
|
||||
def GetResources(self):
|
||||
"""Set icon, menu and tooltip."""
|
||||
_menu = "Intersection"
|
||||
_tip = "Snaps to edges intersections"
|
||||
_tip = "Set snapping to the intersection of edges."
|
||||
|
||||
return {'Pixmap': 'Snap_Intersection',
|
||||
'MenuText': QT_TRANSLATE_NOOP("Draft_Snap_Intersection",
|
||||
_menu),
|
||||
@@ -140,7 +185,9 @@ class Draft_Snap_Intersection:
|
||||
_tip)}
|
||||
|
||||
def Activated(self):
|
||||
"""Execute this when the command is called."""
|
||||
"""Execute when the command is called."""
|
||||
super().Activated()
|
||||
|
||||
if hasattr(Gui, "Snapper"):
|
||||
if hasattr(Gui.Snapper, "toolbarButtons"):
|
||||
for b in Gui.Snapper.toolbarButtons:
|
||||
@@ -151,19 +198,28 @@ class Draft_Snap_Intersection:
|
||||
Gui.addCommand('Draft_Snap_Intersection', Draft_Snap_Intersection())
|
||||
|
||||
|
||||
class Draft_Snap_Parallel:
|
||||
"""Command to snap to the parallel of an edge."""
|
||||
class Draft_Snap_Parallel(gui_base.GuiCommandSimplest):
|
||||
"""GuiCommand for the Draft_Snap_Parallel tool.
|
||||
|
||||
Set snapping to a direction that is parallel to an edge.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
super().__init__(name=_tr("Parallel snap"))
|
||||
|
||||
def GetResources(self):
|
||||
"""Set icon, menu and tooltip."""
|
||||
_menu = "Parallel"
|
||||
_tip = "Snaps to parallel directions of edges"
|
||||
_tip = "Set snapping to a direction that is parallel to an edge."
|
||||
|
||||
return {'Pixmap': 'Snap_Parallel',
|
||||
'MenuText': QT_TRANSLATE_NOOP("Draft_Snap_Parallel", _menu),
|
||||
'ToolTip': QT_TRANSLATE_NOOP("Draft_Snap_Parallel", _tip)}
|
||||
|
||||
def Activated(self):
|
||||
"""Execute this when the command is called."""
|
||||
"""Execute when the command is called."""
|
||||
super().Activated()
|
||||
|
||||
if hasattr(Gui, "Snapper"):
|
||||
if hasattr(Gui.Snapper, "toolbarButtons"):
|
||||
for b in Gui.Snapper.toolbarButtons:
|
||||
@@ -174,19 +230,28 @@ class Draft_Snap_Parallel:
|
||||
Gui.addCommand('Draft_Snap_Parallel', Draft_Snap_Parallel())
|
||||
|
||||
|
||||
class Draft_Snap_Endpoint:
|
||||
"""Command to snap to an endpoint of an edge."""
|
||||
class Draft_Snap_Endpoint(gui_base.GuiCommandSimplest):
|
||||
"""GuiCommand for the Draft_Snap_Endpoint tool.
|
||||
|
||||
Set snapping to endpoints of an edge.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
super().__init__(name=_tr("Endpoint snap"))
|
||||
|
||||
def GetResources(self):
|
||||
"""Set icon, menu and tooltip."""
|
||||
_menu = "Endpoint"
|
||||
_tip = "Snaps to endpoints of edges"
|
||||
_tip = "Set snapping to endpoints of an edge."
|
||||
|
||||
return {'Pixmap': 'Snap_Endpoint',
|
||||
'MenuText': QT_TRANSLATE_NOOP("Draft_Snap_Endpoint", _menu),
|
||||
'ToolTip': QT_TRANSLATE_NOOP("Draft_Snap_Endpoint", _tip)}
|
||||
|
||||
def Activated(self):
|
||||
"""Execute this when the command is called."""
|
||||
"""Execute when the command is called."""
|
||||
super().Activated()
|
||||
|
||||
if hasattr(Gui, "Snapper"):
|
||||
if hasattr(Gui.Snapper, "toolbarButtons"):
|
||||
for b in Gui.Snapper.toolbarButtons:
|
||||
@@ -197,18 +262,30 @@ class Draft_Snap_Endpoint:
|
||||
Gui.addCommand('Draft_Snap_Endpoint', Draft_Snap_Endpoint())
|
||||
|
||||
|
||||
class Draft_Snap_Angle:
|
||||
"""Command to snap to 90 degree angles."""
|
||||
class Draft_Snap_Angle(gui_base.GuiCommandSimplest):
|
||||
"""GuiCommand for the Draft_Snap_Angle tool.
|
||||
|
||||
Set snapping to points in a circular arc located at multiples
|
||||
of 30 and 45 degree angles.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
super().__init__(name=_tr("Angle snap (30 and 45 degrees)"))
|
||||
|
||||
def GetResources(self):
|
||||
"""Set icon, menu and tooltip."""
|
||||
_tip = "Snaps to 45 and 90 degrees points on arcs and circles"
|
||||
_menu = "Angles (30 and 45 degrees)"
|
||||
_tip = ("Set snapping to points in a circular arc located "
|
||||
"at multiples of 30 and 45 degree angles.")
|
||||
|
||||
return {'Pixmap': 'Snap_Angle',
|
||||
'MenuText': QT_TRANSLATE_NOOP("Draft_Snap_Angle", "Angles"),
|
||||
'MenuText': QT_TRANSLATE_NOOP("Draft_Snap_Angle", _menu),
|
||||
'ToolTip': QT_TRANSLATE_NOOP("Draft_Snap_Angle", _tip)}
|
||||
|
||||
def Activated(self):
|
||||
"""Execute this when the command is called."""
|
||||
"""Execute when the command is called."""
|
||||
super().Activated()
|
||||
|
||||
if hasattr(Gui, "Snapper"):
|
||||
if hasattr(Gui.Snapper, "toolbarButtons"):
|
||||
for b in Gui.Snapper.toolbarButtons:
|
||||
@@ -219,18 +296,27 @@ class Draft_Snap_Angle:
|
||||
Gui.addCommand('Draft_Snap_Angle', Draft_Snap_Angle())
|
||||
|
||||
|
||||
class Draft_Snap_Center:
|
||||
"""Command to snap to the centers of arcs and circumferences."""
|
||||
class Draft_Snap_Center(gui_base.GuiCommandSimplest):
|
||||
"""GuiCommand for the Draft_Snap_Center tool.
|
||||
|
||||
Set snapping to the center of a circular arc.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
super().__init__(name=_tr("Arc center snap"))
|
||||
|
||||
def GetResources(self):
|
||||
"""Set icon, menu and tooltip."""
|
||||
_tip = "Snaps to center of circles and arcs"
|
||||
_tip = "Set snapping to the center of a circular arc."
|
||||
|
||||
return {'Pixmap': 'Snap_Center',
|
||||
'MenuText': QT_TRANSLATE_NOOP("Draft_Snap_Center", "Center"),
|
||||
'ToolTip': QT_TRANSLATE_NOOP("Draft_Snap_Center", _tip)}
|
||||
|
||||
def Activated(self):
|
||||
"""Execute this when the command is called."""
|
||||
"""Execute when the command is called."""
|
||||
super().Activated()
|
||||
|
||||
if hasattr(Gui, "Snapper"):
|
||||
if hasattr(Gui.Snapper, "toolbarButtons"):
|
||||
for b in Gui.Snapper.toolbarButtons:
|
||||
@@ -241,19 +327,28 @@ class Draft_Snap_Center:
|
||||
Gui.addCommand('Draft_Snap_Center', Draft_Snap_Center())
|
||||
|
||||
|
||||
class Draft_Snap_Extension:
|
||||
"""Command to snap to the extension of an edge."""
|
||||
class Draft_Snap_Extension(gui_base.GuiCommandSimplest):
|
||||
"""GuiCommand for the Draft_Snap_Extension tool.
|
||||
|
||||
Set snapping to the extension of an edge.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
super().__init__(name=_tr("Edge extension snap"))
|
||||
|
||||
def GetResources(self):
|
||||
"""Set icon, menu and tooltip."""
|
||||
_menu = "Extension"
|
||||
_tip = "Snaps to extension of edges"
|
||||
_tip = "Set snapping to the extension of an edge."
|
||||
|
||||
return {'Pixmap': 'Snap_Extension',
|
||||
'MenuText': QT_TRANSLATE_NOOP("Draft_Snap_Extension", _menu),
|
||||
'ToolTip': QT_TRANSLATE_NOOP("Draft_Snap_Extension", _tip)}
|
||||
|
||||
def Activated(self):
|
||||
"""Execute this when the command is called."""
|
||||
"""Execute when the command is called."""
|
||||
super().Activated()
|
||||
|
||||
if hasattr(Gui, "Snapper"):
|
||||
if hasattr(Gui.Snapper, "toolbarButtons"):
|
||||
for b in Gui.Snapper.toolbarButtons:
|
||||
@@ -264,18 +359,27 @@ class Draft_Snap_Extension:
|
||||
Gui.addCommand('Draft_Snap_Extension', Draft_Snap_Extension())
|
||||
|
||||
|
||||
class Draft_Snap_Near:
|
||||
"""Command to snap to the nearest point of an edge."""
|
||||
class Draft_Snap_Near(gui_base.GuiCommandSimplest):
|
||||
"""GuiCommand for the Draft_Snap_Near tool.
|
||||
|
||||
Set snapping to the nearest point of an edge.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
super().__init__(name=_tr("Near snap"))
|
||||
|
||||
def GetResources(self):
|
||||
"""Set icon, menu and tooltip."""
|
||||
_tip = "Snaps to nearest point on edges"
|
||||
_tip = "Set snapping to the nearest point of an edge."
|
||||
|
||||
return {'Pixmap': 'Snap_Near',
|
||||
'MenuText': QT_TRANSLATE_NOOP("Draft_Snap_Near", "Nearest"),
|
||||
'ToolTip': QT_TRANSLATE_NOOP("Draft_Snap_Near", _tip)}
|
||||
|
||||
def Activated(self):
|
||||
"""Execute this when the command is called."""
|
||||
"""Execute when the command is called."""
|
||||
super().Activated()
|
||||
|
||||
if hasattr(Gui, "Snapper"):
|
||||
if hasattr(Gui.Snapper, "toolbarButtons"):
|
||||
for b in Gui.Snapper.toolbarButtons:
|
||||
@@ -286,18 +390,30 @@ class Draft_Snap_Near:
|
||||
Gui.addCommand('Draft_Snap_Near', Draft_Snap_Near())
|
||||
|
||||
|
||||
class Draft_Snap_Ortho:
|
||||
"""Command to snap to the orthogonal directions."""
|
||||
class Draft_Snap_Ortho(gui_base.GuiCommandSimplest):
|
||||
"""GuiCommand for the Draft_Snap_Ortho tool.
|
||||
|
||||
Set snapping to a direction that is a multiple of 45 degrees
|
||||
from a point.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
super().__init__(name=_tr("Orthogonal snap"))
|
||||
|
||||
def GetResources(self):
|
||||
"""Set icon, menu and tooltip."""
|
||||
_tip = "Snaps to orthogonal and 45 degrees directions"
|
||||
_menu = "Orthogonal angles (45 degrees)"
|
||||
_tip = ("Set snapping to a direction that is a multiple "
|
||||
"of 45 degrees from a point.")
|
||||
|
||||
return {'Pixmap': 'Snap_Ortho',
|
||||
'MenuText': QT_TRANSLATE_NOOP("Draft_Snap_Ortho", "Ortho"),
|
||||
'MenuText': QT_TRANSLATE_NOOP("Draft_Snap_Ortho", _menu),
|
||||
'ToolTip': QT_TRANSLATE_NOOP("Draft_Snap_Ortho", _tip)}
|
||||
|
||||
def Activated(self):
|
||||
"""Execute this when the command is called."""
|
||||
"""Execute when the command is called."""
|
||||
super().Activated()
|
||||
|
||||
if hasattr(Gui, "Snapper"):
|
||||
if hasattr(Gui.Snapper, "toolbarButtons"):
|
||||
for b in Gui.Snapper.toolbarButtons:
|
||||
@@ -308,19 +424,28 @@ class Draft_Snap_Ortho:
|
||||
Gui.addCommand('Draft_Snap_Ortho', Draft_Snap_Ortho())
|
||||
|
||||
|
||||
class Draft_Snap_Special:
|
||||
"""Command to snap to the special point of an object."""
|
||||
class Draft_Snap_Special(gui_base.GuiCommandSimplest):
|
||||
"""GuiCommand for the Draft_Snap_Special tool.
|
||||
|
||||
Set snapping to the special points defined inside an object.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
super().__init__(name=_tr("Special point snap"))
|
||||
|
||||
def GetResources(self):
|
||||
"""Set icon, menu and tooltip."""
|
||||
_menu = "Special"
|
||||
_tip = "Snaps to special locations of objects"
|
||||
_tip = "Set snapping to the special points defined inside an object."
|
||||
|
||||
return {'Pixmap': 'Snap_Special',
|
||||
'MenuText': QT_TRANSLATE_NOOP("Draft_Snap_Special", _menu),
|
||||
'ToolTip': QT_TRANSLATE_NOOP("Draft_Snap_Special", _tip)}
|
||||
|
||||
def Activated(self):
|
||||
"""Execute this when the command is called."""
|
||||
"""Execute when the command is called."""
|
||||
super().Activated()
|
||||
|
||||
if hasattr(Gui, "Snapper"):
|
||||
if hasattr(Gui.Snapper, "toolbarButtons"):
|
||||
for b in Gui.Snapper.toolbarButtons:
|
||||
@@ -331,19 +456,30 @@ class Draft_Snap_Special:
|
||||
Gui.addCommand('Draft_Snap_Special', Draft_Snap_Special())
|
||||
|
||||
|
||||
class Draft_Snap_Dimensions:
|
||||
"""Command to temporary show dimensions when snapping."""
|
||||
class Draft_Snap_Dimensions(gui_base.GuiCommandSimplest):
|
||||
"""GuiCommand for the Draft_Snap_Dimensions tool.
|
||||
|
||||
Show temporary linear dimensions when editing an object
|
||||
and using other snapping methods.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
super().__init__(name=_tr("Dimension display"))
|
||||
|
||||
def GetResources(self):
|
||||
"""Set icon, menu and tooltip."""
|
||||
_menu = "Dimensions"
|
||||
_tip = "Shows temporary dimensions when snapping to Arch objects"
|
||||
_menu = "Show dimensions"
|
||||
_tip = ("Show temporary linear dimensions when editing an object "
|
||||
"and using other snapping methods.")
|
||||
|
||||
return {'Pixmap': 'Snap_Dimensions',
|
||||
'MenuText': QT_TRANSLATE_NOOP("Draft_Snap_Dimensions", _menu),
|
||||
'ToolTip': QT_TRANSLATE_NOOP("Draft_Snap_Dimensions", _tip)}
|
||||
|
||||
def Activated(self):
|
||||
"""Execute this when the command is called."""
|
||||
"""Execute when the command is called."""
|
||||
super().Activated()
|
||||
|
||||
if hasattr(Gui, "Snapper"):
|
||||
if hasattr(Gui.Snapper, "toolbarButtons"):
|
||||
for b in Gui.Snapper.toolbarButtons:
|
||||
@@ -354,13 +490,28 @@ class Draft_Snap_Dimensions:
|
||||
Gui.addCommand('Draft_Snap_Dimensions', Draft_Snap_Dimensions())
|
||||
|
||||
|
||||
class Draft_Snap_WorkingPlane:
|
||||
"""Command to snap to a point in the current working plane."""
|
||||
class Draft_Snap_WorkingPlane(gui_base.GuiCommandSimplest):
|
||||
"""GuiCommand for the Draft_Snap_WorkingPlane tool.
|
||||
|
||||
Restricts snapping to a point in the current working plane.
|
||||
If you select a point outside the working plane, for example,
|
||||
by using other snapping methods, it will snap to that point's
|
||||
projection in the current working plane.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
super().__init__(name=_tr("Working plane snap"))
|
||||
|
||||
def GetResources(self):
|
||||
"""Set icon, menu and tooltip."""
|
||||
_menu = "Working plane"
|
||||
_tip = "Restricts the snapped point to the current working plane"
|
||||
_tip = ("Restricts snapping to a point in the current "
|
||||
"working plane.\n"
|
||||
"If you select a point outside the working plane, "
|
||||
"for example, by using other snapping methods,\n"
|
||||
"it will snap to that point's projection "
|
||||
"in the current working plane.")
|
||||
|
||||
return {'Pixmap': 'Snap_WorkingPlane',
|
||||
'MenuText': QT_TRANSLATE_NOOP("Draft_Snap_WorkingPlane",
|
||||
_menu),
|
||||
@@ -368,7 +519,9 @@ class Draft_Snap_WorkingPlane:
|
||||
_tip)}
|
||||
|
||||
def Activated(self):
|
||||
"""Execute this when the command is called."""
|
||||
"""Execute when the command is called."""
|
||||
super().Activated()
|
||||
|
||||
if hasattr(Gui, "Snapper"):
|
||||
if hasattr(Gui.Snapper, "toolbarButtons"):
|
||||
for b in Gui.Snapper.toolbarButtons:
|
||||
@@ -379,22 +532,29 @@ class Draft_Snap_WorkingPlane:
|
||||
Gui.addCommand('Draft_Snap_WorkingPlane', Draft_Snap_WorkingPlane())
|
||||
|
||||
|
||||
class ShowSnapBar:
|
||||
class ShowSnapBar(gui_base.GuiCommandSimplest):
|
||||
"""GuiCommand for the Draft_ShowSnapBar tool.
|
||||
|
||||
Show the snap toolbar if it's hidden.
|
||||
Show the snap toolbar if it is hidden.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
super().__init__(name=_tr("Show snap toolbar"))
|
||||
|
||||
def GetResources(self):
|
||||
"""Set icon, menu and tooltip."""
|
||||
_tip = "Show the snap toolbar if it is hidden."
|
||||
|
||||
return {'Pixmap': 'Draft_Snap',
|
||||
'MenuText': QT_TRANSLATE_NOOP("Draft_ShowSnapBar",
|
||||
"Show snap toolbar"),
|
||||
'ToolTip': QT_TRANSLATE_NOOP("Draft_ShowSnapBar",
|
||||
"Shows Draft snap toolbar.")}
|
||||
_tip)}
|
||||
|
||||
def Activated(self):
|
||||
"""Execute when the command is called."""
|
||||
super().Activated()
|
||||
|
||||
if hasattr(Gui, "Snapper"):
|
||||
Gui.Snapper.show()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user