Commit Graph

103 Commits

Author SHA1 Message Date
carlopav
d115db2cbb Draft: Autogroup, insert guard to prevent cyclic references
ref. Forum discussion: Draft_OrthoArray: Crash when using active Std_Part. https://forum.freecadweb.org/viewtopic.php?f=23&t=59155&p=508132#p508132

Autogroup try to add new created Draft Objects into the active Part, but if the Part is used as a Base for the new object this could create a cyclic reference. 
This behaviour is prevented by adding a check for " obj in active_part.InListRecursive"
2021-06-06 11:21:21 +02:00
carlopav
f050f77343 Draft: Autogroup, rename variables to more readable names 2021-06-05 17:07:32 +02:00
Matthijs Kooijman
19ada8fd1f Draft: Do not move children of App::Link objects
This caused the original object to be moved when using the Draft move
tool to move a link object, when the original object has MoveWithHost
set (e.g. a Window). There was already a similar exception for clones,
so it makes sense to extend this for links too.

Note that there seem to be more problems with the "MoveWithHost"
mechanism and fixing them might completely refactor this code, but until
then, this is a simple and targeted fix that at least makes moving
links to windows work as expected.

See https://forum.freecadweb.org/viewtopic.php?f=23&t=57223 for
discussion of this bug, its fix and the additional problems mentioned.
2021-05-22 16:51:04 +02:00
Matthijs Kooijman
82d0d3007d Draft: Improve docs for get_group_contents spaces parameter
The documentation suggested subtly different semantics from what the
code implements.
2021-05-09 17:33:46 +02:00
Yorik van Havre
e2e380655b Draft: Allow to set 'arch' unit override on dimensions 2021-04-29 19:51:34 +02:00
Yorik van Havre
317177dad6 Draft: Fixed default color for new dimensions (now uses DefautTextColor instead of DefaultLineColor) 2021-04-23 15:46:39 +02:00
Łukasz Stelmach
d35daaeffd Draft: Ensure horizontal orientation of snap_widget
From time to time when switching to other workbenches snap_widget changes
orientation to vertical. Make sure it stays horizontal.

Signed-off-by: Łukasz Stelmach <stlman@poczta.fm>
2021-04-19 19:58:06 +02:00
Benjamin Nauck
6d37a38437 Draft: Simplify load_texture after py3 requirement
This commit does the following things:
 * Remove python2 support
 * Using a bytearray instead of chr list to build up the binary data.
   this also removes the need of using char encoding.
2021-03-10 20:49:29 +01:00
paul lee
0e81e76f7d [Draft.draftutils.groups] get_windows() to support Links
FC Forum Discussion - https://forum.freecadweb.org/viewtopic.php?f=23&t=55438
2021-02-12 09:59:28 +08:00
Chris Hennes
fe7e45a7de [DRAFT] Catch only Exception, not BaseException 2021-02-11 11:52:45 +01:00
luz paz
2a8c1271d5 Draft: fix header uniformity + trailing whitespace
[skip ci]
2020-12-11 13:19:49 +01:00
Yorik van Havre
f13c8974b5 Draft: Colored grid axes 2020-12-03 15:15:15 +01:00
Yorik van Havre
bff31175cb Draft: better checks for no active document 2020-11-16 13:25:12 +01:00
Yorik van Havre
88f5fc20b1 Draft: Condensed the Draft toolbar style buttons into one with more options 2020-11-10 14:14:18 +01:00
Yorik van Havre
0fdd157394 Draft: Added TechDraw patterns 2020-10-26 11:52:14 +01:00
Yorik van Havre
71cd301ca7 Draft: Added pref option to set default dimension unit 2020-10-14 17:21:27 +02:00
Yorik van Havre
4134315434 Draft: Fixed translation of construction group 2020-10-12 16:11:31 +02:00
Yorik van Havre
5609b38e9a Draft: Fixed patterns + added default pattern size pref option 2020-10-12 15:12:50 +02:00
vocx-fc
49e1ff1bcf Draft: get_bbox function to get the bounding box from RootNode
Normally the bounding box is taken from `Shape.BoundBox`.
Certain objects don't have a `Shape`, like `App::FeaturePythons`,
so the bounding box is calculated from `ViewObject.RootNode`.
2020-09-30 12:06:48 +02:00
Amritpal Singh
21e1dff25c Adopted vocx-fc comment. 2020-09-29 18:50:30 +02:00
Amritpal Singh
c64d0bf991 Fixed bug: In exporting IFC with shared clone shapes geometry, clone of clone object displaced because of bug in Draft.get_clone_base function. 2020-09-29 18:50:30 +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
carlopav
28c00f8383 Draft: provide the possibility to implement support for Edit in objs
As suggested by @Vanuan. and already implemented in new experimental BIM Wall: 1084a4b0a9
Draft: updated Draft Edit

thanks to the suggestions by @Vanuan
Draft: further bugfixing and improvements in Draft_Edit


Draft: moved Draft_Edit preview code into respective GuiTools
2020-09-09 14:13:29 +02:00
vocx-fc
6a3de864e7 Draft: add modules of draftutils to the proper Doxygen group
This includes `gui_utils`, `init_draft_statusbar`, `init_tools`,
`messages`, `todo`, `translate`, `utils`.

These are added to the `draftutils` Doxygen group
so that the functions 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
ec1a720bfb Draft: move the convertDraftTexts function to make_text
The old `convertDraftTexts` function was moved from the `Draft.py`
module to the `draftutils.utils` module; however, here it is
not possible to use because the `makeText` function
is not accessible. Therefore, the function is moved to
`draftmake.make_text`.
2020-07-13 14:35:38 +02:00
vocx-fc
aaeab8bc5d Draft: move units functions outside DraftGui.py
The functions `getDefaultUnit`, `makeFormatSpec`, `displayExternal`
are used to get the default unit schema for lengths and angles,
and display a string with a particular format.

They aren't used in `DraftGui.py`, but are used by the
viewprovider of the Dimension objects. Therefore, they are moved
into a separate module, so that they can be imported without
using the entire `DraftGui` module.
2020-07-10 12:29:30 +02:00
vocx-fc
94b0fe1599 Draft: clean up ViewProviderLabel class
Various improvements in style, PEP8, spacing, docstrings.

Improve the methods to update the text, the arrow, and the frame
of the label.

Options to handle `Justification` and `LineSpacing` are added.
These can be handled just like with the `ViewProviderText` object,
as the internal text node is the same, a `SoAsciiText`.

Nevertheless, currently the leader line and the frame that are
drawn for the label don't consider the correction in position
for the `Justification` or `Linespacing` so the graphics
may be overlapped in certain situations.
2020-07-10 12:23:43 +02:00
vocx-fc
22e9cf8921 Draft: clean up ViewProviderText class
Various improvements in style, PEP8, spacing, docstrings.

The list of strings is set to empty before being assigned again.
This solves a problem of the text not being updated correctly.

In the past some `try-except` blocks were there to catch and
ignore certain exceptions that apparently were caused by a
race condition, where certain properties are not assigned
to the object before they are used. These errors
don't seem to occur in v0.19, so we removed the exception
handling. We leave comments mentioning the issue
in case it re-appears.

The `DisplayMode` is swapped, so now `'2D text'` means that the
text always faces the camera, and `'3D text'` means that the
text can be positioned in different orientations in the 3D space.
This is consistent with the `Draft Label` behavior.

A function `draftutils.gui_utils.migrate_text_display_mode`
is provided to help migrate older objects of type `Text`
or `DraftText` to the new display mode.
2020-07-10 12:23:43 +02:00
vocx-fc
270e4b100a Draft: move default annotation style properties to utils module
These style properties are used by `ViewProviderDraftAnnotation`
and by the Gui Command `Draft_AnnotationStyleEditor`.

Therefore, they are moved from `draftguitools.gui_annotationstyleeditor`
module to the `draftutils.utils` module, so that they
are in a central location where they won't cause circular
dependencies.
2020-06-19 12:15:25 +02:00
luz.paz
720b0b96d0 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-15 10:11:22 +02:00
vocx-fc
a719859054 Draft: adjust the text size for Labels with format_object
This function, `draftutils.gui_utils.format_object`,
takes the value defined in the `DrafToolBar`, and uses it
to specify the `FontSize` for `Text` objects.

Now it specifies the `TextSize` for `Label` elements as well.
2020-06-15 09:59:57 +02:00
hlg
0759436661 Arch/Draft: minor fixes 2020-06-03 14:50:17 +02:00
vocx-fc
c5193ec6f7 Draft: add use_instead function to warn users about old functions
This can be used to deprecate older definitions
and suggest users to try a different function. This will be used
in the make functions in `draftmake`.
2020-06-02 12:29:50 +02:00
vocx-fc
78d7616ddc Draft: add find_object function to find objects by label in a document
Also add `find_doc` to be able to test the existence of an
active document before searching for the object.

These can be used in the make functions of most modifier commands.
2020-06-02 12:29:50 +02:00
vocx-fc
fea82942d3 Draft: clean up the utils module a bit, PEP8, style 2020-06-02 12:29:50 +02:00
Yorik van Havre
43c4f9af3d Draft: Added a border around the Draft grid (can be disabled in prefs) 2020-05-27 18:02:04 +02:00
carlopav
a98e2076db Draft: Edit reordering 1
Started a general refactor to handle all the conversion between global and object coordinate system inside the main methods and just use object coordinates inside object functions.
Draft: Edit reordering 2

Fixed Editing of Part objects according to the new refactor
Draft: fix in autogroup function for dimensions


Draft: fixed Polygon editing when inscribed or circumscribed


Draft: Edit support for Ellipse object


.


Draft: Edit docstrings


Draft: Edit reordering 3


Draft: Fixed Edit for structure object

And also refactor Edit methods that control special object display during editing.
Draft: Fixed edit for arch wall object
2020-05-25 13:37:55 +02:00
carlopav
5d7ae69c54 Draft: fix Statusbar snap and scale if Draft is the default startup wb
ref: https://forum.freecadweb.org/viewtopic.php?f=23&t=43990&start=50#p396139
2020-05-18 12:19:27 +02:00
carlopav
2c4de88132 Draft: moved ConvertDraftText to utils.py 2020-05-15 14:43:26 +02:00
carlopav
b1e2574f1c Draft: move get_DXF to utils.py 2020-05-15 14:43:26 +02:00
carlopav
3a44b4e2c0 Draft: moved getrgb to utils.py 2020-05-15 14:43:26 +02:00
vocx-fc
d438aec821 Draft: remove old DraftFillet class, and make it a redirect
Remove the make function that creates the old object,
its corresponding Gui Command, and the old `DraftFillet.Fillet`
proxy class, which now is a redirection to the new `Fillet`
class defined in `draftobjects.fillet`.

Also change the unit test, and the `draft_test_object` script
to run `Draft.make_fillet`.
2020-05-13 11:37:56 +02:00
vocx-fc
68e6d8d164 Draft: activate both Fillet commands to test
In this moment the old fillet tool is `Draft_Fillet`
and the new tool is `Draft_Fillet_new`. They are imported both,
so they can both be tested from the interface.
2020-05-13 11:37:56 +02:00
carlopav
64619a615a Draft: Bugfix to getCloneBase after objects splitting 2020-05-12 10:37:20 +02:00
vocx-fc
fee81e8290 Draft: correct description of draftutils package
These utilities are general in the entire workbench,
some of them can be used without a GUI, and some of them
absolutely require the GUI to function.
2020-05-06 12:46:24 +02:00
vocx-fc
da413bd2c2 Draft: small improvements to the todo module
Small ammeds to the docstrings and the use of `App` and `Gui`
namespaces, and the explicit use of the `ToDo` class
in `PascalCase`.
2020-05-04 10:55:18 +02:00
vocx-fc
14423df83c Draft: show the error message of the ToDo class in the terminal
The error is both sent to the log file and to the console
instead of only the log.

This is helpful to troubleshoot problems with the delayed
execution of commands, such as when testing a relatively
broken version like d7a9f2ebf9.
2020-05-04 10:55:18 +02:00
carlopav
ad0a400da2 Draft: split isClosedEdge form Draft.py
.
2020-05-04 10:51:08 +02:00