Salome HOME
Issue #559: Control doesn't have variable if its text is empty
[modules/shaper.git] / src / ModuleBase / ModuleBase_IModule.cpp
index 0e2ce8d7f6bc7545a1c204fd6d6f2e670bdd8bcb..1f759feb5b70a88fd16ccb21f74633a50c27ca23 100644 (file)
@@ -12,6 +12,7 @@
 
 #include <ModelAPI_Events.h>
 #include <ModelAPI_CompositeFeature.h>
+#include <ModelAPI_Session.h>
 
 #include <Config_PointerMessage.h>
 #include <Config_WidgetReader.h>
@@ -74,9 +75,11 @@ ModuleBase_Operation* ModuleBase_IModule::createOperation(const std::string& the
   ModuleBase_Operation* aCurOperation = myWorkshop->currentOperation();
   if (aCurOperation) {
     FeaturePtr aFeature = aCurOperation->feature();
-    CompositeFeaturePtr aCompFea = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(aFeature);
-    if (aCompFea)
-      anOperation->setParentFeature(aCompFea);
+    CompositeFeaturePtr aCompFeature =
+        std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(aFeature);
+    if (aCompFeature) {
+      anOperation->setParentFeature(aCompFeature);
+    }
   }
 
   std::string aPluginFileName = myFeaturesInFiles[theFeatureId];
@@ -95,6 +98,7 @@ void ModuleBase_IModule::createFeatures()
 {
   registerValidators();
   registerFilters();
+  registerProperties();
 
   Config_ModuleReader aXMLReader = Config_ModuleReader();
   aXMLReader.readAll();
@@ -107,6 +111,22 @@ void ModuleBase_IModule::actionCreated(QAction* theFeature)
   connect(theFeature, SIGNAL(triggered(bool)), this, SLOT(onFeatureTriggered()));
 }
 
+bool ModuleBase_IModule::canDisplayObject(const ObjectPtr& theObject) const
+{
+  return true;
+}
+
+bool ModuleBase_IModule::canUndo() const
+{
+  SessionPtr aMgr = ModelAPI_Session::get();
+  return aMgr->hasModuleDocument() && aMgr->canUndo() && !aMgr->isOperation();
+}
+
+bool ModuleBase_IModule::canRedo() const
+{
+  SessionPtr aMgr = ModelAPI_Session::get();
+  return aMgr->hasModuleDocument() && aMgr->canRedo() && !aMgr->isOperation();
+}
 
 void ModuleBase_IModule::onFeatureTriggered()
 {
@@ -127,4 +147,4 @@ void ModuleBase_IModule::editFeature(FeaturePtr theFeature)
   ModuleBase_Operation* anOperation = createOperation(aFeatureId);
   anOperation->setFeature(theFeature);
   sendOperation(anOperation);
-}
\ No newline at end of file
+}