]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #21: set title of property panel from xml description
authorsbh <sergey.belash@opencascade.com>
Fri, 18 Apr 2014 15:04:44 +0000 (19:04 +0400)
committersbh <sergey.belash@opencascade.com>
Fri, 18 Apr 2014 15:04:44 +0000 (19:04 +0400)
12 files changed:
src/Config/Config_WidgetReader.cpp
src/Config/Config_WidgetReader.h
src/ModuleBase/CMakeLists.txt
src/ModuleBase/ModuleBase_PropPanelOperation.cpp [new file with mode: 0644]
src/ModuleBase/ModuleBase_PropPanelOperation.h [new file with mode: 0644]
src/PartSet/PartSet_Module.cpp
src/XGUI/XGUI_MainWindow.cpp
src/XGUI/XGUI_MainWindow.h
src/XGUI/XGUI_WidgetFactory.cpp
src/XGUI/XGUI_WidgetFactory.h
src/XGUI/XGUI_Workshop.cpp
src/XGUI/XGUI_Workshop.h

index d78539982efcad4919069ff6cd211e6c04cbd390..8f47a62007bf55be12b8fd4039af25843a183480 100644 (file)
@@ -29,11 +29,16 @@ Config_WidgetReader::~Config_WidgetReader()
 {
 }
 
-std::string Config_WidgetReader::featureWidgetCfg(std::string theFeatureName)
+std::string Config_WidgetReader::featureWidgetCfg(const std::string& theFeatureName)
 {
   return myWidgetCache[theFeatureName];
 }
 
+std::string Config_WidgetReader::featureDescription(const std::string& theFeatureName)
+{
+  return myDescriptionCache[theFeatureName];
+}
+
 void Config_WidgetReader::processNode(xmlNodePtr theNode)
 {
   if (isNode(theNode, NODE_FEATURE, NULL)) {
@@ -45,6 +50,7 @@ void Config_WidgetReader::processNode(xmlNodePtr theNode)
       result = std::string((char*) buffer->content);
     }
     myWidgetCache[aNodeName] = result;
+    myDescriptionCache[aNodeName] = getProperty(theNode, FEATURE_TEXT);
   }
 }
 
index 7b5aa86f4908e97aa352db1eebfd5ce62c91a978..ae76cc996254fa681044ffd1e6578fa6c766d606 100644 (file)
@@ -21,7 +21,8 @@ public:
   CONFIG_EXPORT Config_WidgetReader(const std::string& theXmlFile);
   CONFIG_EXPORT virtual ~Config_WidgetReader();
 
-  CONFIG_EXPORT std::string featureWidgetCfg(std::string theFeatureName);
+  CONFIG_EXPORT std::string featureWidgetCfg(const std::string& theFeatureName);
+  CONFIG_EXPORT std::string featureDescription(const std::string& theFeatureName);
 
 protected:
   void processNode(xmlNodePtr theNode);
@@ -29,6 +30,7 @@ protected:
 
 private:
   std::map<std::string, std::string> myWidgetCache;
+  std::map<std::string, std::string> myDescriptionCache;
 
 };
 
index efd8db9c13e77cf4357a430c2753ebf1cd4d9643..fcd731c9e1db4f896a4756d0e23a356e17071d6d 100644 (file)
@@ -4,10 +4,12 @@ SET(CMAKE_AUTOMOC ON)
 SET(PROJECT_HEADERS
     ModuleBase.h
        ModuleBase_Operation.h
+       ModuleBase_PropPanelOperation.h
 )
 
 SET(PROJECT_SOURCES
        ModuleBase_Operation.cpp
+       ModuleBase_PropPanelOperation.cpp
 )
 
 SET(PROJECT_LIBRARIES
diff --git a/src/ModuleBase/ModuleBase_PropPanelOperation.cpp b/src/ModuleBase/ModuleBase_PropPanelOperation.cpp
new file mode 100644 (file)
index 0000000..a35aaf7
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * ModuleBase_PropPanelOperation.cpp
+ *
+ *  Created on: Apr 2, 2014
+ *      Author: sbh
+ */
+
+#include <ModuleBase_PropPanelOperation.h>
+#include <QString>
+
+/*!
+ \brief Constructor
+ \param XGUI_Workshop - workshop for this operation
+
+ Constructs an empty operation. Constructor should work very fast because many
+ operators may be created after starting workshop but only several from them
+ may be used. As result this constructor stores given workshop in myApp field
+ and set Waiting status.
+ */
+ModuleBase_PropPanelOperation::ModuleBase_PropPanelOperation(const QString& theId, QObject* parent)
+: ModuleBase_Operation(theId, parent)
+{
+}
+
+/*!
+ * \brief Destructor
+ */
+ModuleBase_PropPanelOperation::~ModuleBase_PropPanelOperation()
+{
+
+}
+
diff --git a/src/ModuleBase/ModuleBase_PropPanelOperation.h b/src/ModuleBase/ModuleBase_PropPanelOperation.h
new file mode 100644 (file)
index 0000000..c6dc068
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * ModuleBase_PropPanelOperation.h
+ *
+ *  Created on: Apr 2, 2014
+ *      Author: sbh
+ */
+
+#ifndef MODULEBASE_PROPPANELOPERATION_H
+#define MODULEBASE_PROPPANELOPERATION_H
+
+#include <ModuleBase.h>
+#include <ModuleBase_Operation.h>
+
+#include <QObject>
+#include <QString>
+
+#include <memory>
+
+/*!
+ * \class ModuleBase_PropPanelOperation
+ *
+ */
+class MODULEBASE_EXPORT ModuleBase_PropPanelOperation: public ModuleBase_Operation
+{
+
+  Q_OBJECT
+
+public:
+  ModuleBase_PropPanelOperation(const QString& theId = "", QObject* parent = 0);
+  virtual ~ModuleBase_PropPanelOperation();
+
+  /*!
+   *  \brief Returns XML representation of the operation's widget.
+   *  \return XML QString
+   *
+   *  Returns XML representation of the operation's widget.
+   */
+  const QString& xmlRepresentation() const
+  {
+    return myXmlRepr;
+  }
+
+  /*!
+   *  \brief Sets XML representation of the operation's widget.
+   *  \param xmlRepr - XML QString
+   *
+   *  Sets XML representation of the operation's widget.
+   */
+  void setXmlRepresentation(const QString& xmlRepr)
+  {
+    this->myXmlRepr = xmlRepr;
+  }
+
+
+  /*
+   *  Returns a short description of operation (will be
+   *  inserted in title of property panel)
+   */
+  const QString& description() const
+  {
+    return myDescription;
+  }
+
+  /*
+   *  Sets a short description of operation (will be
+   *  inserted in title of property panel)
+   */
+  void setDescription(const QString& theDescription)
+  {
+    this->myDescription = theDescription;
+  }
+
+private:
+  //!< Next fields could be extracted into a subclass;
+  QString myXmlRepr;
+  QString myDescription;
+};
+
+#endif //MODULEBASE_PROPPANELOPERATION_H
index 3a24568f49a2bd9d81e75632b0a6d2bd93364cff..fb437c5ba52b712363473543f534ef9691f0c6e8 100644 (file)
@@ -1,5 +1,5 @@
 #include <PartSet_Module.h>
-#include <ModuleBase_Operation.h>
+#include <ModuleBase_PropPanelOperation.h>
 
 #include <Config_PointerMessage.h>
 #include <Config_ModuleReader.h>
@@ -55,11 +55,13 @@ void PartSet_Module::onFeatureTriggered()
   XGUI_Command* aCmd = dynamic_cast<XGUI_Command*>(sender());
   QString aCmdId = aCmd->id();
   std::string aXmlCfg = aWdgReader.featureWidgetCfg(aCmdId.toStdString());
+  std::string aDescription = aWdgReader.featureDescription(aCmdId.toStdString());
   //TODO(sbh): Implement static method to extract event id [SEID]
   static Event_ID aModuleEvent = Event_Loop::eventByName("PartSetModuleEvent");
   Config_PointerMessage aMessage(aModuleEvent, this);
-  ModuleBase_Operation* aPartSetOp = new ModuleBase_Operation(aCmdId, this);
+  ModuleBase_PropPanelOperation* aPartSetOp = new ModuleBase_PropPanelOperation(aCmdId, this);
   aPartSetOp->setXmlRepresentation(QString::fromStdString(aXmlCfg));
+  aPartSetOp->setDescription(QString::fromStdString(aDescription));
   aMessage.setPointer(aPartSetOp);
   Event_Loop::loop()->send(aMessage);
 }
index b648d59ce0de4b00085db06e540ff1dd70c59b2c..fdaaf16f0e00e6524f6c4c581b35cda2f2d6666e 100644 (file)
@@ -121,11 +121,17 @@ void XGUI_MainWindow::createDockWidgets()
   tabifyDockWidget(aObjDock, myPropertyPanelDock);
 }
 
+void XGUI_MainWindow::setPropertyPannelTitle(const QString& theTitle)
+{
+  myPropertyPanelDock->setWindowTitle(theTitle);
+}
+
 
 QDockWidget* XGUI_MainWindow::createPropertyPanel()
 {
   QDockWidget* aPropPanel = new QDockWidget(this);
   aPropPanel->setWindowTitle(tr("Property Panel"));
+  QAction* aViewAct = aPropPanel->toggleViewAction();
   aPropPanel->setObjectName(XGUI::PROP_PANEL);
 
   QWidget* aContent = new QWidget(aPropPanel);
index 186b3b87d6f60728651eea3f382dee0dd281b1ab..2a71a876a00327a14758f54812ef941a43be002f 100644 (file)
@@ -46,6 +46,7 @@ public:
 
   // Creates Dock widgets: Object broewser and Property panel
   void createDockWidgets();
+  void setPropertyPannelTitle(const QString& theTitle);
 
 public slots:
   void showPythonConsole();
index 4c5223324299d594dadbdb04c2662354821898db..929f71771e761a342d9184d38cd3615eb39fc53c 100644 (file)
@@ -9,7 +9,7 @@
 
 #include <XGUI_SwitchWidget.h>
 
-#include <ModuleBase_Operation.h>
+#include <ModuleBase_PropPanelOperation.h>
 #include <Config_Keywords.h>
 #include <Config_WidgetAPI.h>
 
@@ -29,7 +29,7 @@
 #include <cfloat>
 #include <climits>
 
-XGUI_WidgetFactory::XGUI_WidgetFactory(ModuleBase_Operation* theOperation)
+XGUI_WidgetFactory::XGUI_WidgetFactory(ModuleBase_PropPanelOperation* theOperation)
     : myOperation(theOperation)
 {
   QString aXml = myOperation->xmlRepresentation();
index 27a65fa430c3ce215d6787b6ed62e35d134b45b8..ed0ba16c6ab76077bff23e23c20cfe2cdd84c4e2 100644 (file)
 
 class QWidget;
 class Config_WidgetAPI;
-class ModuleBase_Operation;
+class ModuleBase_PropPanelOperation;
 
 class XGUI_EXPORT XGUI_WidgetFactory
 {
 public:
-  XGUI_WidgetFactory(ModuleBase_Operation*);
+  XGUI_WidgetFactory(ModuleBase_PropPanelOperation*);
   virtual ~XGUI_WidgetFactory();
 
   void createWidget(QWidget* theParent);
@@ -34,7 +34,7 @@ protected:
 
 private:
   Config_WidgetAPI* myWidgetApi;
-  ModuleBase_Operation*   myOperation;
+  ModuleBase_PropPanelOperation*   myOperation;
 
 
 };
index 58d5a87c1f5fdb0a9c14a76095575fd0e6f2a00c..48e3770cebdaee086a8120b7bc0115ab57301509 100644 (file)
@@ -18,7 +18,7 @@
 #include <ModelAPI_AttributeDocRef.h>
 
 #include <Event_Loop.h>
-#include <ModuleBase_Operation.h>
+#include <ModuleBase_PropPanelOperation.h>
 #include <Config_FeatureMessage.h>
 #include <Config_PointerMessage.h>
 
@@ -147,7 +147,8 @@ void XGUI_Workshop::processEvent(const Event_Message* theMessage)
   const Config_PointerMessage* aPartSetMsg =
       dynamic_cast<const Config_PointerMessage*>(theMessage);
   if (aPartSetMsg) {
-    ModuleBase_Operation* aOperation = (ModuleBase_Operation*)(aPartSetMsg->pointer());
+    ModuleBase_PropPanelOperation* aOperation =
+        (ModuleBase_PropPanelOperation*)(aPartSetMsg->pointer());
     setCurrentOperation(aOperation);
     if(aOperation->xmlRepresentation().isEmpty()) { //!< No need for property panel
       myCurrentOperation->start();
@@ -204,7 +205,7 @@ void XGUI_Workshop::addFeature(const Config_FeatureMessage* theMessage)
 /*
  *
  */
-void XGUI_Workshop::fillPropertyPanel(ModuleBase_Operation* theOperation)
+void XGUI_Workshop::fillPropertyPanel(ModuleBase_PropPanelOperation* theOperation)
 {
   connectToPropertyPanel(theOperation);
   QWidget* aPropWidget = myMainWindow->findChild<QWidget*>(XGUI::PROP_PANEL_WDG);
@@ -212,6 +213,7 @@ void XGUI_Workshop::fillPropertyPanel(ModuleBase_Operation* theOperation)
   theOperation->start();
   XGUI_WidgetFactory aFactory = XGUI_WidgetFactory(theOperation);
   aFactory.createWidget(aPropWidget);
+  myMainWindow->setPropertyPannelTitle(theOperation->description());
 }
 
 void XGUI_Workshop::setCurrentOperation(ModuleBase_Operation* theOperation)
index 371fbb366f4b57de084f327bebfa4f89aff09ce2..aff5c239bc90755867f18e9446a52f92d02e83b6 100644 (file)
@@ -15,6 +15,7 @@ class XGUI_Module;
 class XGUI_Workbench;
 class XGUI_SelectionMgr;
 class ModuleBase_Operation;
+class ModuleBase_PropPanelOperation;
 
 class Config_FeatureMessage;
 class Config_PointerMessage;
@@ -63,7 +64,7 @@ public slots:
 protected:
   //Event-loop processing methods:
   void addFeature(const Config_FeatureMessage*);
-  void fillPropertyPanel(ModuleBase_Operation* theOperation);
+  void fillPropertyPanel(ModuleBase_PropPanelOperation* theOperation);
   void connectToPropertyPanel(ModuleBase_Operation* theOperation);
   void setCurrentOperation(ModuleBase_Operation* theOperation);