Salome HOME
5797683bba080dd31a5ba9e84d7f45dc6f1ffc7e
[modules/shaper.git] / src / PartSet / PartSet_WidgetSubShapeSelector.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        PartSet_WidgetSubShapeSelector.h
4 // Created:     21 Jul 2016
5 // Author:      Natalia ERMOLAEVA
6
7
8 #ifndef PartSet_WidgetSubShapeSelector_H
9 #define PartSet_WidgetSubShapeSelector_H
10
11 #include "PartSet.h"
12
13 #include <ModuleBase_WidgetShapeSelector.h>
14 #include <PartSet_MouseProcessor.h>
15
16 #include <ModelAPI_CompositeFeature.h>
17 #include <GeomDataAPI_Point2D.h>
18
19 #include <QObject>
20
21 #include <set>
22 #include <map>
23
24 class ModuleBase_IWorkshop;
25 class Config_WidgetAPI;
26 class ModuleBase_IViewWindow;
27 class ModuleBase_ViewerPrs;
28
29 class QWidget;
30 class QMouseEvent;
31
32 /**
33 * \ingroup Modules
34 * Customosation of PartSet_WidgetSubShapeSelector 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
37 */
38 class PARTSET_EXPORT PartSet_WidgetSubShapeSelector: public ModuleBase_WidgetShapeSelector,
39                                                      public PartSet_MouseProcessor
40 {
41 Q_OBJECT
42  public:
43   /// Constructor
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_WidgetSubShapeSelector(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop,
48                                  const Config_WidgetAPI* theData);
49
50   virtual ~PartSet_WidgetSubShapeSelector();
51
52   /// Set sketcher
53   /// \param theSketch a sketcher object
54   void setSketcher(CompositeFeaturePtr theSketch) { mySketch = theSketch; }
55
56   /// Retrurns installed sketcher
57   CompositeFeaturePtr sketch() const { return mySketch; }
58
59   /// The methiod called when widget is deactivated
60   virtual void deactivate();
61
62   /// Processing the mouse move event in the viewer
63   /// \param theWindow a view window
64   /// \param theEvent a mouse event
65   virtual void mouseMoved(ModuleBase_IViewWindow* theWindow, QMouseEvent* theEvent);
66
67   /// Returns values which should be highlighted when the whidget is active
68   /// \param theValues a list of presentations
69   virtual void getHighlighted(QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues);
70
71   /// Set the given wrapped value to the current widget
72   /// This value should be processed in the widget according to the needs
73   /// The method is called by the current operation to process the operation preselection.
74   /// It is redefined to fill attributes responsible for the sub selection
75   /// \param theValues the wrapped selection values
76   /// \param theToValidate a flag on validation of the values
77   virtual bool setSelection(QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues,
78                             const bool theToValidate);
79
80 protected:
81   /// Checks the widget validity. By default, it returns true.
82   /// \param thePrs a selected presentation in the view
83   /// \return a boolean value
84   //virtual bool isValidSelectionCustom(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs);
85
86   /// Return an object and geom shape by the viewer presentation
87   /// \param thePrs a selection
88   /// \param theObject an output object
89   /// \param theShape a shape of the selection
90   //virtual void getGeomSelection(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs,
91   //                              ObjectPtr& theObject,
92   //                              GeomShapePtr& theShape);
93   void fillObjectShapes(const ObjectPtr& theObject);
94
95 protected:
96   /// The methiod called when widget is activated
97   virtual void activateCustom();
98
99 protected:
100   std::shared_ptr<ModuleBase_ViewerPrs> myCurrentSubShape;
101   std::map<ObjectPtr, std::set<GeomShapePtr> > myCashedShapes;
102   std::map<ObjectPtr, std::set<AttributePoint2DPtr> > myCashedReferences;
103
104   /// Pointer to a sketch 
105   CompositeFeaturePtr mySketch;
106 };
107
108 #endif