Commit Graph

43 Commits

Author SHA1 Message Date
Florian Foinant-Willig
482b45dadc Sketcher: Fix Point to Line Distance 2023-12-20 20:03:13 +01:00
Abdullah Tahiri
759930e3aa Sketcher: Move lint comment to right position 2023-12-18 10:55:16 -06:00
Florian Foinant-Willig
df32ad2d38 Fix isCircleOrArc usage 2023-12-17 16:01:29 +01:00
Abdullah Tahiri
4d860203fc Sketcher: Utils/CommandConstraints/EditModeConstraintCoinManager - refactor duplicated code 2023-12-17 16:01:29 +01:00
Florian Foinant-Willig
94eaa7db78 Sketcher: Arc to arc or circle distance constraint 2023-12-17 16:01:29 +01:00
Paddle
a2c909f329 Draw arc helpers for radius constraints. 2023-11-24 15:07:35 +01:00
Paddle
74dd736e3c Improve angle constraint rendering. 2023-11-24 15:07:35 +01:00
Chris Hennes
cf84c171e6 Merge pull request #10978 from FlachyJoe/modernize-type-check
Modernize type and derived type checking
2023-11-06 10:44:32 -06:00
Abdullah Tahiri
882262bfa8 Sketcher Gui: clang-tidy diagnostic errors 2023-11-05 07:11:57 +01:00
Florian Foinant-Willig
a32851073d Sketcher: modernize type checking 2023-10-23 18:09:23 +02:00
pre-commit-ci[bot]
222a2520b1 [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2023-09-12 13:02:35 -04:00
bdieterm
7013ce0cbc Sketcher: fix segfault on distance constraints without SecondPos 2023-08-29 16:24:15 -05:00
Florian Foinant-Willig
ae60811fba Sketcher: Point to Circle Distance Constraints (#9559) 2023-08-28 10:58:09 -05:00
luzpaz
3d0bfa214f Fix various typos 2023-08-13 08:17:01 -07:00
andrea
6c2a5c1539 removed coin<3 references 2023-08-04 21:19:29 -06:00
Abdullah Tahiri
1d61ed187c Sketcher: Fix bug angle via point visualisation
===============================================

Issue description:
https://forum.freecad.org/viewtopic.php?f=3&t=70325
https://github.com/FreeCAD/FreeCAD/issues/7520

The general algorithm to calculate normals miserably fails when
the curve is a line segment and the point through which the normal
to a curve is to be drawn is colinear with the line segment.

The solution is to provide specific code for this corner case.

fixes #7520
2023-05-28 06:45:50 +02:00
Abdullah Tahiri
ec899d75c6 SketcherGui: apply clang-format 2023-05-25 17:08:03 +02:00
Abdullah Tahiri
fdd3525424 SketcherGui: Separate user and developer errors
===============================================

Revisiting all console calls:
- Using the Notification Framework when the user needs to be notified
- Turning them into DeveloperError/DeveloperWarnings when messages are intended only for developers
2023-05-25 14:09:06 +02:00
Florian Foinant-Willig
e69e9019df Sketcher: fix Circle to Line distance constraint display 2023-05-15 12:14:21 +02:00
Florian Foinant-Willig
6de3c5833f Sketch: Fix Point to Line constraint display 2023-05-14 21:37:21 +02:00
Florian Foinant-Willig
70eb14ac9c Sketcher : Circle to Line Distance Constraint 2023-05-02 15:41:51 +02:00
luzpaz
129d5882a7 Migrate domain name from freecadweb to freecad (#9352)
* Migrate domain name from freecadweb to freecad
* Migrate src/Mod/Material files
* Migrate Stylesheet related files
* Migrate *.svg files
* Migrate miscellaneous files
* Migrate some build files
* Migrate recently added TD AR_IRAM template files

Closes #6415
2023-04-24 15:19:20 -05:00
Abdullah Tahiri
11c76c998e Sketcher: Fix double icons not selectable
=========================================

The scaling factor used  was the one of the ViewProviderSketch, however ZoomTranslation uses its own scaling factor.

fixes #6283
2023-04-20 20:45:40 +02:00
Paddle
fc8c1cbed7 Move SoDatumLabel from Sketcher to Core so that it can be reused anywhere. 2023-04-12 16:48:07 +02:00
flachyjoe
21c2eb6014 Sketcher: Add circle to circle distance constraint 2023-03-19 14:05:35 +01:00
Abdullah Tahiri
d01edd53a2 EditCoinManager: Refactor and extend layer support to use VisualLayerList property and ViewProviderSketchGeometryExtension 2023-03-02 20:42:48 +01:00
Abdullah Tahiri
e566daa1af Sketcher: Correct font sizes and updates
========================================

Fonts:
- SoDatumLabel internally uses QFont and thus points. It was being fed pixels, for which the configured size in preferences did not match the actual on screen size. This is corrected.
- Font sizes fed directly from parameters to the coin nodes skeleton were not being updated, as the parameter observer is initialised after the nodes are created, and the parameter
observer was not configured to update this nodes. This is corrected.

Colors:
- Some color parameters were not being being updated by the parameter observer. This is corrected.
2023-02-15 17:29:46 +01:00
Abdullah Tahiri
01013bc411 Sketcher: Make parabola axis to be internal alignment 2022-12-21 16:01:23 +01:00
Uwe
ce8816685b [Sketch] Gui: E - Short*: remove unused headers
- also some sorting
2022-12-12 02:52:33 +01:00
wmayer
82866db0ca Mod: replace QRegExp with QRegularExpression 2022-10-07 14:03:53 +02:00
0penBrain
3d7fa720e6 [Bugfix]Sketcher: some user colors aren't taken into account 2022-09-11 22:04:38 +02:00
0penBrain
3f220f1dd8 Sketcher/BackEdit: makes sketch elements render on -Z if sketch viewed from back side 2022-09-09 16:09:42 +02:00
berniev
da9ebc572f Mod: redundant void 2 2022-08-08 10:27:50 +02:00
wmayer
ead5154b18 Sketcher: modernize C++11
* use nullptr
2022-03-23 19:26:15 +01:00
0penBrain
34106f49e7 [Sketcher] Disable constraints selection when geometry/constraint handler is active 2022-02-17 16:17:04 +01:00
Ajinkya Dahale
82edb612ad [Sketcher] Check constraint type before drawing icons
Change is in `EditModeConstraintCoinManager::drawConstraintIcon` on the lines of 247a9f0876.
2022-02-15 13:44:02 +01:00
Ajinkya Dahale
4ad0bdc5b2 [Sketcher] Reformat statements in EditModeConstraintCoinManager.cpp 2022-02-15 13:44:02 +01:00
mwganson
e535204f8e Sketcher: prevent crash when accessing null pointer 2022-01-16 15:14:05 +01:00
luz paz
19e984f8c9 Fix various typos
Found via `codespell -q 3 -L aci,ake,aline,alle,alledges,alocation,als,ang,anid,apoints,ba,beginn,behaviour,bloaded,bottome,byteorder,calculater,cancelled,cancelling,cas,cascade,centimetre,childrens,childs,colour,colours,commen,connexion,currenty,dof,doubleclick,dum,eiter,elemente,ende,feld,finde,findf,freez,hist,iff,indicies,initialisation,initialise,initialised,initialises,initialisiert,inout,ist,kilometre,lod,mantatory,methode,metres,millimetre,modell,nd,noe,normale,normaly,nto,numer,oce,oder,ontop,orgin,orginx,orginy,ot,pard,parm,parms,pres,programm,que,rady,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,./build/doc/SourceDocu`
2022-01-12 14:50:39 -06:00
Abdullah Tahiri
247a9f0876 Sketcher: EditCoinManager - Check constraint types on updating constraint color
===============================================================================

Problem:
- While SketchObject inhibits intermediate updates during internal command execution, sometimes
a change in the selection (clear selection) in an intermediary step triggers an spurious update colour.

- There will be a final draw and this update colours at the end of the internal command.

- If the types of the constraints changed during the intermediary steps, it may happen that the constraint
coin nodes at a given position no longer correspond to the constraint type in the SketchObject property. This
may cause a attempt to access to a non-existing node or static casting a existing node to the wrong type.

Solution:
- Check the type of the constraint against the cached type. If not matching, cancel the color update.
2022-01-09 11:40:49 +01:00
wmayer
118b7aa0cc Sketcher: improve exception handling
* if determining the normal raises an exception then fall back to a default value
* when handling a Base::Exception then call its ReportException() function to get as much information as possible
2022-01-08 13:48:01 +01:00
Abdullah Tahiri
f04d5171da EditCoinManager: Additional refactoring 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