Salome HOME
Issue #1664: In the Sketcher, add the function Split a segment. Validator for selecti...
[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
18 #include <QObject>
19
20 #include <set>
21 #include <map>
22
23 class ModuleBase_IWorkshop;
24 class Config_WidgetAPI;
25 class ModuleBase_IViewWindow;
26 class ModuleBase_ViewerPrs;
27
28 class QWidget;
29 class QMouseEvent;
30
31 /**
32 * \ingroup Modules
33 * Customosation of PartSet_WidgetSubShapeSelector in order to visualize sub-shape 
34 * by mouse move over shape in the viewer. Split of the object is performed by
35 * coincident points to the object. Segment between nearest coincidence is highlighted
36 */
37 class PARTSET_EXPORT PartSet_WidgetSubShapeSelector: public ModuleBase_WidgetShapeSelector,
38                                                      public PartSet_MouseProcessor
39 {
40 Q_OBJECT
41  public:
42   /// Constructor
43   /// \param theParent the parent object
44   /// \param theWorkshop instance of workshop interface
45   /// \param theData the widget configuation. The attribute of the model widget is obtained from
46   PartSet_WidgetSubShapeSelector(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop,
47                                  const Config_WidgetAPI* theData);
48
49   virtual ~PartSet_WidgetSubShapeSelector();
50
51   /// Set sketcher
52   /// \param theSketch a sketcher object
53   void setSketcher(CompositeFeaturePtr theSketch) { mySketch = theSketch; }
54
55   /// Retrurns installed sketcher
56   CompositeFeaturePtr sketch() const { return mySketch; }
57
58   /// The methiod called when widget is deactivated
59   virtual void deactivate();
60
61   /// Processing the mouse move event in the viewer
62   /// \param theWindow a view window
63   /// \param theEvent a mouse event
64   virtual void mouseMoved(ModuleBase_IViewWindow* theWindow, QMouseEvent* theEvent);
65
66   /// Returns values which should be highlighted when the whidget is active
67   /// \param theValues a list of presentations
68   virtual void getHighlighted(QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues);
69
70 protected:
71   /// Checks the widget validity. By default, it returns true.
72   /// \param thePrs a selected presentation in the view
73   /// \return a boolean value
74   //virtual bool isValidSelectionCustom(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs);
75
76   /// Return an object and geom shape by the viewer presentation
77   /// \param thePrs a selection
78   /// \param theObject an output object
79   /// \param theShape a shape of the selection
80   //virtual void getGeomSelection(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs,
81   //                              ObjectPtr& theObject,
82   //                              GeomShapePtr& theShape);
83   void fillObjectShapes(const ObjectPtr& theObject);
84
85 protected:
86   /// The methiod called when widget is activated
87   virtual void activateCustom();
88
89 protected:
90   std::shared_ptr<ModuleBase_ViewerPrs> myCurrentSubShape;
91   std::map<ObjectPtr, std::set<GeomShapePtr> > myCashedShapes;
92
93   /// Pointer to a sketch 
94   CompositeFeaturePtr mySketch;
95 };
96
97 #endif