Commit Graph

291 Commits

Author SHA1 Message Date
Roy-043
fda7f95646 Sketcher: Minor improvements for some GUI texts
Menu texts for new B-spline tools were inconistent. See https://forum.freecad.org/viewtopic.php?t=78808
2023-06-10 18:39:32 +02:00
Abdullah Tahiri
78ae9c1d7d SketcherGui: apply clang-format 2023-05-25 17:08:03 +02:00
Chris Hennes
397807b72d Gui: Minor translation fixes 2023-05-11 18:31:34 -05:00
wmayer
b0c9871722 Use View3DInventorViewer::setSelectionEnabled instead of SoFCUnifiedSelection::selectionRole 2023-05-04 08:03:11 +02:00
Chris Hennes
cb10e49b27 Sketcher: Tweak wording as suggested by translators 2023-05-02 20:29:36 +02:00
Ajinkya Dahale
c66ed794f9 [Sketcher] Clear out some TODOs and other comments 2023-03-24 16:30:48 +01:00
Ajinkya Dahale
8803404d88 [Sketcher] Fix and support periodic B-spline by interpolation
This commit is part of a project funded by the Open Toolchain Foundation under
the title "Open Toolchain Foundation - Curve drawing tool in Sketcher
Workbench".
2023-03-24 16:30:48 +01:00
Ajinkya Dahale
f340b4104b [Sketcher] Add missing GUI elements for B-spline by knots
Commented out the periodic version for now since they don't work completely well.

This commit is part of a project funded by the Open Toolchain Foundation under the title "Open Toolchain Foundation - Curve drawing tool in Sketcher Workbench"
2023-03-24 16:30:48 +01:00
Ajinkya Dahale
357a3c0692 [Sketcher] Add icon for B-Spline by interpolation tool
This commit is part of a project funded by the Open Toolchain Foundation under the title "Open Toolchain Foundation - Curve drawing tool in Sketcher Workbench"

[Sketcher] Add better icons for `CreateBSplineByInterpolation`

Courtesy @paddlestroke.
2023-03-24 16:30:48 +01:00
Ajinkya Dahale
94db5271b3 [Sketcher] [WIP] Add periodic B-spline support for interpolation DSH
This commit is part of a project funded by the Open Toolchain Foundation under the title "Open Toolchain Foundation - Curve drawing tool in Sketcher Workbench"
2023-03-24 16:30:48 +01:00
Ajinkya Dahale
e83a9804c1 [Sketcher] Create DSH for drawing B-splines by interpolation
Only creates 1-degree splines by describing knots.

This commit is part of a project funded by the Open Toolchain Foundation under the title "Open Toolchain Foundation - Curve drawing tool in Sketcher Workbench"
2023-03-24 16:30:48 +01:00
Uwe
e24daabf1f [Sketch] Gui: A - D: remove unused headers
- also some sorting
2022-12-11 23:47:03 +01:00
Roy-043
7ae40aebd2 Sketcher: Correct icon for Sketcher_CreatePointFillet 2022-10-25 00:33:28 +02:00
wmayer
cbac99a8ed Sketcher: [skip ci] remove unused includes 2022-09-25 11:09:29 +02:00
berniev
f4ffd15864 Mod: redundant void 2 2022-08-08 10:27:50 +02:00
Uwe
6c7cf1c276 [Sketcher] fix icon name
- fix a FIXME, Sketcher_CreateEllipse depicts already the right thing, it just has to be renamed
2022-07-29 01:26:00 +02:00
Uwe
1b5d51f5b8 [Sketcher] [skip CI] CommandCreateGeo: code style fix
- the MSVC IDE had problems with this, thus apply our .clang style
2022-07-27 16:05:39 +02:00
0penBrain
776c17df01 [BUGFIX] Sketcher: fix icon normal/construction toggling when commands used in custom toolbar
Fixes #7064
2022-07-27 14:28:54 +02:00
Abdullah Tahiri
c5da665d45 Split DSHs from CommandCreateGeo 2022-06-28 19:29:47 +02:00
Abdullah Tahiri
12a2de626a DrawSketchHandler: Cursor rework and preselect at point functionalities 2022-06-28 19:29:19 +02:00
Abdullah Tahiri
51f2c55334 Utils refactor w/o commandcreategeo 2022-06-28 19:28:06 +02:00
Abdullah Tahiri
2c58060524 Sketcher-Utils: Refactor common code up 2022-06-28 19:27:20 +02:00
Paddle
74d6d1855c Sketcher: Create Geometry ConstraintToAttachment function 2022-06-28 19:27:04 +02:00
Abdullah Tahiri
5657b4e434 Sketcher: Cleanup obsolete DrawSketchHandlers 2022-06-28 19:22:58 +02:00
Uwe
61be686687 [Sketch] remove unnecessary Boolean comparisons 2022-06-19 18:35:52 +02:00
wmayer
c5bab68332 Gui: add convenience functions to SelectionFilterGate 2022-04-19 15:04:14 +02:00
wmayer
94c5d89d1f Sketcher: fix crash after having created a new B-Spline
The crash might be related to issue #6324: Segmentation fault on knot insertion in older B-Spline
2022-04-17 17:33:11 +02:00
wmayer
d21a60b294 All: modernize C++11
* replace deprecated headers
2022-03-23 22:44:18 +01:00
wmayer
51186c018e Sketcher: modernize C++11
* use nullptr
2022-03-23 19:26:15 +01:00
Abdullah Tahiri
ee98a3d87f Sketcher: Some code comments 2022-03-13 19:28:38 +01:00
Abdullah Tahiri
7294d4d7a3 Sketcher: move comment to right position 2022-03-12 18:45:16 +01:00
Abdullah Tahiri
5e88ee99f5 Sketcher: BSpline code review and fix
=====================================

- Avoid using EditCurve for the double use of storing the pole positions and the last mouse position. Split into individual vector for poles and previous cursor position (with appropriate names).
- Store all pole geoids to better show the intend of the code.
- Avoid indexing when referring the last inserted value of a std::vector, use back() instead.
- Encapsulate code to draw the bspline polygon and the cursor text to the given position. This allow to select the right function for every case, while avoiding unclear names, such as "mousemove()".
- Refactor code to finish command, to avoid calling unclear names such as "releasebutton" to better show the intend of the function call.
- Ensure deleted pole does not appear anymore in the scenograph.
2022-03-12 15:47:50 +01:00
Ajinkya Dahale
201ef90a89 [Sketcher] Constrain first pole when created
By doing this, duplicate radius constraints are not made when deleting and
redefining second pole.
2022-03-09 16:43:47 +01:00
Ajinkya Dahale
3fa1735088 [Sketcher] Redraw correctly on pole delete in "create b-spline"
This ensures that the last preview line drawn is always at the cursor and that
the coordinates are always w.r.t. the last defined pole.
2022-03-09 16:43:47 +01:00
Uwe
4f5c29edd6 [Gui] Quarter: remove unused includes 2022-03-09 01:12:15 +01:00
Ajinkya Dahale
ec2522130b [Sketcher] Allow deleting last knot during B-Spline creation 2022-03-06 16:14:07 +01:00
Ajinkya Dahale
c6f19758d1 [Sketcher] Reduce duplicate code in DrawSketchHandlerBSpline 2022-03-06 16:14:07 +01:00
Abdullah Tahiri
79f52556f4 Sketcher: Clean up old crosshair code
====================================

- Remove old unconnected code
- Move member functions to correct cpp file
2022-03-04 06:26:46 +01:00
Ajinkya Dahale
06f290e311 [Sketcher] Allow setting B-Spline degree at creation 2022-02-27 16:48:23 +01:00
wmayer
f7392d47b9 Sketcher: fix warnings:
* fix -Winconsistent-missing-override
* fix -Woverloaded-virtual that is also a bug because the DrawSketchHandlerArcOfParabola didn't set the suitable mouse cursor
2022-02-17 21:14:37 +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
7cf12a58d6 Sketcher: Use Part::Geom2dCircle::getCircleCenter
=================================================

In 3eaabbe, GetCircleCenter was moved up to Part for code reuse.
2021-12-27 21:03:51 +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
9978c0f867 Sketcher: white-space only commit - remove unnecessary indentation 2021-12-25 16:32:43 +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
0penBrain
f568cc6d96 [Sketcher][Bugfix] Slot: fix segfault accessing empty vector 2021-12-01 18:48:05 +01:00
0penBrain
1188f7d7a1 [Sketcher] Allow to autoconstraint slot horizontal/vertical 2021-11-29 14:38:53 +01:00
0penBrain
a00f2877f3 [Sketcher] Ability to snap slot horizontal/vertical
Triggered by pressing Ctrl key when creating the slot
 Extra constraint is added in case snapping is enabled
2021-11-29 14:38:53 +01:00