Commit Graph

96 Commits

Author SHA1 Message Date
vocx-fc
0f30c8ba2b Draft: migrate DraftText type to Text 2020-07-10 12:23:43 +02:00
vocx-fc
70617e2e85 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 9873eb0a74.
2020-07-07 10:15:14 +02:00
luz.paz
ef37cc3930 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
245fa7af0f 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
8f0a7696c2 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
d5cafc3138 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
462b303c49 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
93f1e87bc0 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
63df9aa7dc 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
d8bb119768 Draft: adjust text of tooltip in arrays 2020-06-17 12:13:39 +02:00
vocx-fc
61f8ab8829 Draft: fix small warning for the DraftLink class used in arrays 2020-06-17 12:13:39 +02:00
vocx-fc
48fe9d4088 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
6b14fa35dc 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
8c3ee6e4b3 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
d23b664a2e 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
fa092ae3df 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
9dc454ea2a 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
1983172f5a Draft: fixed wrong QT_TRANSLATE_NOOP usage in Draft Objects
.
2020-06-09 11:55:46 +02:00
vocx-fc
f6378b1c0b 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
286be34765 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
f955519903 Draft: migrate older properties of PathArray 2020-06-05 13:14:46 +02:00
vocx-fc
17de210655 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
641a7d596a 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
07ee03b928 Draft: set the properties of PathArray through functions 2020-06-05 13:14:46 +02:00
vocx-fc
da2504efdd 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
vocx-fc
466751c7a8 Draft: clean up code, PEP8, and docstrings in PathArray
Test the inputs to the `make_path_array` function
and return `None` if there is a problem.

Now the make function accepts as input a `"String"` which must be
the `Label` of an object in the document, so it is easier to create
arrays quickly from the Python console.

Add the new parameters to the make function, `align_mode`,
`tan_vector`, `force_vertical`, and `vertical_vector`.
These properties were added to the proxy object in 0db11da9cf.

Add  message deprecating the older call `makePathArray`.

Adjust the GuiCommand accordingly. Now it uses the commit
mechanism of the parent `Modifier` class so that the executed
functions are recorded in the Python console.

Clean up the `PathArray` class as well.
2020-06-05 13:14:46 +02:00
vocx-fc
f40d0efee1 Draft: separate the placement functions from the Array class
This way they can be tested individually in the Python console
without needing the `Array` class at all. In the future these
methods could be moved to `DraftGeomUtils` or to `draftfunctions`.
2020-06-03 14:47:44 +02:00
vocx-fc
2ee20d1a7a Draft: hide properties of other array types in Array class
Leave only the corresponding properties by examining
the value of `ArrayType`.
2020-06-03 14:47:44 +02:00
vocx-fc
1c480fd5dc Draft: set the properties of the Array through functions
Since the `Array` class handles three different types, they
have different sets of properties. We add them to specific functions
so that they are clearly identified.
2020-06-03 14:47:44 +02:00
vocx-fc
ca9cfc6804 Draft: clean up code, PEP8, and docstrings for Array class
Added author of the `CircularArray` array type, "M. G. Berberich"
(berberic2) or "rynn" in the forum.
2020-06-03 14:47:44 +02:00
vocx-fc
d93e8518b0 Draft: clean up code, PEP8, and docstrings for DraftLink
This class was created by realthunder during the `LinkMerge`,
in 8cd9339b8c, to demonstrate how to use the `App::Link`
objects to create Link aware arrays.

It is used by `draftobject.array` (ortho, polar, circular)
and `draftobject.patharray` to create respective Link arrays.

This class is a bit mysterious. We need more documentation
on how the properties are being set, and how the code interacts
with the arrays that use it.
2020-06-03 14:47:44 +02:00
vocx-fc
22c9f9a762 Draft: migrate PointList property to PointObject in PointArray
Use the `onDocumentRestored` method to check for the old
property.

Also modify the position of the base object in the draft test
script.
2020-06-03 14:44:00 +02:00
vocx-fc
eaea9bed6f Draft: add additional displacement property for PointArray
The displacement is added to the position already defined by
the point, in order to impart an additional shift in the copy.

The rotation is also added to the original shape's rotation
by multiplying the quaternions.

Implement `onDocumentRestore` to add the new property
to older objects.
2020-06-03 14:44:00 +02:00
vocx-fc
62d5df3508 Draft: clean up code, PEP8, and docstrings for PointArray
Test the inputs to the `make_point_array` function
and return `None` if there is a problem.

Now the make function accepts as input a `"String"` which must be
the `Label` of an object in the document, so it is easier to create
arrays quickly from the Python console.

Add a message deprecating the older call `makePointArray`.

Adjust the GuiCommand accordingly. Now it uses the commit
mechanism of the parent `Modifier` class so that the executed
functions are recorded in the Python console.

Clean up the `PointArray` class as well.
2020-06-03 14:44:00 +02:00
wandererfan
c203879b50 [Draft]Path Array tangent rotation direction 2020-06-02 13:55:44 -04:00
Yorik van Havre
d97ee0d4a5 Draft: Added Area and Offset properties to Facebinder 2020-06-02 14:00:25 +02:00
Yorik van Havre
83aaa29bb5 Draft: Fixed translation regression 2020-06-02 13:44:46 +02:00
vocx-fc
8c3705599d Draft: small fix for older PathArray objects
Older PathLinkArray objects had a `useLink` attribute
which was migrated to `use_link`. A recent commit, 0db11da9cf,
made some improvements to the PathArray
object, but broke the migration of the property.

This fixes the migration, so that now all objects should
open correctly.
2020-05-29 13:34:34 +02:00
wandererfan
6a3b2a02f5 [Draft]Post-review changes 2020-05-23 11:22:14 -04:00
wandererfan
a697c838fc [Draft]Additional modes for PathArray 2020-05-23 11:22:14 -04:00
vocx-fc
3172e82dc1 Draft: move circular, ortho, and polar make functions
Previously they were in `draftobjects`, but since they
don't define new objects, just create objects,
they are moved to `draftmake`.

Also ajust the `CMakeLists.txt` and the corresponding Gui Commands
which use these make functions.

These functions internally use the `Draft.makeArray` function.
We will put comments as reminders so that when this function
is moved to its own module, we can update the derived functions.
2020-05-18 12:42:10 +02:00
carlopav
0e9d274bf4 Draft: various cleanup
Mainly added an empty line at the end of each file and changed docstrings.
2020-05-15 14:43:26 +02:00
carlopav
1733b6dc74 Draft: split DrawingView from Draft.py 2020-05-15 14:43:26 +02:00
carlopav
767413997d Draft: cleanup of Array properties after splitting 2020-05-15 14:43:26 +02:00
carlopav
fe29205e60 Draft: split Array from Draft.py 2020-05-15 14:43:26 +02:00
carlopav
a4b5fb2cd4 Draft: split PointArray from Draft.py 2020-05-15 14:43:26 +02:00
carlopav
ebc84af368 Draft: split Path Array and viewprovider Array from Draft.Py
Draft: fix typo in PathArray
2020-05-15 14:43:26 +02:00
carlopav
c53f447f58 Draft: Split DraftLink from Draft.py 2020-05-15 14:43:26 +02:00
vocx-fc
785023d898 Draft: split Fillet code into various modules
The original code was in `DraftFillet.py` which is split
into a different modules like the rest of the workbench.

The object code is in `draftobjects`, the viewprovider
is in `draftviewproviders`, and the function to create it
is in `draftmake`.
2020-05-13 11:37:56 +02:00
vocx-fc
a79664d3e3 Draft: small updates to the Annotation class
This annotation class implements `onDocumentRestored`
in order to add the `ScaleMultiplier` property to older
`Dimension`, `Label`, and `Text` objects.
2020-05-12 10:02:21 +02:00