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>
23 class ModuleBase_IWorkshop;
24 class Config_WidgetAPI;
25 class ModuleBase_IViewWindow;
26 class ModuleBase_ViewerPrs;
29 class GeomDataAPI_Point2D;
36 * Customosation of PartSet_WidgetFeaturePointSelector in order to visualize sub-shape
37 * by mouse move over shape in the viewer. Split of the object is performed by
38 * coincident points to the object. Segment between nearest coincidence is highlighted
40 class PARTSET_EXPORT PartSet_WidgetFeaturePointSelector: public ModuleBase_WidgetShapeSelector,
41 public PartSet_MouseProcessor
46 /// \param theParent the parent object
47 /// \param theWorkshop instance of workshop interface
48 /// \param theData the widget configuation. The attribute of the model widget is obtained from
49 PartSet_WidgetFeaturePointSelector(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop,
50 const Config_WidgetAPI* theData);
52 virtual ~PartSet_WidgetFeaturePointSelector();
54 /// Checks all widget validator if the owner is valid. Firstly it checks custom widget
55 /// validating, next, the attribute's validating. It trying on the give selection to current
56 /// attribute by setting the value inside and calling validators. After this, the previous
57 /// attribute value is restored.The valid/invalid value is cashed.
58 /// \param theValue a selected presentation in the view
59 /// \return a boolean value
60 virtual bool isValidSelection(const std::shared_ptr<ModuleBase_ViewerPrs>& theValue);
62 /// Activate or deactivate selection and selection filters
63 /// \return true if the selection filter of the widget is activated in viewer context
64 virtual bool activateSelectionAndFilters(bool toActivate);
67 /// \param theSketch a sketcher object
68 void setSketcher(CompositeFeaturePtr theSketch) { mySketch = theSketch; }
70 /// Retrurns installed sketcher
71 CompositeFeaturePtr sketch() const { return mySketch; }
73 /// The methiod called when widget is deactivated
74 virtual void deactivate();
76 /// Processing the mouse move event in the viewer
77 /// \param theWindow a view window
78 /// \param theEvent a mouse event
79 virtual void mouseMoved(ModuleBase_IViewWindow* theWindow, QMouseEvent* theEvent);
81 /// Processing the mouse release event in the viewer
82 /// \param theWindow a view window
83 /// \param theEvent a mouse event
84 virtual void mouseReleased(ModuleBase_IViewWindow* theWindow, QMouseEvent* theEvent);
86 /// Set the given wrapped value to the current widget
87 /// This value should be processed in the widget according to the needs
88 /// The method is called by the current operation to process the operation preselection.
89 /// It is redefined to fill attributes responsible for the sub selection
90 /// \param theValues the wrapped selection values
91 /// \param theToValidate a flag on validation of the values
92 virtual bool setSelection(QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues,
93 const bool theToValidate);
95 /// Fill preselection used in mouseReleased
96 virtual void setPreSelection(const std::shared_ptr<ModuleBase_ViewerPrs>& thePreSelected,
97 ModuleBase_IViewWindow* theWnd,
98 QMouseEvent* theEvent);
100 /// Return the attribute values wrapped in a list of viewer presentations
101 /// \return a list of viewer presentations, which contains an attribute result and
102 /// a shape. If the attribute do not uses the shape, it is empty
103 virtual QList<std::shared_ptr<ModuleBase_ViewerPrs>> getAttributeSelection() const;
106 /// The methiod called when widget is activated
107 virtual void activateCustom();
110 bool fillFeature(const std::shared_ptr<ModuleBase_ViewerPrs>& theSelectedPrs,
111 ModuleBase_IViewWindow* theWnd,
112 QMouseEvent* theEvent);
114 /// Pointer to a sketch
115 CompositeFeaturePtr mySketch;
116 Quantity_Color myHighlightColor;
117 Quantity_Color mySelectionColor;
119 std::string mySelectedObjectAttribute;
120 std::string mySelectedPointAttribute;
121 std::string myPreviewObjectAttribute;
122 std::string myPreviewPointAttribute;