]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #1383 Preview button: using Config_FeatureMessage instead of list of parameters...
authornds <nds@opencascade.com>
Tue, 12 Apr 2016 11:47:16 +0000 (14:47 +0300)
committernds <nds@opencascade.com>
Tue, 12 Apr 2016 11:47:16 +0000 (14:47 +0300)
src/SHAPERGUI/SHAPERGUI.cpp
src/SHAPERGUI/SHAPERGUI.h
src/XGUI/XGUI_ActionsMgr.cpp
src/XGUI/XGUI_SalomeConnector.h
src/XGUI/XGUI_Workshop.cpp
src/XGUI/XGUI_WorkshopListener.cpp

index 587069d6c8c34d1457058940faa1ad2350dfe7c5..ef44ec327d7d42b5ee8ccc38b71e84e78493bbd7 100644 (file)
@@ -543,33 +543,15 @@ QAction* SHAPERGUI::command(const QString& theId) const
   return 0;
 }
 
-//******************************************************
-void SHAPERGUI::setNestedActions(const QString& theId, const QStringList& theActions)
-{
-  myNestedActions[theId] = theActions;
-}
-
-//******************************************************
-QStringList SHAPERGUI::nestedActions(const QString& theId) const
-{
-  if (myNestedActions.contains(theId))
-    return myNestedActions[theId];
-  return QStringList();
-}
-
-//******************************************************
-void SHAPERGUI::setDocumentKind(const QString& theId, const QString& theKind)
+void SHAPERGUI::setFeatureInfo(const QString& theFeatureId,
+                               const std::shared_ptr<Config_FeatureMessage>& theMessage)
 {
-  myDocumentType[theId] = theKind;
+  myFeaturesInfo.insert(theFeatureId, theMessage);
 }
 
-//******************************************************
-QString SHAPERGUI::documentKind(const QString& theId) const
+const std::shared_ptr<Config_FeatureMessage>& SHAPERGUI::featureInfo(const QString& theFeatureId)
 {
-  if (myDocumentType.contains(theId))
-    return myDocumentType[theId];
-  return QString();
-
+  return myFeaturesInfo.contains(theFeatureId) ? myFeaturesInfo[theFeatureId] : NULL;
 }
 
 //******************************************************
index 7efea881ab2608e69e9b22d510a69e9fe383dd84..ed007ff9102ed83eba791c91134496a030db074e 100644 (file)
@@ -92,21 +92,16 @@ Q_OBJECT
 
   virtual QAction* command(const QString& theId) const;
 
-  //! Set nested actions dependent on command Id
-  //! \param theId - the command ID
-  //! \param theActions - the list of nested actions
-  virtual void setNestedActions(const QString& theId, const QStringList& theActions);
+    //! Stores XML information for the feature kind
+  //! \param theFeatureId a feature kind
+  //! \param theMessage a container of the feature XML properties
+  virtual void setFeatureInfo(const QString& theFeatureId,
+                              const std::shared_ptr<Config_FeatureMessage>& theMessage);
 
-  //! Returns list of nested actions according to the given command ID
-  virtual QStringList nestedActions(const QString& theId) const;
-
-  //! Set the document kind of the action by the given command Id
-  //! \param theId - the command ID
-  //! \param theKind - the document kind
-  virtual void setDocumentKind(const QString& theId, const QString& theKind);
-
-  //! Returns the document kind of the action by the given command ID
-  virtual QString documentKind(const QString& theId) const;
+  //! Returns XML information for the feature kind
+  //! \param theFeatureId a feature kind
+  //! \return theMessage a container of the feature XML properties
+  virtual const std::shared_ptr<Config_FeatureMessage>& featureInfo(const QString& theFeatureId);
 
   //! Returns interface to Salome viewer
   virtual ModuleBase_IViewer* viewer() const
@@ -197,11 +192,8 @@ Q_OBJECT
   /// Proxy viewer for connection to OCC Viewer in SALOME
   SHAPERGUI_SalomeViewer* myProxyViewer;
 
-  /// Map of nested actions [ActionID: list of nested actions Id]
-  QMap<QString, QStringList> myNestedActions;
-
-  /// Map of document types
-  QMap<QString, QString> myDocumentType;
+  /// Map of feature kind to a container of XML properties for the feature
+  QMap<QString, std::shared_ptr<Config_FeatureMessage> > myFeaturesInfo;
 
   /// Flag of opened document state
   bool myIsOpened;
index f5e19cc92b8cd2a3b8036e772c6c812413b5185e..8491751974072acaed09bd543d3c15496297d9a2 100644 (file)
@@ -61,7 +61,11 @@ void XGUI_ActionsMgr::addCommand(QAction* theCmd)
   myActions.insert(aId, theCmd);
 #ifdef HAVE_SALOME
     XGUI_Workshop* aWorkshop = static_cast<XGUI_Workshop*>(parent());
-    myNestedActions[aId] = aWorkshop->salomeConnector()->nestedActions(aId);
+    const std::shared_ptr<Config_FeatureMessage>& anInfo =
+                         aWorkshop->salomeConnector()->featureInfo(aId);
+    if (anInfo.get())
+      myNestedActions[aId] = QString::fromStdString(anInfo->nestedFeatures())
+                                   .split(" ", QString::SkipEmptyParts);
 #else
   AppElements_Command* aXCmd = dynamic_cast<AppElements_Command*>(theCmd);
   myNestedActions[aId] = aXCmd->nestedCommands();
@@ -363,7 +367,8 @@ void XGUI_ActionsMgr::updateByDocumentKind()
 #ifdef HAVE_SALOME
     QString aId = eachAction->data().toString();
     if (!aId.isEmpty()) {
-      aCmdDocKind = aWorkshop->salomeConnector()->documentKind(aId);
+      aCmdDocKind = QString::fromStdString(
+                 aWorkshop->salomeConnector()->featureInfo(aId)->documentKind());
     }
 #else
     AppElements_Command* aCmd = dynamic_cast<AppElements_Command*>(eachAction);
index ac2c60f40f8b8c06d2656cc97b70a01fa6d02773..3000b8350d0665d02fc3c50c658726726c7cd0a3 100644 (file)
@@ -11,6 +11,7 @@
 #include <ModuleBase_ActionInfo.h>
 
 class QMainWindow;
+class Config_FeatureMessage;
 class ModuleBase_IViewer;
 
 /**
@@ -99,21 +100,16 @@ class XGUI_EXPORT XGUI_SalomeConnector
   //! Returns list of Ids of defined actions (just by NewGeom module)
   virtual QStringList commandIdList() const = 0;
 
-  //! Set nested actions dependent on command Id
-  //! \param theId - the command ID
-  //! \param theActions - the list of nested actions
-  virtual void setNestedActions(const QString& theId, const QStringList& theActions) = 0;
+  //! Stores XML information for the feature kind
+  //! \param theFeatureId a feature kind
+  //! \param theMessage a container of the feature XML properties
+  virtual void setFeatureInfo(const QString& theFeatureId,
+                              const std::shared_ptr<Config_FeatureMessage>& theMessage) = 0;
 
-  //! Returns list of nested actions according to the given command ID
-  virtual QStringList nestedActions(const QString& theId) const = 0;
-
-  //! Set the document kind of the action by the given command Id
-  //! \param theId - the command ID
-  //! \param theKind - the document kind
-  virtual void setDocumentKind(const QString& theId, const QString& theKind) = 0;
-
-  //! Returns the document kind of the action by the given command ID
-  virtual QString documentKind(const QString& theId) const = 0;
+  //! Returns XML information for the feature kind
+  //! \param theFeatureId a feature kind
+  //! \return theMessage a container of the feature XML properties
+  virtual const std::shared_ptr<Config_FeatureMessage>& featureInfo(const QString& theFeatureId) = 0;
 
   //! Returns interface to Salome viewer
   virtual ModuleBase_IViewer* viewer() const = 0;
index 82fd1bcf4848a2b5ffc850b02b770fdfa94e73a8..e7d8483fb5cdea7ed291aed4a822665b1deaba3f 100755 (executable)
@@ -485,7 +485,7 @@ void XGUI_Workshop::setPropertyPanel(ModuleBase_Operation* theOperation)
 
   // update visible state of Preview button
 #ifdef HAVE_SALOME
-  bool anIsAutoPreview = true;//mySalomeConnector->featureInfo(aFeatureKind)->isAutoPreview();
+  bool anIsAutoPreview = mySalomeConnector->featureInfo(aFeatureKind.c_str())->isAutoPreview();
 #else
   AppElements_MainMenu* aMenuBar = mainWindow()->menuObject();
   AppElements_Command* aCommand = aMenuBar->feature(aFeatureKind.c_str());
@@ -612,8 +612,13 @@ void XGUI_Workshop::setGrantedFeatures(ModuleBase_Operation* theOperation)
     return;
 
   QStringList aGrantedIds;
-  if (isSalomeMode())
-    aGrantedIds = mySalomeConnector->nestedActions(theOperation->id());
+  if (isSalomeMode()) {
+    const std::shared_ptr<Config_FeatureMessage>& anInfo =
+                         mySalomeConnector->featureInfo(theOperation->id());
+    if (anInfo.get())
+      aGrantedIds = QString::fromStdString(anInfo->nestedFeatures())
+                                   .split(" ", QString::SkipEmptyParts);
+  }
   else
     aGrantedIds = myActionsMgr->nestedCommands(theOperation->id());
 
index 51b2d7405614e8119bdfed95450d720263346853..ff6e7379237f654684276d117f700138130889b1 100755 (executable)
@@ -483,7 +483,6 @@ void XGUI_WorkshopListener::addFeature(const std::shared_ptr<Config_FeatureMessa
   QString aWchName = QString::fromStdString(theMessage->workbenchId());
   QStringList aNestedFeatures =
       QString::fromStdString(theMessage->nestedFeatures()).split(" ", QString::SkipEmptyParts);
-  QString aDocKind = QString::fromStdString(theMessage->documentKind());
   QList<QAction*> aNestedActList;
   bool isColumnButton = !aNestedFeatures.isEmpty();
   if (isColumnButton) {
@@ -512,8 +511,7 @@ void XGUI_WorkshopListener::addFeature(const std::shared_ptr<Config_FeatureMessa
     aFeatureInfo.toolTip = aFeatureInfo.text;
     aAction = aSalomeConnector->addFeature(aWchName, aFeatureInfo);
   }
-  aSalomeConnector->setNestedActions(aFeatureInfo.id, aNestedFeatures);
-  aSalomeConnector->setDocumentKind(aFeatureInfo.id, aDocKind);
+  aSalomeConnector->setFeatureInfo(aFeatureInfo.id, theMessage);
 
   aWorkshop->actionsMgr()->addCommand(aAction);
   aWorkshop->module()->actionCreated(aAction);