1 // Copyright (C) 2014-2019 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef PartSet_WidgetFeaturePointSelector_H
21 #define PartSet_WidgetFeaturePointSelector_H
23 #include <ModelAPI_CompositeFeature.h>
24 #include <ModuleBase_WidgetShapeSelector.h>
27 #include "PartSet_MouseProcessor.h"
29 #include <Quantity_Color.hxx>
35 class ModuleBase_IWorkshop;
36 class Config_WidgetAPI;
37 class ModuleBase_IViewWindow;
38 class ModuleBase_ViewerPrs;
41 class GeomDataAPI_Point2D;
48 * Customosation of PartSet_WidgetFeaturePointSelector in order to visualize sub-shape
49 * by mouse move over shape in the viewer. Split of the object is performed by
50 * coincident points to the object. Segment between nearest coincidence is highlighted
52 class PARTSET_EXPORT PartSet_WidgetFeaturePointSelector: public ModuleBase_WidgetShapeSelector,
53 public PartSet_MouseProcessor
58 /// \param theParent the parent object
59 /// \param theWorkshop instance of workshop interface
60 /// \param theData the widget configuation. The attribute of the model widget is obtained from
61 PartSet_WidgetFeaturePointSelector(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop,
62 const Config_WidgetAPI* theData);
64 virtual ~PartSet_WidgetFeaturePointSelector();
66 /// Checks all widget validator if the owner is valid. Firstly it checks custom widget
67 /// validating, next, the attribute's validating. It trying on the give selection to current
68 /// attribute by setting the value inside and calling validators. After this, the previous
69 /// attribute value is restored.The valid/invalid value is cashed.
70 /// \param theValue a selected presentation in the view
71 /// \return a boolean value
72 virtual bool isValidSelection(const std::shared_ptr<ModuleBase_ViewerPrs>& theValue);
74 /// Activate or deactivate selection and selection filters
75 /// \return true if the selection filter of the widget is activated in viewer context
76 virtual void updateSelectionModesAndFilters(bool toActivate);
79 /// \param theSketch a sketcher object
80 void setSketcher(CompositeFeaturePtr theSketch) { mySketch = theSketch; }
82 /// Retrurns installed sketcher
83 CompositeFeaturePtr sketch() const { return mySketch; }
85 /// The methiod called when widget is deactivated
86 virtual void deactivate();
88 /// Processing the mouse move event in the viewer
89 /// \param theWindow a view window
90 /// \param theEvent a mouse event
91 virtual void mouseMoved(ModuleBase_IViewWindow* theWindow, QMouseEvent* theEvent);
93 /// Processing the mouse release event in the viewer
94 /// \param theWindow a view window
95 /// \param theEvent a mouse event
96 virtual void mouseReleased(ModuleBase_IViewWindow* theWindow, QMouseEvent* theEvent);
98 /// Set the given wrapped value to the current widget
99 /// This value should be processed in the widget according to the needs
100 /// The method is called by the current operation to process the operation preselection.
101 /// It is redefined to fill attributes responsible for the sub selection
102 /// \param theValues the wrapped selection values
103 /// \param theToValidate a flag on validation of the values
104 virtual bool setSelection(QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues,
105 const bool theToValidate);
107 /// Fill preselection used in mouseReleased
108 virtual void setPreSelection(const std::shared_ptr<ModuleBase_ViewerPrs>& thePreSelected,
109 ModuleBase_IViewWindow* theWnd,
110 QMouseEvent* theEvent);
112 /// Return the attribute values wrapped in a list of viewer presentations
113 /// \return a list of viewer presentations, which contains an attribute result and
114 /// a shape. If the attribute do not uses the shape, it is empty
115 virtual QList<std::shared_ptr<ModuleBase_ViewerPrs>> getAttributeSelection() const;
118 /// The methiod called when widget is activated
119 virtual void activateCustom();
122 bool fillFeature(const std::shared_ptr<ModuleBase_ViewerPrs>& theSelectedPrs,
123 ModuleBase_IViewWindow* theWnd,
124 QMouseEvent* theEvent);
126 /// Pointer to a sketch
127 CompositeFeaturePtr mySketch;
128 Quantity_Color myHighlightColor;
129 Quantity_Color mySelectionColor;
131 std::string mySelectedObjectAttribute;
132 std::string mySelectedPointAttribute;
133 std::string myPreviewObjectAttribute;
134 std::string myPreviewPointAttribute;