Commit Graph

296 Commits

Author SHA1 Message Date
pre-commit-ci[bot]
d31c2130fb [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2023-09-16 05:14:03 +00:00
AgCaliva
4a504437d3 merge master via cli 2023-09-16 02:12:58 -03:00
AgCaliva
280e5e3987 Fixing DOMDocument redefinition 2023-09-16 00:38:41 -03:00
Chris Hennes
791fe02934 Sketcher: Reformat to current clang-format standard 2023-09-04 07:17:28 -05:00
Roy-043
faf2142c7a Update CommandCreateGeo.cpp
Additional change: "via" -> "by"
2023-06-10 18:46:37 +02:00
Roy-043
469aae0af5 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
ec899d75c6 SketcherGui: apply clang-format 2023-05-25 17:08:03 +02:00
Chris Hennes
80b29d2dbf Gui: Minor translation fixes 2023-05-11 18:31:34 -05:00
wmayer
2de08f77b7 Use View3DInventorViewer::setSelectionEnabled instead of SoFCUnifiedSelection::selectionRole 2023-05-04 08:03:11 +02:00
Chris Hennes
a0fc6bc727 Sketcher: Tweak wording as suggested by translators 2023-05-02 20:29:36 +02:00
Ajinkya Dahale
d6060c79aa [Sketcher] Clear out some TODOs and other comments 2023-03-24 16:30:48 +01:00
Ajinkya Dahale
02558f3793 [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
ab64e2251d [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
944c31cf7b [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
b8956d3f1b [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
fc05c6bae3 [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
08932bd92d [Sketch] Gui: A - D: remove unused headers
- also some sorting
2022-12-11 23:47:03 +01:00
Roy-043
55510f33c5 Sketcher: Correct icon for Sketcher_CreatePointFillet 2022-10-25 00:33:28 +02:00
wmayer
e2a552a9c6 Sketcher: [skip ci] remove unused includes 2022-09-25 11:09:29 +02:00
berniev
da9ebc572f Mod: redundant void 2 2022-08-08 10:27:50 +02:00
Uwe
d4c60abf70 [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
03041f0aff [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
dbe8f47d93 [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
9763ed29e2 Split DSHs from CommandCreateGeo 2022-06-28 19:29:47 +02:00
Abdullah Tahiri
3678a525a2 DrawSketchHandler: Cursor rework and preselect at point functionalities 2022-06-28 19:29:19 +02:00
Abdullah Tahiri
c6459bb7d3 Utils refactor w/o commandcreategeo 2022-06-28 19:28:06 +02:00
Abdullah Tahiri
bae8050fac Sketcher-Utils: Refactor common code up 2022-06-28 19:27:20 +02:00
Paddle
f99abec58e Sketcher: Create Geometry ConstraintToAttachment function 2022-06-28 19:27:04 +02:00
Abdullah Tahiri
80cd03cded Sketcher: Cleanup obsolete DrawSketchHandlers 2022-06-28 19:22:58 +02:00
Uwe
68a499574a [Sketch] remove unnecessary Boolean comparisons 2022-06-19 18:35:52 +02:00
wmayer
922ce46506 Gui: add convenience functions to SelectionFilterGate 2022-04-19 15:04:14 +02:00
wmayer
139370a20f 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
97330443a2 All: modernize C++11
* replace deprecated headers
2022-03-23 22:44:18 +01:00
wmayer
ead5154b18 Sketcher: modernize C++11
* use nullptr
2022-03-23 19:26:15 +01:00
Abdullah Tahiri
2908150282 Sketcher: Some code comments 2022-03-13 19:28:38 +01:00
Abdullah Tahiri
e48d3e355d Sketcher: move comment to right position 2022-03-12 18:45:16 +01:00
Abdullah Tahiri
a6e67dafa2 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
c596c2fe3d [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
1d9dd035e7 [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
9654786c67 [Gui] Quarter: remove unused includes 2022-03-09 01:12:15 +01:00
Ajinkya Dahale
47a040537b [Sketcher] Allow deleting last knot during B-Spline creation 2022-03-06 16:14:07 +01:00
Ajinkya Dahale
00ef0e0504 [Sketcher] Reduce duplicate code in DrawSketchHandlerBSpline 2022-03-06 16:14:07 +01:00
Abdullah Tahiri
464ae1f6b0 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
15281aed86 [Sketcher] Allow setting B-Spline degree at creation 2022-02-27 16:48:23 +01:00
wmayer
c5dfa7fa01 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
d8c052c666 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
0f6e8b95a9 Sketcher: Use Part::Geom2dCircle::getCircleCenter
=================================================

In 955fe45, GetCircleCenter was moved up to Part for code reuse.
2021-12-27 21:03:51 +01:00
Abdullah Tahiri
92e6094449 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
6cf2d39a24 Sketcher: white-space only commit - remove unnecessary indentation 2021-12-25 16:32:43 +01:00
Abdullah Tahiri
97c82a6703 Sketcher: Convert PointPos into an enum CLASS 2021-12-11 16:17:21 +01:00