]> SALOME platform Git repositories - modules/shaper.git/blob - src/PartSet/PartSet_WidgetFeaturePointSelector.h
Salome HOME
Issue #2149 Split does not highlight the selected edge
[modules/shaper.git] / src / PartSet / PartSet_WidgetFeaturePointSelector.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        PartSet_WidgetFeaturePointSelector.h
4 // Created:     28 Feb 2017
5 // Author:      Natalia ERMOLAEVA
6
7
8 #ifndef PartSet_WidgetFeaturePointSelector_H
9 #define PartSet_WidgetFeaturePointSelector_H
10
11 #include <ModelAPI_CompositeFeature.h>
12 #include <ModuleBase_WidgetShapeSelector.h>
13
14 #include "PartSet.h"
15 #include "PartSet_MouseProcessor.h"
16
17 #include <Quantity_Color.hxx>
18
19 #include <QObject>
20
21 #include <string>
22
23 class ModuleBase_IWorkshop;
24 class Config_WidgetAPI;
25 class ModuleBase_IViewWindow;
26 class ModuleBase_ViewerPrs;
27
28 class GeomAPI_Pnt;
29 class GeomDataAPI_Point2D;
30
31 class QWidget;
32 class QMouseEvent;
33
34 /**
35 * \ingroup Modules
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
39 */
40 class PARTSET_EXPORT PartSet_WidgetFeaturePointSelector: public ModuleBase_WidgetShapeSelector,
41                                                          public PartSet_MouseProcessor
42 {
43 Q_OBJECT
44  public:
45   /// Constructor
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);
51
52   virtual ~PartSet_WidgetFeaturePointSelector();
53
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);
61
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);
65
66   /// Set sketcher
67   /// \param theSketch a sketcher object
68   void setSketcher(CompositeFeaturePtr theSketch) { mySketch = theSketch; }
69
70   /// Retrurns installed sketcher
71   CompositeFeaturePtr sketch() const { return mySketch; }
72
73   /// The methiod called when widget is deactivated
74   virtual void deactivate();
75
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);
80
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);
85
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);
94
95   /// Fill preselection used in mouseReleased
96   virtual void setPreSelection(const std::shared_ptr<ModuleBase_ViewerPrs>& thePreSelected,
97                                ModuleBase_IViewWindow* theWnd,
98                                QMouseEvent* theEvent);
99 protected:
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;
104
105 protected:
106   /// The methiod called when widget is activated
107   virtual void activateCustom();
108
109 protected:
110   bool fillFeature(const std::shared_ptr<ModuleBase_ViewerPrs>& theSelectedPrs,
111                    ModuleBase_IViewWindow* theWnd,
112                    QMouseEvent* theEvent);
113
114   /// Pointer to a sketch
115   CompositeFeaturePtr mySketch;
116   Quantity_Color myHighlightColor;
117   Quantity_Color mySelectionColor;
118
119   std::string mySelectedObjectAttribute;
120   std::string mySelectedPointAttribute;
121   std::string myPreviewObjectAttribute;
122   std::string myPreviewPointAttribute;
123 };
124
125 #endif