Draft: add modules of draftfunctions to the proper Doxygen group

This includes `array`, `cut`, `downgrade`, `draftiffy`, `extrude`,
`fuse`, `heal`, `join`, `mirror`, `move`, `offset`, `rotate`,
`scale`, `split` and `upgrade`.

These are added to the `draftfunction` Doxygen group
so that the functions contained in each module are listed
appropriately in the automatically generated documentation.
This commit is contained in:
vocx-fc
2020-05-05 17:46:54 -05:00
committed by Yorik van Havre
parent 223e627900
commit a1ce2389d3
15 changed files with 157 additions and 129 deletions

View File

@@ -22,17 +22,17 @@
# * USA *
# * *
# ***************************************************************************
"""Provides the object code for Draft array function."""
"""Provides functions to create non-parametric arrayed copies."""
## @package array
# \ingroup DRAFT
# \brief Provides the object code for Draft array.
# \ingroup draftfuctions
# \brief Provides functions to create non-parametric arrayed copies.
## \addtogroup draftfuctions
# @{
import FreeCAD as App
import draftutils.utils as utils
from draftfunctions.move import move
from draftfunctions.rotate import rotate
import draftfunctions.move as move
import draftfunctions.rotate as rotate
def array(objectslist, arg1, arg2, arg3, arg4=None, arg5=None, arg6=None):
@@ -77,12 +77,12 @@ def rectArray(objectslist,xvector,yvector,xnum,ynum):
for xcount in range(xnum):
currentxvector=App.Vector(xvector).multiply(xcount)
if not xcount==0:
move(objectslist,currentxvector,True)
move.move(objectslist,currentxvector,True)
for ycount in range(ynum):
currentxvector=App.Vector(currentxvector)
currentyvector=currentxvector.add(App.Vector(yvector).multiply(ycount))
if not ycount==0:
move(objectslist,currentyvector,True)
move.move(objectslist,currentyvector,True)
def rectArray2(objectslist,xvector,yvector,zvector,xnum,ynum,znum):
@@ -91,16 +91,16 @@ def rectArray2(objectslist,xvector,yvector,zvector,xnum,ynum,znum):
for xcount in range(xnum):
currentxvector=App.Vector(xvector).multiply(xcount)
if not xcount==0:
move(objectslist,currentxvector,True)
move.move(objectslist,currentxvector,True)
for ycount in range(ynum):
currentxvector=App.Vector(currentxvector)
currentyvector=currentxvector.add(App.Vector(yvector).multiply(ycount))
if not ycount==0:
move(objectslist,currentyvector,True)
move.move(objectslist,currentyvector,True)
for zcount in range(znum):
currentzvector=currentyvector.add(App.Vector(zvector).multiply(zcount))
if not zcount==0:
move(objectslist,currentzvector,True)
move.move(objectslist,currentzvector,True)
def polarArray(objectslist,center,angle,num):
@@ -109,4 +109,6 @@ def polarArray(objectslist,center,angle,num):
fraction = float(angle)/num
for i in range(num):
currangle = fraction + (i*fraction)
rotate(objectslist,currangle,center,copy=True)
rotate.rotate(objectslist,currangle,center,copy=True)
## @}

View File

@@ -20,13 +20,16 @@
# * USA *
# * *
# ***************************************************************************
"""Provides provides the code for Draft cut function."""
"""Provides functions to create a cut object from two objects."""
## @package cut
# \ingroup DRAFT
# \brief Provides provides the code for Draft cut function.
# \ingroup draftfuctions
# \brief Provides functions to create a cut object from two objects.
## \addtogroup draftfuctions
# @{
import FreeCAD as App
import draftutils.gui_utils as gui_utils
from draftutils.translate import _tr
from draftutils.messages import _err
@@ -65,3 +68,5 @@ def cut(object1, object2):
object2.ViewObject.Visibility = False
return obj
## @}

View File

@@ -20,19 +20,21 @@
# * USA *
# * *
# ***************************************************************************
"""Provides the code for Draft downgrade function.
"""Provides functions to downgrade objects by different methods.
See also the `upgrade` function.
"""
## @package downgrade
# \ingroup DRAFT
# \brief Provides the code for Draft downgrade function.
# \ingroup draftfuctions
# \brief Provides functions to downgrade objects by different methods.
## \addtogroup draftfuctions
# @{
import FreeCAD as App
import draftutils.gui_utils as gui_utils
import draftutils.utils as utils
import draftutils.gui_utils as gui_utils
import draftfunctions.cut as cut
from draftutils.messages import _msg
from draftutils.translate import _tr
@@ -297,3 +299,5 @@ def downgrade(objects, delete=False, force=None):
gui_utils.select(add_list)
return add_list, delete_list
## @}

View File

@@ -20,20 +20,18 @@
# * USA *
# * *
# ***************************************************************************
"""This module provides the code for Draft draftify function.
"""
"""Provides functions to transform sketches into Draft objects."""
## @package draftify
# \ingroup DRAFT
# \brief This module provides the code for Draft draftify function.
# \ingroup draftfuctions
# \brief Provides functions to transform sketches into Draft objects.
## \addtogroup draftfuctions
# @{
import FreeCAD as App
import draftutils.gui_utils as gui_utils
import draftutils.utils as utils
from draftmake.make_block import makeBlock
from draftmake.make_wire import makeWire
from draftmake.make_circle import makeCircle
import draftmake.make_block as make_block
import draftmake.make_wire as make_wire
import draftmake.make_circle as make_circle
def draftify(objectslist, makeblock=False, delete=True):
@@ -66,12 +64,12 @@ def draftify(objectslist, makeblock=False, delete=True):
w = Part.Wire(cluster)
if DraftGeomUtils.hasCurves(w):
if (len(w.Edges) == 1) and (DraftGeomUtils.geomType(w.Edges[0]) == "Circle"):
nobj = makeCircle(w.Edges[0])
nobj = make_circle.make_circle(w.Edges[0])
else:
nobj = App.ActiveDocument.addObject("Part::Feature", obj.Name)
nobj.Shape = w
else:
nobj = makeWire(w)
nobj = make_wire.make_wire(w)
newobjlist.append(nobj)
gui_utils.format_object(nobj, obj)
# sketches are always in wireframe mode. In Draft we don't like that!
@@ -81,8 +79,10 @@ def draftify(objectslist, makeblock=False, delete=True):
App.ActiveDocument.removeObject(obj.Name)
if makeblock:
return makeBlock(newobjlist)
return make_block.make_block(newobjlist)
else:
if len(newobjlist) == 1:
return newobjlist[0]
return newobjlist
## @}

View File

@@ -20,14 +20,14 @@
# * USA *
# * *
# ***************************************************************************
"""This module provides the code for Draft extrude function.
"""
"""Provides functions to create an extrusion object from a profile."""
## @package extrude
# \ingroup DRAFT
# \brief This module provides the code for Draft extrude function.
# \ingroup draftfuctions
# \brief Provides functions to create an extrusion object from a profile.
## \addtogroup draftfuctions
# @{
import FreeCAD as App
import draftutils.gui_utils as gui_utils
@@ -59,3 +59,5 @@ def extrude(obj, vector, solid=False):
gui_utils.select(newobj)
return newobj
## @}

View File

@@ -20,18 +20,18 @@
# * USA *
# * *
# ***************************************************************************
"""This module provides the code for Draft fuse function.
"""
"""Provides functions to create a fusion of two shapes."""
## @package fuse
# \ingroup DRAFT
# \brief This module provides the code for Draft fuse function.
# \ingroup draftfuctions
# \brief Provides functions to create a fusion of two shapes.
## \addtogroup draftfuctions
# @{
import FreeCAD as App
import draftutils.gui_utils as gui_utils
import draftutils.utils as utils
from draftmake.make_wire import Wire
if App.GuiUp:
from draftviewproviders.view_wire import ViewProviderWire
@@ -78,3 +78,5 @@ def fuse(object1, object2):
gui_utils.select(obj)
return obj
## @}

View File

@@ -20,15 +20,14 @@
# * USA *
# * *
# ***************************************************************************
"""This module provides the code for Draft heal function.
"""
"""Provides functions to repair certain objects created with old versions."""
## @package heal
# \ingroup DRAFT
# \brief This module provides the code for Draft heal function.
# \ingroup draftfuctions
# \brief Provides functions to repair certain objects from old versions.
## \addtogroup draftfuctions
# @{
import FreeCAD as App
import draftutils.gui_utils as gui_utils
import draftutils.utils as utils
from draftmake.make_copy import make_copy
@@ -113,3 +112,5 @@ def heal(objlist=None, delete=True, reparent=True):
if dellist and delete:
for n in dellist:
App.ActiveDocument.removeObject(n)
## @}

View File

@@ -20,12 +20,13 @@
# * USA *
# * *
# ***************************************************************************
"""This module provides the code for Draft join functions.
"""
"""Provides functions to join wires together into a single wire."""
## @package join
# \ingroup DRAFT
# \brief This module provides the code for Draft join functions.
# \ingroup draftfuctions
# \brief Provides functions to join wires together into a single wire.
## \addtogroup draftfuctions
# @{
import FreeCAD as App
@@ -89,3 +90,5 @@ def join_two_wires(wire1, wire2):
joinTwoWires = join_two_wires
## @}

View File

@@ -21,19 +21,21 @@
# * USA *
# * *
# ***************************************************************************
"""Provides the code for the mirror operation.
"""Provides functions to produce a mirrored object.
It just creates a `Part::Mirroring` object, and sets the appropriate
`Source` and `Normal` properties.
"""
## @package mirror
# \ingroup DRAFT
# \brief Provides the code for the mirror operation.
# \ingroup draftfunctions
# \brief Provides functions to produce a mirrored object.
## \addtogroup draftfuctions
# @{
import FreeCAD as App
import draftutils.utils as utils
import draftutils.gui_utils as gui_utils
from draftutils.messages import _err
from draftutils.translate import _tr
@@ -120,3 +122,5 @@ def mirror(objlist, p1, p2):
gui_utils.select(result)
return result
## @}

View File

@@ -20,21 +20,20 @@
# * USA *
# * *
# ***************************************************************************
"""This module provides the code for Draft move function.
"""
"""Provides functions to move objects from one position to another."""
## @package move
# \ingroup DRAFT
# \brief This module provides the code for Draft move function.
# \ingroup draftfuctions
# \brief Provides functions to move objects from one position to another.
## \addtogroup draftfuctions
# @{
import FreeCAD as App
import draftutils.utils as utils
import draftutils.groups as groups
import draftutils.gui_utils as gui_utils
from draftmake.make_copy import make_copy
from draftmake.make_line import make_line
from draftfunctions.join import join_wires
import draftutils.groups as groups
import draftfunctions.join as join
import draftmake.make_copy as make_copy
import draftmake.make_line as make_line
def move(objectslist, vector, copy=False):
@@ -81,7 +80,7 @@ def move(objectslist, vector, copy=False):
if utils.get_type(obj) == "Point":
if copy:
newobj = make_copy(obj)
newobj = make_copy.make_copy(obj)
else:
newobj = obj
newobj.X = obj.X + real_vector.x
@@ -93,7 +92,7 @@ def move(objectslist, vector, copy=False):
elif hasattr(obj,'Shape'):
if copy:
newobj = make_copy(obj)
newobj = make_copy.make_copy(obj)
else:
newobj = obj
pla = newobj.Placement
@@ -101,21 +100,21 @@ def move(objectslist, vector, copy=False):
elif utils.get_type(obj) == "Annotation":
if copy:
newobj = make_copy(obj)
newobj = make_copy.make_copy(obj)
else:
newobj = obj
newobj.Position = obj.Position.add(real_vector)
elif utils.get_type(obj) in ("Text", "DraftText"):
if copy:
newobj = make_copy(obj)
newobj = make_copy.make_copy(obj)
else:
newobj = obj
newobj.Placement.Base = obj.Placement.Base.add(real_vector)
elif utils.get_type(obj) in ["Dimension", "LinearDimension"]:
if copy:
newobj = make_copy(obj)
newobj = make_copy.make_copy(obj)
else:
newobj = obj
newobj.Start = obj.Start.add(real_vector)
@@ -124,14 +123,14 @@ def move(objectslist, vector, copy=False):
elif utils.get_type(obj) in ["AngularDimension"]:
if copy:
newobj = make_copy(obj)
newobj = make_copy.make_copy(obj)
else:
newobj = obj
newobj.Center = obj.Start.add(real_vector)
elif "Placement" in obj.PropertiesList:
if copy:
newobj = make_copy(obj)
newobj = make_copy.make_copy(obj)
else:
newobj = obj
pla = obj.Placement
@@ -198,7 +197,7 @@ def copy_moved_edges(arguments):
copied_edges = []
for argument in arguments:
copied_edges.append(copy_moved_edge(argument[0], argument[1], argument[2]))
join_wires(copied_edges)
join.join_wires(copied_edges)
copyMovedEdges = copy_moved_edges
@@ -214,4 +213,6 @@ def copy_moved_edge(object, edge_index, vector):
vertex2 = object.Placement.multVec(object.Points[0]).add(vector)
else:
vertex2 = object.Placement.multVec(object.Points[edge_index+1]).add(vector)
return make_line(vertex1, vertex2)
return make_line.make_line(vertex1, vertex2)
## @}

View File

@@ -20,23 +20,21 @@
# * USA *
# * *
# ***************************************************************************
"""This module provides the code for Draft offset function.
"""
"""Provides functions to create offsets of different shapes."""
## @package offset
# \ingroup DRAFT
# \brief This module provides the code for Draft offset function.
# \ingroup draftfuctions
# \brief Provides functions to create offsets of different shapes.
## \addtogroup draftfuctions
# @{
import math
import FreeCAD as App
import DraftVecUtils
import draftutils.gui_utils as gui_utils
import draftutils.utils as utils
from draftmake.make_copy import make_copy
from draftmake.make_rectangle import makeRectangle
from draftmake.make_wire import makeWire
from draftmake.make_polygon import makePolygon
@@ -244,3 +242,5 @@ def offset(obj, delta, copy=False, bind=False, sym=False, occ=False):
if delete:
App.ActiveDocument.removeObject(delete)
return newobj
## @}

View File

@@ -20,24 +20,23 @@
# * USA *
# * *
# ***************************************************************************
"""This module provides the code for Draft rotate function.
"""
"""Provides functions to rotate shapes around a center and axis."""
## @package rotate
# \ingroup DRAFT
# \brief This module provides the code for Draft rotate function.
# \ingroup draftfuctions
# \brief Provides functions to rotate shapes around a center and axis.
## \addtogroup draftfuctions
# @{
import math
import FreeCAD as App
import DraftVecUtils
import draftutils.utils as utils
import draftutils.groups as groups
import draftutils.gui_utils as gui_utils
from draftfunctions.join import join_wires
from draftmake.make_line import make_line
from draftmake.make_copy import make_copy
import draftutils.groups as groups
import draftfunctions.join as join
import draftmake.make_line as make_line
import draftmake.make_copy as make_copy
def rotate(objectslist, angle, center=App.Vector(0,0,0),
@@ -91,7 +90,7 @@ def rotate(objectslist, angle, center=App.Vector(0,0,0),
real_axis = axis
if copy:
newobj = make_copy(obj)
newobj = make_copy.make_copy(obj)
else:
newobj = obj
if obj.isDerivedFrom("App::Annotation"):
@@ -207,7 +206,7 @@ def copy_rotated_edges(arguments):
for argument in arguments:
copied_edges.append(copy_rotated_edge(argument[0], argument[1],
argument[2], argument[3], argument[4]))
join_wires(copied_edges)
join.join_wires(copied_edges)
copyRotatedEdges = copy_rotated_edges
@@ -229,5 +228,6 @@ def copy_rotated_edge(object, edge_index, angle, center, axis):
vertex2 = rotate_vector_from_center(
object.Placement.multVec(object.Points[edge_index+1]),
angle, axis, center)
return make_line(vertex1, vertex2)
return make_line.make_line(vertex1, vertex2)
## @}

View File

@@ -20,24 +20,19 @@
# * USA *
# * *
# ***************************************************************************
"""This module provides the code for Draft scale function.
"""
"""Provides functions to scale shapes."""
## @package scale
# \ingroup DRAFT
# \brief This module provides the code for Draft scale function.
import math
# \ingroup draftfuctions
# \brief Provides functions to scale shapes.
## \addtogroup draftfuctions
# @{
import FreeCAD as App
import DraftVecUtils
import draftutils.gui_utils as gui_utils
import draftutils.utils as utils
from draftfunctions.join import join_wires
from draftmake.make_copy import make_copy
import draftutils.gui_utils as gui_utils
import draftfunctions.join as join
import draftmake.make_copy as make_copy
def scale(objectslist, scale=App.Vector(1,1,1),
@@ -70,7 +65,7 @@ def scale(objectslist, scale=App.Vector(1,1,1),
newobjlist = []
for obj in objectslist:
if copy:
newobj = make_copy(obj)
newobj = make_copy.make_copy(obj)
else:
newobj = obj
if hasattr(obj,'Shape'):
@@ -202,7 +197,9 @@ def copy_scaled_edges(arguments):
for argument in arguments:
copied_edges.append(copyScaledEdge(argument[0], argument[1],
argument[2], argument[3]))
join_wires(copied_edges)
join.join_wires(copied_edges)
copyScaledEdges = copy_scaled_edges
## @}

View File

@@ -20,15 +20,15 @@
# * USA *
# * *
# ***************************************************************************
"""This module provides the code for Draft split functions.
"""
"""Provides functions to split wires into separate wire objects."""
## @package split
# \ingroup DRAFT
# \brief This module provides the code for Draft split functions.
# \ingroup draftfuctions
# \brief Provides functions to split wires into separate wire objects.
## \addtogroup draftfuctions
# @{
import draftutils.utils as utils
from draftmake.make_wire import make_wire
import draftmake.make_wire as make_wire
def split(wire, newPoint, edgeIndex):
@@ -43,10 +43,10 @@ def split(wire, newPoint, edgeIndex):
def split_closed_wire(wire, edgeIndex):
wire.Closed = False
if edgeIndex == len(wire.Points):
make_wire([wire.Placement.multVec(wire.Points[0]),
make_wire.make_wire([wire.Placement.multVec(wire.Points[0]),
wire.Placement.multVec(wire.Points[-1])], placement=wire.Placement)
else:
make_wire([wire.Placement.multVec(wire.Points[edgeIndex-1]),
make_wire.make_wire([wire.Placement.multVec(wire.Points[edgeIndex-1]),
wire.Placement.multVec(wire.Points[edgeIndex])], placement=wire.Placement)
wire.Points = list(reversed(wire.Points[0:edgeIndex])) + list(reversed(wire.Points[edgeIndex:]))
@@ -67,7 +67,9 @@ def split_open_wire(wire, newPoint, edgeIndex):
elif index > edgeIndex:
wire2Points.append(wire.Placement.multVec(point))
wire.Points = wire1Points
make_wire(wire2Points, placement=wire.Placement)
make_wire.make_wire(wire2Points, placement=wire.Placement)
splitOpenWire = split_open_wire
## @}

View File

@@ -20,21 +20,20 @@
# * USA *
# * *
# ***************************************************************************
"""Provides the code for Draft upgrade function.
"""Provides functions to upgrade objects by different methods.
See also the `downgrade` function.
"""
## @package downgrade
# \ingroup DRAFT
# \brief Provides the code for Draft upgrade function.
# \ingroup draftfuctions
# \brief Provides functions to upgrade objects by different methods.
import re
import lazy_loader.lazy_loader as lz
import FreeCAD as App
import lazy_loader.lazy_loader as lz
import draftutils.gui_utils as gui_utils
import draftutils.utils as utils
import draftutils.gui_utils as gui_utils
import draftfunctions.draftify as ext_draftify
import draftfunctions.fuse as fuse
import draftmake.make_line as make_line
@@ -48,8 +47,12 @@ from draftutils.translate import _tr
Part = lz.LazyLoader("Part", globals(), "Part")
DraftGeomUtils = lz.LazyLoader("DraftGeomUtils", globals(), "DraftGeomUtils")
Arch = lz.LazyLoader("Arch", globals(), "Arch")
_DEBUG = False
## \addtogroup draftfuctions
# @{
def upgrade(objects, delete=False, force=None):
"""Upgrade the given objects.
@@ -505,3 +508,5 @@ def upgrade(objects, delete=False, force=None):
gui_utils.select(add_list)
return add_list, delete_list
## @}