Commit Graph

121 Commits

Author SHA1 Message Date
Yorik van Havre
01c9010664 Draft: added AutoUpdate property to shape2Dviews to disambiguate with VisibleOnly property 2021-07-07 15:45:22 +02:00
Yorik van Havre
5b32b806f6 Arch: Added Depth property to SectionPlanes 2021-07-01 13:46:24 +02:00
Yorik van Havre
9332e52d94 Draft: Added ExclusionPoints property to shape2dview object 2021-06-01 11:30:04 +02:00
Matthijs Kooijman
ecc05545c1 Draft: Simplify code using getattr default value
This uses the default value that can be passed to getattr to simplify
code that uses it. By choosing an appropriate default value, a separate
call to hasattr can be avoided and in some cases duplicate code can be
avoided.

This applies this trick where possible in wire.py and circle.py.

This commit does not change behavior.
2021-05-22 17:44:04 +02:00
Yorik van Havre
665e8bd32e Draft: Changed shapestring FillLetters property to MakeFace 2021-05-05 15:41:28 +02:00
Yorik van Havre
ccc4151b30 Draft: Added a 'solid faces' projection mode to shape2dviews to treat individual faces 2021-04-30 16:44:20 +02:00
tomate44
0f9ed158de Draft.ShapeString : add option to choose wires or faces output 2021-04-05 12:20:04 +02:00
David Osterberg
f39002fb07 Draft: Fix PathTwistedArray bug 2021-02-22 08:01:34 +01:00
Yorik van Havre
43feb585ad Draft: Fixed broken translations everywhere 2021-02-12 14:44:58 +01:00
Chris Hennes
fe7e45a7de [DRAFT] Catch only Exception, not BaseException 2021-02-11 11:52:45 +01:00
luz paz
ccbc13ee82 Draft: fix LGTM 'Testing for None should use the 'is' operator' alerrts
https://lgtm.com/projects/g/FreeCAD/FreeCAD/alerts/?mode=tree&ruleFocus=7900090
2021-02-03 21:58:47 +01:00
Stefan Tröger
446ce21517 Remove ExtensionProxy and rely on default Python proxy for extensions. fixes #0004534 2021-01-30 16:00:48 +01:00
luz paz
2a8c1271d5 Draft: fix header uniformity + trailing whitespace
[skip ci]
2020-12-11 13:19:49 +01:00
Zheng, Lei
4d3ea2d850 Draft: support object without shape in DraftLink 2020-10-19 13:22:20 +02:00
marioalexis
aa88f3ded0 Improve make_sketch and geometric related functions 2020-10-19 13:15:14 +02:00
vocx-fc
f799717f4d Arch: consider DraftText objects in the section plane for compatibility
After the reorganization of the Draft Workbench,
the `'DraftText'` objects are now of Proxy.Type `'Text'`.
In the `DraftAnnotation` class the `__setstate__` method
was defined to automatically migrate the Type.

The `Arch SectionPlane` only handles `'Text'` objects. If for
some reason there is still an old `'DraftText'` object
which has not been migrated to the new Type, it won't be found.
This is corrected by adding `'DraftText'` to the list of objects
to process.
2020-10-12 11:43:37 +02:00
Zheng, Lei
31e8bb27a6 Draft: fix point array without using link 2020-09-21 14:01:42 +02:00
Zheng, Lei
607c14b512 Draft: add support for point link array 2020-09-21 14:01:39 +02:00
vocx-fc
c79f890112 Draft: move getDXF to draftfunctions submodule
Update the appropriate interface in `Draft.py`.
2020-09-16 13:09:13 +02:00
vocx-fc
7627d0b81a Draft: move getSVG to draftfunctions submodule
Small fixes where the `get_svg` function is used, for example,
in the (obsolete) `DrawingView` class and `Arch_SectionPlane`.

Also update the unit tests accordingly.
2020-09-09 12:53:54 +02:00
vocx-fc
e477283ffc Draft: new PathTwistedArray object
It takes a `Shape` and replicates it around a path, while at the
same time adding a rotation to each copy. This can be used to create
a twisted "ribcage" from a frame-like object, which can be used
in a more complicated `Shape`, for example, a tunnel or bridge
object.
2020-09-03 12:34:16 +02:00
vocx-fc
831e517717 Draft: migrate Layer object and function to the new structure
Move `make_layer` to `draftmake`; `Layer` and `LayerContainer`
to `draftobjects`; `ViewProviderLayer` and `ViewProviderLayerContainer`
to `draftviewproviders`.

The make function and the classes are imported in `Draft.py`
to support the usage of the older `VisGroup`.
2020-07-20 14:21:15 +02:00
vocx-fc
42599838f4 Draft: add modules of draftobjects to the proper Doxygen group
This includes `array`, `base`, `bezcurve`, `block`, `bspline`,
`circle`, `clone`, `dimension`, `draft_annotation`, `draftlink`,
`drawingview`, `ellipse`, `facebinder`, `fillet`, `label`,
`patharray`, `point`, `pointarray`, `polygon`, `rectangle`,
`shape2dview`, `shapestring`, `text`, `wire`, `wwproxy`.

These are added to the `draftobjects` Doxygen group
so that the functions and classes contained in each module
are listed appropriately in the automatically generated
documentation.
2020-07-17 13:01:45 +02:00
vocx-fc
91a23e4a40 Draft: add Doxygen strings to the packages' __init__ files
The packages are `draftfunctions`, `draftgeoutils`, `draftguitools`,
`draftmake`, `draftobjects`, `drafttaskpanels`, `drafttests`,
`draftutils`, `draftviewproviders`.
2020-07-17 13:01:45 +02:00
vocx-fc
6503d9351d Draft: move grouping functions to draftutils.groups module
These functions were previously in `draftutils.utils`,
and are related to grouping objects and finding objects
inside groups. These include `get_group_names`, `ungroup`,
`get_windows`, `get_group_contents`, `get_movable_children`.
These are imported in the main `Draft.py` module, so compatibility
is retained.

Modules which use these functions are updated; these include
Gui Commands like `Move`, `Rotate`, `Scale`, `AddToGroup`,
as well as objects like `DrawingView` and `Shape2DView`,
and `ViewProviderClone`.
The code inside the `importDXF` module is also updated.

The Arch Workbench uses many of these functions
but it does so from the `Draft` namespace, so these edits
don't change the situation for these commands.
2020-07-13 14:35:38 +02:00
vocx-fc
de6f251f75 Draft: migrate DraftText type to Text 2020-07-10 12:23:43 +02:00
vocx-fc
f2750cbe72 Draft: set a space before the Link group
For some reason all `App::Link` properties are in a group that
starts with a space, so `' Link'`, not just `'Link'`.

This was changed in 927379c175.
2020-07-07 10:15:14 +02:00
luz.paz
1da81df756 Fix typos [skip-ci]
Found via codespell v1.18.0.dev0  
```
codespell -q 3 -L aci,ake,aline,alle,alledges,alocation,als,ang,anid,ba,beginn,behaviour,bloaded,byteorder,calculater,cancelled,cancelling,cas,cascade,centimetre,childs,colour,colours,commen,connexion,currenty,dof,doubleclick,dum,eiter,elemente,ende,feld,finde,findf,freez,hist,iff,indicies,initialisation,initialise,initialised,initialises,initialisiert,ist,kilometre,lod,mantatory,methode,metres,millimetre,modell,nd,noe,normale,normaly,nto,numer,oder,orgin,orginx,orginy,ot,pard,pres,programm,que,recurrance,rougly,seperator,serie,sinc,strack,substraction,te,thist,thru,tread,uint,unter,vertexes,wallthickness,whitespaces -S ./.git,*.po,*.ts,./ChangeLog.txt,./src/3rdParty,./src/Mod/Assembly/App/opendcm,./src/CXX,./src/zipios++,./src/Base/swig*,./src/Mod/Robot/App/kdl_cp,./src/Mod/Import/App/SCL,./src/WindowsInstaller,./src/Doc/FreeCAD.uml
```
2020-06-29 20:52:23 +02:00
vocx-fc
3f75dc7c61 Draft: clean up the ViewProviderDraftAnnotation class
This class is the base of the viewproviders of annotation-type
objects like dimensions (linear, radial, angular), labels,
and texts.

The basic properties of `ViewProviderDraftAnnotation`
are set up by a method `set_properties`, which can be called
in the derived classes.

In the general proxy object `DraftAnnotation` we implement
the `onDocumentRestored` method in order to add the missing
view property `AnnotationStyle` to older objects.
2020-06-19 12:15:25 +02:00
vocx-fc
96d81c77b2 Draft: add prototype function to AngularDimension to link objects
At the moment the user must manually modify `FirstAngle`
and `LastAngle` to obtain a new `Angle`, but since the values
are manually entered the result is not tied to any actual object
in the document.

We introduce a function `measure_two_obj_angles`
to calculate the corresponding parameters from a pair of objects
and their edges.
Currently this function is deactivated because it is intended
for testing purposes only.

This needs to be improved because at the moment it only gives
two possible angles. We should be able to get the four angles
of a two-line intersection. Maybe a new property is required
to indicate the quadrant to choose and display.
2020-06-17 12:53:29 +02:00
vocx-fc
4ef2063715 Draft: organize execute code of the dimension classes
Instead of placing the entire code in the `execute` method,
we use three medthods to extract the `Start` and `End` dimension
points from different combinations of edges.

One method to get the dimension from a single object, from the edge,
either linear or circular; one method to get the dimension
from a single object, from two vertices; one method to measure
the distance between two objects, from two different vertices.
2020-06-17 12:53:29 +02:00
vocx-fc
c042eb7454 Draft: set properties of the Dimension class through functions
There are three classes `DimensionBase`, `LinearDimension`, and
`AngularDimension`, their properties are set only if they don't
already exist.

Provide also better documentation in the tooltips,
and use `setPropertyStatus` to hide and show the intended
properties in the property editor.

The `Support` property is not used at all except as a way to
store an object, so it should probably be removed in the future.
2020-06-17 12:53:29 +02:00
vocx-fc
e81ca586a2 Draft: move make_dimension function to its own module
Previously the `make_dimension` and `make_angular_dimension`
functions were in `draftobjects/dimension.py`.
Now they are moved to `draftmake/make_dimension.py`.

The original `makeAngularDimension` function requires angles
in radians which is counterintuitive for most cases. Also
the order is `[big, small]`.

The new function `make_angular_dimension` accepts angles
in degrees, and the order is `[small, big]`. The older
function is retained for compatibility purposes.

Also perform several improvements such as PEP8 cleanup,
writing complete docstrings, type checking the input arguments,
and depreacting the older call.

The `Draft.py` module, Gui Command, unit test, and test script
are updated accordingly.
2020-06-17 12:53:29 +02:00
vocx-fc
9d0e4259c3 Draft: clean up the internal DraftAnnotation class
Add a function to clarify the added properties,
and clean up the PEP8 style of the code.
2020-06-17 12:53:29 +02:00
vocx-fc
86dd7cbe05 Draft: adjust text of tooltip in arrays 2020-06-17 12:13:39 +02:00
vocx-fc
927379c175 Draft: fix small warning for the DraftLink class used in arrays 2020-06-17 12:13:39 +02:00
vocx-fc
466ae17a4a Draft: hide properties not used in the Label object
When `LabelType` is `'Custom'`, the `Target` property
is hidden and `CustomText` is shown.

For other values of `LabelType`, `Target` is shown,
and in turn `CustomText` is hidden.

This avoids showing unused information in the property editor.
2020-06-15 10:01:04 +02:00
vocx-fc
bbdd9abcdc Draft: combine two types of labels using functions
We use smaller functions to return a list of strings corresponding
to each basic value of `LabelType`. Then the final `Text` value
can be defined as a simple value, or as the concatenation
of two smaller lists, depending on the value of `LabelType`.

Since we have 8 basic values, we could return up to 8^2
combinations, but at the moment we only return 8 basic
values and 5 simple combinations, which are the ones
that make the most sense.

In the future we could define new properties, say, `LabelType2`
and `LabelType3`, to be able to combine two or three types
of strings in an arbitrary fashion. At the moment, the possible
combinations are hard coded in `LabelType`.
2020-06-15 10:01:04 +02:00
vocx-fc
d3d904e381 Draft: organize the execute code of the Label in a function
Instead of placing the entire code in the `execute` method,
a `return_info` function is used to return the specific string
that we wish to display depending on the `Target` object,
 the `LabelType`, and subelement in `Target`, if any.

We also make the code more readable by using smaller variables,
and avoiding notations with lists of lists (`variable[0][1][6:]`).
2020-06-15 10:01:04 +02:00
vocx-fc
40e707ef4b Draft: set the properties of the Label class through functions
There are three general types of properties, target, leader,
and label; so we set the 9 properties using three functions,
and provide better documentation in the tooltips
for each property.
2020-06-15 10:01:04 +02:00
vocx-fc
c7eab9c65e Draft: move make_label function to its own module
Also perform several improvements such as PEP8 cleanup,
writing complete docstrings, type checking the input arguments,
and deprecating the older call.

Update `Draft.py`, the Gui Command, the unit test, and test script
as well.
2020-06-15 10:01:04 +02:00
vocx-fc
327b306307 Draft: add some explanation on the properties of PathArray
The use of `App::PropertyLinkSubList` for `'PathSubelements'`
is a mistake because we could use a single `App::PropertyLinkSub`
to handle both `'PathObject'` and `'PathSubelements'` properties.

This commit doesn't change any code, it just adds comments
explaining the situation so that it is not forgotten,
and we remember to address it in the future.

Ideally we should migrate the objects, but we may also decide
to break compatibility with older `PathArrays` if both properties
can't be migrated easily.
2020-06-09 12:02:25 +02:00
carlopav
904f3408bc Draft: fixed wrong QT_TRANSLATE_NOOP usage in Draft Objects
.
2020-06-09 11:55:46 +02:00
vocx-fc
c700dc5d05 Draft: improve handling of Part::Vertex when used with PointArray
The `Part::Vertex` object has both `Placement`, and `X`, `Y`, `Z`
properties. The net displacement is the sum of both of these two
properties.

Previously, the `PointArray` would only use the `Placement`
which would produce a seemingly erroneous result
because `X`, `Y`, and `Z` would be ignored.
2020-06-05 13:21:02 +02:00
vocx-fc
565f2b35b4 Draft: move make_text function to its own module
Also perform several improvements such as PEP8 cleanup,
write complete docstring, type checking of the input arguments,
accepting a full placement to modify the position,
and deprecating the older call.

Update the Gui Command as well.
2020-06-05 13:20:35 +02:00
vocx-fc
7caa8d4dcf Draft: migrate older properties of PathArray 2020-06-05 13:14:46 +02:00
vocx-fc
f2f22e155b Draft: rename PathArray properties
`PathObj` becomes `PathObject`, `Xlate` becomes `ExtraTranslation`,
and `PathSubs` becomes `PathSubelements`.

Update `make_path_array` function and the Gui Command.
2020-06-05 13:14:46 +02:00
vocx-fc
f1bcffbc16 Draft: hide properties not used in the PathArray
Certain properties do not need to be shown in the property editor
when a particular `AlignMode` is chosen. This keeps the number
of properties displayed organized and easy to manage.
2020-06-05 13:14:46 +02:00
vocx-fc
572788edd7 Draft: set the properties of PathArray through functions 2020-06-05 13:14:46 +02:00
vocx-fc
9dd1c2efa5 Draft: cleanup logic of PathArray proxy object code
Return early from the `execute` method if no base or path exist.

Add method `get_wires` which internally uses `get_wire_from_subelements`
(renamed method), to get the edges from the path object,
and its subelements, if any. If no wires are found
return early from `execute`.

The final rotation applied to the copies will be the base rotation
of the base object's shape. The only exception is when the
`AlignMode` is `'Tangent'`; in this case, it performs
a pre-rotation with the `TangentVector`.
2020-06-05 13:14:46 +02:00