Salome HOME
Provide hasPreview method for operations with preview
[modules/shaper.git] / src / ModuleBase / ModuleBase_Operation.h
index 89b369995926046420fbd3256b035f732b1623c0..17be4cba4286a6e6e63ea45c6ed6e3ec622c681a 100644 (file)
@@ -5,20 +5,23 @@
  *      Author: sbh
  */
 
-
 #ifndef ModuleBase_Operation_H
 #define ModuleBase_Operation_H
 
 #include <ModuleBase.h>
 #include <ModuleBase_IOperation.h>
 
+#include <ModelAPI_Feature.h>
+
 #include <QObject>
 #include <QString>
 
 #include <boost/shared_ptr.hpp>
 
-class ModelAPI_Feature;
 class ModelAPI_Document;
+class ModuleBase_ModelWidget;
+
+class QKeyEvent;
 
 /*!
  \class ModuleBase_Operation
@@ -36,11 +39,11 @@ class ModelAPI_Document;
  *  - 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
@@ -52,7 +55,10 @@ public:
   QString id() const;
   /// Returns the operation feature
   /// \return the feature
-  boost::shared_ptr<ModelAPI_Feature> feature() const;
+  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.
@@ -60,13 +66,34 @@ public:
   virtual bool isNestedOperationsEnabled() const;
 
   // Data model methods.
-  /// Stores a real value in model.
-  /// \param theValue - to store
-  void storeReal(double theValue);
   /// Stores a custom value in model.
   void storeCustomValue();
 
-protected:
+  /// Sets the operation feature
+  void setEditingFeature(FeaturePtr theFeature);
+
+  /// 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:
+  /// Slots which listen the mode widget activation
+  /// \param theWidget the model widget
+  virtual void onWidgetActivated(ModuleBase_ModelWidget* theWidget);
+
+signals:
+  /// Signals about the activating of the next widget
+  /// \param theWidget the previous active widget
+  void activateNextWidget(ModuleBase_ModelWidget* theWidget);
+
+ protected:
   /// Virtual method called when operation started (see start() method for more description)
   /// Default impl calls corresponding slot and commits immediately.
   virtual void startOperation();
@@ -76,6 +103,8 @@ protected:
   virtual void abortOperation();
   /// Virtual method called when operation committed (see commit() method for more description)
   virtual void commitOperation();
+  /// Virtual method called after operation committed (see commit() method for more description)
+  virtual void afterCommitOperation();
 
   /// Send update message by loop
   void flushUpdated();
@@ -85,14 +114,18 @@ protected:
   /// Creates an operation new feature
   /// \param theFlushMessage the flag whether the create message should be flushed
   /// \returns the created feature
-  virtual boost::shared_ptr<ModelAPI_Feature> createFeature(const bool theFlushMessage = true);
+  virtual FeaturePtr createFeature(const bool theFlushMessage = true);
 
-  /// Returns the operation feature
-  /// \return the feature
-  void setFeature(boost::shared_ptr<ModelAPI_Feature> theFeature);
+ protected:
+  /// Sets the operation feature
+  void setFeature(FeaturePtr theFeature);
+
+  /// 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;
 
-private:
-  boost::shared_ptr<ModelAPI_Feature> myFeature; /// the operation feature to be handled
+ protected:
+  FeaturePtr myFeature;  /// the operation feature to be handled
 };
 
 #endif