Salome HOME
Source documentation updated. Obsolete files removed
[modules/shaper.git] / src / PartSet / PartSet_WidgetShapeSelector.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        PartSet_WidgetShapeSelector.h
4 // Created:     27 Nov 2014
5 // Author:      Vitaly Smetannikov
6
7
8 #ifndef PartSet_WidgetShapeSelector_H
9 #define PartSet_WidgetShapeSelector_H
10
11 #include "PartSet.h"
12
13 #include <ModuleBase_WidgetShapeSelector.h>
14
15 #include <ModelAPI_CompositeFeature.h>
16
17 class PartSet_ExternalObjectsMgr;
18
19 /**
20 * \ingroup Modules
21 * Customosation of ModuleBase_WidgetShapeSelector in order to provide 
22 * working with sketch specific objects and external objects.
23 */
24 class PARTSET_EXPORT PartSet_WidgetShapeSelector: public ModuleBase_WidgetShapeSelector
25 {
26 Q_OBJECT
27  public:
28   /// Constructor
29   /// \param theParent the parent object
30   /// \param theWorkshop instance of workshop interface
31   /// \param theData the widget configuation. The attribute of the model widget is obtained from
32   /// \param theParentId is Id of a parent of the current attribute
33   PartSet_WidgetShapeSelector(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop,
34     const Config_WidgetAPI* theData, const std::string& theParentId);
35
36   virtual ~PartSet_WidgetShapeSelector();
37
38   /// Set sketcher
39   /// \param theSketch a sketcher object
40   void setSketcher(CompositeFeaturePtr theSketch) { mySketch = theSketch; }
41
42   /// Retrurns installed sketcher
43   CompositeFeaturePtr sketch() const { return mySketch; }
44
45 protected:
46   /// Checks the widget validity. By default, it returns true.
47   /// \param thePrs a selected presentation in the view
48   /// \return a boolean value
49   virtual bool isValidSelectionCustom(const ModuleBase_ViewerPrs& thePrs);
50
51   /// Store the values to the model attribute of the widget. It casts this attribute to
52   /// the specific type and set the given values
53   /// \param theSelectedObject an object
54   /// \param theShape a selected shape, which is used in the selection attribute
55   /// \return true if it is succeed
56   virtual void setObject(ObjectPtr theSelectedObject, GeomShapePtr theShape);
57
58   /// Return an object and geom shape by the viewer presentation
59   /// \param thePrs a selection
60   /// \param theObject an output object
61   /// \param theShape a shape of the selection
62   virtual void getGeomSelection(const ModuleBase_ViewerPrs& thePrs,
63                                 ObjectPtr& theObject,
64                                 GeomShapePtr& theShape);
65
66   /// Get the shape from the attribute if the attribute contain a shape
67   /// It processes the ref attr type of attributes. It obtains the referenced attribute,
68   /// results of the attribute feature. And it founds a vertes in the owners of the results
69   /// If the vertex is found, it creates a geom shape on it.
70   /// \return a shape
71   virtual GeomShapePtr getShape() const;
72
73   /// Creates a backup of the current values of the attribute
74   /// It should be realized in the specific widget because of different
75   /// parameters of the current attribute
76   /// \param theValid a boolean flag, if restore happens for valid parameters
77   void restoreAttributeValue(const bool theValid);
78
79   /// Found the sketch point attribute by the shape and set it in the feature attribute
80   /// otherwise set the selected object
81   /// \param theSelectedObject an object
82   /// \param theShape a selected shape, which is used in the selection attribute
83   void setPointAttribute(ObjectPtr theSelectedObject, GeomShapePtr theShape);
84
85 protected:
86   /// A reference to external objects manager
87   PartSet_ExternalObjectsMgr* myExternalObjectMgr;
88
89   /// Pointer to a sketch 
90   CompositeFeaturePtr mySketch;
91 };
92
93 #endif