Salome HOME
5dbb9869e38bf07eb118384a16b2b9be84b366e2
[modules/shaper.git] / src / PartSet / PartSet_WidgetMultiSelector.h
1 // Copyright (C) 2014-2023  CEA/DEN, EDF R&D
2 //
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.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #ifndef PartSet_WidgetMultiSelector_H
21 #define PartSet_WidgetMultiSelector_H
22
23 #include "PartSet.h"
24
25 #include <ModuleBase_WidgetMultiSelector.h>
26
27 #include <ModelAPI_CompositeFeature.h>
28
29 class PartSet_ExternalObjectsMgr;
30 class ModuleBase_ViewerPrs;
31
32 /**
33 * \ingroup Modules
34 * Customosation of ModuleBase_WidgetMultiSelector in order to provide 
35 * working with sketch specific objects and creation of external objects.
36 */
37 class PARTSET_EXPORT PartSet_WidgetMultiSelector: public ModuleBase_WidgetMultiSelector
38 {
39 Q_OBJECT
40  public:
41   /// Constructor
42   /// \param theParent the parent object
43   /// \param theWorkshop instance of workshop interface
44   /// \param theData the widget configuation. The attribute of the model widget is obtained from
45   PartSet_WidgetMultiSelector(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop,
46                               const Config_WidgetAPI* theData);
47
48   virtual ~PartSet_WidgetMultiSelector();
49
50   /// Defines if it is supposed that the widget should interact with the viewer.
51   virtual bool isViewerSelector() { return true; }
52
53   /// Set sketcher
54   /// \param theSketch a sketcher object
55   void setSketcher(CompositeFeaturePtr theSketch) { mySketch = theSketch; }
56
57   /// Retrurns installed sketcher
58   CompositeFeaturePtr sketch() const { return mySketch; }
59
60 protected:
61   /// Checks the widget validity. By default, it returns true.
62   /// \param thePrs a selected presentation in the view
63   /// \return a boolean value
64   virtual bool isValidSelectionCustom(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs);
65
66   /// Creates a backup of the current values of the attribute
67   /// It should be realized in the specific widget because of different
68   /// parameters of the current attribute
69   /// \param theAttribute an attribute
70   /// \param theValid a boolean flag, if restore happens for valid parameters
71   virtual void restoreAttributeValue(const AttributePtr& theAttribute, const bool theValid);
72
73   /// Return an object and geom shape by the viewer presentation
74   /// \param thePrs a selection
75   /// \param theObject an output object
76   /// \param theShape a shape of the selection
77   virtual void getGeomSelection(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs,
78                                 ObjectPtr& theObject,
79                                 GeomShapePtr& theShape);
80
81 protected:
82   /// Manager of external objects
83   PartSet_ExternalObjectsMgr* myExternalObjectMgr;
84
85   /// Pointer to a sketch
86   CompositeFeaturePtr mySketch;
87 };
88
89 #endif