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