Salome HOME
Improvement for key "Delete" processing: should be done only on possible objects...
[modules/shaper.git] / src / ModuleBase / ModuleBase_IModule.cpp
index bf95e40c5fbcea20bbb919decb269b9d6e6eb447..fa0395ad9462eafc374d70d71a4ef75486ff5df9 100644 (file)
@@ -9,6 +9,9 @@
 #include "ModuleBase_OperationDescription.h"
 #include "ModuleBase_OperationFeature.h"
 #include "ModuleBase_ModelWidget.h"
+#include "ModuleBase_WidgetFactory.h"
+#include "ModuleBase_PageWidget.h"
+#include "ModuleBase_Dialog.h"
 
 #include <Events_Loop.h>
 
 #include <Config_ModuleReader.h>
 
 #include <QAction>
+#include <QMainWindow>
+#include <QDialog>
+#include <QLayout>
+#include <QDialogButtonBox>
+#include <QPushButton>
 
 ModuleBase_IModule::ModuleBase_IModule(ModuleBase_IWorkshop* theParent)
   : QObject(theParent), myWorkshop(theParent) 
@@ -41,6 +49,26 @@ ModuleBase_IModule::ModuleBase_IModule(ModuleBase_IWorkshop* theParent)
   //        SLOT(onMouseDoubleClick(QMouseEvent*)));
 }
 
+void ModuleBase_IModule::launchModal(const QString& theCmdId)
+{
+  if (!myWorkshop->canStartOperation(theCmdId))
+    return;
+
+  std::string aXmlCfg, aDescription;
+  getXMLRepresentation(theCmdId.toStdString(), aXmlCfg, aDescription);
+
+  SessionPtr aMgr = ModelAPI_Session::get();
+  aMgr->startOperation(theCmdId.toStdString());
+
+  ModuleBase_Dialog aDlg(myWorkshop, theCmdId, aXmlCfg);
+  if (aDlg.exec() == QDialog::Accepted)
+    aMgr->finishOperation();
+  else
+    aMgr->abortOperation();
+  myWorkshop->updateCommandStatus();
+}
+
+
 void ModuleBase_IModule::launchOperation(const QString& theCmdId)
 {
   if (!myWorkshop->canStartOperation(theCmdId))
@@ -71,6 +99,11 @@ Handle(AIS_InteractiveObject) ModuleBase_IModule::createPresentation(const Resul
   return Handle(AIS_InteractiveObject)();
 }
 
+bool ModuleBase_IModule::canBeShaded(Handle(AIS_InteractiveObject) theAIS) const
+{
+  return true;
+}
+
 QString ModuleBase_IModule::getFeatureError(const FeaturePtr& theFeature)
 {
   return ModelAPI_Tools::getFeatureError(theFeature).c_str();
@@ -171,8 +204,14 @@ void ModuleBase_IModule::onFeatureTriggered()
     }
   }
   else {
-    launchOperation(aCmd->data().toString());
-    emit operationLaunched();
+    QString aCmdId = aCmd->data().toString();
+    std::shared_ptr<Config_FeatureMessage> aInfo = myWorkshop->featureInfo(aCmdId);
+    if (aInfo.get() && aInfo->isModal()) {
+      launchModal(aCmdId);
+    } else {
+      launchOperation(aCmdId);
+      emit operationLaunched();
+    }
   }
 }