]> SALOME platform Git repositories - modules/paravis.git/commitdiff
Salome HOME
Pipeline Browser popups, ACtive Variable Controls toolbar, Loomarl toolbar, QtAssista...
authormkr <mkr@opencascade.com>
Tue, 2 Dec 2008 15:28:55 +0000 (15:28 +0000)
committermkr <mkr@opencascade.com>
Tue, 2 Dec 2008 15:28:55 +0000 (15:28 +0000)
src/PVGUI/Makefile.am
src/PVGUI/PVGUI_Module.cxx
src/PVGUI/PVGUI_Module.h
src/PVGUI/PVGUI_Module_actions.cxx
src/PVGUI/PVGUI_Module_impl.h
src/PVGUI/PVGUI_Module_widgets.cxx
src/PVGUI/resources/PARAVIS_msg_en.ts

index 82a5db84c061d9119c769d64a3989ea627449ca4..5bc31639055ae8152a5ae89da98fb9813edefae6 100644 (file)
@@ -56,6 +56,7 @@ nodist_libPARAVIS_la_SOURCES = $(MOC_FILES)
 # additionnal compilation flags
 libPARAVIS_la_CPPFLAGS = \
        $(QT_INCLUDES) \
+       $(QT_ASSISTANT_INCLUDES) \
        $(PARAVIEW_INCLUDES) \
        $(CAS_CPPFLAGS) \
        $(PYTHON_INCLUDES) \
@@ -63,6 +64,7 @@ libPARAVIS_la_CPPFLAGS = \
 
 # additionnal linkage flags
 libPARAVIS_la_LDFLAGS = \
+       $(QT_ASSISTANT_LIBS) \
        $(PARAVIEW_LIBS) \
        $(GUI_LDFLAGS) \
        -lLightApp 
index 800fa266f10d766090baa44d62645240ff5d9132..752c7ea7a1a79ca0f82c69062ae5cc2d5808c024 100644 (file)
@@ -1,4 +1,4 @@
-// LIGHT : sample (no-corba-engine) SALOME module
+// PARAVIS : ParaView wrapper SALOME module
 //
 // Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 
 #include <QAction>
 #include <QApplication>
+#include <QCursor>
+#include <QDir>
+#include <QFile>
+#include <QFileInfo>
 #include <QIcon>
 #include <QInputDialog>
+#include <QStatusBar>
 #include <QString>
 #include <QStringList>
+#include <QTimer>
 #include <QToolBar>
 
 #include <pqApplicationCore.h>
@@ -353,7 +359,7 @@ void PVGUI_Module::showView( bool toShow )
 /*!
   \brief Manage the label of Undo operation.
 */
-void PVGUI_Module::onUndoLabel(const QString& label)
+void PVGUI_Module::onUndoLabel( const QString& label )
 {
   action(UndoId)->setText(
     label.isEmpty() ? tr("Can't Undo") : QString(tr("&Undo %1")).arg(label));
@@ -364,7 +370,7 @@ void PVGUI_Module::onUndoLabel(const QString& label)
 /*!
   \brief Manage the label of Redo operation.
 */
-void PVGUI_Module::onRedoLabel(const QString& label)
+void PVGUI_Module::onRedoLabel( const QString& label )
 {
   action(RedoId)->setText(
     label.isEmpty() ? tr("Can't Redo") : QString(tr("&Redo %1")).arg(label));
@@ -375,7 +381,7 @@ void PVGUI_Module::onRedoLabel(const QString& label)
 /*!
   \brief Manage the label of Undo Camera operation.
 */
-void PVGUI_Module::onCameraUndoLabel(const QString& label)
+void PVGUI_Module::onCameraUndoLabel( const QString& label )
 {
   action(CameraUndoId)->setText(
     label.isEmpty() ? tr("Can't Undo Camera") : QString(tr("U&ndo %1")).arg(label));
@@ -386,7 +392,7 @@ void PVGUI_Module::onCameraUndoLabel(const QString& label)
 /*!
   \brief Manage the label of Redo Camera operation.
 */
-void PVGUI_Module::onCameraRedoLabel(const QString& label)
+void PVGUI_Module::onCameraRedoLabel( const QString& label )
 {
   action(CameraRedoId)->setText(
     label.isEmpty() ? tr("Can't Redo Camera") : QString(tr("R&edo %1")).arg(label));
@@ -408,7 +414,7 @@ void PVGUI_Module::onDeleteAll()
 /*!
   \brief Slot to check/uncheck the action for corresponding selection mode.
 */
-void PVGUI_Module::onSelectionModeChanged(int mode)
+void PVGUI_Module::onSelectionModeChanged( int mode )
 {
   if( toolMgr()->toolBar( mySelectionControlsTb )->isEnabled() ) {
     if(mode == pqRubberBandHelper::SELECT) //surface selection
@@ -429,7 +435,7 @@ void PVGUI_Module::onSelectionModeChanged(int mode)
 /*!
   \brief Slot to manage the change of axis center.
 */
-void PVGUI_Module::onShowCenterAxisChanged(bool enabled)
+void PVGUI_Module::onShowCenterAxisChanged( bool enabled )
 {
   action(ShowCenterId)->setEnabled(enabled);
   action(ShowCenterId)->blockSignals(true);
@@ -442,7 +448,7 @@ void PVGUI_Module::onShowCenterAxisChanged(bool enabled)
 /*!
   \brief Slot to set tooltips for the first anf the last frames, i.e. a time range of animation.
 */
-void PVGUI_Module::setTimeRanges(double start, double end)
+void PVGUI_Module::setTimeRanges( double start, double end )
 {
   action(FirstFrameId)->setToolTip(QString("First Frame (%1)").arg(start, 0, 'g'));
   action(LastFrameId)->setToolTip(QString("Last Frame (%1)").arg(end, 0, 'g'));
@@ -451,7 +457,7 @@ void PVGUI_Module::setTimeRanges(double start, double end)
 /*!
   \brief Slot to manage the plaing process of animation.
 */
-void PVGUI_Module::onPlaying(bool playing)
+void PVGUI_Module::onPlaying( bool playing )
 {
   SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
   if(playing) {
@@ -496,6 +502,166 @@ void PVGUI_Module::onHelpAbout()
   dialog->show();
 }
 
+/*!
+  \brief Slot to show help for proxy.
+*/
+void PVGUI_Module::showHelpForProxy( const QString& proxy )
+{
+  // make sure assistant is ready
+  this->makeAssistant();
+
+  if(this->Implementation->AssistantClient) {
+    this->Implementation->AssistantClient->openAssistant();
+    QString page("%1/Documentation/%2.html");
+    page = page.arg(this->Implementation->DocumentationDir);
+    page = page.arg(proxy);
+    this->Implementation->AssistantClient->showPage(page);
+  }
+}
+
+QString Locate( const QString& appName )
+{
+  QString app_dir = QCoreApplication::applicationDirPath();
+  const char* inst_dirs[] = {
+    "/./",
+    "/../bin/",
+    "/../../bin/",
+    0
+  };
+  for (const char** dir = inst_dirs; *dir; ++dir) {
+    QString path = app_dir;
+    path += *dir;
+    path += appName;
+    //cout << "Checking : " << path.toAscii().data() << " ... ";
+    //cout.flush();
+    QFileInfo finfo (path);
+    if (finfo.exists()) {
+      //cout << " Success!" << endl;
+      return path;
+    }
+    //cout << " Failed" << endl;
+  }
+  return app_dir + QDir::separator() + appName;
+}
+
+/*!
+  \brief Initialized an assistant client.
+*/
+void PVGUI_Module::makeAssistant()
+{
+  if(this->Implementation->AssistantClient)
+    return;
+  
+  QString assistantExe;
+  QString profileFile;
+  
+  const char* assistantName = "assistant";
+#ifdef WNT
+  const char* extString = ".exe";
+  const char* binDir = "\\";
+  const char* binDir1 = "\\..\\";
+#else
+  const char* extString = "";
+  const char* binDir = "/";
+  const char* binDir1 = "/";
+#endif
+
+  QString assistantProgName;
+  assistantProgName = assistantProgName + assistantName + extString;
+
+  QString helper = QCoreApplication::applicationDirPath() + binDir + QString("pqClientDocFinder.txt");
+  if(!QFile::exists(helper))
+    helper = QCoreApplication::applicationDirPath() + binDir1 + QString("pqClientDocFinder.txt");
+  if(QFile::exists(helper)) {
+    QFile file(helper);
+    if(file.open(QIODevice::ReadOnly)) {
+      assistantExe = file.readLine().trimmed() + assistantProgName;
+      profileFile = file.readLine().trimmed();
+    }
+  }
+
+  if(assistantExe.isEmpty()) {
+    assistantExe = ::Locate(assistantProgName);
+    /*
+    QString assistant = QCoreApplication::applicationDirPath();
+    assistant += QDir::separator();
+    assistant += assistantName;
+    assistantExe = assistant;
+    */
+  }
+
+  this->Implementation->AssistantClient = new QAssistantClient(assistantExe, this);
+  QObject::connect(this->Implementation->AssistantClient, SIGNAL(error(const QString&)),
+                   this,                                  SLOT(assistantError(const QString&)));
+
+  QStringList args;
+  args.append(QString("-profile"));
+
+  if(profileFile.isEmpty()) {
+    // see if help is bundled up with the application
+    QString profile = ::Locate("pqClient.adp");
+    /*QCoreApplication::applicationDirPath() + QDir::separator()
+      + QString("pqClient.adp");*/
+    
+    if(QFile::exists(profile))
+      profileFile = profile;
+  }
+
+  if(profileFile.isEmpty() && getenv("PARAVIEW_HELP")) {
+    // not bundled, ask for help
+    args.append(getenv("PARAVIEW_HELP"));
+  }
+  else if(profileFile.isEmpty()) {
+    // no help, error out
+    SUIT_MessageBox::critical(getApp()->desktop(),"Help error", "Couldn't find"
+                             " pqClient.adp.\nTry setting the PARAVIEW_HELP environment variable which"
+                             " points to that file");
+    delete this->Implementation->AssistantClient;
+    return;
+  }
+
+  QFileInfo fi(profileFile);
+  this->Implementation->DocumentationDir = fi.absolutePath();
+
+  args.append(profileFile);
+
+  this->Implementation->AssistantClient->setArguments(args);
+}
+
+/*!
+  \brief Slot to call the message handler with the critical message.
+*/
+void PVGUI_Module::assistantError( const QString& error )
+{
+  qCritical(error.toAscii().data());
+}
+
+/*!
+  \brief Slot to show the waiting state.
+*/
+void PVGUI_Module::onPreAccept()
+{
+  getApp()->desktop()->statusBar()->showMessage(tr("Updating..."));
+  QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
+}
+
+/*!
+  \brief Slot to show the ready state.
+*/
+void PVGUI_Module::onPostAccept()
+{
+  getApp()->desktop()->statusBar()->showMessage(tr("Ready"), 2000);
+  QTimer::singleShot(0, this, SLOT(endWaitCursor()));
+}
+
+/*!
+  \brief Slot to switch off wait cursor.
+*/
+void PVGUI_Module::endWaitCursor()
+{
+  QApplication::restoreOverrideCursor();
+}
+
 /*!
   \brief Returns the ParaView multi-view manager.
 */
index c8c35951e416683038851afe016e2349b92f2620..56efb877f24cf28845ae7eb38c0201bcdaab4e91 100644 (file)
@@ -206,18 +206,26 @@ private slots:
 
   void onDeleteAll();
 
-  void onSelectionModeChanged(int mode);
+  void onSelectionModeChanged( int mode );
 
-  void onShowCenterAxisChanged(bool);
+  void onShowCenterAxisChanged( bool );
 
-  void setTimeRanges(double, double);
+  void setTimeRanges( double, double );
 
-  void onPlaying(bool);
+  void onPlaying( bool );
   
   void onAddCameraLink();
   
   void onHelpAbout();
 
+  void showHelpForProxy( const QString& proxy );
+  void makeAssistant();
+  void assistantError( const QString& err );
+  
+  void onPreAccept();
+  void onPostAccept();
+  void endWaitCursor();
+
 public slots:
   virtual bool           activateModule( SUIT_Study* );
   virtual bool           deactivateModule( SUIT_Study* );
index 5332dba084824903a9cb7145e42589356ca18232..5df5d284115df2eeac8bcc37d3b7762b54e230a2 100644 (file)
@@ -1,4 +1,4 @@
-// LIGHT : sample (no-corba-engine) SALOME module
+// PARAVIS : ParaView wrapper SALOME module
 //
 // Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -67,7 +67,7 @@ void PVGUI_Module::pvCreateActions()
   // Open File
   aPixmap = resMgr->loadPixmap( "ParaView", tr("ICON_OPEN_FILE"), false );
   createAction( OpenFileId, tr("TOP_OPEN_FILE"), QIcon(aPixmap),
-                tr("MEN_OPEN_FILE"), tr("STB_OPEN_FILE"), 
+                tr("MEN_OPEN"), tr("STB_OPEN_FILE"), 
                0, desk, false, &Implementation->Core, SLOT( onFileOpen() ) );
 
   // Load State
@@ -533,6 +533,7 @@ void PVGUI_Module::pvCreateActions()
                              tr("MEN_ENABLE_TOOLTIPS"), 0, desk );
   aQtxAction->setStatusTip( tr( "PRP_APP_ENABLE_TOOLTIPS" ) );
   aQtxAction->setCheckable(true);
+  aQtxAction->setChecked(true);
   registerAction( EnableTooltipsId, aQtxAction );
 }
 
@@ -744,6 +745,7 @@ void PVGUI_Module::pvCreateToolBars()
   // --- Toolbar "Active Variable Controls"
 
   aToolId = createTool( tr("TOOL_ACTIVE_VARIABLE_CONTROLS") );
+  QToolBar* aTB = toolMgr()->toolBar( aToolId );
   
   createTool( ShowColorLegendId, aToolId );
 
@@ -772,11 +774,20 @@ void PVGUI_Module::pvCreateToolBars()
   colorScale->setRescaleAction( aQtxAction ); /// !!!
   createTool( ResetRangeId, aToolId );
 
+  Implementation->Core.setupVariableToolbar(aTB);
+  QList<QAction*> anActns = aTB->actions();
+  for (int i = 0; i < anActns.size(); ++i)
+    if ( anActns.at(i) != action(ShowColorLegendId) ) {
+      createTool( anActns.at(i), aToolId );
+      connect( &Implementation->Core, SIGNAL( enableVariableToolbar(bool) ),
+              anActns.at(i),         SLOT( setEnabled(bool) ) );
+    }
+  
   // --- Toolbar "Representation"
 
-  QToolBar* aTB = toolMgr()->toolBar( createTool( tr("TOOL_REPRESENTATION") ) );
+  aTB = toolMgr()->toolBar( createTool( tr("TOOL_REPRESENTATION") ) );
   Implementation->Core.setupRepresentationToolbar(aTB);
-  QList<QAction*> anActns = aTB->actions();
+  anActns = aTB->actions();
   for (int i = 0; i < anActns.size(); ++i)
     connect( &Implementation->Core, SIGNAL( enableVariableToolbar(bool) ),
             anActns.at(i),         SLOT( setEnabled(bool) ) );
@@ -811,7 +822,10 @@ void PVGUI_Module::pvCreateToolBars()
  
   // --- Toolbar "Lookmarks"
 
-  Implementation->Core.setupLookmarkToolbar(toolMgr()->toolBar(createTool( tr("TOOL_LOOKMARKS") )));
+  aTB = toolMgr()->toolBar(createTool( tr("TOOL_LOOKMARKS") ));
+  aTB->setContextMenuPolicy(Qt::CustomContextMenu);
+  aTB->setOrientation(Qt::Vertical);
+  Implementation->Core.setupLookmarkToolbar(aTB);
 }
 
 /*!
index 72cc7494a818c9884e7a2875d30439c8ff7deef8..e4684a145db348fff253a904e9eea0165040d823 100644 (file)
@@ -28,6 +28,9 @@
 
 #include "PVGUI_Module.h"
 
+#include <QAssistantClient>
+#include <QPointer>
+
 #include <pqMainWindowCore.h>
 
 //////////////////////////////////////////////////////////////////////////////
@@ -37,7 +40,7 @@ class PVGUI_Module::pqImplementation
 {
  public:
   pqImplementation(QWidget* parent) :
-    //AssistantClient(0),
+    AssistantClient(0),
     Core(parent)//,
     //RecentFilesMenu(0),
     //ViewMenu(0),
@@ -49,14 +52,13 @@ class PVGUI_Module::pqImplementation
   {
     //delete this->ViewMenu;
     //delete this->ToolbarsMenu;
-    //if(this->AssistantClient)
-    //  {
-    //  this->AssistantClient->closeAssistant();
-    //  delete this->AssistantClient;
-    //  }
+    if(this->AssistantClient) {
+      this->AssistantClient->closeAssistant();
+      delete this->AssistantClient;
+    }
   }
   
-  //QPointer<QAssistantClient> AssistantClient;
+  QPointer<QAssistantClient> AssistantClient;
   //Ui::MainWindow UI;
   pqMainWindowCore Core;
   //pqRecentFilesMenu* RecentFilesMenu;
index 623976c1f958f17e656add8c766726793ddb07f7..99188d9406de4fa2bcdd3aba471853d4fb07fe5e 100644 (file)
@@ -1,4 +1,4 @@
-// LIGHT : sample (no-corba-engine) SALOME module
+// PARAVIS : ParaView wrapper SALOME module
 //
 // Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 #include <LightApp_Application.h>
 #include <SUIT_Desktop.h>
 
+#include <QAction>
 #include <QDockWidget>
 
 #include <pqAnimationPanel.h>
 #include <pqComparativeVisPanel.h>
 #include <pqMainWindowCore.h>
+#include <pqObjectInspectorWidget.h>
 #include <pqPipelineBrowser.h>
+#include <pqPipelineBrowserContextMenu.h>
 #include <pqPipelineMenu.h>
+#include <pqProxyTabWidget.h>
 
 /*!
   \brief Create dock widgets for ParaView widgets such as object inspector, pipeline browser, etc.
@@ -57,25 +61,13 @@ void PVGUI_Module::setupDockWidgets()
   objectInspectorDock->setAllowedAreas( Qt::LeftDockWidgetArea|Qt::NoDockWidgetArea|Qt::RightDockWidgetArea );
   desk->addDockWidget( Qt::LeftDockWidgetArea, objectInspectorDock );
   pqProxyTabWidget* const proxyTab = Implementation->Core.setupProxyTabWidget( objectInspectorDock );
-  // TODO...
-  /*  QObject::connect(
-    proxyTab->getObjectInspector(),
-    SIGNAL(helpRequested(QString)),
-    this,
-    SLOT(showHelpForProxy(QString)));
-
-  QObject::connect(
-    proxyTab->getObjectInspector(),
-    SIGNAL(preaccept()),
-    this,
-    SLOT(onPreAccept()));
-
-  QObject::connect(
-    proxyTab->getObjectInspector(),
-    SIGNAL(postaccept()),
-    this,
-    SLOT(onPostAccept()));*/
-
+  connect( proxyTab->getObjectInspector(), SIGNAL( helpRequested(QString) ),
+          this,                           SLOT( showHelpForProxy(QString) ) );
+  connect( proxyTab->getObjectInspector(), SIGNAL( preaccept() ),
+          this,                           SLOT( onPreAccept() ) );
+  connect( proxyTab->getObjectInspector(), SIGNAL( postaccept() ),
+          this,                           SLOT( onPostAccept() ) );
+  
   QDockWidget* statisticsViewDock  = new QDockWidget( tr( "Statistics View" ), desk );
   statisticsViewDock->setAllowedAreas( Qt::BottomDockWidgetArea|Qt::LeftDockWidgetArea|Qt::NoDockWidgetArea|Qt::RightDockWidgetArea );
   desk->addDockWidget( Qt::BottomDockWidgetArea, statisticsViewDock );
@@ -136,16 +128,21 @@ void PVGUI_Module::setupDockWidgets()
 */
 void PVGUI_Module::setupDockWidgetsContextMenu()
 {
+  // Pipeline menu
+  Implementation->Core.pipelineMenu().setMenuAction( pqPipelineMenu::ChangeInputAction,
+                                                    action(ChangeInputId) );
+  Implementation->Core.pipelineMenu().setMenuAction( pqPipelineMenu::DeleteAction,
+                                                    action(DeleteId) );
+
+  // Pipeline Browser menu
   pqPipelineBrowser *browser = Implementation->Core.pipelineBrowser();
-  // TODO...
-  /*connect(this->Implementation->UI.actionChangeInput, SIGNAL(triggered()),
-    browser, SLOT(changeInput()));
-  connect(this->Implementation->UI.actionDelete, SIGNAL(triggered()),
-    browser, SLOT(deleteSelected()));
-  pqPipelineBrowserContextMenu *browserMenu =
-    new pqPipelineBrowserContextMenu(browser);
-  browserMenu->setMenuAction(this->Implementation->UI.actionFileOpen);
-  browserMenu->setMenuAction(this->Implementation->UI.actionChangeInput);
-  browserMenu->setMenuAction(this->Implementation->UI.actionDelete);
-  browserMenu->setMenuAction(this->Implementation->UI.actionToolsCreateCustomFilter);*/
+  pqPipelineBrowserContextMenu *browserMenu = new pqPipelineBrowserContextMenu(browser);
+
+  browserMenu->setMenuAction(action(OpenFileId));
+  if ( action(OpenFileId)->text().compare(tr("MEN_OPEN")) == 0 )
+    action(OpenFileId)->setText(tr("MEN_OPEN_FILE"));
+
+  browserMenu->setMenuAction(action(ChangeInputId));
+  browserMenu->setMenuAction(action(DeleteId));
+  browserMenu->setMenuAction(action(CreateCustomFilterId));
 }
index 54b90ea73568994adc6fac4dd11300cd02ab9a5a..6937edc9c18f28aa24ccdb587ef842b9cfeb3902 100644 (file)
         <source>TOP_OPEN_FILE</source>
         <translation>Open File</translation>
     </message>
+    <message>
+        <source>MEN_OPEN</source>
+        <translation>&amp;Open</translation>
+    </message>
     <message>
         <source>MEN_OPEN_FILE</source>
         <translation>&amp;Open File...</translation>