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
13 #include <ModuleBase_WidgetShapeSelector.h>
14 #include <PartSet_MouseProcessor.h>
16 #include <ModelAPI_CompositeFeature.h>
17 #include <GeomDataAPI_Point2D.h>
24 class ModuleBase_IWorkshop;
25 class Config_WidgetAPI;
26 class ModuleBase_IViewWindow;
27 class ModuleBase_ViewerPrs;
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
38 class PARTSET_EXPORT PartSet_WidgetSubShapeSelector: public ModuleBase_WidgetShapeSelector,
39 public PartSet_MouseProcessor
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);
50 virtual ~PartSet_WidgetSubShapeSelector();
53 /// \param theSketch a sketcher object
54 void setSketcher(CompositeFeaturePtr theSketch) { mySketch = theSketch; }
56 /// Retrurns installed sketcher
57 CompositeFeaturePtr sketch() const { return mySketch; }
59 /// The methiod called when widget is deactivated
60 virtual void deactivate();
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);
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);
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);
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);
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);
95 /// Return an object and geom shape by the viewer presentation
96 /// \param thePrs a selection
97 /// \param theObject an output object
98 /// \param theShape a shape of the selection
99 virtual void getGeomSelection(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs,
100 ObjectPtr& theObject,
101 GeomShapePtr& theShape);
103 /// Return the attribute values wrapped in a list of viewer presentations
104 /// \return a list of viewer presentations, which contains an attribute result and
105 /// a shape. If the attribute do not uses the shape, it is empty
106 virtual QList<std::shared_ptr<ModuleBase_ViewerPrs>> getAttributeSelection() const;
109 /// The methiod called when widget is activated
110 virtual void activateCustom();
113 std::shared_ptr<ModuleBase_ViewerPrs> myCurrentSubShape;
114 std::map<ObjectPtr, std::set<GeomShapePtr> > myCashedShapes;
115 std::map<ObjectPtr, std::set<AttributePoint2DPtr> > myCashedReferences;
117 /// Pointer to a sketch
118 CompositeFeaturePtr mySketch;