Draft: activate new array make functions

They are made available in the `Draft` namespace,
and are also used in the unit tests, the test script,
and the GuiCommands.
This commit is contained in:
vocx-fc
2020-05-14 19:11:15 -05:00
committed by Yorik van Havre
parent 3172e82dc1
commit 623cd5df35
6 changed files with 80 additions and 78 deletions

View File

@@ -338,12 +338,12 @@ if FreeCAD.GuiUp:
from draftviewproviders.view_array import ViewProviderDraftArray
from draftviewproviders.view_array import _ViewProviderDraftArray
# from draftmake.make_circulararray import make_circular_array
# from draftmake.make_orthoarray import make_ortho_array
# from draftmake.make_orthoarray import make_ortho_array2d
# from draftmake.make_orthoarray import make_rect_array
# from draftmake.make_orthoarray import make_rect_array2d
# from draftmake.make_polararray import make_polar_array
from draftmake.make_circulararray import make_circular_array
from draftmake.make_orthoarray import make_ortho_array
from draftmake.make_orthoarray import make_ortho_array2d
from draftmake.make_orthoarray import make_rect_array
from draftmake.make_orthoarray import make_rect_array2d
from draftmake.make_polararray import make_polar_array
# facebinder
from draftmake.make_facebinder import make_facebinder, makeFacebinder

View File

@@ -278,7 +278,7 @@ class TaskPanelCircularArray:
# of this class, the GuiCommand.
# This is needed to schedule geometry manipulation
# that would crash Coin3D if done in the event callback.
_cmd = "DD.make_circular_array"
_cmd = "Draft.make_circular_array"
_cmd += "("
_cmd += "App.ActiveDocument." + sel_obj.Name + ", "
_cmd += "r_distance=" + str(self.r_distance) + ", "
@@ -291,13 +291,10 @@ class TaskPanelCircularArray:
_cmd += ")"
Gui.addModule('Draft')
Gui.addModule('draftmake.make_circulararray')
_cmd_list = ["# DD = Draft # in the future",
"DD = draftmake.make_circulararray",
"obj = " + _cmd,
"obj.Fuse = " + str(self.fuse),
"Draft.autogroup(obj)",
_cmd_list = ["_obj_ = " + _cmd,
"_obj_.Fuse = " + str(self.fuse),
"Draft.autogroup(_obj_)",
"App.ActiveDocument.recompute()"]
# We commit the command list through the parent command

View File

@@ -248,7 +248,7 @@ class TaskPanelOrthoArray:
# of this class, the GuiCommand.
# This is needed to schedule geometry manipulation
# that would crash Coin3D if done in the event callback.
_cmd = "DD.make_ortho_array"
_cmd = "Draft.make_ortho_array"
_cmd += "("
_cmd += "App.ActiveDocument." + sel_obj.Name + ", "
_cmd += "v_x=" + DraftVecUtils.toString(self.v_x) + ", "
@@ -261,13 +261,10 @@ class TaskPanelOrthoArray:
_cmd += ")"
Gui.addModule('Draft')
Gui.addModule('draftmake.make_orthoarray')
_cmd_list = ["# DD = Draft # in the future",
"DD = draftmake.make_orthoarray",
"obj = " + _cmd,
"obj.Fuse = " + str(self.fuse),
"Draft.autogroup(obj)",
_cmd_list = ["_obj_ = " + _cmd,
"_obj_.Fuse = " + str(self.fuse),
"Draft.autogroup(_obj_)",
"App.ActiveDocument.recompute()"]
# We commit the command list through the parent command

View File

@@ -242,7 +242,7 @@ class TaskPanelPolarArray:
# of this class, the GuiCommand.
# This is needed to schedule geometry manipulation
# that would crash Coin3D if done in the event callback.
_cmd = "DD.make_polar_array"
_cmd = "Draft.make_polar_array"
_cmd += "("
_cmd += "App.ActiveDocument." + sel_obj.Name + ", "
_cmd += "number=" + str(self.number) + ", "
@@ -254,11 +254,9 @@ class TaskPanelPolarArray:
Gui.addModule('Draft')
Gui.addModule('draftmake.make_polararray')
_cmd_list = ["# DD = Draft # in the future",
"DD = draftmake.make_polararray",
"obj = " + _cmd,
"obj.Fuse = " + str(self.fuse),
"Draft.autogroup(obj)",
_cmd_list = ["_obj_ = " + _cmd,
"_obj_.Fuse = " + str(self.fuse),
"Draft.autogroup(_obj_)",
"App.ActiveDocument.recompute()"]
# We commit the command list through the parent command

View File

@@ -373,11 +373,12 @@ def _create_objects(doc=None,
if App.GuiUp:
rect_h.ViewObject.Visibility = False
Draft.makeArray(rect_h,
Vector(600, 0, 0),
Vector(0, 600, 0),
Vector(0, 0, 0),
3, 2, 1)
Draft.make_ortho_array(rect_h,
Vector(600, 0, 0),
Vector(0, 600, 0),
Vector(0, 0, 0),
3, 2, 1,
use_link=False)
t_xpos = 1700
t_ypos = 2200
_set_text(["Array"], Vector(t_xpos, t_ypos, 0))
@@ -389,12 +390,12 @@ def _create_objects(doc=None,
_msg(16 * "-")
_msg("Orthogonal link array")
Draft.makeArray(rect_h_2,
Vector(800, 0, 0),
Vector(0, 500, 0),
Vector(0, 0, 0),
2, 4, 1,
use_link=True)
Draft.make_ortho_array(rect_h_2,
Vector(800, 0, 0),
Vector(0, 500, 0),
Vector(0, 0, 0),
2, 4, 1,
use_link=True)
t_ypos += 2600
_set_text(["Link array"], Vector(t_xpos, t_ypos, 0))
@@ -408,10 +409,12 @@ def _create_objects(doc=None,
if App.GuiUp:
wire_h.ViewObject.Visibility = False
Draft.makeArray(wire_h,
Vector(5000, 3000, 0),
200,
8)
Draft.make_polar_array(wire_h,
8,
200,
Vector(5000, 3000, 0),
use_link=False)
t_xpos = 4600
t_ypos = 2200
_set_text(["Polar array"], Vector(t_xpos, t_ypos, 0))
@@ -425,11 +428,11 @@ def _create_objects(doc=None,
if App.GuiUp:
wire_h_2.ViewObject.Visibility = False
Draft.makeArray(wire_h_2,
Vector(5000, 6000, 0),
200,
8,
use_link=True)
Draft.make_polar_array(wire_h_2,
8,
200,
Vector(5000, 6000, 0),
use_link=True)
t_ypos += 3200
_set_text(["Polar link array"], Vector(t_xpos, t_ypos, 0))
@@ -441,12 +444,13 @@ def _create_objects(doc=None,
if App.GuiUp:
poly_h.ViewObject.Visibility = False
Draft.makeArray(poly_h,
500, 600,
Vector(0, 0, 1),
Vector(0, 0, 0),
3,
1)
Draft.make_circular_array(poly_h,
500, 600,
3,
1,
Vector(0, 0, 1),
Vector(0, 0, 0),
use_link=False)
t_xpos = 7700
t_ypos = 1700
_set_text(["Circular array"], Vector(t_xpos, t_ypos, 0))
@@ -458,13 +462,13 @@ def _create_objects(doc=None,
if App.GuiUp:
poly_h_2.ViewObject.Visibility = False
Draft.makeArray(poly_h_2,
550, 450,
Vector(0, 0, 1),
Vector(0, 0, 0),
3,
1,
use_link=True)
Draft.make_circular_array(poly_h_2,
550, 450,
3,
1,
Vector(0, 0, 1),
Vector(0, 0, 0),
use_link=True)
t_ypos += 3100
_set_text(["Circular link array"], Vector(t_xpos, t_ypos, 0))
@@ -481,7 +485,8 @@ def _create_objects(doc=None,
Vector(11500, 3200, 0),
Vector(12000, 4000, 0)])
Draft.makePathArray(poly_h, bspline_path, 5)
Draft.make_path_array(poly_h, bspline_path, 5,
use_link=False)
t_xpos = 10400
t_ypos = 2200
_set_text(["Path array"], Vector(t_xpos, t_ypos, 0))
@@ -498,8 +503,8 @@ def _create_objects(doc=None,
Vector(11500, 6000, 0),
Vector(12000, 5200, 0)])
Draft.makePathArray(poly_h_2, bspline_path_2, 6,
use_link=True)
Draft.make_path_array(poly_h_2, bspline_path_2, 6,
use_link=True)
t_ypos += 2000
_set_text(["Path link array"], Vector(t_xpos, t_ypos, 0))
@@ -519,7 +524,7 @@ def _create_objects(doc=None,
if App.GuiUp:
compound.ViewObject.PointSize = 5
Draft.makePointArray(poly_h, compound)
Draft.make_point_array(poly_h, compound)
t_xpos = 13000
t_ypos = 2200
_set_text(["Point array"], Vector(t_xpos, t_ypos, 0))
@@ -532,7 +537,7 @@ def _create_objects(doc=None,
Vector(15500, 2500, 0),
Vector(15200, 2300, 0)])
Draft.clone(wire_h, Vector(0, 1000, 0))
Draft.make_clone(wire_h, Vector(0, 1000, 0))
t_xpos = 15000
t_ypos = 2100
_set_text(["Clone"], Vector(t_xpos, t_ypos, 0))

View File

@@ -370,7 +370,7 @@ class DraftModification(unittest.TestCase):
def test_rectangular_array(self):
"""Create a rectangle, and a rectangular array."""
operation = "Draft Array"
operation = "Draft OrthoArray"
_msg(" Test '{}'".format(operation))
length = 4
width = 2
@@ -381,15 +381,20 @@ class DraftModification(unittest.TestCase):
dir_x = Vector(5, 0, 0)
dir_y = Vector(0, 4, 0)
dir_z = Vector(0, 0, 6)
number_x = 3
number_y = 4
number_z = 6
_msg(" Array")
_msg(" direction_x={}".format(dir_x))
_msg(" direction_y={}".format(dir_y))
_msg(" number_x={0}, number_y={1}".format(number_x, number_y))
obj = Draft.makeArray(rect,
dir_x, dir_y,
number_x, number_y)
_msg(" direction_z={}".format(dir_z))
_msg(" number_x={0}, number_y={1}, number_z={2}".format(number_x,
number_y,
number_z))
obj = Draft.make_ortho_array(rect,
dir_x, dir_y, dir_z,
number_x, number_y, number_z)
self.assertTrue(obj, "'{}' failed".format(operation))
def test_polar_array(self):
@@ -407,10 +412,10 @@ class DraftModification(unittest.TestCase):
angle = 180
number = 5
_msg(" Array")
_msg(" number={0}, polar_angle={1}".format(number, angle))
_msg(" center={}".format(center))
_msg(" polar_angle={0}, number={1}".format(angle, number))
obj = Draft.makeArray(rect,
center, angle, number)
obj = Draft.make_polar_array(rect,
number, angle, center)
self.assertTrue(obj, "'{}' failed".format(operation))
def test_circular_array(self):
@@ -436,10 +441,10 @@ class DraftModification(unittest.TestCase):
_msg(" number={0}, symmetry={1}".format(number, symmetry))
_msg(" axis={}".format(axis))
_msg(" center={}".format(center))
obj = Draft.makeArray(rect,
rad_distance, tan_distance,
axis, center,
number, symmetry)
obj = Draft.make_circular_array(rect,
rad_distance, tan_distance,
number, symmetry,
axis, center)
self.assertTrue(obj, "'{}' failed".format(operation))
def test_path_array(self):
@@ -467,7 +472,7 @@ class DraftModification(unittest.TestCase):
_msg(" Path Array")
_msg(" number={}, translation={}".format(number, translation))
_msg(" align={}".format(align))
obj = Draft.makePathArray(poly, wire, number, translation, align)
obj = Draft.make_path_array(poly, wire, number, translation, align)
self.assertTrue(obj, "'{}' failed".format(operation))
def test_point_array(self):
@@ -497,7 +502,7 @@ class DraftModification(unittest.TestCase):
poly = Draft.make_polygon(n_faces, radius)
_msg(" Point Array")
obj = Draft.makePointArray(poly, compound)
obj = Draft.make_point_array(poly, compound)
self.assertTrue(obj, "'{}' failed".format(operation))
def test_clone(self):