Skip to content

Commit

Permalink
Merge pull request #4348 from marioalexis84/draft-coordinate_input
Browse files Browse the repository at this point in the history
[0.20] [Draft] Add global mode to enter points - Fixes #4108
  • Loading branch information
yorikvanhavre committed Mar 26, 2021
2 parents 515c7de + 589cec2 commit c4a49a5
Show file tree
Hide file tree
Showing 17 changed files with 356 additions and 152 deletions.
421 changes: 292 additions & 129 deletions src/Mod/Draft/DraftGui.py

Large diffs are not rendered by default.

44 changes: 44 additions & 0 deletions src/Mod/Draft/Resources/ui/preferences-draftinterface.ui
Expand Up @@ -867,6 +867,50 @@
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QLabel" name="label_27">
<property name="text">
<string>Global</string>
</property>
</widget>
</item>
<item row="4" column="3">
<widget class="Gui::PrefLineEdit" name="lineEdit_21">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>25</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>G</string>
</property>
<property name="maxLength">
<number>1</number>
</property>
<property name="placeholderText">
<string/>
</property>
<property name="clearButtonEnabled" stdset="0">
<bool>false</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>inCommandShortcutGlobal</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Draft</cstring>
</property>
</widget>
</item>
</layout>
</item>
</layout>
Expand Down
3 changes: 0 additions & 3 deletions src/Mod/Draft/draftguitools/gui_base_original.py
Expand Up @@ -137,7 +137,6 @@ def Activated(self, name="None", noplanesetup=False, is_subtool=False):
self.ui = Gui.draftToolBar
self.featureName = name
self.ui.sourceCmd = self
self.ui.setTitle(name)
self.ui.show()
if not noplanesetup:
App.DraftWorkingPlane.setup()
Expand All @@ -146,14 +145,12 @@ def Activated(self, name="None", noplanesetup=False, is_subtool=False):
self.constrain = None
self.obj = None
self.extendedCopy = False
self.ui.setTitle(name)
self.planetrack = None
if utils.get_param("showPlaneTracker", False):
self.planetrack = trackers.PlaneTracker()
if hasattr(Gui, "Snapper"):
Gui.Snapper.setTrackers()

_log("GuiCommand: {}".format(self.featureName))
_msg("{}".format(16*"-"))
_msg("GuiCommand: {}".format(self.featureName))

Expand Down
6 changes: 4 additions & 2 deletions src/Mod/Draft/draftguitools/gui_beziers.py
Expand Up @@ -69,7 +69,8 @@ def Activated(self):
Activate the specific bezier curve tracker.
"""
super(BezCurve, self).Activated(name=translate("draft", "BezCurve"))
super(BezCurve, self).Activated(name=translate("draft", "Bezier curve"),
icon="Draft_BezCurve")
if self.doc:
self.bezcurvetrack = trackers.bezcurveTracker()

Expand Down Expand Up @@ -246,7 +247,8 @@ def Activated(self):
Activate the specific BezCurve tracker.
"""
super(CubicBezCurve, self).Activated(name=translate("draft", "CubicBezCurve"))
super(CubicBezCurve, self).Activated(name=translate("draft", "Cubic Bezier curve"),
icon="Draft_CubicBezCurve")
if self.doc:
self.bezcurvetrack = trackers.bezcurveTracker()

Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Draft/draftguitools/gui_dimensions.py
Expand Up @@ -98,7 +98,7 @@ def Activated(self):
else:
super(Dimension, self).Activated(name)
if self.ui:
self.ui.pointUi(name)
self.ui.pointUi(title=name, icon="Draft_Dimension")
self.ui.continueCmd.show()
self.ui.selectButton.show()
self.altdown = False
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Draft/draftguitools/gui_ellipses.py
Expand Up @@ -65,7 +65,7 @@ def Activated(self):
super(Ellipse, self).Activated(name)
if self.ui:
self.refpoint = None
self.ui.pointUi(name)
self.ui.pointUi(title=name, icon="Draft_Ellipse")
self.ui.extUi()
self.call = self.view.addEventCallback("SoEvent", self.action)
self.rect = trackers.rectangleTracker()
Expand Down
11 changes: 5 additions & 6 deletions src/Mod/Draft/draftguitools/gui_lines.py
Expand Up @@ -64,7 +64,7 @@ def GetResources(self):
'MenuText': QT_TRANSLATE_NOOP("Draft_Line", "Line"),
'ToolTip': QT_TRANSLATE_NOOP("Draft_Line", "Creates a 2-point line. CTRL to snap, SHIFT to constrain.")}

def Activated(self, name=translate("draft", "Line")):
def Activated(self, name=translate("draft", "Line"), icon="Draft_Line"):
"""Execute when the command is called."""
super(Line, self).Activated(name)

Expand All @@ -73,11 +73,9 @@ def Activated(self, name=translate("draft", "Line")):
self.obj = None # stores the temp shape
self.oldWP = None # stores the WP if we modify it
if self.isWire:
self.ui.wireUi(name)
self.ui.wireUi(title=name, icon=icon)
else:
self.ui.lineUi(name)
self.ui.setTitle(translate("draft", "Line"))

self.ui.lineUi(title=name, icon=icon)
if sys.version_info.major < 3:
if isinstance(self.featureName, unicode):
self.featureName = self.featureName.encode("utf8")
Expand Down Expand Up @@ -361,7 +359,8 @@ def Activated(self):
# If there was no selection or the selection was just one object
# then we proceed with the normal line creation functions,
# only this time we will be able to input more than two points
super(Wire, self).Activated(name=translate("draft", "Polyline"))
super(Wire, self).Activated(name=translate("draft", "Polyline"),
icon="Draft_Wire")


Gui.addCommand('Draft_Wire', Wire())
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Draft/draftguitools/gui_mirror.py
Expand Up @@ -84,7 +84,7 @@ def proceed(self):
self.view.removeEventCallback("SoEvent", self.call)

self.sel = Gui.Selection.getSelection()
self.ui.pointUi(self.name)
self.ui.pointUi(title=self.name, icon="Draft_Mirror")
self.ui.modUi()
self.ui.xValue.setFocus()
self.ui.xValue.selectAll()
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Draft/draftguitools/gui_move.py
Expand Up @@ -94,7 +94,7 @@ def proceed(self):
spaces=True,
noarchchild=True)
self.selected_subelements = Gui.Selection.getSelectionEx()
self.ui.lineUi(self.name)
self.ui.lineUi(self.name, icon="Draft_Move")
self.ui.modUi()
if self.copymode:
self.ui.isCopy.setChecked(True)
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Draft/draftguitools/gui_points.py
Expand Up @@ -74,7 +74,7 @@ def Activated(self):
upv)
self.point = None
if self.ui:
self.ui.pointUi()
self.ui.pointUi(icon="Draft_Point")
self.ui.continueCmd.show()
# adding 2 callback functions
self.callbackClick = self.view.addEventCallbackPivy(coin.SoMouseButtonEvent.getClassTypeId(), self.click)
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Draft/draftguitools/gui_polygons.py
Expand Up @@ -67,7 +67,7 @@ def Activated(self):
self.rad = None
self.tangents = []
self.tanpoints = []
self.ui.pointUi(name)
self.ui.pointUi(title=name, icon="Draft_Polygon")
self.ui.extUi()
self.ui.numFaces.show()
self.ui.numFacesLabel.show()
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Draft/draftguitools/gui_rectangles.py
Expand Up @@ -60,7 +60,7 @@ def Activated(self):
super(Rectangle, self).Activated(name)
if self.ui:
self.refpoint = None
self.ui.pointUi(name)
self.ui.pointUi(title=name, icon="Draft_Rectangle")
self.ui.extUi()
if utils.getParam("UsePartPrimitives", False):
self.fillstate = self.ui.hasFill.isChecked()
Expand Down
1 change: 0 additions & 1 deletion src/Mod/Draft/draftguitools/gui_rotate.py
Expand Up @@ -95,7 +95,6 @@ def proceed(self):
self.center = None
self.ui.rotateSetCenterUi()
self.ui.modUi()
self.ui.setTitle(translate("draft", "Rotate"))
self.arctrack = trackers.arcTracker()
self.call = self.view.addEventCallback("SoEvent", self.action)
_msg(translate("draft", "Pick rotation center"))
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Draft/draftguitools/gui_scale.py
Expand Up @@ -99,7 +99,7 @@ def proceed(self):
groups.get_group_contents(self.selected_objects)
self.selected_subelements = Gui.Selection.getSelectionEx()
self.refs = []
self.ui.pointUi(self.name)
self.ui.pointUi(title=self.name, icon="Draft_Scale")
self.ui.modUi()
self.ui.xValue.setFocus()
self.ui.xValue.selectAll()
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Draft/draftguitools/gui_shapestrings.py
Expand Up @@ -91,7 +91,7 @@ def Activated(self):
self.dialog = None
self.text = ''
self.ui.sourceCmd = self
self.ui.pointUi(name)
self.ui.pointUi(title=name, icon="Draft_ShapeString")
self.active = True
self.call = self.view.addEventCallback("SoEvent", self.action)
self.ssBase = None
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Draft/draftguitools/gui_splines.py
Expand Up @@ -65,7 +65,7 @@ def Activated(self):
Activate the specific BSpline tracker.
"""
super(BSpline, self).Activated(name=translate("draft", "BSpline"))
super(BSpline, self).Activated(name=translate("draft", "B-spline"), icon="Draft_BSpline")
if self.doc:
self.bsplinetrack = trackers.bsplineTracker()

Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Draft/draftguitools/gui_stretch.py
Expand Up @@ -111,7 +111,7 @@ def proceed(self):
if self.ui and self.sel:
self.step = 1
self.refpoint = None
self.ui.pointUi("Stretch")
self.ui.pointUi(title="Stretch", icon="Draft_Stretch")
self.ui.extUi()
self.call = self.view.addEventCallback("SoEvent", self.action)
self.rectracker = trackers.rectangleTracker(dotted=True,
Expand Down

0 comments on commit c4a49a5

Please sign in to comment.