Commit Graph

127 Commits

Author SHA1 Message Date
ppphp
12e8fb1695 fix unique ptr usage in sketch (#15008)
* fix unique ptr usage in sketch

* [pre-commit.ci] auto fixes from pre-commit.com hooks
2024-07-08 10:53:49 -05:00
Alexandre Prokoudine
c9dba8a51e Adjust names of two Sketcher tools to make their functions discoverable
Users report that they have a hard time figuring out that 'Array transform' does
movement/translations, and 'Polar transform' does rotation. Hence this
adjustment of their user-visible names.
2024-06-17 10:57:10 -05:00
PaddleStroke
a8adc573f8 Sketcher: Symmetry tool rework. 2024-03-25 17:48:01 +01:00
Paddle
6293a2b357 Translate DSH : A replacement for rectangular array. 2024-02-12 17:48:22 +01:00
PaddleStroke
a2c1596a03 [Sketcher] Scale DSH : adds a tool to scale geometries. (#11265)
* Scale DSH : sketcher tool to scale geometries.
* Sketcher: Rotate and Scale : Move indexInVec to Utils.h as indexOfGeoId

---------

Co-authored-by: Paddle <PaddleStroke@users.noreply.github.com>
2024-02-01 09:08:58 +01:00
Paddle
85b5a343f0 Sketcher: PythonConverter: Replace useLastGeoIdVar bool by enum class 2024-01-20 06:49:32 +01:00
Paddle
7654c4446b Sketcher: copy paste : move from XML to python. 2024-01-19 11:13:53 +01:00
Paddle
88883faaf8 Sketcher: Add copy/cut/paste sketcher commands 2024-01-19 11:13:53 +01:00
Paddle
a5a77fc0fd Rotate DSH : Polar pattern tool for sketcher. 2023-12-20 06:59:47 +01:00
Paddle
68dd184646 CommandSketcherTools : add local getSketchObject to avoid copy paste. 2023-12-20 06:59:47 +01:00
Roy-043
83fbcf4239 Sketcher: Sketcher_Offset: menu text and shortcut
* Menu text "Offset geometry" (singular).
* Shortcut "Z, O" was already in use. Changed to "Z, T".
2023-12-05 15:25:52 +01:00
Paddle
72b03cb787 Offset DSH : various fixes 2023-11-07 15:36:21 +01:00
Chris Hennes
590fb19f31 Merge pull request #10978 from FlachyJoe/modernize-type-check
Modernize type and derived type checking
2023-11-06 10:44:32 -06:00
Paddle
8239483c35 Offset fix isActive function. 2023-11-04 08:58:50 +01:00
Paddle
513e1a46c8 Sketcher: Offset DSH 2023-11-03 14:02:25 +01:00
Florian Foinant-Willig
c0e8fa1e75 Sketcher: modernize type checking 2023-10-23 18:09:23 +02:00
wmayer
b6f331f4fa modernize C++: use transparent functors 2023-08-07 16:08:35 +02:00
Abdullah Tahiri
78ae9c1d7d SketcherGui: apply clang-format 2023-05-25 17:08:03 +02:00
Abdullah Tahiri
2bc3295cf3 Sketcher: Obey non-intrusive preferences for modal pop-ups
==========================================================

This commit turns the remaining blocking pop-ups in which the user can only click "ok"
into non-intrusive notifications, depending on the user preferences in settings.
2023-05-24 18:35:41 +02:00
Abdullah Tahiri
686e5d06b2 Sketcher: Remove references to non-existing icons
=================================================

User Syres realised that some commands that are in use by the solver messages url referenced non-existing icons, which
triggers errors in the report view while customising:
https://forum.freecad.org/viewtopic.php?p=666167&sid=16ac6777c440d632e5f60083fb4327ca#p666167

This commit removes them.
2023-03-10 18:18:58 +01:00
wandererfan
de723238fa [Sketcher]fix cursor display of angles 2023-01-30 11:04:42 -08:00
Uwe
e24daabf1f [Sketch] Gui: A - D: remove unused headers
- also some sorting
2022-12-11 23:47:03 +01:00
0penBrain
4b8b93c3b8 Sketcher: disable auto-constraint in Copy/Clone/Move commands 2022-11-18 08:18:58 +01:00
0penBrain
44c77e5542 [Typo]Sketcher: 'Clone' is the first command of CompCopy, match the tooltip 2022-11-16 14:48:39 +01:00
wmayer
cbac99a8ed Sketcher: [skip ci] remove unused includes 2022-09-25 11:09:29 +02:00
wandererfan
eb93e599c0 [Sketcher]make cursor coord display unit aware 2022-08-31 16:31:27 -04:00
wmayer
138629633f Sketcher: modernize C++: replace 'typedef' with 'using' 2022-08-29 23:13:16 +02:00
berniev
180edfa3cc Mod: Single arg ctors must be explicit 2022-08-24 16:55:20 +02:00
berniev
71dc5ead2f Mod: Use override etc 2 2022-08-09 12:52:26 +02:00
berniev
f4ffd15864 Mod: redundant void 2 2022-08-08 10:27:50 +02:00
berniev
53ba98d636 Mod: use empty 2022-08-06 19:30:13 +02:00
Abdullah Tahiri
574766a4bf Remove obsolete DSH Tools - CloseShape and ConnectLines 2022-06-28 19:29:35 +02:00
Abdullah Tahiri
51f2c55334 Utils refactor w/o commandcreategeo 2022-06-28 19:28:06 +02:00
wmayer
51186c018e Sketcher: modernize C++11
* use nullptr
2022-03-23 19:26:15 +01:00
Ajinkya Dahale
9007662425 [Sketcher] Fix "toggle internal geo" on multi-selection
Some deleted GeoIds can stay in selection and GeoIds can change as some objects
are deleted.
2022-03-13 06:58:40 +01:00
wmayer
8f786ea6ef Gui: Optimize includes to reduce compile time 2022-03-07 20:29:18 +01:00
Abdullah Tahiri
f7741d4399 DrawSketchHandler: activation and deactivation via NVI pattern
==============================================================

With the introduction of overridable default behaviour for commands, it makes sense to keep control of the execution path of the activation and deactivation.

Non-virtual interface pattern enforces execution control of the virtual functions, while allowing the behaviour to be overriden in a case by case basis.
2022-02-17 19:37:48 +01:00
Abdullah Tahiri
71c9dc3e0e Sketcher: EditModeCoinManager/DrawSkechHandler refactoring
======================================================

Creation of EditModeCoinManager class and helpers.

In a nutshell:
- EditModeCoinManager gets most of the content of struct EditData
- Drawing is partly outsourced to EditModeCoinManager
- EditModeCoinManager gets a nested Observer class to deal with parameters
- A struct DrawingParameters is created to store all parameters used for drawing
- EditModeCoinManager assume responsibility for determining the drawing size of the Axes
- Preselection detection responsibility is moved to EditModeCoinManager.
- Generation of constraint nodes and constraint drawing is moved to EditModeCoinManager.
- Constraint generation parameters are refactored into ConstraintParameters.
- Text rendering functions are moved to EditModeCoinManager.
- Move HDPI resolution responsibility from VPSketch to EditModeCoinManager
- Move responsibility to create the scenograph for edit mode to EditModeCoinManager
- Move full updateColor responsibility to EditModeCoinManager
- Allows for mapping N logical layers (LayerId of GeometryFacade) to M coin Layers (M<N). This
is convenient as, unless the representation must be different, there is no point in creating coin
layers (overhead).

Refactoring of geometry drawing:
- Determination of the curve values to draw are outsourced to OCC (SRP and remove code duplications).
- Refactor specific drawing of each geometry type into a single template method, based on classes of geometry.
- Drawing of geometry and constraints made agnostic of scale factors of BSpline weights so that a uniform treatment can be provided.

Refactoring of Overlay Layer:
- A new class EditModeInformationOverlayConverter is a full rewrite of the previous overlay routines.

ViewProviderSketch:
- Major cleanup due to migration of functionalities to EditModeCoinManager
- Reduce public api of ViewProviderSketch due to refactor of DrawSketchHandler
- Major addition of documentation
- ShortcutListener implementation using new ViewProvider Attorney
- Gets a parameter handling nested class to handle all parameters (observer)
- Move rubberband to smart pointer
- Refactor selection and preselection into nested classes
- Removal of SEL_PARAMS macro. This macro was making the code unreadable as it "captured" a local stringstream that appeared unused. Substituted by local private member functions.
- Remove EditData
- Improve documentation
- Refactor Preselection struct to remove magical numbers
- Refactor Selection mechanism to remove hacks

ViewProviderSketchDrawSketchHandlerAttorney:
- new Attorney to limit access to ViewProviderSketch and reduce its public interface
- In order to enforce a certain degree of encapsulation and promote a not too tight coupling, while still allowing well
defined collaboration, DrawSketchHandler accesses ViewProviderSketch via this Attorney class.
-DrawSketchHandler has the responsibility of drawing edit temporal curves and markers necessary to enable visual feedback
to the user, as well as the UI interaction during such edits. This is its exclusive responsibility under the Single
Responsibility Principle.
- A plethora of speciliased handlers derive from DrawSketchHandler for each specialised editing (see for example all the
handlers for creation of new geometry). These derived classes do * not * have direct access to the
ViewProviderSketchDrawSketchHandlerAttorney. This is intentional to keep coupling under control. However, generic
functionality requiring access to the Attorney can be implemented in DrawSketchHandler and used from its derived classes
by virtue of the inheritance. This promotes a concentrating the coupling in a single point (and code reuse).

EditModeCoinManager:
- Refactor of updateConstraintColor
- Multifield - new struct to identify a single element in a multifield field per layer
- Move geometry management to delegate class EditModeCoinGeometryManager
- Remove refactored code that was never used in the original ViewProviderSketch.

CommandSketcherBSpline:
- EditModeCoinManager automatically tracks parameter change and triggers the necessary redraw, rendering an explicit redraw obsolete and unnecessary.

Rebase on top of master:
- Commits added to master to ViewProviderSketch applied to EditModeCoinManager.
- Memory leaks - wmayer
- Constraint Diameter Symbol - OpenBrain
- Minor bugfix to display angle constraints - syres

Architecture Description
=======================

* Encapsulation and collaboration - restricting friendship - reducing public interface

Summary:
- DrawSketchHandler to ViewProviderSketch friendship regulated via attorney.
- ShortcutListener to ViewProviderSketch friendship regulated via attorney.
- EditModeCoinManager (new class) to ViewProviderSketch friendship regulated via attorney.
- ViewProviderSketch public interface is heavily reduced.

In further detail:
While access from ViewProviderSketch to other classes is regulated via their public interface, DrawSketchHandler, ShortcutListener and EditCoinManager (new class) access
to ViewProviderSketch non-public interface via attorneys. Previously, it was an unrestricted access (friend classes). Now this interface is restricted and regulated via attorneys.
This increases the encapsulation of ViewProviderSketch, reduces the coupling between classes and promotes an ordered growth. This I call the "collaboration interface".

At the same time, ViewProviderSketch substantially reduces its public interface. Access from Command draw handlers (deriving from DrawSketchHandler) is intended to be restricted to
the functionality exposed by DrawSketchHandler to its derived classes. However, this is still only partly enforced to keep the refactoring within limits. A further refactoring of
DrawSketchHandler and derivatives is for future discussion.

* Complexity and delegation

Summary:
- Complexity of coin node management is dealt with by delegation to helper classes and specialised objects.

In further detail:

ViewProviderSketch is halved in terms of code size. Higher level ViewProviderSketch functions remain

* Automatic update of parameters - Parameter observer nested classes

Summary:
- ViewProviderSketch and CoinManager get their own observer nested classes to monitor the parameters relevant to them and automatically update on change.

The split enables that each class deals only with parameters within their own responsibilities, effectively isolating the specifics and decoupling the implementations. It is
more convenient as there is no need to leave edit mode to update parameters. It is more compact as it leverages core code.

More information:
https://forum.freecadweb.org/viewtopic.php?p=553257#p553257
2021-12-27 21:03:51 +01:00
Abdullah Tahiri
44567167ff Sketcher: Convert PointPos into an enum CLASS 2021-12-11 16:17:21 +01:00
Abdullah Tahiri
182596ba08 Sketcher: GeoId, GeoElementId and GeoUndef refactor
===================================================

This commit is an independent refactor of the identifications used at Sketcher level.

It introduces a new type "GeoElementId" as a combination of GeoId and PointPos.

It moves the Undefined GeoId, previous Constraint::GeoUndef to GeoEnum, together with all
other fixed values of GeoIds.
2021-12-11 16:17:21 +01:00
Abdullah Tahiri
01d37cdaad Sketcher: move GUI common utility functions to a new file Utils.h
=================================================================

Common utility functions used by almost all Command classes were previous in Constraint.h.

Aside from providing a very bad intent, it created unnecessary header dependencies.

This commit separates these common functions into a new header, utils.h, which is then
used in all command classes where it is necessary.
2021-12-07 16:30:55 +01:00
Abdullah Tahiri
ffa6f0c50f Sketcher: CommandSketcherTools add missing include that was indirectly satisfied 2021-12-07 16:30:53 +01:00
luz paz
d877ee4d47 Make source code comments use gender neutral pronouns
The changes also include some grammatical fixes as well.
2021-12-02 16:18:04 -05:00
Abdullah Tahiri
9f15372d86 Sketcher: Default Shortcuts
===========================

Following:
https://forum.freecadweb.org/viewtopic.php?p=539914#p539914

Following requests from OpenBrain and ChrisB:
https://forum.freecadweb.org/viewtopic.php?p=540015#p540015

Following request from M4X:

Recomendation to use "L" and "I" for vertical and horizontal distance constraints and "R" for radius.

https://forum.freecadweb.org/viewtopic.php?p=540049#p540049

https://forum.freecadweb.org/viewtopic.php?p=540011#p540011
2021-10-16 09:23:22 +02:00
Abdullah Tahiri
8242c68509 Sketcher: Copy and Array tool Snap at 5 degrees using CTRL 2021-10-12 09:41:58 +02:00
wmayer
94516cb0a6 Sketcher: [skip ci] fix -Wunused-lambda-capture 2021-10-06 19:46:57 +02:00
Abdullah Tahiri
e953c8e0e6 Sketcher: user addSelections for group selection in SketcherTools 2021-10-06 13:44:06 +02:00
wmayer
3edea9891f Sketcher: [skip ci] remove superfluous QT_TRANSLATE_NOOP from Sketcher commands 2021-09-29 15:46:06 +02:00
FreeCAD-Tools
1d1c126407 Update CommandSketcherTools.cpp 2021-09-27 15:59:31 +03:00
Abdullah Tahiri
4847d5cab3 Sketcher: Rectangular Array Snap mode
=====================================

Rectangular Array gets a snap mode every 10 degrees when pressing CTRL (for consistency with Multiline arc, which also snaps using CTRL).

Request:
https://forum.freecadweb.org/viewtopic.php?p=535691#p535691
2021-09-25 21:58:14 +02:00