]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Merge branch 'master' of newgeom:newgeom
authorvsv <vitaly.smetannikov@opencascade.com>
Fri, 25 Apr 2014 13:41:47 +0000 (17:41 +0400)
committervsv <vitaly.smetannikov@opencascade.com>
Fri, 25 Apr 2014 13:41:47 +0000 (17:41 +0400)
Conflicts:
src/XGUI/XGUI_Workshop.cpp

12 files changed:
src/NewGeom/NewGeom_Module.cpp
src/NewGeom/NewGeom_Module.h
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h
src/XGUI/CMakeLists.txt
src/XGUI/XGUI_MainWindow.cpp
src/XGUI/XGUI_MainWindow.h
src/XGUI/XGUI_Module.h
src/XGUI/XGUI_SalomeConnector.h [new file with mode: 0644]
src/XGUI/XGUI_SelectionMgr.cpp
src/XGUI/XGUI_Workshop.cpp
src/XGUI/XGUI_Workshop.h

index e5f2ec1eeb223a42391b41a644be77117bf28988..affe26d7962d8eb0318ac414c85de81e029dd274 100644 (file)
@@ -3,8 +3,12 @@
 #include "NewGeom_Module.h"
 #include "NewGeom_DataModel.h"
 
+#include <XGUI_Workshop.h>
+
 #include <LightApp_Application.h>
 #include <OCCViewer_ViewModel.h>
+#include <SUIT_Desktop.h>
+#include <QtxActionMenuMgr.h>
 
 
 extern "C" {
@@ -18,44 +22,140 @@ extern "C" {
 }
 
 
-
+//******************************************************
 NewGeom_Module::NewGeom_Module()
 : LightApp_Module( "NewGeom" )
 {
+  myWorkshop = new XGUI_Workshop(this);
 }
 
-
+//******************************************************
 NewGeom_Module::~NewGeom_Module()
 {
 }
 
+//******************************************************
 void NewGeom_Module::initialize(CAM_Application* theApp)
 {
   LightApp_Module::initialize(theApp);
+  
+  myWorkshop->startApplication();
 }
 
+//******************************************************
 void NewGeom_Module::windows(QMap<int, int>& theWndMap) const
 {
   theWndMap.insert( LightApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
 }
 
+//******************************************************
 void NewGeom_Module::viewManagers(QStringList& theList) const
 {
   theList.append( OCCViewer_Viewer::Type() );
 }
 
+//******************************************************
 bool NewGeom_Module::activateModule(SUIT_Study* theStudy)
 {
-  return LightApp_Module::activateModule(theStudy);
+  bool isDone = LightApp_Module::activateModule(theStudy);
+  if (isDone) {
+    setMenuShown( true );
+    setToolShown( true );
+  }
+  return isDone;
 }
 
+//******************************************************
 bool NewGeom_Module::deactivateModule(SUIT_Study* theStudy)
 {
+  setMenuShown( false );
+  setToolShown( false );
   return LightApp_Module::deactivateModule(theStudy);
 }
 
+//******************************************************
 CAM_DataModel* NewGeom_Module::createDataModel()
 {
-  return new NewGeom_DataModel(this);
+  return new NewGeom_DataModel( this );
+}
+
+//******************************************************
+void NewGeom_Module::addFeature(const QString& theWBName,
+                                const QString& theId, 
+                                const QString& theTitle, 
+                                const QString& theTip,
+                                const QIcon& theIcon, 
+                                bool isCheckable,
+                                QObject* theReciever,
+                                const char* theMember,
+                                const QKeySequence& theKeys)
+{
+  int aMenu = createMenu(theWBName, -1, -1, 50);
+  int aTool = createTool(theWBName);
+
+  int aId = myActionsList.size();
+  myActionsList.append(theId);
+  SUIT_Desktop* aDesk = application()->desktop();
+  int aKeys = 0;
+  for (int i = 0; i < theKeys.count(); i++) 
+    aKeys += theKeys[i];
+  createAction(aId, theTip, theIcon, theTitle, theTip, aKeys, aDesk, 
+               isCheckable, theReciever, theMember);
+  int aItemId = createMenu( aId,  aMenu, -1, 10 );
+  int aToolId = createTool( aId, aTool );
+}
+
+//******************************************************
+void NewGeom_Module::addEditCommand(const QString& theId,
+                                    const QString& theTitle,
+                                    const QString& theTip,
+                                    const QIcon& theIcon, 
+                                    bool isCheckable,
+                                    QObject* theReciever,
+                                    const char* theMember,
+                                    const QKeySequence& theKeys)
+{
+  int aMenu = createMenu(tr( "MEN_DESK_EDIT" ), -1, -1);
+
+  int aId = myActionsList.size();
+  myActionsList.append(theId);
+  SUIT_Desktop* aDesk = application()->desktop();
+  int aKeys = 0;
+  for (int i = 0; i < theKeys.count(); i++) 
+    aKeys += theKeys[i];
+  createAction(aId, theTip, theIcon, theTitle, theTip, aKeys, aDesk, 
+               isCheckable, theReciever, theMember);
+  createMenu( aId, aMenu, 10 );
 }
 
+//******************************************************
+void NewGeom_Module::addEditMenuSeparator()
+{
+  int aMenu = createMenu(tr( "MEN_DESK_EDIT" ), -1, -1);
+  createMenu( separator(), aMenu, -1, 10 );
+}
+
+//******************************************************
+QMainWindow* NewGeom_Module::desktop() const
+{
+  return application()->desktop();
+}
+
+//******************************************************
+QString NewGeom_Module::commandId(const QAction* theCmd) const
+{
+  int aId = actionId(theCmd);
+  if (aId < myActionsList.size())
+    return myActionsList[aId];
+  return QString();
+}
+
+//******************************************************
+QAction* NewGeom_Module::command(const QString& theId) const
+{
+  int aId = myActionsList.indexOf(theId);
+  if ((aId != -1) && (aId < myActionsList.size())) {
+    return action(aId);
+  }
+  return 0;
+}
\ No newline at end of file
index b18ff6606c7f321ea35efecc3982a82e609ffb31..8df0ef372c3bf617d3090012319ff7b210b366c6 100644 (file)
@@ -4,9 +4,15 @@
 #define NewGeom_Module_H
 
 #include "NewGeom.h"
+
 #include <LightApp_Module.h>
+#include <XGUI_SalomeConnector.h>
+
+#include <QStringList>
+
+class XGUI_Workshop;
 
-class NewGeom_EXPORT NewGeom_Module: public LightApp_Module
+class NewGeom_EXPORT NewGeom_Module: public LightApp_Module, public XGUI_SalomeConnector
 {
   Q_OBJECT
 public:
@@ -17,6 +23,34 @@ public:
   virtual void windows( QMap<int, int>& theWndMap) const;
   virtual void viewManagers( QStringList& theList) const;
 
+  //--- XGUI connector interface -----
+  virtual void addFeature(const QString& theWBName,
+                          const QString& theId, 
+                          const QString& theTitle, 
+                          const QString& theTip,
+                          const QIcon& theIcon, 
+                          bool isCheckable = false,
+                          QObject* reciever = 0,
+                          const char* member = 0,
+                          const QKeySequence& theKeys = QKeySequence());
+
+  virtual void addEditCommand(const QString& theId,
+                              const QString& theTitle,
+                              const QString& theTip,
+                              const QIcon& theIcon, 
+                              bool isCheckable,
+                              QObject* reciever,
+                              const char* member,
+                              const QKeySequence& theKeys);
+
+  virtual void addEditMenuSeparator();
+
+  virtual QMainWindow* desktop() const;
+
+  virtual QString commandId(const QAction* theCmd) const;
+
+  virtual QAction* command(const QString& theId) const;
+
 public slots:
   bool activateModule( SUIT_Study* theStudy);
   bool deactivateModule( SUIT_Study* theStudy);
@@ -26,7 +60,9 @@ protected:
 
 
 private:
+  QStringList myActionsList;
 
+  XGUI_Workshop* myWorkshop;
 };
 
 #endif
index 71d0987a4bbebcec134cea5127758d8e868af099..1a0e84dd5c0125236e3df181065eb3af7b6bc42f 100644 (file)
@@ -39,8 +39,9 @@ PartSet_Module::PartSet_Module(XGUI_Workshop* theWshop)
   connect(anOperationMgr, SIGNAL(operationStarted()), this, SLOT(onOperationStarted()));
   connect(anOperationMgr, SIGNAL(operationStopped(ModuleBase_Operation*)),
           this, SLOT(onOperationStopped(ModuleBase_Operation*)));
-  connect(myWorkshop->mainWindow()->viewer(), SIGNAL(selectionChanged()),
-          this, SLOT(onViewSelectionChanged()));
+  if (!myWorkshop->isSalomeMode())
+    connect(myWorkshop->mainWindow()->viewer(), SIGNAL(selectionChanged()),
+            this, SLOT(onViewSelectionChanged()));
 }
 
 PartSet_Module::~PartSet_Module()
@@ -70,18 +71,22 @@ std::string PartSet_Module::featureFile(const std::string& theFeatureId)
 void PartSet_Module::onFeatureTriggered()
 {
   XGUI_Command* aCmd = dynamic_cast<XGUI_Command*>(sender());
-  QString aCmdId = aCmd->id();
-  std::string aStdCmdId = aCmdId.toStdString();
+  launchOperation(aCmd->id());
+}
+  
+void PartSet_Module::launchOperation(const QString& theCmdId)
+{
+  std::string aStdCmdId = theCmdId.toStdString();
   std::string aPluginFileName = featureFile(aStdCmdId);
   Config_WidgetReader aWdgReader = Config_WidgetReader(aPluginFileName);
   aWdgReader.readAll();
   std::string aXmlCfg = aWdgReader.featureWidgetCfg(aStdCmdId);
   std::string aDescription = aWdgReader.featureDescription(aStdCmdId);
   ModuleBase_PropPanelOperation* aPartSetOp;
-  if (aCmdId == "Sketch" ) {
-    aPartSetOp = new PartSet_OperationSketch(aCmdId, this);
+  if (theCmdId == "Sketch" ) {
+    aPartSetOp = new PartSet_OperationSketch(theCmdId, this);
   } else {
-    aPartSetOp = new ModuleBase_PropPanelOperation(aCmdId, this);
+    aPartSetOp = new ModuleBase_PropPanelOperation(theCmdId, this);
   }
   aPartSetOp->setXmlRepresentation(QString::fromStdString(aXmlCfg));
   aPartSetOp->setDescription(QString::fromStdString(aDescription));
index c7d8e8d3b8a476bdb383257b68c3674ac41cf4d8..523a15ad210a702de378f66562dc510329ff97c5 100644 (file)
@@ -23,6 +23,8 @@ public:
   virtual void featureCreated(XGUI_Command* theFeature);
   std::string featureFile(const std::string&);
 
+  virtual void launchOperation(const QString& theCmdId);
+
 public slots:
   void onFeatureTriggered();
   /// SLOT, that is called after the operation is started. Perform some specific for module
index a246e4060ebcd25ac868fb9babc49dabc0fc7bcd..3741d32e61d01c14d8af28daa646c91484cd926f 100644 (file)
@@ -27,6 +27,7 @@ SET(PROJECT_HEADERS
     XGUI_DataTreeModel.h
     XGUI_SelectionMgr.h
     XGUI_SwitchWidget.h
+    XGUI_SalomeConnector.h
 )
 
 SET(PROJECT_AUTOMOC 
index b675c5fd7d59639c83e5075dec96d6d27092df76..cbc3e67f32994ff7338a1d2cceafdb534dc6bbf4 100644 (file)
@@ -28,9 +28,7 @@
 
 XGUI_MainWindow::XGUI_MainWindow(QWidget* parent)
     : QMainWindow(parent), 
-    myObjectBrowser(0),
-    myPythonConsole(0),
-    myPropertyPanelDock(0)
+    myPythonConsole(0)
 {
   setWindowTitle(tr("New Geom"));
   myMenuBar = new XGUI_MainMenu(this);
@@ -39,8 +37,6 @@ XGUI_MainWindow::XGUI_MainWindow(QWidget* parent)
   setCentralWidget(aMdiArea);
 
   myViewer = new XGUI_Viewer(this);
-
-  //createDockWidgets();
 }
 
 XGUI_MainWindow::~XGUI_MainWindow(void)
@@ -53,18 +49,6 @@ QMdiArea* XGUI_MainWindow::mdiArea() const
   return static_cast<QMdiArea*>(centralWidget());
 }
 
-//******************************************************
-void XGUI_MainWindow::showObjectBrowser()
-{
-  myObjectBrowser->parentWidget()->show();
-}
-
-//******************************************************
-void XGUI_MainWindow::hideObjectBrowser()
-{
-  myObjectBrowser->parentWidget()->hide();
-}
-
 //******************************************************
 void XGUI_MainWindow::showPythonConsole()
 {
@@ -89,93 +73,4 @@ void XGUI_MainWindow::hidePythonConsole()
     myPythonConsole->parentWidget()->hide();
 }
 
-void XGUI_MainWindow::showPropertyPanel()
-{
-  QAction* aViewAct = myPropertyPanelDock->toggleViewAction();
-  //<! Restore ability to close panel from the window's menu
-  aViewAct->setEnabled(true);
-  myPropertyPanelDock->show();
-  myPropertyPanelDock->raise();
-}
-
-void XGUI_MainWindow::hidePropertyPanel()
-{
-  QAction* aViewAct = myPropertyPanelDock->toggleViewAction();
-  //<! Do not allow to show empty property panel
-  aViewAct->setEnabled(false);
-  myPropertyPanelDock->hide();
-}
 
-/*
- * Creates dock widgets, places them in corresponding area
- * and tabifies if necessary.
- */
-void XGUI_MainWindow::createDockWidgets()
-{
-  QDockWidget* aObjDock = createObjectBrowser();
-  addDockWidget(Qt::LeftDockWidgetArea, aObjDock);
-  myPropertyPanelDock = createPropertyPanel();
-  addDockWidget(Qt::LeftDockWidgetArea, myPropertyPanelDock);
-  hidePropertyPanel(); //<! Invisible by default
-  hideObjectBrowser();
-  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);
-  QVBoxLayout* aMainLay = new QVBoxLayout(aContent);
-  aMainLay->setContentsMargins(3, 3, 3, 3);
-  aPropPanel->setWidget(aContent);
-
-  QFrame* aFrm = new QFrame(aContent);
-  aFrm->setFrameStyle(QFrame::Sunken);
-  aFrm->setFrameShape(QFrame::Panel);
-  QHBoxLayout* aBtnLay = new QHBoxLayout(aFrm);
-  aBtnLay->setContentsMargins(0, 0, 0, 0);
-  aMainLay->addWidget(aFrm);
-
-  QPushButton* aBtn = new QPushButton(QIcon(":pictures/button_help.png"), "", aFrm);
-  aBtn->setFlat(true);
-  //connect(aBtn, SIGNAL(clicked()), this, SIGNAL(propertyHelpPressed()));
-  aBtnLay->addWidget(aBtn);
-  aBtnLay->addStretch(1);
-  aBtn = new QPushButton(QIcon(":pictures/button_ok.png"), "", aFrm);
-  aBtn->setObjectName(XGUI::PROP_PANEL_OK);
-  aBtn->setFlat(true);
-  //connect(aBtn, SIGNAL(clicked()), this, SIGNAL(propertyOkPressed()));
-  aBtnLay->addWidget(aBtn);
-  aBtn = new QPushButton(QIcon(":pictures/button_cancel.png"), "", aFrm);
-  aBtn->setObjectName(XGUI::PROP_PANEL_CANCEL);
-  aBtn->setFlat(true);
-  //connect(aBtn, SIGNAL(clicked()), this, SIGNAL(propertyClosePressed()));
-  aBtnLay->addWidget(aBtn);
-
-  QWidget* aCustomWidget = new QWidget(aContent);
-  aCustomWidget->setObjectName(XGUI::PROP_PANEL_WDG);
-  aMainLay->addWidget(aCustomWidget);
-  aMainLay->addStretch(1);
-
-  return aPropPanel;
-}
-
-QDockWidget* XGUI_MainWindow::createObjectBrowser()
-{
-  QDockWidget* aObjDock = new QDockWidget(this);
-  aObjDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
-  aObjDock->setWindowTitle(tr("Object browser"));
-  myObjectBrowser = new XGUI_ObjectsBrowser(aObjDock);
-  aObjDock->setWidget(myObjectBrowser);
-  return aObjDock;
-}
index 2a71a876a00327a14758f54812ef941a43be002f..553aa27358cf613de2479593b1897022770034e5 100644 (file)
@@ -6,7 +6,6 @@
 
 class XGUI_MainMenu;
 class XGUI_Viewer;
-class XGUI_ObjectsBrowser;
 class QMdiArea;
 class PyConsole_EnhConsole;
 
@@ -29,12 +28,6 @@ public:
     return myMenuBar;
   }
 
-  //! Returns Object browser
-  XGUI_ObjectsBrowser* objectBrowser() const
-  {
-    return myObjectBrowser;
-  }
-
   //! Returns MDI area
   QMdiArea* mdiArea() const;
 
@@ -44,25 +37,12 @@ public:
     return myViewer;
   }
 
-  // Creates Dock widgets: Object broewser and Property panel
-  void createDockWidgets();
-  void setPropertyPannelTitle(const QString& theTitle);
-
 public slots:
   void showPythonConsole();
   void hidePythonConsole();
-  void showPropertyPanel();
-  void hidePropertyPanel();
-  void showObjectBrowser();
-  void hideObjectBrowser();
 
 private:
-  QDockWidget* createObjectBrowser();
-  QDockWidget* createPropertyPanel();
-
   XGUI_MainMenu* myMenuBar;
-  XGUI_ObjectsBrowser* myObjectBrowser;
-  QDockWidget* myPropertyPanelDock;
 
   XGUI_Viewer* myViewer;
 
index 347cc061a6c485ac53ff1117fae152679d5bbd46..48de0ad69b8a309550d3e2745a6573bba43af839 100644 (file)
@@ -2,6 +2,7 @@
 #define XGUI_Module_H\r
 \r
 #include <XGUI_Workshop.h>\r
+#include <QString>\r
 \r
 class XGUI_Command;\r
 \r
@@ -10,6 +11,7 @@ class XGUI_Module
 public:\r
   virtual void createFeatures() = 0;\r
   virtual void featureCreated(XGUI_Command*) = 0;\r
+  virtual void launchOperation(const QString& theCmdId) = 0;\r
 \r
   virtual ~XGUI_Module() {};\r
 };\r
diff --git a/src/XGUI/XGUI_SalomeConnector.h b/src/XGUI/XGUI_SalomeConnector.h
new file mode 100644 (file)
index 0000000..b2384b6
--- /dev/null
@@ -0,0 +1,39 @@
+#ifndef XGUI_SALOMECONNECTOR_H
+#define XGUI_SALOMECONNECTOR_H
+
+#include "XGUI.h"
+
+#include <QString>
+
+class QMainWindow;
+
+class XGUI_EXPORT XGUI_SalomeConnector
+{
+public:
+  virtual void addFeature(const QString& theWBName,
+                          const QString& theId, 
+                          const QString& theTitle, 
+                          const QString& theTip,
+                          const QIcon& theIcon, 
+                          bool isCheckable,
+                          QObject* reciever,
+                          const char* member,
+                          const QKeySequence& theKeys) = 0;
+
+  virtual void addEditCommand(const QString& theId,
+                              const QString& theTitle,
+                              const QString& theTip,
+                              const QIcon& theIcon, 
+                              bool isCheckable,
+                              QObject* reciever,
+                              const char* member,
+                              const QKeySequence& theKeys) = 0;
+  virtual void addEditMenuSeparator() = 0;
+
+  virtual QMainWindow* desktop() const = 0;
+
+  virtual QString commandId(const QAction* theCmd) const = 0;
+  virtual QAction* command(const QString& theId) const = 0;
+};
+
+#endif
\ No newline at end of file
index 6421d278b62bcd816a9999d6ae99cc485ea1196c..c2d2c3de305f0dac81555fe4ee8aaef8a4167ad7 100644 (file)
@@ -27,7 +27,7 @@ XGUI_SelectionMgr::~XGUI_SelectionMgr()
 
 void XGUI_SelectionMgr::onSelectionChanged()
 {
-  XGUI_ObjectsBrowser* aObjBrowser = myWorkshop->mainWindow()->objectBrowser();
+  XGUI_ObjectsBrowser* aObjBrowser = myWorkshop->objectBrowser();
   mySelectedData = aObjBrowser->selectedData();
   
   // Set current document
index cbc3ce14610a781abcc743f987fb50b11f665ba3..cbd6239cbb6642f88e114af2820c6fe2017cadd6 100644 (file)
@@ -13,6 +13,7 @@
 #include "XGUI_ObjectsBrowser.h"
 #include "XGUI_Displayer.h"
 #include "XGUI_OperationMgr.h"
+#include "XGUI_SalomeConnector.h"
 
 #include <ModelAPI_PluginManager.h>
 #include <ModelAPI_Feature.h>
@@ -31,6 +32,7 @@
 #include <QMdiSubWindow>
 #include <QPushButton>
 #include <QDockWidget>
+#include <QLayout>
 
 #ifdef _DEBUG
 #include <QDebug>
 #include <dlfcn.h>
 #endif
 
-XGUI_Workshop::XGUI_Workshop()
+XGUI_Workshop::XGUI_Workshop(XGUI_SalomeConnector* theConnector)
   : QObject(), 
-  myPartSetModule(NULL)
+  myPartSetModule(NULL),
+  mySalomeConnector(theConnector),
+  myPropertyPanelDock(0),
+  myObjectBrowser(0)
 {
-  myMainWindow = new XGUI_MainWindow();
+  myMainWindow = mySalomeConnector? 0 : new XGUI_MainWindow();
   mySelector = new XGUI_SelectionMgr(this);
-  myDisplayer = new XGUI_Displayer(myMainWindow->viewer());
+  myDisplayer = myMainWindow? new XGUI_Displayer(myMainWindow->viewer()) : 0;
   myOperationMgr = new XGUI_OperationMgr(this);
   connect(myOperationMgr, SIGNAL(operationStarted()),  this, SLOT(onOperationStarted()));
   connect(myOperationMgr, SIGNAL(operationStopped(ModuleBase_Operation*)),
@@ -72,9 +77,10 @@ void XGUI_Workshop::startApplication()
   Events_ID aPartSetId = aLoop->eventByName("PartSetModuleEvent");
   aLoop->registerListener(this, aPartSetId);
   activateModule();
-  myMainWindow->show();
-
-  updateCommandStatus();
+  if (myMainWindow) {
+    myMainWindow->show();
+    updateCommandStatus();
+  }
   onNew();
   // Testing of document creation
   //boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
@@ -92,6 +98,21 @@ void XGUI_Workshop::startApplication()
 //******************************************************
 void XGUI_Workshop::initMenu()
 {
+  if (isSalomeMode()) {
+    // Create only Undo, Redo commands
+    salomeConnector()->addEditCommand("UNDO_CMD", 
+                                      tr("Undo"), tr("Undo last command"),
+                                      QIcon(":pictures/undo.png"), 
+                                      false, this, SLOT(onUndo()),
+                                      QKeySequence::Undo);
+    salomeConnector()->addEditCommand("REDO_CMD", 
+                                      tr("Redo"), tr("Redo last command"),
+                                      QIcon(":pictures/redo.png"), 
+                                      false, this, SLOT(onRedo()),
+                                      QKeySequence::Redo);
+    salomeConnector()->addEditMenuSeparator();
+    return;
+  }
   XGUI_Workbench* aPage = myMainWindow->menuObject()->generalPage();
 
   // File commands group
@@ -179,17 +200,16 @@ void XGUI_Workshop::onOperationStarted()
   ModuleBase_PropPanelOperation* aOperation =
         (ModuleBase_PropPanelOperation*)(myOperationMgr->currentOperation());
 
-  if(aOperation->xmlRepresentation().isEmpty()) { //!< No need for property panel
-  } else {
+  if(!aOperation->xmlRepresentation().isEmpty()) { //!< No need for property panel
     connectWithOperation(aOperation);
-    QWidget* aPropWidget = myMainWindow->findChild<QWidget*>(XGUI::PROP_PANEL_WDG);
+    QWidget* aPropWidget = myPropertyPanelDock->findChild<QWidget*>(XGUI::PROP_PANEL_WDG);
     qDeleteAll(aPropWidget->children());
 
-    myMainWindow->showPropertyPanel();
+    showPropertyPanel();
 
     XGUI_WidgetFactory aFactory = XGUI_WidgetFactory(aOperation);
     aFactory.createWidget(aPropWidget);
-    myMainWindow->setPropertyPannelTitle(aOperation->description());
+    setPropertyPannelTitle(aOperation->description());
   }
 }
 
@@ -202,12 +222,14 @@ void XGUI_Workshop::onOperationStopped(ModuleBase_Operation* theOperation)
   if(aOperation->xmlRepresentation().isEmpty()) { //!< No need for property panel
     updateCommandStatus();
   } else {
-    myMainWindow->hidePropertyPanel();
+    hidePropertyPanel();
     updateCommandStatus();
 
+  if (myMainWindow) {
     XGUI_MainMenu* aMenu = myMainWindow->menuObject();
     aMenu->restoreCommandState();
   }
+  }
 }
 
 /*
@@ -222,29 +244,39 @@ void XGUI_Workshop::addFeature(const Config_FeatureMessage* theMessage)
     return;
   }
   //Find or create Workbench
-  XGUI_MainMenu* aMenuBar = myMainWindow->menuObject();
   QString aWchName = QString::fromStdString(theMessage->workbenchId());
-  XGUI_Workbench* aPage = aMenuBar->findWorkbench(aWchName);
-  if (!aPage) {
-    aPage = addWorkbench(aWchName);
-  }
-  //Find or create Group
-  QString aGroupName = QString::fromStdString(theMessage->groupId());
-  XGUI_MenuGroupPanel* aGroup = aPage->findGroup(aGroupName);
-  if (!aGroup) {
-    aGroup = aPage->addGroup(aGroupName);
+  if (isSalomeMode()) {
+    salomeConnector()->addFeature(aWchName,
+                                  QString::fromStdString(theMessage->id()),
+                                  QString::fromStdString(theMessage->text()),
+                                  QString::fromStdString(theMessage->tooltip()),
+                                  QIcon(theMessage->icon().c_str()),
+                                  false, this, 
+                                  SLOT(onFeatureTriggered()), QKeySequence());
+  } else {
+    XGUI_MainMenu* aMenuBar = myMainWindow->menuObject();
+    XGUI_Workbench* aPage = aMenuBar->findWorkbench(aWchName);
+    if (!aPage) {
+      aPage = addWorkbench(aWchName);
+    }
+    //Find or create Group
+    QString aGroupName = QString::fromStdString(theMessage->groupId());
+    XGUI_MenuGroupPanel* aGroup = aPage->findGroup(aGroupName);
+    if (!aGroup) {
+      aGroup = aPage->addGroup(aGroupName);
+    }
+    bool isUsePropPanel = theMessage->isUseInput();
+    //Create feature...
+    XGUI_Command* aCommand = aGroup->addFeature(QString::fromStdString(theMessage->id()),
+                                                QString::fromStdString(theMessage->text()),
+                                                QString::fromStdString(theMessage->tooltip()),
+                                                QIcon(theMessage->icon().c_str()),
+                                                QKeySequence(), isUsePropPanel);
+    
+    connect(aCommand,                   SIGNAL(toggled(bool)),
+            myMainWindow->menuObject(), SLOT(onFeatureChecked(bool)));
+    myPartSetModule->featureCreated(aCommand);
   }
-  bool isUsePropPanel = theMessage->isUseInput();
-  //Create feature...
-  XGUI_Command* aCommand = aGroup->addFeature(QString::fromStdString(theMessage->id()),
-                                              QString::fromStdString(theMessage->text()),
-                                              QString::fromStdString(theMessage->tooltip()),
-                                              QIcon(theMessage->icon().c_str()),
-                                              QKeySequence(), isUsePropPanel);
-  
-  connect(aCommand,                   SIGNAL(toggled(bool)),
-          myMainWindow->menuObject(), SLOT(onFeatureChecked(bool)));
-  myPartSetModule->featureCreated(aCommand);
 }
 
 /*
@@ -254,17 +286,20 @@ void XGUI_Workshop::addFeature(const Config_FeatureMessage* theMessage)
  */
 void XGUI_Workshop::connectWithOperation(ModuleBase_Operation* theOperation)
 {
-  QDockWidget* aPanel = myMainWindow->findChild<QDockWidget*>(XGUI::PROP_PANEL);
-  QPushButton* aOkBtn = aPanel->findChild<QPushButton*>(XGUI::PROP_PANEL_OK);
+  QPushButton* aOkBtn = myPropertyPanelDock->findChild<QPushButton*>(XGUI::PROP_PANEL_OK);
   connect(aOkBtn, SIGNAL(clicked()), theOperation, SLOT(commit()));
-  QPushButton* aCancelBtn = aPanel->findChild<QPushButton*>(XGUI::PROP_PANEL_CANCEL);
+  QPushButton* aCancelBtn = myPropertyPanelDock->findChild<QPushButton*>(XGUI::PROP_PANEL_CANCEL);
   connect(aCancelBtn, SIGNAL(clicked()), theOperation, SLOT(abort()));
 
-  XGUI_MainMenu* aMenu = myMainWindow->menuObject();
-  XGUI_Command* aCommand = aMenu->feature(theOperation->operationId());
+  QAction* aCommand = 0;
+  if (isSalomeMode()) {
+    aCommand = salomeConnector()->command(theOperation->operationId());
+  } else {
+    XGUI_MainMenu* aMenu = myMainWindow->menuObject();
+    aCommand = aMenu->feature(theOperation->operationId());
+  }
   //Abort operation on uncheck the command
   connect(aCommand, SIGNAL(toggled(bool)), theOperation, SLOT(setRunning(bool)));
-
 }
 
 //******************************************************
@@ -277,15 +312,17 @@ void XGUI_Workshop::onExit()
 void XGUI_Workshop::onNew()
 {
   QApplication::setOverrideCursor(Qt::WaitCursor);
-  if (myMainWindow->objectBrowser() == 0) {
-    myMainWindow->createDockWidgets();
-    mySelector->connectObjectBrowser(myMainWindow->objectBrowser());
+  if (objectBrowser() == 0) {
+    createDockWidgets();
+    mySelector->connectObjectBrowser(objectBrowser());
+  }
+  showObjectBrowser();
+  if (!isSalomeMode()) {
+    myMainWindow->showPythonConsole();
+    QMdiSubWindow* aWnd = myMainWindow->viewer()->createView();
+    aWnd->showMaximized();
+    updateCommandStatus();
   }
-  myMainWindow->showObjectBrowser();
-  myMainWindow->showPythonConsole();
-  QMdiSubWindow* aWnd = myMainWindow->viewer()->createView();
-  aWnd->showMaximized();
-  updateCommandStatus();
   QApplication::restoreOverrideCursor();
 }
 
@@ -312,7 +349,7 @@ void XGUI_Workshop::onSaveAs()
 //******************************************************
 void XGUI_Workshop::onUndo()
 {
-  myMainWindow->objectBrowser()->setCurrentIndex(QModelIndex());
+  objectBrowser()->setCurrentIndex(QModelIndex());
   boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
   boost::shared_ptr<ModelAPI_Document> aDoc = aMgr->rootDocument();
   aDoc->undo();
@@ -322,7 +359,7 @@ void XGUI_Workshop::onUndo()
 //******************************************************
 void XGUI_Workshop::onRedo()
 {
-  myMainWindow->objectBrowser()->setCurrentIndex(QModelIndex());
+  objectBrowser()->setCurrentIndex(QModelIndex());
   boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
   boost::shared_ptr<ModelAPI_Document> aDoc = aMgr->rootDocument();
   aDoc->redo();
@@ -402,6 +439,8 @@ bool XGUI_Workshop::activateModule()
 //******************************************************
 void XGUI_Workshop::updateCommandStatus()
 {
+  if (isSalomeMode()) // TODO: update commands in SALOME
+    return;
   XGUI_MainMenu* aMenuBar = myMainWindow->menuObject();
 
   QList<XGUI_Command*> aCommands = aMenuBar->features();
@@ -433,3 +472,121 @@ void XGUI_Workshop::updateCommandStatus()
     }
   }
 }
+
+//******************************************************
+QDockWidget* XGUI_Workshop::createObjectBrowser(QWidget* theParent)
+{
+  QDockWidget* aObjDock = new QDockWidget(theParent);
+  aObjDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
+  aObjDock->setWindowTitle(tr("Object browser"));
+  myObjectBrowser = new XGUI_ObjectsBrowser(aObjDock);
+  aObjDock->setWidget(myObjectBrowser);
+  return aObjDock;
+}
+
+//******************************************************
+QDockWidget* XGUI_Workshop::createPropertyPanel(QWidget* theParent)
+{
+  QDockWidget* aPropPanel = new QDockWidget(theParent);
+  aPropPanel->setWindowTitle(tr("Property Panel"));
+  QAction* aViewAct = aPropPanel->toggleViewAction();
+  aPropPanel->setObjectName(XGUI::PROP_PANEL);
+
+  QWidget* aContent = new QWidget(aPropPanel);
+  QVBoxLayout* aMainLay = new QVBoxLayout(aContent);
+  aMainLay->setContentsMargins(3, 3, 3, 3);
+  aPropPanel->setWidget(aContent);
+
+  QFrame* aFrm = new QFrame(aContent);
+  aFrm->setFrameStyle(QFrame::Sunken);
+  aFrm->setFrameShape(QFrame::Panel);
+  QHBoxLayout* aBtnLay = new QHBoxLayout(aFrm);
+  aBtnLay->setContentsMargins(0, 0, 0, 0);
+  aMainLay->addWidget(aFrm);
+
+  QPushButton* aBtn = new QPushButton(QIcon(":pictures/button_help.png"), "", aFrm);
+  aBtn->setFlat(true);
+  aBtnLay->addWidget(aBtn);
+  aBtnLay->addStretch(1);
+  aBtn = new QPushButton(QIcon(":pictures/button_ok.png"), "", aFrm);
+  aBtn->setObjectName(XGUI::PROP_PANEL_OK);
+  aBtn->setFlat(true);
+  aBtnLay->addWidget(aBtn);
+  aBtn = new QPushButton(QIcon(":pictures/button_cancel.png"), "", aFrm);
+  aBtn->setObjectName(XGUI::PROP_PANEL_CANCEL);
+  aBtn->setFlat(true);
+  aBtnLay->addWidget(aBtn);
+
+  QWidget* aCustomWidget = new QWidget(aContent);
+  aCustomWidget->setObjectName(XGUI::PROP_PANEL_WDG);
+  aMainLay->addWidget(aCustomWidget);
+  aMainLay->addStretch(1);
+
+  return aPropPanel;
+}
+
+//******************************************************
+void XGUI_Workshop::setPropertyPannelTitle(const QString& theTitle)
+{
+  myPropertyPanelDock->setWindowTitle(theTitle);
+}
+
+//******************************************************
+/*
+ * Creates dock widgets, places them in corresponding area
+ * and tabifies if necessary.
+ */
+void XGUI_Workshop::createDockWidgets()
+{
+  QMainWindow* aDesktop = isSalomeMode()? salomeConnector()->desktop() :
+                                          myMainWindow;
+  QDockWidget* aObjDock = createObjectBrowser(aDesktop);
+  aDesktop->addDockWidget(Qt::LeftDockWidgetArea, aObjDock);
+  myPropertyPanelDock = createPropertyPanel(aDesktop);
+  aDesktop->addDockWidget(Qt::LeftDockWidgetArea, myPropertyPanelDock);
+  hidePropertyPanel(); //<! Invisible by default
+  hideObjectBrowser();
+  aDesktop->tabifyDockWidget(aObjDock, myPropertyPanelDock);
+}
+
+//******************************************************
+void XGUI_Workshop::showPropertyPanel()
+{
+  QAction* aViewAct = myPropertyPanelDock->toggleViewAction();
+  //<! Restore ability to close panel from the window's menu
+  aViewAct->setEnabled(true);
+  myPropertyPanelDock->show();
+  myPropertyPanelDock->raise();
+}
+
+//******************************************************
+void XGUI_Workshop::hidePropertyPanel()
+{
+  QAction* aViewAct = myPropertyPanelDock->toggleViewAction();
+  //<! Do not allow to show empty property panel
+  aViewAct->setEnabled(false);
+  myPropertyPanelDock->hide();
+}
+
+//******************************************************
+void XGUI_Workshop::showObjectBrowser()
+{
+  myObjectBrowser->parentWidget()->show();
+}
+
+//******************************************************
+void XGUI_Workshop::hideObjectBrowser()
+{
+  myObjectBrowser->parentWidget()->hide();
+}
+
+//******************************************************
+void XGUI_Workshop::onFeatureTriggered()
+{
+  QAction* aCmd = dynamic_cast<QAction*>(sender());
+  if (aCmd) {
+    QString aId = salomeConnector()->commandId(aCmd);
+    if (!aId.isNull())
+      myPartSetModule->launchOperation(aId);
+  }
+}
index 6c9034d49e30d95b990a8cade7b9627bea1f6db5..0b477c5265f37760da0acec157e862c53e07c274 100644 (file)
@@ -16,12 +16,17 @@ class XGUI_Workbench;
 class XGUI_SelectionMgr;
 class XGUI_Displayer;
 class XGUI_OperationMgr;
+class XGUI_SalomeConnector;
+class XGUI_ObjectsBrowser;
 class ModuleBase_Operation;
 class ModuleBase_PropPanelOperation;
 
 class Config_FeatureMessage;
 class Config_PointerMessage;
 
+class QWidget;
+class QDockWidget;
+
 /**\class XGUI_Workshop
  * \ingroup GUI
  * \brief Class which defines a configuration of the application (Workshop) and launches it.
@@ -31,7 +36,7 @@ class XGUI_EXPORT XGUI_Workshop: public QObject, public Events_Listener
 Q_OBJECT
 public:
 
-  XGUI_Workshop();
+  XGUI_Workshop(XGUI_SalomeConnector* theConnector = 0);
   virtual ~XGUI_Workshop();
 
   //! Starting of the application
@@ -58,6 +63,14 @@ public:
   //! Redefinition of Events_Listener method
   virtual void processEvent(const Events_Message* theMessage);
 
+  XGUI_SalomeConnector* salomeConnector() const { return mySalomeConnector; }
+
+  //! Returns true if the application works as SALOME module
+  bool isSalomeMode() const { return mySalomeConnector != 0; }
+
+  //! Returns Object browser
+  XGUI_ObjectsBrowser* objectBrowser() const { return myObjectBrowser; }
+
 public slots:
   void updateCommandStatus();
 
@@ -69,6 +82,13 @@ public slots:
   void onUndo();
   void onRedo();
 
+  void showPropertyPanel();
+  void hidePropertyPanel();
+  void showObjectBrowser();
+  void hideObjectBrowser();
+
+  void onFeatureTriggered();
+
 protected:
   //Event-loop processing methods:
   void addFeature(const Config_FeatureMessage*);
@@ -89,13 +109,26 @@ private:
   XGUI_Module* loadModule(const QString& theModule);
   bool activateModule();
 
+  QDockWidget* createObjectBrowser(QWidget* theParent);
+  QDockWidget* createPropertyPanel(QWidget* theParent);
+
+  // Creates Dock widgets: Object browser and Property panel
+  void createDockWidgets();
+  void setPropertyPannelTitle(const QString& theTitle);
+
+
   XGUI_MainWindow* myMainWindow;
   XGUI_Module* myPartSetModule;
 
+  XGUI_ObjectsBrowser* myObjectBrowser;
+  QDockWidget* myPropertyPanelDock;
+
   XGUI_SelectionMgr* mySelector;
   XGUI_Displayer* myDisplayer;
 
   XGUI_OperationMgr* myOperationMgr; ///< manager to manipulate through the operations
+
+  XGUI_SalomeConnector* mySalomeConnector;
 };
 
 #endif