Salome HOME
Set font of the Root Label the same as in Tree View
[modules/shaper.git] / src / XGUI / XGUI_Workshop.cpp
old mode 100644 (file)
new mode 100755 (executable)
index 4f5e03c..25ed50f
@@ -310,6 +310,10 @@ void XGUI_Workshop::initMenu()
   aCommand->connectTo(this, SLOT(onSave()));
   //aCommand->disable();
 
+  aCommand = aGroup->addFeature("SAVEAS_CMD", tr("Save as..."), tr("Save the document into a file"),
+                                QIcon(":pictures/save.png"), QKeySequence());
+  aCommand->connectTo(this, SLOT(onSaveAs()));
+
   QString aUndoId = "UNDO_CMD";
   aCommand = aGroup->addFeature(aUndoId, tr("Undo"), tr("Undo last command"),
                                 QIcon(":pictures/undo.png"), QKeySequence::Undo);
@@ -328,13 +332,10 @@ void XGUI_Workshop::initMenu()
                  SIGNAL(updateRedoHistory(const QList<ActionInfo>&)),
                  SLOT(onRedo(int)));
 
-  aCommand = aGroup->addFeature("REBUILD_CMD", tr("Rebuild"), tr("Rebuild data objects"),
-    QIcon(":pictures/rebuild.png"), QKeySequence());
-  aCommand->connectTo(this, SLOT(onRebuild()));
+  //aCommand = aGroup->addFeature("REBUILD_CMD", tr("Rebuild"), tr("Rebuild data objects"),
+  //  QIcon(":pictures/rebuild.png"), QKeySequence());
+  //aCommand->connectTo(this, SLOT(onRebuild()));
 
-  aCommand = aGroup->addFeature("SAVEAS_CMD", tr("Save as..."), tr("Save the document into a file"),
-                                QIcon(":pictures/save.png"), QKeySequence());
-  aCommand->connectTo(this, SLOT(onSaveAs()));
   //aCommand->disable();
 
   aCommand = aGroup->addFeature("OPEN_CMD", tr("Open..."), tr("Open a new document"),
@@ -460,7 +461,8 @@ void XGUI_Workshop::onOperationStarted(ModuleBase_Operation* theOperation)
   }
   updateCommandStatus();
 
-  myModule->onOperationStarted(aFOperation);
+  connectToPropertyPanel(true);
+  myModule->operationStarted(aFOperation);
 
   // the objects of the current operation should be deactivated
   QObjectPtrList anObjects;
@@ -485,10 +487,11 @@ void XGUI_Workshop::onOperationResumed(ModuleBase_Operation* theOperation)
 
   if (theOperation->getDescription()->hasXmlRepresentation()) {  //!< No need for property panel
     setPropertyPanel(theOperation);
+    connectToPropertyPanel(true);
   }
   updateCommandStatus();
 
-  myModule->onOperationResumed(theOperation);
+  myModule->operationResumed(theOperation);
 }
 
 
@@ -508,7 +511,8 @@ void XGUI_Workshop::onOperationStopped(ModuleBase_Operation* theOperation)
   hidePropertyPanel();
   myPropertyPanel->cleanContent();
 
-  myModule->onOperationStopped(aFOperation);
+  connectToPropertyPanel(false);
+  myModule->operationStopped(aFOperation);
 
   // the deactivated objects of the current operation should be activated back.
   // They were deactivated on operation start or an object redisplay
@@ -534,12 +538,12 @@ void XGUI_Workshop::onOperationStopped(ModuleBase_Operation* theOperation)
 
 void XGUI_Workshop::onOperationCommitted(ModuleBase_Operation* theOperation)
 {
-  myModule->onOperationCommitted(theOperation);
+  myModule->operationCommitted(theOperation);
 }
 
 void XGUI_Workshop::onOperationAborted(ModuleBase_Operation* theOperation)
 {
-  myModule->onOperationAborted(theOperation);
+  myModule->operationAborted(theOperation);
 }
 
 void XGUI_Workshop::setGrantedFeatures(ModuleBase_Operation* theOperation)
@@ -607,6 +611,23 @@ void XGUI_Workshop::setPropertyPanel(ModuleBase_Operation* theOperation)
   myErrorMgr->setPropertyPanel(myPropertyPanel);
 }
 
+void XGUI_Workshop::connectToPropertyPanel(const bool isToConnect)
+{
+  XGUI_PropertyPanel* aPropertyPanel = propertyPanel();
+  if (aPropertyPanel) {
+    const QList<ModuleBase_ModelWidget*>& aWidgets = aPropertyPanel->modelWidgets();
+    foreach (ModuleBase_ModelWidget* aWidget, aWidgets) {
+       myModule->connectToPropertyPanel(aWidget, isToConnect);
+      if (isToConnect) {
+        connect(aWidget, SIGNAL(valueStateChanged(int)), this, SLOT(onWidgetStateChanged(int)));
+      }
+      else {
+        disconnect(aWidget, SIGNAL(valueStateChanged(int)), this, SLOT(onWidgetStateChanged(int)));
+      }
+    }
+  }
+}
+
 /*
  * Saves document with given name.
  */
@@ -843,6 +864,21 @@ void XGUI_Workshop::onRebuild()
 }
 
 //******************************************************
+void XGUI_Workshop::onWidgetStateChanged(int thePreviousState)
+{
+  ModuleBase_ModelWidget* anActiveWidget = 0;
+  ModuleBase_Operation* anOperation = myOperationMgr->currentOperation();
+  if (anOperation) {
+    ModuleBase_IPropertyPanel* aPanel = anOperation->propertyPanel();
+    if (aPanel)
+      anActiveWidget = aPanel->activeWidget();
+  }
+  if (anActiveWidget)
+    operationMgr()->onValidateOperation();
+
+  myModule->widgetStateChanged(thePreviousState);
+}
+
 ModuleBase_IModule* XGUI_Workshop::loadModule(const QString& theModule)
 {
   QString libName = QString::fromStdString(library(theModule.toStdString()));
@@ -1010,8 +1046,6 @@ void XGUI_Workshop::createDockWidgets()
 
   QAction* aCancelAct = myActionsMgr->operationStateAction(XGUI_ActionsMgr::Abort);
   connect(aCancelAct, SIGNAL(triggered()), myOperationMgr, SLOT(onAbortOperation()));
-  connect(myPropertyPanel, SIGNAL(noMoreWidgets(const std::string&)),
-          myModule, SLOT(onNoMoreWidgets(const std::string&)));
   connect(myPropertyPanel, SIGNAL(keyReleased(QKeyEvent*)),
           myOperationMgr,  SLOT(onKeyReleased(QKeyEvent*)));
   //connect(myOperationMgr,  SIGNAL(validationStateChanged(bool)),