1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: PartSet_WidgetFeaturePointSelector.h
4 // Created: 28 Feb 2017
5 // Author: Natalia ERMOLAEVA
8 #ifndef PartSet_WidgetFeaturePointSelector_H
9 #define PartSet_WidgetFeaturePointSelector_H
11 #include <ModelAPI_CompositeFeature.h>
12 #include <ModuleBase_WidgetShapeSelector.h>
15 #include "PartSet_MouseProcessor.h"
17 #include <Quantity_Color.hxx>
21 class ModuleBase_IWorkshop;
22 class Config_WidgetAPI;
23 class ModuleBase_IViewWindow;
24 class ModuleBase_ViewerPrs;
27 class GeomDataAPI_Point2D;
34 * Customosation of PartSet_WidgetFeaturePointSelector 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_WidgetFeaturePointSelector: 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_WidgetFeaturePointSelector(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop,
48 const Config_WidgetAPI* theData);
50 virtual ~PartSet_WidgetFeaturePointSelector();
52 /// Checks all widget validator if the owner is valid. Firstly it checks custom widget validating,
53 /// next, the attribute's validating. It trying on the give selection to current attribute by
54 /// setting the value inside and calling validators. After this, the previous attribute value is
55 /// restored.The valid/invalid value is cashed.
56 /// \param theValue a selected presentation in the view
57 /// \return a boolean value
58 virtual bool isValidSelection(const std::shared_ptr<ModuleBase_ViewerPrs>& theValue);
61 /// \param theSketch a sketcher object
62 void setSketcher(CompositeFeaturePtr theSketch) { mySketch = theSketch; }
64 /// Retrurns installed sketcher
65 CompositeFeaturePtr sketch() const { return mySketch; }
67 /// The methiod called when widget is deactivated
68 virtual void deactivate();
70 /// Processing the mouse move event in the viewer
71 /// \param theWindow a view window
72 /// \param theEvent a mouse event
73 virtual void mouseMoved(ModuleBase_IViewWindow* theWindow, QMouseEvent* theEvent);
75 /// Processing the mouse release event in the viewer
76 /// \param theWindow a view window
77 /// \param theEvent a mouse event
78 virtual void mouseReleased(ModuleBase_IViewWindow* theWindow, QMouseEvent* theEvent);
80 /// Returns values which should be highlighted when the whidget is active
81 /// \param theValues a list of presentations
82 //virtual void getHighlighted(QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues);
84 /// Set the given wrapped value to the current widget
85 /// This value should be processed in the widget according to the needs
86 /// The method is called by the current operation to process the operation preselection.
87 /// It is redefined to fill attributes responsible for the sub selection
88 /// \param theValues the wrapped selection values
89 /// \param theToValidate a flag on validation of the values
90 virtual bool setSelection(QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues,
91 const bool theToValidate);
93 /// Fill preselection used in mouseReleased
94 //virtual void setPreSelection(const std::shared_ptr<ModuleBase_ViewerPrs>& thePreSelected);
95 virtual void setPreSelection(const std::shared_ptr<ModuleBase_ViewerPrs>& thePreSelected,
96 ModuleBase_IViewWindow* theWnd,
97 QMouseEvent* theEvent);
99 /// Return the attribute values wrapped in a list of viewer presentations
100 /// \return a list of viewer presentations, which contains an attribute result and
101 /// a shape. If the attribute do not uses the shape, it is empty
102 virtual QList<std::shared_ptr<ModuleBase_ViewerPrs>> getAttributeSelection() const;
105 /// The methiod called when widget is activated
106 virtual void activateCustom();
109 bool fillFeature(const std::shared_ptr<ModuleBase_ViewerPrs>& theSelectedPrs,
110 ModuleBase_IViewWindow* theWnd,
111 QMouseEvent* theEvent);
113 /// Pointer to a sketch
114 CompositeFeaturePtr mySketch;
115 Quantity_Color myHighlightColor;
116 Quantity_Color mySelectionColor;