1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: PartSet_WidgetSketchCreator.h
4 // Created: 08 June 2015
5 // Author: Vitaly SMETANNIKOV
7 #ifndef PartSet_WidgetSketchCreator_H
8 #define PartSet_WidgetSketchCreator_H
12 #include <ModuleBase_WidgetSelector.h>
18 class ModuleBase_Operation;
19 class ModuleBase_IWorkshop;
20 class PartSet_PreviewPlanes;
24 * A widget which allow creation of a sketch in another operation.
25 * It creates sketch on aqctivation of this widget. If sketch object is already created then
26 * it will transfer a focus to next widget. It is supposed that the widget will be placed as
27 * a first widget in property panel
29 class PARTSET_EXPORT PartSet_WidgetSketchCreator : public ModuleBase_WidgetSelector
35 /// \param theParent the parent object
36 /// \param theModule a reference to a module object
37 /// \param theData the widget configuation. The attribute of the model widget is obtained from
38 PartSet_WidgetSketchCreator(QWidget* theParent, PartSet_Module* theModule,
39 const Config_WidgetAPI* theData);
41 virtual ~PartSet_WidgetSketchCreator();
43 /// Returns list of widget controls
44 /// \return a control list
45 virtual QList<QWidget*> getControls() const;
47 /// Set focus to the first control of the current widget. The focus policy of the control is checked.
48 /// If the widget has the NonFocus focus policy, it is skipped.
49 /// \return the state whether the widget can accept the focus
50 virtual bool focusTo();
52 /// The methiod called when widget is deactivated
53 virtual void deactivate();
55 /// Set the given wrapped value to the current widget
56 /// This value should be processed in the widget according to the needs
57 /// \param theValues the wrapped selection values
58 /// \param theToValidate a validation of the values flag
59 virtual bool setSelection(QList<ModuleBase_ViewerPrs>& theValues,
60 const bool theToValidate);
62 /// Editing mode depends on mode of current operation. This value is defined by it.
63 virtual void setEditingMode(bool isEditing);
65 /// Check if the current and the parent operations are a composite. If the parent operation contains
66 /// attribute selection list, the method returns false if it is invalid in this attibute validator
67 /// \param theWorkshop a current workshop
68 /// \return boolean value
69 static bool canCommitCurrentSketch(ModuleBase_IWorkshop* theWorkshop);
72 /// Saves the internal parameters to the given feature
73 /// \return True in success
74 virtual bool storeValueCustom() const;
76 virtual bool restoreValueCustom();
78 /// Sets the selection control visible and set the current widget as active in property panel
79 /// It leads to connect to onSelectionChanged slot
80 void activateSelectionControl();
82 /// Visualization of the current control or others in PP
83 /// \param theSelectionControl state whether the control should be shown/hidden
84 void setVisibleSelectionControl(const bool theSelectionControl);
86 /// Retunrs a list of possible shape types
87 /// \return a list of shapes
88 virtual QIntList getShapeTypes() const;
90 /// Emits model changed info, updates the current control by selection change
91 /// \param theDone a state whether the selection is set
92 void updateOnSelectionChanged(const bool theDone);
95 /// Returns true if the selection mode is active. This is when composition feature has no
96 /// a sub-object and the attribute list is empty
97 /// \return boolean value
98 bool isSelectionMode() const;
101 void onResumed(ModuleBase_Operation* theOp);
104 /// Append new Sketch, set the selected plane for the sketch and start Edit operation.
105 /// \param theValues a selection list
106 /// \return true if the sketch is started
107 bool startSketchOperation(const QList<ModuleBase_ViewerPrs>& theValues);
109 /// Appends the selection to the sketch base attribute
110 /// \param theValue a selection value from the viewer
111 /// \return true if the value is set
112 bool setBaseAttributeSelection(const ModuleBase_ViewerPrs& theValue);
115 std::string myAttributeListID;
117 PartSet_Module* myModule;
119 /// Label of the widget
122 /// Input control of the widget
123 QLineEdit* myTextLine;
125 /// List of accepting shapes types
126 QStringList myShapeTypes;
128 /// class to show/hide preview planes
129 PartSet_PreviewPlanes* myPreviewPlanes;