Commit Graph

26785 Commits

Author SHA1 Message Date
Abdullah Tahiri
dfd726ec35 Sketcher: Sketch - extraction of geometry as GeoList with owned memory allocation
=================================================================================

Apart from simplifying code, the allocated memory is not managed by the lifetime of the unique pointer owned by the GeometryFacade, preventing memory leaks.
2021-12-27 21:03:51 +01:00
Abdullah Tahiri
62bb8f67c8 Sketcher: GeometryFacade - Add ownership parameter to factory method 2021-12-27 21:03:51 +01:00
Abdullah Tahiri
9ce2eaf32e Sketcher: GeoList - Fix bug in index conversion 2021-12-27 21:03:51 +01:00
Abdullah Tahiri
4bcca31b02 Sketcher: Fix root point not fully constrained when sketch is empty 2021-12-27 21:03:51 +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
b9ed85a2de Sketcher: GeoEnum and GeoListId constant reference outside the translation unit
================================================================================

GeoEnum static members are used in constexpr in GeoListId.

Previous code worked because the static members where inside the same translation unit.

This code:
1. Declares the static members to use them as constant expressions with the value
2. Definition of the static members (odr-used) shall not contain an initializer.
2021-12-27 21:03:51 +01:00
wmayer
afa40eaf87 Gui: reduce code duplication in ReportOutputObserver and ReportOutput 2021-12-27 17:50:48 +01:00
wmayer
0bc96dfedd + code refactoring of View3DInventorPy::viewDefaultOrientation 2021-12-27 16:32:31 +01:00
Yorik van Havre
cbede02dc5 Arch: Fixed units display of building parts 2021-12-27 15:09:39 +01:00
luz paz
03d836c6bf Cam: fix previously mistranslated source comment
Fix mistranslation introduced in 1c83d8fedd
2021-12-26 23:56:05 +01:00
luz paz
3683740d4d Link: Fix doxygen typo 2021-12-25 20:44:55 +01:00
luzpaz
1c83d8fedd Points: translate doxygen from DE to EN + fix superfluous whitespace (#5287)
* Points: translate doxygen from DE to EN + fix superfluous whitespace

For the purpose of making the source documentation uniform, source comments in this file were translated to english.

* Points: remove superfluous whitespace

* Fix left over DE to EN translations (from Cam and Mesh code)
2021-12-25 20:41:12 +01:00
Uwe
5923ce1858 [GUI] don't show report view on warnings by default
I introduced FreeCAD to several people and see that especially newbies are confused with all the warnings they get but cannot understand.
The solution was to change that the report view panel is not automatically shown on every warning.
This PR does this.

More experienced users can anytime enable the option. Thus this PR has not much impact but obviously makes life easier for beginners.
2021-12-25 20:40:24 +01:00
Uwe
ce236c3f03 [Mesh] rename gmsh -> Gmsh
I was informed that Gmsh names itself with a capital G. I had a look and in FEM it is already named Gmsh, but not in the Mesh WB. Therefore this PR.

(The other changes than the pure renaming was automatically done by Qt's designer.)
2021-12-25 20:39:47 +01:00
Abdullah Tahiri
6cf2d39a24 Sketcher: white-space only commit - remove unnecessary indentation 2021-12-25 16:32:43 +01:00
Ajinkya Dahale
3bd2bcc72f [Sketcher] Constrain new B-spline pole weight only if equal to first
When new control points are created in a b-spline in a sketch, do not constrain
their weights to be equal to the first, unless they are already equal. This way
if we have unequal weights to begin with and OCC has computed the appropriate
weights so that the new spline is closer to the original, the weights are not
disturbed.
2021-12-25 08:42:18 +01:00
0penBrain
ba78b194b3 [Sketcher] Ensure reference angle constraint is always positive, fixes #4621 2021-12-25 08:21:34 +01:00
mwganson
32e0e427c0 [sketcher_mapsketch] prevent circular dependency by disallowing mapping a sketch to an object in the sketch's outlistrecursive, make the command active only when there is a selection, recompute after doing attachment 2021-12-25 08:09:54 +01:00
Uwe
0a27540479 [PD] refine helix intersection calculation 2021-12-24 01:40:25 +01:00
Uwe
3cff3202ef [PD] fix Helix creation bug
Helices with zero height and zero growth are valid as long as there are no more than 1.0 turns.
2021-12-24 01:10:21 +01:00
Zheng, Lei
4ca362df0a App: catch Base::Exception in ObjectIdentifier::getDep() 2021-12-23 15:35:22 +01:00
wmayer
53f24f4bc2 Sketcher: add unit test for sketch with expressions 2021-12-23 15:32:24 +01:00
luz paz
1653d26ffa Cam: translate doxygen from DE/FR to EN
For the purpose of making the source documentation uniform, source comments in this file were translated to english.
2021-12-22 15:20:17 +01:00
Chris Hennes
b0fc0ab0f4 cMake: Default /MP to ON for MSVC 2021-12-21 23:07:02 -06:00
Zheng, Lei
afd003db78 App: fix Enumeration assignment and comparison 2021-12-21 21:41:02 -07:00
Zheng, Lei
ccf10b8867 Minor code changes according to suggestions 2021-12-21 21:41:02 -07:00
Zheng, Lei
35d7b71466 Spreadsheet: code style change 2021-12-21 21:41:02 -07:00
Zheng, Lei
75e639c94c App/Gui: add new ObjectStatus TouchOnColorChange
For triggering recompute on color changes
2021-12-21 21:41:02 -07:00
Zheng, Lei
b32369d185 App: insert UUID property to trace the source of copied object
A property _ObjectUUID will be added to an object before it is being to
copied, if the property does not exists. Anoter propert _SourceUUID
property will be added to any copied object, with value set to its
source objct's _ObjectUUID.
2021-12-21 21:41:02 -07:00
Zheng, Lei
d286a54fc1 PartDesign: show error on SubShapeBinder CopyOnChange failure
The failure is not obivous as it would have been occurred in a
hidden temporary document.
2021-12-21 21:41:02 -07:00
Zheng, Lei
f6c2688319 App: clarify documentation of PropertyContainer::getPropertyNamedList() 2021-12-21 21:41:02 -07:00
Zheng, Lei
715d67e2c3 Gui: do not prompt when closing view of temp document 2021-12-21 21:41:02 -07:00
Zheng, Lei
d0b7bf1669 App: fix property status restore 2021-12-21 21:41:02 -07:00
Zheng, Lei
0029f3206d Spreadsheet: improve copy/cut/paste cells
Add color bound around user copy/cut ranges. Do not touch Spreadsheet
object when cutting, only do so when pasting.
2021-12-21 21:41:02 -07:00
Zheng, Lei
2bd4404afb PartDesign: expose SubShapeBinderPython 2021-12-21 21:41:02 -07:00
Zheng, Lei
5f6b34ebad App: expose some property status bits to PropertyContainerPy 2021-12-21 21:41:02 -07:00
Zheng, Lei
39c04e4877 PartDesign: support CopyOnChange in SubShapeBinder 2021-12-21 21:41:02 -07:00
Zheng, Lei
99f199ad7e App: fix pending object remove on recomputing 2021-12-21 21:41:02 -07:00
Zheng, Lei
caa29060cf Spreadsheet: fix handling of absolute cell address 2021-12-21 21:41:02 -07:00
Zheng, Lei
0dcea9b2e1 App: warning on invalid cell offset in Expression 2021-12-21 21:41:02 -07:00
Zheng, Lei
a9895e4f04 Gui: expose 'Expression...' property editor menu action
For expression binding of all type of property. Previously this action
is only available if 'Show all' is activated.
2021-12-21 21:41:02 -07:00
Zheng, Lei
08cdd323b6 App: add Property::isSame() API
To compare if two property contains the same content. The default
implementation in Property uses the persistense interface to save both
properties to string and compares the content. This may not work at the
moment if the property saves content in separate file or in binary.

Various properties have cheaper implementation to direct compare their
internal values.
2021-12-21 21:41:02 -07:00
Zheng, Lei
51d4e5c2a9 Draft: support 'CopyOnChange' in Draft link array 2021-12-21 21:41:02 -07:00
Zheng, Lei
4f29e81d0c App: support CopyOnChange property in Link
New property status bit 'CopyOnChange' is added for any document object
to publish any property as a 'Configuration' option. When Link is
linked to any object with such property, it will duplicate those
properties and added it Link itself as dynamic properties. If the user
changes any of these dynamic properties, the Link will auto copy the
linked to object and apply the new configuration to it.

The Link has a new property 'LinkCopyOnChange' to allow user to
enable/disable this feature.

Spreadsheet's 'Configuration Table' feature will publish its
configuration property with 'CopyOnChange'.

Currently, once the linked object is copied, it will be independent with
the original object. There is no mechanism to auto sync changes back to
the copy.
2021-12-21 21:41:02 -07:00
Zheng, Lei
1f604ec632 Gui: fix property view linked property highlight 2021-12-21 21:41:02 -07:00
Zheng, Lei
bd201c82ce Spreadsheet: add menu action 'Configuration table...'
To make it easy for user to create dynamically switchable configuration
tables using spreadsheet.
2021-12-21 21:41:02 -07:00
Zheng, Lei
7d23d5b984 Spreadsheet: support mapping protocol in PropertySheetPy
Read only mapping protocol support to retrieve a range of cell values.
Expects the key to be a string of either a single cell address or a
range.
2021-12-21 21:41:02 -07:00
Chris Hennes
82759f6203 Spreadsheet: Compilation fixes for cherry-picked commits 2021-12-21 21:41:02 -07:00
Zheng, Lei
2a3951ca32 Spreadsheet: change alias handling
No longer add dynamic property for alias, simply rely on
get(Dynamic)PropertyByName() to check for aliases.

Add new API PropertyContainer::getPropertyNamedList() so that
ExpressionCompleter can discover properties with aliases.
2021-12-21 21:41:02 -07:00