Salome HOME
updated copyright message
[modules/shaper.git] / src / PartSet / PartSet_WidgetShapeSelector.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_WidgetShapeSelector_H
21 #define PartSet_WidgetShapeSelector_H
22
23 #include "PartSet.h"
24
25 #include <ModuleBase_WidgetShapeSelector.h>
26
27 #include <ModelAPI_CompositeFeature.h>
28
29 class PartSet_ExternalObjectsMgr;
30
31 /**
32 * \ingroup Modules
33 * Customosation of ModuleBase_WidgetShapeSelector in order to provide 
34 * working with sketch specific objects and external objects.
35 */
36 class PARTSET_EXPORT PartSet_WidgetShapeSelector: public ModuleBase_WidgetShapeSelector
37 {
38 Q_OBJECT
39  public:
40   /// Constructor
41   /// \param theParent the parent object
42   /// \param theWorkshop instance of workshop interface
43   /// \param theData the widget configuation. The attribute of the model widget is obtained from
44   PartSet_WidgetShapeSelector(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop,
45                               const Config_WidgetAPI* theData);
46
47   virtual ~PartSet_WidgetShapeSelector();
48
49   /// Set sketcher
50   /// \param theSketch a sketcher object
51   void setSketcher(CompositeFeaturePtr theSketch) { mySketch = theSketch; }
52
53   /// Retrurns installed sketcher
54   CompositeFeaturePtr sketch() const { return mySketch; }
55
56   /// Appends into container of workshop selection filters
57   /// \param [out] theModuleSelectionFilters module additional modes, -1 means all default modes
58   /// \param [out] theSelectionFilters selection filters
59   virtual void selectionFilters(QIntList& theModuleSelectionFilters,
60                                 SelectMgr_ListOfFilter& theSelectionFilters);
61
62 protected:
63   /// Checks the widget validity. By default, it returns true.
64   /// \param thePrs a selected presentation in the view
65   /// \return a boolean value
66   virtual bool isValidSelectionCustom(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs);
67
68   /// Return an object and geom shape by the viewer presentation
69   /// \param thePrs a selection
70   /// \param theObject an output object
71   /// \param theShape a shape of the selection
72   virtual void getGeomSelection(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs,
73                                 ObjectPtr& theObject,
74                                 GeomShapePtr& theShape);
75
76   /// Creates a backup of the current values of the attribute
77   /// It should be realized in the specific widget because of different
78   /// parameters of the current attribute
79   /// \param theAttribute an attribute
80   /// \param theValid a boolean flag, if restore happens for valid parameters
81   void restoreAttributeValue(const AttributePtr& theAttribute, const bool theValid);
82
83 protected:
84   /// A reference to external objects manager
85   PartSet_ExternalObjectsMgr* myExternalObjectMgr;
86
87   /// Pointer to a sketch
88   CompositeFeaturePtr mySketch;
89
90   bool myUseSketchPlane; ///< state whether the sketch plane filter should be switched on
91 };
92
93 #endif