Salome HOME
Provide hasPreview method for operations with preview
[modules/shaper.git] / src / ModuleBase / ModuleBase_Operation.h
index a40d774e4e1d7ab4db1859ea5f95c7ff9a4e870e..17be4cba4286a6e6e63ea45c6ed6e3ec622c681a 100644 (file)
@@ -5,14 +5,13 @@
  *      Author: sbh
  */
 
-
 #ifndef ModuleBase_Operation_H
 #define ModuleBase_Operation_H
 
 #include <ModuleBase.h>
 #include <ModuleBase_IOperation.h>
 
-#include "ModelAPI_Feature.h"
+#include <ModelAPI_Feature.h>
 
 #include <QObject>
 #include <QString>
@@ -40,11 +39,11 @@ class QKeyEvent;
  *  - virtual void      commitOperation();
  */
 
-class MODULEBASE_EXPORT ModuleBase_Operation: public ModuleBase_IOperation
+class MODULEBASE_EXPORT ModuleBase_Operation : public ModuleBase_IOperation
 {
 Q_OBJECT
 
-public:
+ public:
   /// Constructor
   /// \param theId the operation identifier
   /// \param theParent the QObject parent
@@ -58,6 +57,9 @@ public:
   /// \return the feature
   FeaturePtr feature() const;
 
+  /// Returns true is feature of operation is valid.
+  virtual bool isValid() const;
+
   /// Returns whether the nested operations are enabled.
   /// The state can depend on the operation current state.
   /// \return enabled state
@@ -67,14 +69,21 @@ public:
   /// Stores a custom value in model.
   void storeCustomValue();
 
-  virtual void keyReleased(std::string theName, QKeyEvent* theEvent) {};
-
   /// Sets the operation feature
   void setEditingFeature(FeaturePtr theFeature);
 
-  bool isEditOperation() const { return myIsEditing; }
+  /// Returns True if the current operation works with the given object (feature or result)
+  virtual bool hasObject(ObjectPtr theObj) const;
+
+  virtual void keyReleased(const int theKey) {};
+
+  virtual void activateNextToCurrentWidget() {};
+
+  /// If operation needs to redisplay its result during operation
+  /// then this method has to return True
+  virtual bool hasPreview() const { return false; }
 
-public slots:
+ public slots:
   /// Slots which listen the mode widget activation
   /// \param theWidget the model widget
   virtual void onWidgetActivated(ModuleBase_ModelWidget* theWidget);
@@ -84,7 +93,7 @@ signals:
   /// \param theWidget the previous active widget
   void activateNextWidget(ModuleBase_ModelWidget* theWidget);
 
-protected:
+ protected:
   /// Virtual method called when operation started (see start() method for more description)
   /// Default impl calls corresponding slot and commits immediately.
   virtual void startOperation();
@@ -107,14 +116,16 @@ protected:
   /// \returns the created feature
   virtual FeaturePtr createFeature(const bool theFlushMessage = true);
 
-private:
+ protected:
   /// Sets the operation feature
   void setFeature(FeaturePtr theFeature);
 
-private:
-  FeaturePtr myFeature; /// the operation feature to be handled
+  /// Verifies whether this operator can be commited.
+  /// \return Returns TRUE if current operation can be committed, e.g. all parameters are filled
+  virtual bool canBeCommitted() const;
 
-  bool myIsEditing;
+ protected:
+  FeaturePtr myFeature;  /// the operation feature to be handled
 };
 
 #endif