Files
create/src/Mod/Draft/drafttests
Roy-043 d587e6a91a 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
..

General

2020 May

These files provide the unit tests classes based on the standard Python unittest module.

These files should be imported from the main TestDraft.py and TestDraftGui.py modules which are registered in the program in Init.py and InitGui.py depending on if they require the graphical interface or not.

Each module should define a class derived from unittest.TestCase, and the individual methods of the class correspond to the individual unit tests which try a specific function in the workbench.

The tests should be callable from the terminal.

# All tests that don't require the graphical interface
program --console -t TestDraft

# Only creation tests
program --console -t drafttests.test_creation

# A specific test inside a module and class
program --console -t drafttests.test_creation.DraftCreation.test_line

Where program is the name of the FreeCAD executable.

Most tests should be designed to pass even without the graphical interface, meaning that they should run in console mode.

The exception to this are particular tests that explicitly use the graphical interface.

# All tests that require the graphical interface
program -t TestDraftGui

For more information see the thread: New unit tests for Draft Workbench

To do

Not every single function in the workbench is tested, so new unit tests can be written. This will improve reliability of the workbench, making it easier to discover bugs and regressions.

See the individual modules to check what is missing.

In particular, unit tests for the import and export modules (SVG, DXF, DWG) are required.