]> SALOME platform Git repositories - modules/shaper.git/blob - src/PartSet/PartSet_WidgetSketchCreator.h
Salome HOME
f6f56f8a2b52484cf5a8154d87e03f84afd7fc55
[modules/shaper.git] / src / PartSet / PartSet_WidgetSketchCreator.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        PartSet_WidgetSketchCreator.h
4 // Created:     08 June 2015
5 // Author:      Vitaly SMETANNIKOV
6
7 #ifndef PartSet_WidgetSketchCreator_H
8 #define PartSet_WidgetSketchCreator_H
9
10 #include "PartSet.h"
11
12 #include <ModuleBase_WidgetSelector.h>
13
14 class QLabel;
15 class QLineEdit;
16 class PartSet_Module;
17 class ModuleBase_Operation;
18
19
20 /**
21 * \ingroup Modules
22 * A widget which allow creation of a sketch in another operation.
23 * It creates sketch on aqctivation of this widget. If sketch object is already created then
24 * it will transfer a focus to next widget. It is supposed that the widget will be placed as 
25 * a first widget in property panel
26 */
27 class PARTSET_EXPORT PartSet_WidgetSketchCreator : public ModuleBase_WidgetSelector
28 {
29 Q_OBJECT
30
31 public:
32   /// Constructor
33   /// \param theParent the parent object
34   /// \param theModule a reference to a module object
35   /// \param theData the widget configuation. The attribute of the model widget is obtained from
36   PartSet_WidgetSketchCreator(QWidget* theParent, PartSet_Module* theModule,
37                               const Config_WidgetAPI* theData);
38
39   virtual ~PartSet_WidgetSketchCreator();
40
41   /// Returns list of widget controls
42   /// \return a control list
43   virtual QList<QWidget*> getControls() const;
44
45   /// Set focus to the first control of the current widget. The focus policy of the control is checked.
46   /// If the widget has the NonFocus focus policy, it is skipped.
47   /// \return the state whether the widget can accept the focus
48   virtual bool focusTo();
49
50   /// The methiod called when widget is deactivated
51   virtual void deactivate();
52
53   /// Editing mode depends on mode of current operation. This value is defined by it.
54   virtual void setEditingMode(bool isEditing);
55
56 protected:
57   /// Saves the internal parameters to the given feature
58   /// \return True in success
59   virtual bool storeValueCustom() const;
60
61   virtual bool restoreValueCustom();
62
63   /// The methiod called when widget is activated
64   virtual void activateCustom();
65
66   /// Visualization of the current control or others in PP
67   /// \param theSelectionControl state whether the control should be shown/hidden
68   void setVisibleSelectionControl(const bool theSelectionControl);
69
70   /// Retunrs a list of possible shape types
71   /// \return a list of shapes
72   virtual QIntList getShapeTypes() const;
73
74   /// Store the values to the model attribute of the widget. It casts this attribute to
75   /// the specific type and set the given values
76   /// \param theSelectedObject an object
77   /// \param theShape a selected shape, which is used in the selection attribute
78   /// \return true if it is succeed
79   virtual void setObject(ObjectPtr theSelectedObject, GeomShapePtr theShape);
80
81 private:
82   /// Returns true if the selection mode is active. This is when composition feature has no
83   ///  a sub-object and the attribute list is empty
84   /// \return boolean value
85   bool isSelectionMode() const;
86
87 protected slots:
88   /// Slot which is called on selection event
89   // NDS: virtual is temporary
90   virtual void onSelectionChanged();
91
92 private slots:
93   //void onStarted();
94
95   void onResumed(ModuleBase_Operation* theOp);
96
97 private:
98   /// Append new Sketch, set the selected plane for the sketch and start Edit operation.
99   /// \param theValues a selection list
100   /// \return true if the sketch is started
101   bool startSketchOperation(const QList<ModuleBase_ViewerPrs>& theValues);
102
103 private:
104   std::string myAttributeListID;
105
106   PartSet_Module* myModule;
107
108   /// Label of the widget
109   QLabel* myLabel;
110
111   /// Input control of the widget
112   QLineEdit* myTextLine;
113
114   /// List of accepting shapes types
115   QStringList myShapeTypes;
116
117   /// To check if we need to use body for composite feature or not
118   bool myUseBody;
119
120 };
121
122 #endif