1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
4 * ModuleBase_OperationFeature.h
6 * Created on: Apr 2, 2014
10 #ifndef ModuleBase_OperationFeature_H
11 #define ModuleBase_OperationFeature_H
13 #include <ModuleBase.h>
14 #include <ModuleBase_Operation.h>
15 #include <ModuleBase_ViewerPrs.h>
17 #include <ModelAPI_CompositeFeature.h>
21 #include <QStringList>
23 class ModuleBase_ModelWidget;
24 class ModuleBase_ISelection;
25 class ModuleBase_IViewer;
30 * \class ModuleBase_OperationFeature
32 * \brief Base class for all operations
34 * Base class for all operations. If you perform an action it is reasonable to create
35 * operation intended for this. This is a base class for all operations which provides
36 * mechanism for correct starting operations, starting operations above already started
37 * ones, committing operations and so on. To create own operation it is reasonable to
38 * inherit it from this class and redefines virtual methods to provide own behavior
39 * Main virtual methods are
40 * - virtual bool isReadyToStart();
41 * - virtual void startOperation();
42 * - virtual void abortOperation();
43 * - virtual void commitOperation();
46 class MODULEBASE_EXPORT ModuleBase_OperationFeature : public ModuleBase_Operation
52 /// Appends to operation's history id, if it is an "edit" operation (myIsEditing == true)
53 static QString EditSuffix() { return "_E"; }
55 /// \param theId the operation identifier
56 /// \param theParent the QObject parent
57 ModuleBase_OperationFeature(const QString& theId = "", QObject* theParent = 0);
59 virtual ~ModuleBase_OperationFeature();
61 /// Returns True id the current operation is launched in editing mode
62 bool isEditOperation() const { return myIsEditing; }
64 /// Returns the operation feature
65 /// \return the feature
66 FeaturePtr feature() const;
68 /// Must return True if the operation's feature is valid.
69 /// Since IOperation does not have any feature returns false.
70 virtual bool isValid() const;
72 /// Sets the operation feature
73 void setFeature(FeaturePtr theFeature);
75 /// Returns True if the current operation works with the given object (feature or result)
76 virtual bool hasObject(ObjectPtr theObj) const;
78 /// Initialisation of operation with preliminary selection
79 /// \param theSelection an instance of Selection class
80 /// \param theViewer a viewer to have the viewer the eye position
81 virtual void initSelection(ModuleBase_ISelection* theSelection,
82 ModuleBase_IViewer* theViewer);
84 /// \brief Set property pane to the operation
85 /// \param theProp a property panel instance
86 virtual void setPropertyPanel(ModuleBase_IPropertyPanel* theProp);
88 /// \return Currently installed property panel
89 //ModuleBase_IPropertyPanel* propertyPanel() const { return myPropertyPanel; }
91 /// Activates widgets by preselection if it is accepted. Emits signal if the activation is correct
92 virtual void activateByPreselection();
94 /// If the operation works with feature which is sub-feature of another one
95 /// then this variable has to be initialised by parent feature
96 /// before operation feature creating
97 void setParentFeature(CompositeFeaturePtr theParent);
99 /// \return Installed parent feature (can be NULL)
100 CompositeFeaturePtr parentFeature() const;
103 /// The operation is filled with existing preselection
104 void activatedByPreselection();
108 /// Public slot. Verifies whether operation can be started and starts operation.
109 /// This slot is not virtual and cannot be redefined. Redefine startOperation method
110 /// to change behavior of operation. There is no point in using this method. It would
111 /// be better to inherit own operator from base one and redefine startOperation method
116 /// Public slot. Aborts operation. This slot is not virtual and cannot be redefined.
117 /// Redefine abortOperation method to change behavior of operation instead
120 /// Commits operation
121 /// Public slot. Commits operation. This slot is not virtual and cannot be redefined.
122 /// Redefine commitOperation method to change behavior of operation instead
126 /// Creates an operation new feature
127 /// \param theFlushMessage the flag whether the create message should be flushed
128 /// \returns the created feature
129 virtual FeaturePtr createFeature(const bool theFlushMessage = true);
131 /// Removes the preselection information and clears the map of preselection
132 void clearPreselection();
135 /// The operation feature to be handled
136 FeaturePtr myFeature;
138 /// Editing feature flag
141 /// List of pre-selected object
142 QList<ModuleBase_ViewerPrs> myPreSelection;
144 /// If the operation works with feature which is sub-feature of another one
145 /// then this variable has to be initialised by parent feature
146 /// before operation feature creating
147 CompositeFeaturePtr myParentFeature;
149 /// Last current feature before editing operation. It is cashed when Edit operation is started
150 /// in order to restore the document current feature on commit/abort this operation.
151 FeaturePtr myPreviousCurrentFeature;