Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information