1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: PartSet_WidgetSubShapeSelector.h
4 // Created: 21 Jul 2016
5 // Author: Natalia ERMOLAEVA
8 #ifndef PartSet_WidgetSubShapeSelector_H
9 #define PartSet_WidgetSubShapeSelector_H
12 #include "PartSet_MouseProcessor.h"
14 #include <ModuleBase_WidgetShapeSelector.h>
16 #include <ModelAPI_CompositeFeature.h>
23 class ModuleBase_IWorkshop;
24 class Config_WidgetAPI;
25 class ModuleBase_IViewWindow;
26 class ModuleBase_ViewerPrs;
29 class GeomDataAPI_Point2D;
36 * Customosation of PartSet_WidgetSubShapeSelector 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_WidgetSubShapeSelector: 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_WidgetSubShapeSelector(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop,
50 const Config_WidgetAPI* theData);
52 virtual ~PartSet_WidgetSubShapeSelector();
55 /// \param theSketch a sketcher object
56 void setSketcher(CompositeFeaturePtr theSketch) { mySketch = theSketch; }
58 /// Retrurns installed sketcher
59 CompositeFeaturePtr sketch() const { return mySketch; }
61 /// The methiod called when widget is deactivated
62 virtual void deactivate();
64 /// Processing the mouse move event in the viewer
65 /// \param theWindow a view window
66 /// \param theEvent a mouse event
67 virtual void mouseMoved(ModuleBase_IViewWindow* theWindow, QMouseEvent* theEvent);
69 /// Returns values which should be highlighted when the whidget is active
70 /// \param theValues a list of presentations
71 virtual void getHighlighted(QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues);
73 /// Set the given wrapped value to the current widget
74 /// This value should be processed in the widget according to the needs
75 /// The method is called by the current operation to process the operation preselection.
76 /// It is redefined to fill attributes responsible for the sub selection
77 /// \param theValues the wrapped selection values
78 /// \param theToValidate a flag on validation of the values
79 virtual bool setSelection(QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues,
80 const bool theToValidate);
83 /// Checks the widget validity. By default, it returns true.
84 /// \param thePrs a selected presentation in the view
85 /// \return a boolean value
86 //virtual bool isValidSelectionCustom(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs);
88 /// Return an object and geom shape by the viewer presentation
89 /// \param thePrs a selection
90 /// \param theObject an output object
91 /// \param theShape a shape of the selection
92 //virtual void getGeomSelection(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs,
93 // ObjectPtr& theObject,
94 // GeomShapePtr& theShape);
95 void fillObjectShapes(const ObjectPtr& theObject);
97 /// Return an object and geom shape by the viewer presentation
98 /// \param thePrs a selection
99 /// \param theObject an output object
100 /// \param theShape a shape of the selection
101 virtual void getGeomSelection(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs,
102 ObjectPtr& theObject,
103 GeomShapePtr& theShape);
105 /// Return the attribute values wrapped in a list of viewer presentations
106 /// \return a list of viewer presentations, which contains an attribute result and
107 /// a shape. If the attribute do not uses the shape, it is empty
108 virtual QList<std::shared_ptr<ModuleBase_ViewerPrs>> getAttributeSelection() const;
111 /// The methiod called when widget is activated
112 virtual void activateCustom();
115 std::shared_ptr<ModuleBase_ViewerPrs> myCurrentSubShape;
116 std::map<ObjectPtr, std::set<GeomShapePtr> > myCashedShapes;
118 typedef std::map<std::shared_ptr<GeomDataAPI_Point2D>,
119 std::shared_ptr<GeomAPI_Pnt> > PntToAttributesMap;
120 std::map<ObjectPtr, PntToAttributesMap> myCashedReferences;
122 /// Pointer to a sketch
123 CompositeFeaturePtr mySketch;