| |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| """Provides GUI tools to modify dimension objects. |
| |
| For example, a tool to flip the direction of the text in the dimension |
| as the normal is sometimes not correctly calculated automatically. |
| """ |
| |
| |
| |
|
|
| |
| |
| from PySide.QtCore import QT_TRANSLATE_NOOP |
|
|
| import FreeCADGui as Gui |
| import draftutils.utils as utils |
| import draftguitools.gui_base as gui_base |
|
|
| from draftutils.translate import translate |
|
|
|
|
| class FlipDimension(gui_base.GuiCommandNeedsSelection): |
| """The Draft FlipDimension command definition. |
| |
| Flip the normal direction of the selected dimensions. |
| |
| It inherits `GuiCommandNeedsSelection` to set up the document |
| and other behavior. See this class for more information. |
| """ |
|
|
| def __init__(self): |
| super(Draft_FlipDimension, self).__init__(name=translate("draft", "Flip Dimension")) |
|
|
| def GetResources(self): |
| """Set icon, menu and tooltip.""" |
|
|
| return { |
| "Pixmap": "Draft_FlipDimension", |
| "MenuText": QT_TRANSLATE_NOOP("Draft_FlipDimension", "Flip Dimension"), |
| "ToolTip": QT_TRANSLATE_NOOP( |
| "Draft_FlipDimension", |
| "Flips the normal direction of the selected dimensions (linear, radial, angular).\nIf other objects are selected they are ignored.", |
| ), |
| } |
|
|
| def Activated(self): |
| """Execute when the command is called.""" |
| super(Draft_FlipDimension, self).Activated() |
|
|
| for o in Gui.Selection.getSelection(): |
| if utils.get_type(o) in ("Dimension", "LinearDimension", "AngularDimension"): |
| self.doc.openTransaction("Flip dimension") |
| _cmd = "App.activeDocument()." + o.Name + ".Normal" |
| _cmd += " = " |
| _cmd += "App.activeDocument()." + o.Name + ".Normal.negative()" |
| Gui.doCommand(_cmd) |
| self.doc.commitTransaction() |
| self.doc.recompute() |
|
|
|
|
| Draft_FlipDimension = FlipDimension |
| Gui.addCommand("Draft_FlipDimension", FlipDimension()) |
|
|
| |
|
|