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 validating,
53 /// next, the attribute's validating. It trying on the give selection to current attribute by
54 /// setting the value inside and calling validators. After this, the previous attribute value is
55 /// 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 /// Returns values which should be highlighted when the whidget is active
85 /// \param theValues a list of presentations
86 //virtual void getHighlighted(QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues);
88 /// Set the given wrapped value to the current widget
89 /// This value should be processed in the widget according to the needs
90 /// The method is called by the current operation to process the operation preselection.
91 /// It is redefined to fill attributes responsible for the sub selection
92 /// \param theValues the wrapped selection values
93 /// \param theToValidate a flag on validation of the values
94 virtual bool setSelection(QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues,
95 const bool theToValidate);
97 /// Fill preselection used in mouseReleased
98 //virtual void setPreSelection(const std::shared_ptr<ModuleBase_ViewerPrs>& thePreSelected);
99 virtual void setPreSelection(const std::shared_ptr<ModuleBase_ViewerPrs>& thePreSelected,
100 ModuleBase_IViewWindow* theWnd,
101 QMouseEvent* theEvent);
103 /// Return the attribute values wrapped in a list of viewer presentations
104 /// \return a list of viewer presentations, which contains an attribute result and
105 /// a shape. If the attribute do not uses the shape, it is empty
106 virtual QList<std::shared_ptr<ModuleBase_ViewerPrs>> getAttributeSelection() const;
108 /// Computes and updates name of selected object in the widget
109 virtual void updateSelectionName();
112 /// The methiod called when widget is activated
113 virtual void activateCustom();
116 bool fillFeature(const std::shared_ptr<ModuleBase_ViewerPrs>& theSelectedPrs,
117 ModuleBase_IViewWindow* theWnd,
118 QMouseEvent* theEvent);
120 /// Pointer to a sketch
121 CompositeFeaturePtr mySketch;
122 Quantity_Color myHighlightColor;
123 Quantity_Color mySelectionColor;