@@ -494,8 +494,8 @@ class Arc_3Points(gui_base.GuiCommandSimplest):
|
||||
# Set up the working plane and launch the Snapper
|
||||
# with the indicated callbacks: one for when the user clicks
|
||||
# on the 3D view, and another for when the user moves the pointer.
|
||||
if hasattr(App, "DraftWorkingPlane"):
|
||||
App.DraftWorkingPlane.setup()
|
||||
import WorkingPlane
|
||||
WorkingPlane.get_working_plane()
|
||||
|
||||
Gui.Snapper.getPoint(callback=self.getPoint,
|
||||
movecallback=self.drawArc)
|
||||
|
||||
@@ -36,6 +36,7 @@ of the DraftToolBar, the Snapper, and the working plane.
|
||||
import FreeCAD as App
|
||||
import FreeCADGui as Gui
|
||||
import DraftVecUtils
|
||||
import WorkingPlane
|
||||
import draftutils.utils as utils
|
||||
import draftutils.gui_utils as gui_utils
|
||||
import draftutils.todo as todo
|
||||
@@ -59,9 +60,7 @@ class DraftTool:
|
||||
properties of the running tools such as the task panel, the snapping
|
||||
functions, and the grid trackers.
|
||||
|
||||
It also connects with the `DraftWorkingPlane` class
|
||||
that is installed in the `FreeCAD` namespace in order to set up
|
||||
the working plane if it doesn't exist.
|
||||
It also connects with the `WorkingPlane` class.
|
||||
|
||||
This class is intended to be replaced by newer classes inside the
|
||||
`gui_base` module, in particular, `GuiCommandBase`.
|
||||
@@ -128,8 +127,7 @@ class DraftTool:
|
||||
self.ui = Gui.draftToolBar
|
||||
self.ui.sourceCmd = self
|
||||
self.view = gui_utils.get_3d_view()
|
||||
self.wp = App.DraftWorkingPlane
|
||||
self.wp.setup()
|
||||
self.wp = WorkingPlane.get_working_plane()
|
||||
|
||||
self.planetrack = None
|
||||
if utils.get_param("showPlaneTracker", False):
|
||||
@@ -166,7 +164,7 @@ class DraftTool:
|
||||
self.ui.sourceCmd = None
|
||||
if self.planetrack:
|
||||
self.planetrack.finalize()
|
||||
self.wp.restore()
|
||||
self.wp._restore()
|
||||
if hasattr(Gui, "Snapper"):
|
||||
Gui.Snapper.off()
|
||||
if self.call:
|
||||
@@ -218,8 +216,7 @@ class DraftTool:
|
||||
of the current tool
|
||||
"""
|
||||
# Current plane rotation as a string
|
||||
p = self.wp.getRotation()
|
||||
qr = p.Rotation.Q
|
||||
qr = self.wp.get_placement().Rotation.Q
|
||||
qr = "({0}, {1}, {2}, {3})".format(qr[0], qr[1], qr[2], qr[3])
|
||||
|
||||
# Support object
|
||||
@@ -265,8 +262,8 @@ class Creator(DraftTool):
|
||||
It is the `featureName` of the object, to know what is being run.
|
||||
"""
|
||||
super().Activated(name)
|
||||
# call self.wp.save to sync with self.wp.restore called in finish method
|
||||
self.wp.save()
|
||||
# call _save to sync with _restore called in finish method
|
||||
self.wp._save()
|
||||
self.support = gui_tool_utils.get_support()
|
||||
|
||||
|
||||
@@ -286,6 +283,6 @@ class Modifier(DraftTool):
|
||||
|
||||
def Activated(self, name="None", is_subtool=False):
|
||||
super().Activated(name, is_subtool)
|
||||
# call self.wp.save to sync with self.wp.restore called in finish method
|
||||
self.wp.save()
|
||||
# call _save to sync with _restore called in finish method
|
||||
self.wp._save()
|
||||
## @}
|
||||
|
||||
@@ -580,14 +580,14 @@ class Dimension(gui_base_original.Creator):
|
||||
by projecting on the working plane.
|
||||
"""
|
||||
if not self.proj_point1 or not self.proj_point2:
|
||||
self.proj_point1 = self.wp.projectPoint(self.node[0])
|
||||
self.proj_point2 = self.wp.projectPoint(self.node[1])
|
||||
self.proj_point1 = self.wp.project_point(self.node[0])
|
||||
self.proj_point2 = self.wp.project_point(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 = self.wp.projectPoint(cursor_point)
|
||||
self.point = self.wp.project_point(cursor_point)
|
||||
if not self.force:
|
||||
ref_point = self.point - (self.proj_point2 + self.proj_point1)*1/2
|
||||
ref_angle = abs(ref_point.getAngle(self.wp.u))
|
||||
|
||||
@@ -309,10 +309,6 @@ class Edit(gui_base_original.Modifier):
|
||||
|
||||
self.register_editing_callbacks()
|
||||
|
||||
# TODO: align working plane when editing starts
|
||||
# App.DraftWorkingPlane.save()
|
||||
# self.alignWorkingPlane()
|
||||
|
||||
|
||||
def numericInput(self, numx, numy, numz):
|
||||
"""Execute callback by the toolbar to activate the update function.
|
||||
|
||||
@@ -101,7 +101,7 @@ class Label(gui_base_original.Creator):
|
||||
dist = v.Length
|
||||
h = self.wp.u
|
||||
n = self.wp.axis
|
||||
r = self.wp.getRotation().Rotation
|
||||
r = self.wp.get_placement().Rotation
|
||||
|
||||
if abs(DraftVecUtils.angle(v, h, n)) <= math.pi/4:
|
||||
direction = "Horizontal"
|
||||
|
||||
@@ -182,9 +182,6 @@ class Line(gui_base_original.Creator):
|
||||
self.commit(translate("draft", "Create Wire"),
|
||||
_cmd_list)
|
||||
super().finish()
|
||||
if hasattr(Gui, "Snapper"):
|
||||
Gui.Snapper.setGrid(tool=True)
|
||||
Gui.Snapper.restack()
|
||||
if cont or (cont is None and self.ui and self.ui.continueMode):
|
||||
self.Activated()
|
||||
|
||||
@@ -259,10 +256,7 @@ class Line(gui_base_original.Creator):
|
||||
n = self.wp.axis
|
||||
p = self.node[-1]
|
||||
v = self.node[-1].sub(self.node[-2])
|
||||
self.wp.alignToPointAndAxis(p, n, upvec=v)
|
||||
if hasattr(Gui, "Snapper"):
|
||||
Gui.Snapper.setGrid()
|
||||
Gui.Snapper.restack()
|
||||
self.wp.align_to_point_and_axis(p, n, upvec=v, _hist_add=False)
|
||||
if self.planetrack:
|
||||
self.planetrack.set(self.node[-1])
|
||||
|
||||
|
||||
@@ -60,16 +60,14 @@ class Draft_WorkingPlaneProxy:
|
||||
|
||||
def Activated(self):
|
||||
"""Execute when the command is called."""
|
||||
if hasattr(App, "DraftWorkingPlane"):
|
||||
App.DraftWorkingPlane.setup()
|
||||
App.ActiveDocument.openTransaction("Create WP proxy")
|
||||
Gui.addModule("Draft")
|
||||
_cmd = "Draft.make_workingplaneproxy("
|
||||
_cmd += "FreeCAD.DraftWorkingPlane.getPlacement()"
|
||||
_cmd += ")"
|
||||
Gui.doCommand(_cmd)
|
||||
App.ActiveDocument.commitTransaction()
|
||||
App.ActiveDocument.recompute()
|
||||
App.ActiveDocument.openTransaction("Create WP proxy")
|
||||
Gui.addModule("Draft")
|
||||
Gui.addModule("WorkingPlane")
|
||||
_cmd = "pl = WorkingPlane.get_working_plane().get_placement()"
|
||||
_cmd += "Draft.make_workingplaneproxy(pl)"
|
||||
Gui.doCommand(_cmd)
|
||||
App.ActiveDocument.commitTransaction()
|
||||
App.ActiveDocument.recompute()
|
||||
|
||||
|
||||
Gui.addCommand('Draft_WorkingPlaneProxy', Draft_WorkingPlaneProxy())
|
||||
|
||||
@@ -211,7 +211,7 @@ class Scale(gui_base_original.Modifier):
|
||||
def scale_with_clone(self):
|
||||
"""Scale with clone."""
|
||||
if self.task.relative.isChecked():
|
||||
self.delta = self.wp.getGlobalCoords(self.delta)
|
||||
self.delta = self.wp.get_global_coords(self.delta)
|
||||
|
||||
Gui.addModule("Draft")
|
||||
|
||||
@@ -325,7 +325,7 @@ class Scale(gui_base_original.Modifier):
|
||||
def scale_object(self):
|
||||
"""Scale the object."""
|
||||
if self.task.relative.isChecked():
|
||||
self.delta =self.wp.getGlobalCoords(self.delta)
|
||||
self.delta =self.wp.get_global_coords(self.delta)
|
||||
goods = []
|
||||
bads = []
|
||||
for obj in self.selected_objects:
|
||||
@@ -371,7 +371,7 @@ class Scale(gui_base_original.Modifier):
|
||||
"""Scale the preview of the object."""
|
||||
delta = App.Vector(x, y, z)
|
||||
if rel:
|
||||
delta = self.wp.getGlobalCoords(delta)
|
||||
delta = self.wp.get_global_coords(delta)
|
||||
for ghost in self.ghosts:
|
||||
ghost.scale(delta)
|
||||
# calculate a correction factor depending on the scaling center
|
||||
|
||||
@@ -36,6 +36,7 @@ as they operate on selections and graphical properties.
|
||||
# @{
|
||||
import FreeCAD as App
|
||||
import FreeCADGui as Gui
|
||||
import WorkingPlane
|
||||
import draftutils.gui_utils as gui_utils
|
||||
import draftutils.utils as utils
|
||||
|
||||
@@ -205,7 +206,7 @@ def get_point(target, args, noTracker=False):
|
||||
mask = None
|
||||
|
||||
ctrlPoint = App.Vector(point)
|
||||
wp = App.DraftWorkingPlane
|
||||
wp = WorkingPlane.get_working_plane(update=False)
|
||||
if target.node:
|
||||
if target.featureName == "Rectangle":
|
||||
ui.displayPoint(point, target.node[0], plane=wp, mask=mask)
|
||||
@@ -222,7 +223,7 @@ getPoint = get_point
|
||||
def set_working_plane_to_object_under_cursor(mouseEvent):
|
||||
"""Align the working plane to the face under the cursor.
|
||||
|
||||
The working plane is only aligned if it is `'weak'`.
|
||||
The working plane is only aligned if it is `'auto'`.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
@@ -242,8 +243,8 @@ def set_working_plane_to_object_under_cursor(mouseEvent):
|
||||
return None
|
||||
if "Face" not in objectUnderCursor["Component"]:
|
||||
return None
|
||||
wp = App.DraftWorkingPlane
|
||||
if wp.weak is False:
|
||||
wp = WorkingPlane.get_working_plane(update=False)
|
||||
if not wp.auto:
|
||||
return None
|
||||
|
||||
import Part
|
||||
@@ -255,11 +256,8 @@ def set_working_plane_to_object_under_cursor(mouseEvent):
|
||||
sub = objectUnderCursor["Component"]
|
||||
shape = Part.getShape(obj, sub, needSubElement=True, retType=0)
|
||||
|
||||
if wp.alignToFace(shape) is True:
|
||||
wp.weak = True
|
||||
if hasattr(Gui, "Snapper"):
|
||||
Gui.Snapper.setGrid()
|
||||
Gui.Snapper.restack()
|
||||
if wp.align_to_face(shape, _hist_add=False):
|
||||
wp.auto = True
|
||||
return obj
|
||||
|
||||
return None
|
||||
@@ -271,15 +269,15 @@ setWorkingPlaneToObjectUnderCursor = set_working_plane_to_object_under_cursor
|
||||
def set_working_plane_to_selected_object():
|
||||
"""Align the working plane to a preselected face.
|
||||
|
||||
The working plane is only aligned if it is `'weak'`.
|
||||
The working plane is only aligned if it is `'auto'`.
|
||||
|
||||
Returns
|
||||
-------
|
||||
App::DocumentObject or None
|
||||
The parent object the face belongs to, if alignment occurred, or None.
|
||||
"""
|
||||
wp = App.DraftWorkingPlane
|
||||
if wp.weak is False:
|
||||
wp = WorkingPlane.get_working_plane(update=False)
|
||||
if not wp.auto:
|
||||
return None
|
||||
|
||||
sels = Gui.Selection.getSelectionEx("", 0)
|
||||
@@ -293,11 +291,8 @@ def set_working_plane_to_selected_object():
|
||||
needSubElement=True,
|
||||
retType=0)
|
||||
|
||||
if wp.alignToFace(shape) is True:
|
||||
wp.weak = True
|
||||
if hasattr(Gui, "Snapper"):
|
||||
Gui.Snapper.setGrid()
|
||||
Gui.Snapper.restack()
|
||||
if wp.align_to_face(shape, _hist_add=False):
|
||||
wp.auto = True
|
||||
return sels[0].Object
|
||||
|
||||
return None
|
||||
@@ -309,7 +304,7 @@ setWorkingPlaneToSelectedObject = set_working_plane_to_selected_object
|
||||
def get_support(mouseEvent=None):
|
||||
""""Align the working plane to a preselected face or the face under the cursor.
|
||||
|
||||
The working plane is only aligned if it is `'weak'`.
|
||||
The working plane is only aligned if it is `'auto'`.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
|
||||
Reference in New Issue
Block a user