1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: PartSet_WidgetFeaturePointSelector.h
4 // Created: 28 Feb 2017
5 // Author: Natalia ERMOLAEVA
8 #ifndef PartSet_WidgetFeaturePointSelector_H
9 #define PartSet_WidgetFeaturePointSelector_H
11 #include <ModelAPI_CompositeFeature.h>
12 #include <ModuleBase_WidgetShapeSelector.h>
15 #include "PartSet_MouseProcessor.h"
17 #include <Quantity_Color.hxx>
21 class ModuleBase_IWorkshop;
22 class Config_WidgetAPI;
23 class ModuleBase_IViewWindow;
24 class ModuleBase_ViewerPrs;
27 class GeomDataAPI_Point2D;
34 * Customosation of PartSet_WidgetFeaturePointSelector in order to visualize sub-shape
35 * by mouse move over shape in the viewer. Split of the object is performed by
36 * coincident points to the object. Segment between nearest coincidence is highlighted
38 class PARTSET_EXPORT PartSet_WidgetFeaturePointSelector: public ModuleBase_WidgetShapeSelector,
39 public PartSet_MouseProcessor
44 /// \param theParent the parent object
45 /// \param theWorkshop instance of workshop interface
46 /// \param theData the widget configuation. The attribute of the model widget is obtained from
47 PartSet_WidgetFeaturePointSelector(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop,
48 const Config_WidgetAPI* theData);
50 virtual ~PartSet_WidgetFeaturePointSelector();
52 /// Checks all widget validator if the owner is valid. Firstly it checks custom widget
53 /// validating, next, the attribute's validating. It trying on the give selection to current
54 /// attribute by setting the value inside and calling validators. After this, the previous
55 /// attribute value is restored.The valid/invalid value is cashed.
56 /// \param theValue a selected presentation in the view
57 /// \return a boolean value
58 virtual bool isValidSelection(const std::shared_ptr<ModuleBase_ViewerPrs>& theValue);
60 /// Activate or deactivate selection and selection filters
61 /// \return true if the selection filter of the widget is activated in viewer context
62 virtual bool activateSelectionAndFilters(bool toActivate);
65 /// \param theSketch a sketcher object
66 void setSketcher(CompositeFeaturePtr theSketch) { mySketch = theSketch; }
68 /// Retrurns installed sketcher
69 CompositeFeaturePtr sketch() const { return mySketch; }
71 /// The methiod called when widget is deactivated
72 virtual void deactivate();
74 /// Processing the mouse move event in the viewer
75 /// \param theWindow a view window
76 /// \param theEvent a mouse event
77 virtual void mouseMoved(ModuleBase_IViewWindow* theWindow, QMouseEvent* theEvent);
79 /// Processing the mouse release event in the viewer
80 /// \param theWindow a view window
81 /// \param theEvent a mouse event
82 virtual void mouseReleased(ModuleBase_IViewWindow* theWindow, QMouseEvent* theEvent);
84 /// Set the given wrapped value to the current widget
85 /// This value should be processed in the widget according to the needs
86 /// The method is called by the current operation to process the operation preselection.
87 /// It is redefined to fill attributes responsible for the sub selection
88 /// \param theValues the wrapped selection values
89 /// \param theToValidate a flag on validation of the values
90 virtual bool setSelection(QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues,
91 const bool theToValidate);
93 /// Fill preselection used in mouseReleased
94 virtual void setPreSelection(const std::shared_ptr<ModuleBase_ViewerPrs>& thePreSelected,
95 ModuleBase_IViewWindow* theWnd,
96 QMouseEvent* theEvent);
98 /// Return the attribute values wrapped in a list of viewer presentations
99 /// \return a list of viewer presentations, which contains an attribute result and
100 /// a shape. If the attribute do not uses the shape, it is empty
101 virtual QList<std::shared_ptr<ModuleBase_ViewerPrs>> getAttributeSelection() const;
104 /// The methiod called when widget is activated
105 virtual void activateCustom();
108 bool fillFeature(const std::shared_ptr<ModuleBase_ViewerPrs>& theSelectedPrs,
109 ModuleBase_IViewWindow* theWnd,
110 QMouseEvent* theEvent);
112 /// Pointer to a sketch
113 CompositeFeaturePtr mySketch;
114 Quantity_Color myHighlightColor;
115 Quantity_Color mySelectionColor;