Commit Graph

63 Commits

Author SHA1 Message Date
Roy-043
01409c1407 Draft: gui_utils.py fix error in select function (#19539)
* Draft: gui_utils.py fix error in select function

PR #18795 changed the select function to also handle tuples. This PR adds a check to ensure the referenced objects in the tuple still exist before calling `Gui.Selection.addSelection()`.
2025-02-13 16:00:30 +01:00
Mino-Tsuzuku
0ce232b38a * Move pyopen with encoding to utils. (#19377)
and modify all importing library to use pyopen with encoding.
with this change, DXF OCA AirfoilDAT with multibyte sequence always read as utf-8.
2025-02-04 11:33:43 +01:00
Roy-043
58a7b2ff28 Draft: updates related to transparency to alpha change 2025-01-22 10:04:47 +01:00
Roy-043
2ee620ab42 Draft: make move, rotate and scale commands link-aware (#18795)
* Draft: make move, rotate and scale commands link-aware

Fixes #12836.
Fixes #15681.

These changes are presented as a single ('big') PR because the mentioned commands have several similarities. Working on them seperately would have made less sense.

The commands have been made 'link-aware' meaning they can now handle Links and objects in linked containers.

This required several changes in the following main files. For each command all options are handled by a single function now (the `move`, `rotate` and `scale` functions). This was the only reasonable solution to correctly handle nested placements. As a result there is no longer a need to build very complex 'cmd' strings in the gui_*.py files (which is a good thing IMO).

Main files:

* move.py
* rotate.py
* scale.py
* gui_move.py
* gui_rotate.py
* gui_scale.py
* gui_trackers.py

The following files have also been updated:

* Draft.py: Imports updated.
* DraftGui.py: If `CopyMode` is changed the ghosts have to be updated. The move and rotate commands now also show previews of movable children. But since those are not copied they should be removed from the ghosts if `CopyMode` is changed to `True`.
* utils.py: Some helper functions have been added. An existing helper function (only used internally) has been renamed.
* gui_utils.py: The `select` function has been updated to accept a list of tuples to allow the reselection of nested objects.
* clone.py: A new property `ForceCompound`, necessary for non-uniform scaling, has been added.
* join.py: The `join_wires` function now returns the resultant wire objects.
* task_scale.py: Updated to allow negative scale factors. Support for `SubelementMode` preference added.
* dimension.py: `transform` methods added.
* layer.py: `get_layer` function added.
* svg.py: Updated to use `get_layer`.
* view_text.py: Instead of two added `coin.SoTransform()` nodes the main transform node is used instead. This was done so that ghosts of Draft Texts can be handled properly without requiring dedicated code in gui_trackers.py.

Notes:

* Support for "App::Annotation" is limited. Only their `Position` is handled (by the move and rotate commands).
* Support for "Image::ImagePlane" has been removed from the scale command. The object has its own calibrate feature (see https://wiki.freecad.org/Std_Import).
* Copies and clones are always created in the global space.

* Fix several unit test issues.

* Reset value that was changed while testing

* Rebase and update test_modification.py

* Reintroduce scaling of image planes
2025-01-20 18:23:36 +01:00
Roy-043
a78b7ae66a Draft: Remove unnecessary CamelCase names
The related functions were introduced in V0.19. They should not be also available under CamelCase names.
2024-12-26 12:06:29 +01:00
Roy-043
81436e833a get_appearance_material -> get_view_material
Also removed the ret_default argument.
2024-05-11 10:11:16 +02:00
Roy-043
1b2ef7831f Draft: Draft_SetStyle new Material handling
Discussion: #13657.
2024-05-09 10:49:19 +02:00
Roy-043
152d642b60 Draft: revert Draft WB changes from #13294
Revert the Draft WB related changes of #13294.
2024-04-24 21:27:04 +02:00
David Carter
ba20441935 Material: Material appearance
Uses new material system for appearance

Each feature object now has a property called ShapeMaterial that
describes its physical properties. If it has a shape, it has a
material.

The ShapeColor attribute is replaced by a ShapeAppearance attribute.
This is a material list that describes all appearance properties, not
just diffuse color. As a list in can be used for all elements of a
shape, such as edges and faces.

A new widget is provided to allow the user to select materials in a
consistent fashion. It can also launch the material editor with its
more advanced capabilities.
2024-04-04 07:39:58 -05:00
Yorik van Havre
d77f958112 Draft: Made get_type aware of IFC objects 2024-03-18 18:50:56 +01:00
Chris Hennes
7b07447cce Draft: Remove trailing spaces from translations 2024-03-12 22:42:20 -05:00
Kevin Martin
2b9fa18b68 Eliminate many "doing what you told me to" messages
These messages were perhaps originally intended as a debuggin aid but now add clutter to the output panes. Remaining messges are mostly the result of methods to display attributes of an object (which one could call from the Python console) or actually provide some information which would not be obvious from the circumstances
2024-02-02 08:58:45 -05:00
Roy-043
822f2111e3 Draft: implement new get_param functions (step 3)
See #11677
2023-12-12 20:20:03 +01:00
Roy-043
79eaa01032 Draft: Introduce DefaultAnnoScaleMultiplier parameter
This parameter replaces DraftAnnotationScale.

The parameter can be changed in the preferences and with the Draft_SetStyle command.
2023-12-09 19:17:36 +01:00
Roy-043
770eb5e64a Draft: remove maxSnap parameter
It is superfluous. The maxSnapEdges parameter can be set to zero.
2023-12-08 12:06:36 +01:00
Roy-043
6db658255f Draft: update Draft_ApplyStyle
The command now applies all style properties from `utils.get_default_annotation_style()` and `utils.get_default_shape_style()`.

Additionally: minor improvements to gui_setstyle.py.
2023-12-02 13:11:08 +01:00
Roy-043
e64bb9f499 Draft: update Draft_SetStyle
* Added handling of DefaultShapeVertexColor, DefaultShapePointSize, DefaultAnnoLineColor and DefaultAnnoLineWidth preferences.
* Rearranged the task panel.

Additionally the DefaultDrawStyle and DefaultDisplayMode preferences are now applied by format_object in gui_utils.py.
2023-11-30 21:19:48 +01:00
Roy-043
904b37b47d Draft: implement DefaultAnnoLineWidth and DefaultAnnoLineColor prefs
The format_object function in gui_utils.py still requires some work (in connection with the Draft_SetStyle command). This will be done later.
2023-11-29 23:06:17 +01:00
Roy-043
a462e8e616 Draft: improve handling of anno DisplayMode and LineSpacing
* DisplayMode controlled by new pref DefaultAnnoDisplayMode. This replaces the old dimstyle pref.
* LineSpacing pref is now used when creating annotations. Will be added to prefs ui later.
* format_object no longer changes FontSize as this conflicted with the height parameter in the make_text function.
* make_text function updated.
2023-11-27 15:45:56 +01:00
Roy-043
a3f285cb46 Draft: improve Snap bar show-hide preference
This PR replaces the showSnapBar and hideSnapBar preferences with a single new preference: SnapBarShowOnlyDuringCommands.

Additonally:
Improved some param observer callbacks.
2023-11-24 13:30:03 +01:00
Roy-043
8944c79ebe Draft: make default anno style non-global
Additionally:
* Added the DimShowLine preference. Layout of the tab will be updated later.
* Improved handling of DraftAnnotationScale preference: catch division by zero and use it for the default anno style.
2023-11-23 09:45:12 +01:00
Roy-043
f77c5fdcd7 Draft: remove the tolerance preference
The tolerance function now derives its value from the precision preference.

Additonally:
Removed the epsilon() function. It did not make sense and was not used.
2023-11-13 18:07:37 +01:00
Roy-043
220bf83222 Draft: remove unused dimorientation and saveonexit prefs 2023-11-12 20:54:25 +01:00
Roy-043
01de3d143d Draft: Add TextSpacing to Draft_AnnotationStyleEditor (#9702)
Also reordered the dialog a little.
2023-06-03 10:54:49 +02:00
mosfet80
e9c1a1600a [Draft] Remove obsolete code related to Drawing WB
* [Draft] Remove obsolete code related to Drawing WB




remove unused elif

* [Draft] Remove obsolete code related to the Drawing WB

* Update preferences-draftvisual.ui

Also remove the template label.

* Update utils.py

Remove reference to "template"

* Remove Draft_Drawing.svg from Draft.qrc

---------

Co-authored-by: Roy-043 <info@b-k-g.nl>
Co-authored-by: Roy-043 <70520633+Roy-043@users.noreply.github.com>
2023-04-03 16:36:23 +02:00
Roy-043
1e03fddb67 Draft: housekeeping: remove obsolete code (uiMode and DraftGui.py) (#8327) 2023-02-02 23:24:27 +01:00
Roy-043
96e62f07eb Draft: improve color handling in gui_setstyle.py (#8219)
Alhpa values of colors were not correct.
2023-01-22 11:18:17 +01:00
Roy-043
f7a072b7c7 Draft: Fix and improve Draft_AnnotationStyleEditor (#8207)
* Draft: Fix and improve Draft_AnnotationStyleEditor

* Draft: Fix and improve Draft_AnnotationStyleEditor 2
2023-01-21 10:28:47 +01:00
Roy-043
01d4186535 Draft: Fix handling of groups on move-copy and rotate-copy 2022-07-26 11:26:50 +02:00
0penBrain
272ab6ff72 Draft: fix issues with grid spacing parameter 2022-05-25 09:02:12 +02:00
Roy
acfdfb9c2d Draft: Housekeeping: call 'make' functions with new name, continued 2022-02-12 19:34:57 +01:00
Roy-043
981ddd4699 Draft: Fix issues with translate and _tr (#5351) 2022-01-08 00:04:53 +01:00
Yorik van Havre
ded759f614 Draft: Fixed missing type check in is_clone 2021-07-07 15:44:46 +02:00
Yorik van Havre
8c15f7f84f Draft: Colored grid axes 2020-12-03 15:15:15 +01:00
Yorik van Havre
f58f808d53 Draft: Added TechDraw patterns 2020-10-26 11:52:14 +01:00
Yorik van Havre
84692f95e1 Draft: Added pref option to set default dimension unit 2020-10-14 17:21:27 +02:00
Yorik van Havre
674d7f25f8 Draft: Fixed patterns + added default pattern size pref option 2020-10-12 15:12:50 +02:00
Amritpal Singh
58c20b2567 Adopted vocx-fc comment. 2020-09-29 18:50:30 +02:00
Amritpal Singh
b7b24cbb6c 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
b202b0d469 Draft: move getDXF to draftfunctions submodule
Update the appropriate interface in `Draft.py`.
2020-09-16 13:09:13 +02:00
carlopav
e78b104a75 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
dd70caa723 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
314637e945 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
3a7751049b 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
4909abf458 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
29cba68da9 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
hlg
1da75f6971 Arch/Draft: minor fixes 2020-06-03 14:50:17 +02:00
vocx-fc
20ec1fe9bd 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
d80dc23f5b 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
84529ec5bc Draft: clean up the utils module a bit, PEP8, style 2020-06-02 12:29:50 +02:00