diff --git a/src/Mod/Draft/draftguitools/gui_arcs.py b/src/Mod/Draft/draftguitools/gui_arcs.py index eb3d5f4e6c..a7d458741f 100644 --- a/src/Mod/Draft/draftguitools/gui_arcs.py +++ b/src/Mod/Draft/draftguitools/gui_arcs.py @@ -68,7 +68,7 @@ class Arc(gui_base_original.Creator): def Activated(self): """Execute when the command is called.""" - super(Arc, self).Activated(name=self.featureName) + super().Activated(name=self.featureName) if self.ui: self.step = 0 self.center = None @@ -96,7 +96,7 @@ class Arc(gui_base_original.Creator): Restart (continue) the command if `True`, or if `None` and `ui.continueMode` is `True`. """ - super(Arc, self).finish() + super().finish() if self.ui: self.linetrack.finalize() self.arctrack.finalize() @@ -142,7 +142,6 @@ class Arc(gui_base_original.Creator): from the 3D view. """ import DraftGeomUtils - plane = App.DraftWorkingPlane if arg["Type"] == "SoKeyboardEvent": if arg["Key"] == "ESCAPE": @@ -152,7 +151,7 @@ class Arc(gui_base_original.Creator): # this is to make sure radius is what you see on screen if self.center and DraftVecUtils.dist(self.point, self.center) > 0: viewdelta = DraftVecUtils.project(self.point.sub(self.center), - plane.axis) + self.wp.axis) if not DraftVecUtils.isNull(viewdelta): self.point = self.point.add(viewdelta.negative()) if self.step == 0: # choose center @@ -210,7 +209,7 @@ class Arc(gui_base_original.Creator): elif (self.step == 2): # choose first angle currentrad = DraftVecUtils.dist(self.point, self.center) if currentrad != 0: - angle = DraftVecUtils.angle(plane.u, self.point.sub(self.center), plane.axis) + angle = DraftVecUtils.angle(self.wp.u, self.point.sub(self.center), self.wp.axis) else: angle = 0 self.linetrack.p2(DraftVecUtils.scaleTo(self.point.sub(self.center), self.rad).add(self.center)) @@ -220,7 +219,7 @@ class Arc(gui_base_original.Creator): # choose second angle currentrad = DraftVecUtils.dist(self.point, self.center) if currentrad != 0: - angle = DraftVecUtils.angle(plane.u, self.point.sub(self.center), plane.axis) + angle = DraftVecUtils.angle(self.wp.u, self.point.sub(self.center), self.wp.axis) else: angle = 0 self.linetrack.p2(DraftVecUtils.scaleTo(self.point.sub(self.center), self.rad).add(self.center)) @@ -417,7 +416,6 @@ class Arc(gui_base_original.Creator): when a valid radius has been entered in the input field. """ import DraftGeomUtils - plane = App.DraftWorkingPlane if self.step == 1: self.rad = rad @@ -455,11 +453,11 @@ class Arc(gui_base_original.Creator): self.ui.labelRadius.setText(translate("draft", "Aperture angle")) self.ui.radiusValue.setToolTip(translate("draft", "Aperture angle")) self.firstangle = math.radians(rad) - if DraftVecUtils.equals(plane.axis, App.Vector(1, 0, 0)): + if DraftVecUtils.equals(self.wp.axis, App.Vector(1, 0, 0)): u = App.Vector(0, self.rad, 0) else: - u = DraftVecUtils.scaleTo(App.Vector(1, 0, 0).cross(plane.axis), self.rad) - urotated = DraftVecUtils.rotate(u, math.radians(rad), plane.axis) + u = DraftVecUtils.scaleTo(App.Vector(1, 0, 0).cross(self.wp.axis), self.rad) + urotated = DraftVecUtils.rotate(u, math.radians(rad), self.wp.axis) self.arctrack.setStartAngle(self.firstangle) self.step = 3 self.ui.radiusValue.setText("") @@ -479,7 +477,7 @@ class Arc_3Points(gui_base.GuiCommandSimplest): """GuiCommand for the Draft_Arc_3Points tool.""" def __init__(self): - super(Arc_3Points, self).__init__(name="Arc by 3 points") + super().__init__(name="Arc by 3 points") def GetResources(self): """Set icon, menu and tooltip.""" @@ -490,7 +488,7 @@ class Arc_3Points(gui_base.GuiCommandSimplest): def Activated(self): """Execute when the command is called.""" - super(Arc_3Points, self).Activated() + super().Activated() # Reset the values self.points = [] diff --git a/src/Mod/Draft/draftguitools/gui_dimensions.py b/src/Mod/Draft/draftguitools/gui_dimensions.py index 4d23082fe0..dd0f8e5891 100644 --- a/src/Mod/Draft/draftguitools/gui_dimensions.py +++ b/src/Mod/Draft/draftguitools/gui_dimensions.py @@ -90,13 +90,13 @@ class Dimension(gui_base_original.Creator): if self.cont: self.finish() elif self.selected_app_measure(): - super(Dimension, self).Activated(name="Dimension") + super().Activated(name="Dimension") self.dimtrack = trackers.dimTracker() self.arctrack = trackers.arcTracker() self.create_with_app_measure() self.finish() else: - super(Dimension, self).Activated(name="Dimension") + super().Activated(name="Dimension") if self.ui: self.ui.pointUi(title=translate("draft", "Dimension"), icon="Draft_Dimension") self.ui.continueCmd.show() @@ -176,7 +176,7 @@ class Dimension(gui_base_original.Creator): """Terminate the operation.""" self.cont = None self.dir = None - super(Dimension, self).finish() + super().finish() if self.ui: self.dimtrack.finalize() self.arctrack.finalize() @@ -184,7 +184,7 @@ class Dimension(gui_base_original.Creator): def angle_dimension_normal(self, edge1, edge2): rot = App.Rotation(DraftGeomUtils.vec(edge1), DraftGeomUtils.vec(edge2), - App.DraftWorkingPlane.getNormal(), + self.wp.axis, "XYZ") norm = rot.multVec(App.Vector(0, 0, 1)) vnorm = gui_utils.get_3d_view().getViewDirection() @@ -280,9 +280,8 @@ class Dimension(gui_base_original.Creator): _cmd += ')' _cmd_list = ['_dim_ = ' + _cmd] - plane = App.DraftWorkingPlane - dir_u = DraftVecUtils.toString(plane.u) - dir_v = DraftVecUtils.toString(plane.v) + dir_u = DraftVecUtils.toString(self.wp.u) + dir_v = DraftVecUtils.toString(self.wp.v) if direction == "X": _cmd_list += ['_dim_.Direction = ' + dir_u] elif direction == "Y": @@ -581,28 +580,27 @@ class Dimension(gui_base_original.Creator): by projecting on the working plane. """ if not self.proj_point1 or not self.proj_point2: - plane = App.DraftWorkingPlane - self.proj_point1 = plane.projectPoint(self.node[0]) - self.proj_point2 = plane.projectPoint(self.node[1]) - proj_u= plane.u.dot(self.proj_point2 - self.proj_point1) - proj_v= plane.v.dot(self.proj_point2 - self.proj_point1) + self.proj_point1 = self.wp.projectPoint(self.node[0]) + self.proj_point2 = self.wp.projectPoint(self.node[1]) + proj_u= self.wp.u.dot(self.proj_point2 - self.proj_point1) + proj_v= self.wp.v.dot(self.proj_point2 - self.proj_point1) active_view = Gui.ActiveDocument.ActiveView cursor = active_view.getCursorPos() cursor_point = active_view.getPoint(cursor) - self.point = plane.projectPoint(cursor_point) + self.point = self.wp.projectPoint(cursor_point) if not self.force: ref_point = self.point - (self.proj_point2 + self.proj_point1)*1/2 - ref_angle = abs(ref_point.getAngle(plane.u)) + ref_angle = abs(ref_point.getAngle(self.wp.u)) if (ref_angle > math.pi/4) and (ref_angle <= 0.75*math.pi): self.force = 2 else: self.force = 1 if self.force == 1: self.node[0] = self.proj_point1 - self.node[1] = self.proj_point1 + plane.v*proj_v + self.node[1] = self.proj_point1 + self.wp.v*proj_v elif self.force == 2: self.node[0] = self.proj_point1 - self.node[1] = self.proj_point1 + plane.u*proj_u + self.node[1] = self.proj_point1 + self.wp.u*proj_u Gui.addCommand('Draft_Dimension', Dimension()) diff --git a/src/Mod/Draft/draftguitools/gui_ellipses.py b/src/Mod/Draft/draftguitools/gui_ellipses.py index 8040bd13aa..1deec0160a 100644 --- a/src/Mod/Draft/draftguitools/gui_ellipses.py +++ b/src/Mod/Draft/draftguitools/gui_ellipses.py @@ -61,7 +61,7 @@ class Ellipse(gui_base_original.Creator): def Activated(self): """Execute when the command is called.""" - super(Ellipse, self).Activated(name="Ellipse") + super().Activated(name="Ellipse") if self.ui: self.refpoint = None self.ui.pointUi(title=translate("draft", "Ellipse"), icon="Draft_Ellipse") @@ -79,7 +79,7 @@ class Ellipse(gui_base_original.Creator): Restart (continue) the command if `True`, or if `None` and `ui.continueMode` is `True`. """ - super(Ellipse, self).finish(self) + super().finish(self) if self.ui: self.rect.off() self.rect.finalize() @@ -88,14 +88,13 @@ class Ellipse(gui_base_original.Creator): def createObject(self): """Create the actual object in the current document.""" - plane = App.DraftWorkingPlane p1 = self.node[0] p3 = self.node[-1] diagonal = p3.sub(p1) halfdiag = App.Vector(diagonal).multiply(0.5) center = p1.add(halfdiag) - p2 = p1.add(DraftVecUtils.project(diagonal, plane.v)) - p4 = p1.add(DraftVecUtils.project(diagonal, plane.u)) + p2 = p1.add(DraftVecUtils.project(diagonal, self.wp.v)) + p4 = p1.add(DraftVecUtils.project(diagonal, self.wp.u)) r1 = (p4.sub(p1).Length)/2 r2 = (p2.sub(p1).Length)/2 try: diff --git a/src/Mod/Draft/draftguitools/gui_labels.py b/src/Mod/Draft/draftguitools/gui_labels.py index b33889d79a..2faf45e365 100644 --- a/src/Mod/Draft/draftguitools/gui_labels.py +++ b/src/Mod/Draft/draftguitools/gui_labels.py @@ -66,7 +66,7 @@ class Label(gui_base_original.Creator): def Activated(self): """Execute when the command is called.""" - super(Label, self).Activated(name="Label") + super().Activated(name="Label") self.ghost = None self.labeltype = utils.getParam("labeltype", "Custom") self.sel = Gui.Selection.getSelectionEx() @@ -90,7 +90,7 @@ class Label(gui_base_original.Creator): """Finish the command.""" if self.ghost: self.ghost.finalize() - super(Label, self).finish() + super().finish() def create(self): """Create the actual object.""" @@ -99,14 +99,9 @@ class Label(gui_base_original.Creator): basepoint = self.node[2] v = self.node[2].sub(self.node[1]) dist = v.Length - if hasattr(App, "DraftWorkingPlane"): - h = App.DraftWorkingPlane.u - n = App.DraftWorkingPlane.axis - r = App.DraftWorkingPlane.getRotation().Rotation - else: - h = App.Vector(1, 0, 0) - n = App.Vector(0, 0, 1) - r = App.Rotation() + h = self.wp.u + n = self.wp.axis + r = self.wp.getRotation().Rotation if abs(DraftVecUtils.angle(v, h, n)) <= math.pi/4: direction = "Horizontal" diff --git a/src/Mod/Draft/draftguitools/gui_lines.py b/src/Mod/Draft/draftguitools/gui_lines.py index 3c8a4885b3..1489b76622 100644 --- a/src/Mod/Draft/draftguitools/gui_lines.py +++ b/src/Mod/Draft/draftguitools/gui_lines.py @@ -256,10 +256,10 @@ class Line(gui_base_original.Creator): import DraftGeomUtils n = DraftGeomUtils.getNormal(self.obj.Shape) if not n: - n = App.DraftWorkingPlane.axis + n = self.wp.axis p = self.node[-1] v = self.node[-1].sub(self.node[-2]) - App.DraftWorkingPlane.alignToPointAndAxis(p, n, upvec=v) + self.wp.alignToPointAndAxis(p, n, upvec=v) if hasattr(Gui, "Snapper"): Gui.Snapper.setGrid() Gui.Snapper.restack() diff --git a/src/Mod/Draft/draftguitools/gui_polygons.py b/src/Mod/Draft/draftguitools/gui_polygons.py index 1757e6c633..16683eb432 100644 --- a/src/Mod/Draft/draftguitools/gui_polygons.py +++ b/src/Mod/Draft/draftguitools/gui_polygons.py @@ -59,7 +59,7 @@ class Polygon(gui_base_original.Creator): def Activated(self): """Execute when the command is called.""" - super(Polygon, self).Activated(name="Polygon") + super().Activated(name="Polygon") if self.ui: self.step = 0 self.center = None @@ -86,7 +86,7 @@ class Polygon(gui_base_original.Creator): Restart (continue) the command if `True`, or if `None` and `ui.continueMode` is `True`. """ - super(Polygon, self).finish(self) + super().finish(self) if self.ui: self.arctrack.finalize() self.doc.recompute() @@ -115,7 +115,7 @@ class Polygon(gui_base_original.Creator): # this is to make sure radius is what you see on screen if self.center and DraftVecUtils.dist(self.point, self.center) > 0: viewdelta = DraftVecUtils.project(self.point.sub(self.center), - App.DraftWorkingPlane.axis) + self.wp.axis) if not DraftVecUtils.isNull(viewdelta): self.point = self.point.add(viewdelta.negative()) if self.step == 0: # choose center diff --git a/src/Mod/Draft/draftguitools/gui_rectangles.py b/src/Mod/Draft/draftguitools/gui_rectangles.py index eac5b8fce5..3aa18dbb07 100644 --- a/src/Mod/Draft/draftguitools/gui_rectangles.py +++ b/src/Mod/Draft/draftguitools/gui_rectangles.py @@ -56,7 +56,7 @@ class Rectangle(gui_base_original.Creator): def Activated(self): """Execute when the command is called.""" - super(Rectangle, self).Activated(name="Rectangle") + super().Activated(name="Rectangle") if self.ui: self.refpoint = None self.ui.pointUi(title=translate("draft", "Rectangle"), icon="Draft_Rectangle") @@ -77,7 +77,7 @@ class Rectangle(gui_base_original.Creator): Restart (continue) the command if `True`, or if `None` and `ui.continueMode` is `True`. """ - super(Rectangle, self).finish() + super().finish() if self.ui: if hasattr(self, "fillstate"): self.ui.hasFill.setChecked(self.fillstate) @@ -89,17 +89,16 @@ class Rectangle(gui_base_original.Creator): def createObject(self): """Create the final object in the current document.""" - plane = App.DraftWorkingPlane p1 = self.node[0] p3 = self.node[-1] diagonal = p3.sub(p1) - p2 = p1.add(DraftVecUtils.project(diagonal, plane.v)) - p4 = p1.add(DraftVecUtils.project(diagonal, plane.u)) + p2 = p1.add(DraftVecUtils.project(diagonal, self.wp.v)) + p4 = p1.add(DraftVecUtils.project(diagonal, self.wp.u)) length = p4.sub(p1).Length - if abs(DraftVecUtils.angle(p4.sub(p1), plane.u, plane.axis)) > 1: + if abs(DraftVecUtils.angle(p4.sub(p1), self.wp.u, self.wp.axis)) > 1: length = -length height = p2.sub(p1).Length - if abs(DraftVecUtils.angle(p2.sub(p1), plane.v, plane.axis)) > 1: + if abs(DraftVecUtils.angle(p2.sub(p1), self.wp.v, self.wp.axis)) > 1: height = -height try: # The command to run is built as a series of text strings