Salome HOME
Issue #6 Extended processing of nested actions.
[modules/shaper.git] / src / XGUI / XGUI_Workshop.cpp
index dd6e1200fc321ab3db8b5f3fd42f04f45d916ab4..60bad111dbc77e1b051e2f6df8c41965a11821cc 100644 (file)
@@ -63,6 +63,7 @@ XGUI_Workshop::XGUI_Workshop(XGUI_SalomeConnector* theConnector)
   // So, displayer will be created on demand.
 
   mySelector = new XGUI_SelectionMgr(this);
+  connect(mySelector, SIGNAL(selectionChanged()), this, SLOT(changeCurrentDocument()));
   myOperationMgr = new XGUI_OperationMgr(this);
   myActionsMgr = new XGUI_ActionsMgr(this);
   myErrorDlg = new XGUI_ErrorDialog(myMainWindow);
@@ -290,6 +291,8 @@ void XGUI_Workshop::addFeature(const Config_FeatureMessage* theMessage)
                                                 QString::fromStdString(theMessage->tooltip()),
                                                 QIcon(theMessage->icon().c_str()),
                                                 QKeySequence(), isUsePropPanel);
+    QString aNestedFeatures = QString::fromStdString(theMessage->nestedFeatures());
+    aCommand->setUnblockableCommands(aNestedFeatures.split(" "));
     myActionsMgr->addCommand(aCommand);
     myPartSetModule->featureCreated(aCommand);
   }
@@ -355,7 +358,7 @@ void XGUI_Workshop::onNew()
   QApplication::setOverrideCursor(Qt::WaitCursor);
   if (objectBrowser() == 0) {
     createDockWidgets();
-    mySelector->connectObjectBrowser(objectBrowser());
+    mySelector->connectViewers();
   }
   showObjectBrowser();
   if (!isSalomeMode()) {
@@ -690,3 +693,25 @@ XGUI_Displayer* XGUI_Workshop::displayer() const
   }
   return myDisplayer;
 }
+
+//******************************************************
+void XGUI_Workshop::changeCurrentDocument()
+{
+  QFeatureList aFeatures = objectBrowser()->selectedFeatures();
+  
+  // Set current document
+  if (aFeatures.size() > 0) {
+    FeaturePtr aFeature = aFeatures.first();
+
+    boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
+    boost::shared_ptr<ModelAPI_AttributeDocRef> aDocRef = aFeature->data()->docRef("PartDocument");
+    if (aDocRef)
+      aMgr->setCurrentDocument(aDocRef->value());
+  }
+}
+
+//******************************************************
+void XGUI_Workshop::salomeViewerSelectionChanged()
+{
+  emit salomeViewerSelection();
+}