From: abn Date: Wed, 17 Sep 2014 07:31:12 +0000 (+0200) Subject: Renamed the viewer part into PVViewer_* X-Git-Tag: V7_5_0b1~27^2~8 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=91746ab5545e0d924f7b0a5d6f0850e91f35daf6;p=modules%2Fparavis.git Renamed the viewer part into PVViewer_* --- diff --git a/src/PVGUI/PVGUI_Module.cxx b/src/PVGUI/PVGUI_Module.cxx index fb126fec..97679fdf 100644 --- a/src/PVGUI/PVGUI_Module.cxx +++ b/src/PVGUI/PVGUI_Module.cxx @@ -34,9 +34,9 @@ #include CORBA_SERVER_HEADER(SALOME_ModuleCatalog) #include CORBA_SERVER_HEADER(SALOMEDS) -#include "PVGUI_ViewManager.h" -#include "PVGUI_ViewWindow.h" -#include "PVGUI_ViewModel.h" +#include "PVViewer_ViewManager.h" +#include "PVViewer_ViewWindow.h" +#include "PVViewer_ViewModel.h" #include "PVGUI_Tools.h" #include "PVGUI_ParaViewSettingsPane.h" @@ -298,12 +298,12 @@ PVGUI_Module::~PVGUI_Module() PARAVIS_ORB::PARAVIS_Gen_var PVGUI_Module::GetEngine() { - return PVGUI_ViewManager::GetEngine(); + return PVViewer_ViewManager::GetEngine(); } pqPVApplicationCore * PVGUI_Module::GetPVApplication() { - return PVGUI_ViewManager::GetPVApplication(); + return PVViewer_ViewManager::GetPVApplication(); } /*! @@ -333,7 +333,7 @@ void PVGUI_Module::initialize( CAM_Application* app ) // Initialize ParaView client and associated behaviors // and connect to externally launched pvserver - PVGUI_ViewManager::ParaviewInitApp(aDesktop); + PVViewer_ViewManager::ParaviewInitApp(aDesktop); // Remember current state of desktop toolbars QList foreignToolbars = aDesktop->findChildren(); @@ -341,8 +341,8 @@ void PVGUI_Module::initialize( CAM_Application* app ) setupDockWidgets(); // Behaviors and connection must be instanciated *after* widgets are in place: - PVGUI_ViewManager::ParaviewInitBehaviors(true, aDesktop); - PVGUI_ViewManager::ConnectToExternalPVServer(aDesktop); + PVViewer_ViewManager::ParaviewInitBehaviors(true, aDesktop); + PVViewer_ViewManager::ConnectToExternalPVServer(aDesktop); pvCreateActions(); pvCreateToolBars(); @@ -522,18 +522,18 @@ void PVGUI_Module::windows( QMap& m ) const void PVGUI_Module::showView( bool toShow ) { SalomeApp_Application* anApp = getApp(); - PVGUI_ViewManager* viewMgr = - dynamic_cast( anApp->getViewManager( PVGUI_Viewer::Type(), false ) ); + PVViewer_ViewManager* viewMgr = + dynamic_cast( anApp->getViewManager( PVViewer_Viewer::Type(), false ) ); if ( !viewMgr ) { - viewMgr = new PVGUI_ViewManager( anApp->activeStudy(), anApp->desktop() ); + viewMgr = new PVViewer_ViewManager( anApp->activeStudy(), anApp->desktop() ); anApp->addViewManager( viewMgr ); connect( viewMgr, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ), anApp, SLOT( onCloseView( SUIT_ViewManager* ) ) ); } - PVGUI_ViewWindow* pvWnd = dynamic_cast( viewMgr->getActiveView() ); + PVViewer_ViewWindow* pvWnd = dynamic_cast( viewMgr->getActiveView() ); if ( !pvWnd ) { - pvWnd = dynamic_cast( viewMgr->createViewWindow() ); + pvWnd = dynamic_cast( viewMgr->createViewWindow() ); } pvWnd->setShown( toShow ); @@ -715,7 +715,7 @@ bool PVGUI_Module::deactivateModule( SUIT_Study* study ) */ void PVGUI_Module::onApplicationClosed( SUIT_Application* theApp ) { - PVGUI_ViewManager::ParaviewCleanup(); + PVViewer_ViewManager::ParaviewCleanup(); int aAppsNb = SUIT_Session::session()->applications().size(); if (aAppsNb == 1) { diff --git a/src/PVGUI/view/CMakeLists.txt b/src/PVGUI/view/CMakeLists.txt index 231579c5..6ba33bf4 100644 --- a/src/PVGUI/view/CMakeLists.txt +++ b/src/PVGUI/view/CMakeLists.txt @@ -44,15 +44,15 @@ SET(_link_LIBRARIES # header files / to be processed by moc SET(_moc_HEADERS - PVGUI_ViewManager.h - PVGUI_ViewModel.h - PVGUI_ViewWindow.h - PVGUI_Behaviors.h + PVViewer_ViewManager.h + PVViewer_ViewModel.h + PVViewer_ViewWindow.h + PVViewer_Behaviors.h ) # header files / no moc processing SET(_other_HEADERS - PVGUI_LogWindowAdapter.h + PVViewer_LogWindowAdapter.h ) # header files / to install SET(PVViewer_HEADERS ${_moc_HEADERS} ${_other_HEADERS}) @@ -64,11 +64,11 @@ QT4_WRAP_CPP(_moc_SOURCES ${_moc_HEADERS}) # sources / static SET(_other_SOURCES - PVGUI_ViewManager.cxx - PVGUI_ViewModel.cxx - PVGUI_ViewWindow.cxx - PVGUI_LogWindowAdapter.cxx - PVGUI_Behaviors.cxx + PVViewer_ViewManager.cxx + PVViewer_ViewModel.cxx + PVViewer_ViewWindow.cxx + PVViewer_LogWindowAdapter.cxx + PVViewer_Behaviors.cxx ) # sources / to compile diff --git a/src/PVGUI/view/PVGUI_Behaviors.cxx b/src/PVGUI/view/PVGUI_Behaviors.cxx deleted file mode 100644 index 2a1a2a38..00000000 --- a/src/PVGUI/view/PVGUI_Behaviors.cxx +++ /dev/null @@ -1,120 +0,0 @@ -// Copyright (C) 2010-2014 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -// Author: Adrien Bruneton (CEA) - -#include "PVGUI_Behaviors.h" - -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -bool PVGUI_Behaviors::hasMinimalInstanciated = false; - -PVGUI_Behaviors::PVGUI_Behaviors(SUIT_Desktop * parent) - : QObject(static_cast(parent)) -{ -} - -/**! Instanciate minimal ParaView behaviors needed when using an instance of PVViewer. - * This method should be updated at each new version of ParaView with what is found in - * Qt/ApplicationComponents/pqParaViewBehaviors.cxx - */ -void PVGUI_Behaviors::instanciateMinimalBehaviors(SUIT_Desktop * desk) -{ - hasMinimalInstanciated = true; - - // Register ParaView interfaces. - pqInterfaceTracker* pgm = pqApplicationCore::instance()->interfaceTracker(); - - // Register standard types of property widgets. - pgm->addInterface(new pqStandardPropertyWidgetInterface(pgm)); - // Register standard types of view-frame actions. - pgm->addInterface(new pqStandardViewFrameActionsImplementation(pgm)); - - // Load plugins distributed with application. - pqApplicationCore::instance()->loadDistributedPlugins(); - - new pqDefaultViewBehavior(this); // shows a 3D view as soon as a server connection is made - new pqAlwaysConnectedBehavior(this); // client always connected to a server - new pqAutoLoadPluginXMLBehavior(this); // auto load plugins - new pqVerifyRequiredPluginBehavior(this); - new pqPluginSettingsBehavior(this); - new pqFixPathsInStateFilesBehavior(this); - new pqCrashRecoveryBehavior(this); - new pqCommandLineOptionsBehavior(this); -} - -/**! Instanciate usual ParaView behaviors. - * This method should be updated at each new version of ParaView with what is found in - * Qt/ApplicationComponents/pqParaViewBehaviors.cxx - */ -void PVGUI_Behaviors::instanciateAllBehaviors(SUIT_Desktop * desk) -{ - // "new pqParaViewBehaviors(anApp->desktop(), this);" - // -> (which loads all standard ParaView behaviors at once) has to be replaced in order to - // exclude using of pqQtMessageHandlerBehaviour - - // Define application behaviors. - if (!hasMinimalInstanciated) - instanciateMinimalBehaviors(desk); - //new pqQtMessageHandlerBehavior(this); // THIS ONE TO EXCLUDE !! see comment above - new pqDataTimeStepBehavior(this); - new pqSpreadSheetVisibilityBehavior(this); - new pqPipelineContextMenuBehavior(this); - new pqUndoRedoBehavior(this); - new pqPluginDockWidgetsBehavior(desk); - new pqPluginActionGroupBehavior(desk); - new pqPersistentMainWindowStateBehavior(desk); - new pqObjectPickingBehavior(desk); - new pqCollaborationBehavior(this); - new pqViewStreamingBehavior(this); - - pqApplyBehavior* applyBehavior = new pqApplyBehavior(this); - foreach (pqPropertiesPanel* ppanel, desk->findChildren()) - { - applyBehavior->registerPanel(ppanel); - } - -} diff --git a/src/PVGUI/view/PVGUI_Behaviors.h b/src/PVGUI/view/PVGUI_Behaviors.h deleted file mode 100644 index 63639056..00000000 --- a/src/PVGUI/view/PVGUI_Behaviors.h +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (C) 2010-2014 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -// Author: Adrien Bruneton (CEA) - - -#ifndef PVGUIBEHAVIORS_H_ -#define PVGUIBEHAVIORS_H_ - -#include - -class SalomeApp_Module; -class SUIT_Desktop; - -/**! - * PARAVIS behaviors - mimic what is done in - * Qt/ApplicationComponents/pqParaViewBehaviors.cxx - * Except a few ones, behaviors are destroyed when the module is destroyed. - */ -class PVGUI_Behaviors: public QObject -{ - Q_OBJECT - -public: - PVGUI_Behaviors(SUIT_Desktop * parent); - - void instanciateMinimalBehaviors(SUIT_Desktop * desk); - - void instanciateAllBehaviors(SUIT_Desktop * desk); - - virtual ~PVGUI_Behaviors() {} - -private: - static bool hasMinimalInstanciated; -}; - -#endif /* PVGUIBEHAVIORS_H_ */ diff --git a/src/PVGUI/view/PVGUI_LogWindowAdapter.cxx b/src/PVGUI/view/PVGUI_LogWindowAdapter.cxx deleted file mode 100644 index 6469f0f5..00000000 --- a/src/PVGUI/view/PVGUI_LogWindowAdapter.cxx +++ /dev/null @@ -1,119 +0,0 @@ -// Copyright (C) 2010-2014 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "PVGUI_LogWindowAdapter.h" - -#include - -#include -#include -#include -#include - -vtkStandardNewMacro(PVGUI_LogWindowAdapter); - - - -/*! - * Put the message in the log window. - */ -class TEvent: public SALOME_Event { - LogWindow* myWindow; - QString myMsg; - QColor myColor; - int myFlags; - public: - TEvent( LogWindow* theWindow, const QString theMsg, const QColor theColor, const int flags) : - myWindow ( theWindow ), - myMsg ( theMsg ), - myColor ( theColor ), - myFlags (flags) - {} - - virtual void Execute() { - if(myWindow) - myWindow->putMessage(myMsg, myColor, myFlags); - } -}; - - -PVGUI_LogWindowAdapter::PVGUI_LogWindowAdapter() : - TextCount(0), - ErrorCount(0), - WarningCount(0), - GenericWarningCount(0) -{ -} - -PVGUI_LogWindowAdapter::~PVGUI_LogWindowAdapter() -{ -} - -const unsigned int PVGUI_LogWindowAdapter::getTextCount() -{ - return this->TextCount; -} - -const unsigned int PVGUI_LogWindowAdapter::getErrorCount() -{ - return this->ErrorCount; -} - -const unsigned int PVGUI_LogWindowAdapter::getWarningCount() -{ - return this->WarningCount; -} - -const unsigned int PVGUI_LogWindowAdapter::getGenericWarningCount() -{ - return this->GenericWarningCount; -} - -static LogWindow* getLogWindow() -{ - LogWindow* wnd = 0; - LightApp_Application* anApp = dynamic_cast( SUIT_Session::session()->activeApplication() ); - if ( anApp ) - wnd = anApp->logWindow(); - return wnd; -} - -void PVGUI_LogWindowAdapter::DisplayText(const char* text) -{ - ++this->TextCount; - ProcessVoidEvent( new TEvent( getLogWindow(), text, Qt::darkGreen, LogWindow::DisplayNormal )); -} - -void PVGUI_LogWindowAdapter::DisplayErrorText(const char* text) -{ - ++this->ErrorCount; - ProcessVoidEvent( new TEvent( getLogWindow(), text, Qt::darkRed, LogWindow::DisplayNormal )); -} - -void PVGUI_LogWindowAdapter::DisplayWarningText(const char* text) -{ - ++this->WarningCount; - ProcessVoidEvent( new TEvent( getLogWindow(), text, Qt::black, LogWindow::DisplayNormal )); -} - -void PVGUI_LogWindowAdapter::DisplayGenericWarningText(const char* text) -{ - ++this->GenericWarningCount; - ProcessVoidEvent( new TEvent( getLogWindow() , text, Qt::black, LogWindow::DisplayNormal )); -} diff --git a/src/PVGUI/view/PVGUI_LogWindowAdapter.h b/src/PVGUI/view/PVGUI_LogWindowAdapter.h deleted file mode 100644 index ef539420..00000000 --- a/src/PVGUI/view/PVGUI_LogWindowAdapter.h +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright (C) 2010-2014 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef _PVGUI_LogWindowAdapter_h -#define _PVGUI_LogWindowAdapter_h - -#include - -/*! -vtkOutputWindow implementation that puts VTK output messages to SALOME log window. - -To use, create an instance of PVGUI_LogWindowAdapter and pass it to the -vtkOutputWindow::setInstance() static method. - -This class is based on pqOutputWindow ParaView class. -*/ -class PVGUI_LogWindowAdapter : public vtkOutputWindow -{ -public: - static PVGUI_LogWindowAdapter *New(); - vtkTypeMacro(PVGUI_LogWindowAdapter, vtkOutputWindow); - - //! Returns the number of text messages received - const unsigned int getTextCount(); - //! Returns the number of error messages received - const unsigned int getErrorCount(); - //! Returns the number of warning messages received - const unsigned int getWarningCount(); - //! Returns the number of generic warning messages received - const unsigned int getGenericWarningCount(); - -private: - PVGUI_LogWindowAdapter(); - PVGUI_LogWindowAdapter(const PVGUI_LogWindowAdapter&); - PVGUI_LogWindowAdapter& operator=(const PVGUI_LogWindowAdapter&); - ~PVGUI_LogWindowAdapter(); - - unsigned int TextCount; - unsigned int ErrorCount; - unsigned int WarningCount; - unsigned int GenericWarningCount; - - virtual void DisplayText(const char*); - virtual void DisplayErrorText(const char*); - virtual void DisplayWarningText(const char*); - virtual void DisplayGenericWarningText(const char*); -}; - -#endif // !_PVGUI_LogWindowAdapter_h diff --git a/src/PVGUI/view/PVGUI_ViewManager.cxx b/src/PVGUI/view/PVGUI_ViewManager.cxx deleted file mode 100644 index 1688e863..00000000 --- a/src/PVGUI/view/PVGUI_ViewManager.cxx +++ /dev/null @@ -1,218 +0,0 @@ -// Copyright (C) 2010-2014 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -//---------- Static init ----------------- -pqPVApplicationCore* PVGUI_ViewManager::MyCoreApp = 0; -PARAVIS_ORB::PARAVIS_Gen_var PVGUI_ViewManager::MyEngine; - - -/*! - Constructor -*/ -PVGUI_ViewManager::PVGUI_ViewManager( SUIT_Study* study, SUIT_Desktop* desk ) -: SUIT_ViewManager( study, desk, new PVGUI_Viewer() ) -{ - MESSAGE("PARAVIS - view manager created ...") - setTitle( tr( "PARAVIEW_VIEW_TITLE" ) ); -} - -pqPVApplicationCore * PVGUI_ViewManager::GetPVApplication() -{ - return MyCoreApp; -} - -/*! - \brief Static method, performs initialization of ParaView session. - \param fullSetup whether to instanciate all behaviors or just the minimal ones. - \return \c true if ParaView has been initialized successfully, otherwise false -*/ -bool PVGUI_ViewManager::ParaviewInitApp(SUIT_Desktop * aDesktop) -{ - if ( ! MyCoreApp) { - // Obtain command-line arguments - int argc = 0; - char** argv = 0; - QString aOptions = getenv("PARAVIS_OPTIONS"); - QStringList aOptList = aOptions.split(":", QString::SkipEmptyParts); - argv = new char*[aOptList.size() + 1]; - QStringList args = QApplication::arguments(); - argv[0] = (args.size() > 0)? strdup(args[0].toLatin1().constData()) : strdup("paravis"); - argc++; - - foreach (QString aStr, aOptList) { - argv[argc] = strdup( aStr.toLatin1().constData() ); - argc++; - } - MyCoreApp = new pqPVApplicationCore (argc, argv); - if (MyCoreApp->getOptions()->GetHelpSelected() || - MyCoreApp->getOptions()->GetUnknownArgument() || - MyCoreApp->getOptions()->GetErrorMessage() || - MyCoreApp->getOptions()->GetTellVersion()) { - return false; - } - - // Direct VTK log messages to our SALOME window - TODO: review this - vtkOutputWindow::SetInstance(PVGUI_LogWindowAdapter::New()); - - new pqTabbedMultiViewWidget(); // registers a "MULTIVIEW_WIDGET" on creation - - // At this stage, the pqPythonManager has been initialized, i.e. the current process has - // activated the embedded Python interpreter. "paraview" package has also been imported once already. - // Make sure the current process executes paraview's Python command with the "fromGUI" flag. - // This is used in pvsimple.py to avoid reconnecting the GUI thread to the pvserver (when - // user types "import pvsimple" in SALOME's console). - SalomeApp_Application* app = - dynamic_cast< SalomeApp_Application* >(SUIT_Session::session()->activeApplication()); - PyConsole_Interp* pyInterp = app->pythonConsole()->getInterp(); - { - PyLockWrapper aGil; - std::string cmd = "import paraview; paraview.fromGUI = True;"; - pyInterp->run(cmd.c_str()); - } - - for (int i = 0; i < argc; i++) - free(argv[i]); - delete[] argv; - } - - return true; -} - -void PVGUI_ViewManager::ParaviewInitBehaviors(bool fullSetup, SUIT_Desktop* aDesktop) -{ - PVGUI_Behaviors * behav = new PVGUI_Behaviors(aDesktop); - if(fullSetup) - behav->instanciateAllBehaviors(aDesktop); - else - behav->instanciateMinimalBehaviors(aDesktop); -} - -void PVGUI_ViewManager::ParaviewCleanup() -{ - // Disconnect from server - pqServer* server = pqActiveObjects::instance().activeServer(); - if (server && server->isRemote()) - { - MESSAGE("~PVGUI_Module(): Disconnecting from remote server ..."); - pqServerDisconnectReaction::disconnectFromServer(); - } - - pqApplicationCore::instance()->settings()->sync(); - - pqPVApplicationCore * app = GetPVApplication(); - // Schedule destruction of PVApplication singleton: - if (app) - app->deleteLater(); -} - -PARAVIS_ORB::PARAVIS_Gen_var PVGUI_ViewManager::GetEngine() -{ - // initialize PARAVIS module engine (load, if necessary) - if ( CORBA::is_nil( MyEngine ) ) { - Engines::EngineComponent_var comp = - SalomeApp_Application::lcc()->FindOrLoad_Component( "FactoryServer", "PARAVIS" ); - MyEngine = PARAVIS_ORB::PARAVIS_Gen::_narrow( comp ); - } - return MyEngine; -} - -bool PVGUI_ViewManager::ConnectToExternalPVServer(SUIT_Desktop* aDesktop) -{ - pqServer* server = pqActiveObjects::instance().activeServer(); - if (server && server->isRemote()) - { - // Already connected to an external server, do nothing - MESSAGE("connectToExternalPVServer(): Already connected to an external PVServer, won't reconnect."); - return false; - } - - if (GetEngine()->GetGUIConnected()) - { - // Should never be there as the above should already tell us that we are connected. - std::stringstream msg2; - msg2 << "Internal error while connecting to the pvserver."; - msg2 << "ParaView doesn't see a connection, but PARAVIS engine tells us there is already one!" << std::endl; - qWarning(msg2.str().c_str()); // will go to the ParaView console (see ParavisMessageOutput below) - SUIT_MessageBox::warning( aDesktop, - QString("Error connecting to PVServer"), QString(msg2.str().c_str())); - return false; - } - - std::stringstream msg; - - // Try to connect to the external PVServer - gives priority to an externally specified URL: - QString serverUrlEnv = getenv("PARAVIS_PVSERVER_URL"); - std::string serverUrl; - if (!serverUrlEnv.isEmpty()) - serverUrl = serverUrlEnv.toStdString(); - else - { - // Get the URL from the engine (possibly starting the pvserver) - CORBA::String_var url = GetEngine()->FindOrStartPVServer(0); // take the first free port - serverUrl = (char *)url; - } - - msg << "connectToExternalPVServer(): Trying to connect to the external PVServer '" << serverUrl << "' ..."; - MESSAGE(msg.str()); - - if (!pqServerConnectReaction::connectToServer(pqServerResource(serverUrl.c_str()))) - { - std::stringstream msg2; - msg2 << "Error while connecting to the requested pvserver '" << serverUrl; - msg2 << "'. Might use default built-in connection instead!" << std::endl; - qWarning(msg2.str().c_str()); // will go to the ParaView console (see ParavisMessageOutput below) - SUIT_MessageBox::warning( aDesktop, - QString("Error connecting to PVServer"), QString(msg2.str().c_str())); - return false; - } - else - { - MESSAGE("connectToExternalPVServer(): Connected!"); - GetEngine()->SetGUIConnected(true); - } - return true; -} diff --git a/src/PVGUI/view/PVGUI_ViewManager.h b/src/PVGUI/view/PVGUI_ViewManager.h deleted file mode 100644 index be03a4e7..00000000 --- a/src/PVGUI/view/PVGUI_ViewManager.h +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (C) 2010-2014 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#ifndef PVGUI_VIEWMANAGER_H -#define PVGUI_VIEWMANAGER_H - -#include -#include -#include CORBA_SERVER_HEADER(PARAVIS_Gen) - -class SUIT_Desktop; -class SUIT_Study; -class pqTabbedMultiViewWidget; -class pqPVApplicationCore; - -class PVGUI_ViewManager : public SUIT_ViewManager -{ - Q_OBJECT - -public: - PVGUI_ViewManager( SUIT_Study*, SUIT_Desktop* ); - ~PVGUI_ViewManager() {} - - static pqPVApplicationCore * GetPVApplication(); - static PARAVIS_ORB::PARAVIS_Gen_var GetEngine(); - - //! Initialize ParaView if not yet done (once per session) - static bool ParaviewInitApp(SUIT_Desktop* aDesktop); - static void ParaviewInitBehaviors(bool fullSetup=false, SUIT_Desktop* aDesktop=0); - - static void ParaviewCleanup(); - - //! Connect to the external PVServer, using the PARAVIS engine to launch it if it is not - //! already up. - static bool ConnectToExternalPVServer(SUIT_Desktop* aDesktop); - -private: - static pqPVApplicationCore* MyCoreApp; - static PARAVIS_ORB::PARAVIS_Gen_var MyEngine; - -}; - -#endif diff --git a/src/PVGUI/view/PVGUI_ViewModel.cxx b/src/PVGUI/view/PVGUI_ViewModel.cxx deleted file mode 100644 index 98039462..00000000 --- a/src/PVGUI/view/PVGUI_ViewModel.cxx +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2010-2014 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "PVGUI_ViewModel.h" -#include "PVGUI_ViewWindow.h" - -#include -#include - -#include - -//---------------------------------------- -PVGUI_Viewer::PVGUI_Viewer() -:SUIT_ViewModel() -{ - MESSAGE("PVGUI_Viewer: creating view model ..."); -} - - -/*! - Create new instance of view window on desktop \a theDesktop. - \retval SUIT_ViewWindow* - created view window pointer. -*/ -SUIT_ViewWindow* PVGUI_Viewer::createView(SUIT_Desktop* theDesktop) -{ - PVGUI_ViewWindow* aPVView = new PVGUI_ViewWindow(theDesktop, this); - return aPVView; -} - diff --git a/src/PVGUI/view/PVGUI_ViewModel.h b/src/PVGUI/view/PVGUI_ViewModel.h deleted file mode 100644 index 664d15ef..00000000 --- a/src/PVGUI/view/PVGUI_ViewModel.h +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2010-2014 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#if !defined(_PVGUI_VIEWMODEL_H) -#define _PVGUI_VIEWMODEL_H - -#include - -class SUIT_ViewWindow; -class SUIT_Desktop; -class SUIT_Desktop; - -class PVGUI_Viewer: public SUIT_ViewModel -{ - Q_OBJECT - -public: - PVGUI_Viewer(); - virtual ~PVGUI_Viewer() {} - - virtual SUIT_ViewWindow* createView(SUIT_Desktop* theDesktop); - virtual QString getType() const { return Type(); } - static QString Type() { return "ParaView"; } - -}; - -#endif // !defined(_PVGUI_VIEWMODEL_H) - diff --git a/src/PVGUI/view/PVGUI_ViewWindow.cxx b/src/PVGUI/view/PVGUI_ViewWindow.cxx deleted file mode 100644 index a976975b..00000000 --- a/src/PVGUI/view/PVGUI_ViewWindow.cxx +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright (C) 2010-2014 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -// File : PVGUI_ViewWindow.cxx -// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) -// - -#include "PVGUI_ViewWindow.h" - -#include -#include -#include -#include - -#include -#include - -/*! - \class PVGUI_ViewWindow - \brief PVGUI view window. -*/ - -/*! - \brief Constructor. - \param theDesktop parent desktop window - \param theModel plt2d view model -*/ -PVGUI_ViewWindow::PVGUI_ViewWindow( SUIT_Desktop* theDesktop, PVGUI_Viewer* theModel ) - : SUIT_ViewWindow( theDesktop ), myPVMgr( 0 ) -{ - myModel = theModel; - myPVMgr = qobject_cast(pqApplicationCore::instance()->manager("MULTIVIEW_WIDGET")); - if (myPVMgr) { - myPVMgr->setParent( this ); - // This is mandatory, see setParent() method in Qt 4 documentation - myPVMgr->show(); - setCentralWidget( myPVMgr ); - } else - qDebug("No multiViewManager defined"); -} - -/*! - \brief Destructor. - As pqViewManager persists through the whole session, - the destructor first removes it from the children of this PVGUI_ViewWindow - to prevent its unexpected deletion. -*/ -PVGUI_ViewWindow::~PVGUI_ViewWindow() -{ - if ( myPVMgr ) { - myPVMgr->setParent( 0 ); - myPVMgr->hide(); - myPVMgr = 0; - setCentralWidget( 0 ); - } -} - -/*! - \brief Get the visual parameters of the view window. - \return visual parameters of this view window formatted to the string -*/ -QString PVGUI_ViewWindow::getVisualParameters() -{ - return SUIT_ViewWindow::getVisualParameters(); -} - -/*! - \brief Restore visual parameters of the view window from the formated string - \param parameters view window visual parameters -*/ -void PVGUI_ViewWindow::setVisualParameters( const QString& parameters ) -{ - SUIT_ViewWindow::setVisualParameters( parameters ); -} - - -/*! - \brief Returns the ParaView multi-view manager previously set with setMultiViewManager() -*/ -pqTabbedMultiViewWidget* PVGUI_ViewWindow::getMultiViewManager() const -{ - return myPVMgr; -} diff --git a/src/PVGUI/view/PVGUI_ViewWindow.h b/src/PVGUI/view/PVGUI_ViewWindow.h deleted file mode 100644 index 48f97c29..00000000 --- a/src/PVGUI/view/PVGUI_ViewWindow.h +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (C) 2010-2014 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -// File : Plot2d_ViewWindow.h -// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) -// - -#ifndef PVGUI_VIEWWINDOW_H -#define PVGUI_VIEWWINDOW_H - -#include -#include - -class SUIT_Desktop; -class PVGUI_Viewer; -class pqTabbedMultiViewWidget; - -class PVGUI_ViewWindow : public SUIT_ViewWindow -{ - Q_OBJECT - -public: - PVGUI_ViewWindow( SUIT_Desktop*, PVGUI_Viewer* ); - virtual ~PVGUI_ViewWindow(); - - virtual QString getVisualParameters(); - virtual void setVisualParameters( const QString& ); - - pqTabbedMultiViewWidget* getMultiViewManager() const; - -private: - PVGUI_Viewer* myModel; - pqTabbedMultiViewWidget* myPVMgr; -}; - -#endif // PLOT2D_VIEWWINDOW_H diff --git a/src/PVGUI/view/PVViewer_Behaviors.cxx b/src/PVGUI/view/PVViewer_Behaviors.cxx new file mode 100644 index 00000000..417cd65c --- /dev/null +++ b/src/PVGUI/view/PVViewer_Behaviors.cxx @@ -0,0 +1,120 @@ +// Copyright (C) 2010-2014 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// Author: Adrien Bruneton (CEA) + +#include "PVViewer_Behaviors.h" + +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +bool PVViewer_Behaviors::hasMinimalInstanciated = false; + +PVViewer_Behaviors::PVViewer_Behaviors(SUIT_Desktop * parent) + : QObject(static_cast(parent)) +{ +} + +/**! Instanciate minimal ParaView behaviors needed when using an instance of PVViewer. + * This method should be updated at each new version of ParaView with what is found in + * Qt/ApplicationComponents/pqParaViewBehaviors.cxx + */ +void PVViewer_Behaviors::instanciateMinimalBehaviors(SUIT_Desktop * desk) +{ + hasMinimalInstanciated = true; + + // Register ParaView interfaces. + pqInterfaceTracker* pgm = pqApplicationCore::instance()->interfaceTracker(); + + // Register standard types of property widgets. + pgm->addInterface(new pqStandardPropertyWidgetInterface(pgm)); + // Register standard types of view-frame actions. + pgm->addInterface(new pqStandardViewFrameActionsImplementation(pgm)); + + // Load plugins distributed with application. + pqApplicationCore::instance()->loadDistributedPlugins(); + + new pqDefaultViewBehavior(this); // shows a 3D view as soon as a server connection is made + new pqAlwaysConnectedBehavior(this); // client always connected to a server + new pqAutoLoadPluginXMLBehavior(this); // auto load plugins + new pqVerifyRequiredPluginBehavior(this); + new pqPluginSettingsBehavior(this); + new pqFixPathsInStateFilesBehavior(this); + new pqCrashRecoveryBehavior(this); + new pqCommandLineOptionsBehavior(this); +} + +/**! Instanciate usual ParaView behaviors. + * This method should be updated at each new version of ParaView with what is found in + * Qt/ApplicationComponents/pqParaViewBehaviors.cxx + */ +void PVViewer_Behaviors::instanciateAllBehaviors(SUIT_Desktop * desk) +{ + // "new pqParaViewBehaviors(anApp->desktop(), this);" + // -> (which loads all standard ParaView behaviors at once) has to be replaced in order to + // exclude using of pqQtMessageHandlerBehaviour + + // Define application behaviors. + if (!hasMinimalInstanciated) + instanciateMinimalBehaviors(desk); + //new pqQtMessageHandlerBehavior(this); // THIS ONE TO EXCLUDE !! see comment above + new pqDataTimeStepBehavior(this); + new pqSpreadSheetVisibilityBehavior(this); + new pqPipelineContextMenuBehavior(this); + new pqUndoRedoBehavior(this); + new pqPluginDockWidgetsBehavior(desk); + new pqPluginActionGroupBehavior(desk); + new pqPersistentMainWindowStateBehavior(desk); + new pqObjectPickingBehavior(desk); + new pqCollaborationBehavior(this); + new pqViewStreamingBehavior(this); + + pqApplyBehavior* applyBehavior = new pqApplyBehavior(this); + foreach (pqPropertiesPanel* ppanel, desk->findChildren()) + { + applyBehavior->registerPanel(ppanel); + } + +} diff --git a/src/PVGUI/view/PVViewer_Behaviors.h b/src/PVGUI/view/PVViewer_Behaviors.h new file mode 100644 index 00000000..6e99c26c --- /dev/null +++ b/src/PVGUI/view/PVViewer_Behaviors.h @@ -0,0 +1,52 @@ +// Copyright (C) 2010-2014 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// Author: Adrien Bruneton (CEA) + + +#ifndef PVGUIBEHAVIORS_H_ +#define PVGUIBEHAVIORS_H_ + +#include + +class SalomeApp_Module; +class SUIT_Desktop; + +/**! + * PARAVIS behaviors - mimic what is done in + * Qt/ApplicationComponents/pqParaViewBehaviors.cxx + * Except a few ones, behaviors are destroyed when the module is destroyed. + */ +class PVViewer_Behaviors: public QObject +{ + Q_OBJECT + +public: + PVViewer_Behaviors(SUIT_Desktop * parent); + + void instanciateMinimalBehaviors(SUIT_Desktop * desk); + + void instanciateAllBehaviors(SUIT_Desktop * desk); + + virtual ~PVViewer_Behaviors() {} + +private: + static bool hasMinimalInstanciated; +}; + +#endif /* PVGUIBEHAVIORS_H_ */ diff --git a/src/PVGUI/view/PVViewer_LogWindowAdapter.cxx b/src/PVGUI/view/PVViewer_LogWindowAdapter.cxx new file mode 100644 index 00000000..736b77b6 --- /dev/null +++ b/src/PVGUI/view/PVViewer_LogWindowAdapter.cxx @@ -0,0 +1,119 @@ +// Copyright (C) 2010-2014 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "PVViewer_LogWindowAdapter.h" + +#include + +#include +#include +#include +#include + +vtkStandardNewMacro(PVViewer_LogWindowAdapter); + + + +/*! + * Put the message in the log window. + */ +class TEvent: public SALOME_Event { + LogWindow* myWindow; + QString myMsg; + QColor myColor; + int myFlags; + public: + TEvent( LogWindow* theWindow, const QString theMsg, const QColor theColor, const int flags) : + myWindow ( theWindow ), + myMsg ( theMsg ), + myColor ( theColor ), + myFlags (flags) + {} + + virtual void Execute() { + if(myWindow) + myWindow->putMessage(myMsg, myColor, myFlags); + } +}; + + +PVViewer_LogWindowAdapter::PVViewer_LogWindowAdapter() : + TextCount(0), + ErrorCount(0), + WarningCount(0), + GenericWarningCount(0) +{ +} + +PVViewer_LogWindowAdapter::~PVViewer_LogWindowAdapter() +{ +} + +const unsigned int PVViewer_LogWindowAdapter::getTextCount() +{ + return this->TextCount; +} + +const unsigned int PVViewer_LogWindowAdapter::getErrorCount() +{ + return this->ErrorCount; +} + +const unsigned int PVViewer_LogWindowAdapter::getWarningCount() +{ + return this->WarningCount; +} + +const unsigned int PVViewer_LogWindowAdapter::getGenericWarningCount() +{ + return this->GenericWarningCount; +} + +static LogWindow* getLogWindow() +{ + LogWindow* wnd = 0; + LightApp_Application* anApp = dynamic_cast( SUIT_Session::session()->activeApplication() ); + if ( anApp ) + wnd = anApp->logWindow(); + return wnd; +} + +void PVViewer_LogWindowAdapter::DisplayText(const char* text) +{ + ++this->TextCount; + ProcessVoidEvent( new TEvent( getLogWindow(), text, Qt::darkGreen, LogWindow::DisplayNormal )); +} + +void PVViewer_LogWindowAdapter::DisplayErrorText(const char* text) +{ + ++this->ErrorCount; + ProcessVoidEvent( new TEvent( getLogWindow(), text, Qt::darkRed, LogWindow::DisplayNormal )); +} + +void PVViewer_LogWindowAdapter::DisplayWarningText(const char* text) +{ + ++this->WarningCount; + ProcessVoidEvent( new TEvent( getLogWindow(), text, Qt::black, LogWindow::DisplayNormal )); +} + +void PVViewer_LogWindowAdapter::DisplayGenericWarningText(const char* text) +{ + ++this->GenericWarningCount; + ProcessVoidEvent( new TEvent( getLogWindow() , text, Qt::black, LogWindow::DisplayNormal )); +} diff --git a/src/PVGUI/view/PVViewer_LogWindowAdapter.h b/src/PVGUI/view/PVViewer_LogWindowAdapter.h new file mode 100644 index 00000000..cd8332a8 --- /dev/null +++ b/src/PVGUI/view/PVViewer_LogWindowAdapter.h @@ -0,0 +1,65 @@ +// Copyright (C) 2010-2014 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef _PVViewer_LogWindowAdapter_h +#define _PVViewer_LogWindowAdapter_h + +#include + +/*! +vtkOutputWindow implementation that puts VTK output messages to SALOME log window. + +To use, create an instance of PVViewer_LogWindowAdapter and pass it to the +vtkOutputWindow::setInstance() static method. + +This class is based on pqOutputWindow ParaView class. +*/ +class PVViewer_LogWindowAdapter : public vtkOutputWindow +{ +public: + static PVViewer_LogWindowAdapter *New(); + vtkTypeMacro(PVViewer_LogWindowAdapter, vtkOutputWindow); + + //! Returns the number of text messages received + const unsigned int getTextCount(); + //! Returns the number of error messages received + const unsigned int getErrorCount(); + //! Returns the number of warning messages received + const unsigned int getWarningCount(); + //! Returns the number of generic warning messages received + const unsigned int getGenericWarningCount(); + +private: + PVViewer_LogWindowAdapter(); + PVViewer_LogWindowAdapter(const PVViewer_LogWindowAdapter&); + PVViewer_LogWindowAdapter& operator=(const PVViewer_LogWindowAdapter&); + ~PVViewer_LogWindowAdapter(); + + unsigned int TextCount; + unsigned int ErrorCount; + unsigned int WarningCount; + unsigned int GenericWarningCount; + + virtual void DisplayText(const char*); + virtual void DisplayErrorText(const char*); + virtual void DisplayWarningText(const char*); + virtual void DisplayGenericWarningText(const char*); +}; + +#endif // !_PVViewer_LogWindowAdapter_h diff --git a/src/PVGUI/view/PVViewer_ViewManager.cxx b/src/PVGUI/view/PVViewer_ViewManager.cxx new file mode 100644 index 00000000..b187ca44 --- /dev/null +++ b/src/PVGUI/view/PVViewer_ViewManager.cxx @@ -0,0 +1,218 @@ +// Copyright (C) 2010-2014 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +//---------- Static init ----------------- +pqPVApplicationCore* PVViewer_ViewManager::MyCoreApp = 0; +PARAVIS_ORB::PARAVIS_Gen_var PVViewer_ViewManager::MyEngine; + + +/*! + Constructor +*/ +PVViewer_ViewManager::PVViewer_ViewManager( SUIT_Study* study, SUIT_Desktop* desk ) +: SUIT_ViewManager( study, desk, new PVViewer_Viewer() ) +{ + MESSAGE("PARAVIS - view manager created ...") + setTitle( tr( "PARAVIEW_VIEW_TITLE" ) ); +} + +pqPVApplicationCore * PVViewer_ViewManager::GetPVApplication() +{ + return MyCoreApp; +} + +/*! + \brief Static method, performs initialization of ParaView session. + \param fullSetup whether to instanciate all behaviors or just the minimal ones. + \return \c true if ParaView has been initialized successfully, otherwise false +*/ +bool PVViewer_ViewManager::ParaviewInitApp(SUIT_Desktop * aDesktop) +{ + if ( ! MyCoreApp) { + // Obtain command-line arguments + int argc = 0; + char** argv = 0; + QString aOptions = getenv("PARAVIS_OPTIONS"); + QStringList aOptList = aOptions.split(":", QString::SkipEmptyParts); + argv = new char*[aOptList.size() + 1]; + QStringList args = QApplication::arguments(); + argv[0] = (args.size() > 0)? strdup(args[0].toLatin1().constData()) : strdup("paravis"); + argc++; + + foreach (QString aStr, aOptList) { + argv[argc] = strdup( aStr.toLatin1().constData() ); + argc++; + } + MyCoreApp = new pqPVApplicationCore (argc, argv); + if (MyCoreApp->getOptions()->GetHelpSelected() || + MyCoreApp->getOptions()->GetUnknownArgument() || + MyCoreApp->getOptions()->GetErrorMessage() || + MyCoreApp->getOptions()->GetTellVersion()) { + return false; + } + + // Direct VTK log messages to our SALOME window - TODO: review this + vtkOutputWindow::SetInstance(PVViewer_LogWindowAdapter::New()); + + new pqTabbedMultiViewWidget(); // registers a "MULTIVIEW_WIDGET" on creation + + // At this stage, the pqPythonManager has been initialized, i.e. the current process has + // activated the embedded Python interpreter. "paraview" package has also been imported once already. + // Make sure the current process executes paraview's Python command with the "fromGUI" flag. + // This is used in pvsimple.py to avoid reconnecting the GUI thread to the pvserver (when + // user types "import pvsimple" in SALOME's console). + SalomeApp_Application* app = + dynamic_cast< SalomeApp_Application* >(SUIT_Session::session()->activeApplication()); + PyConsole_Interp* pyInterp = app->pythonConsole()->getInterp(); + { + PyLockWrapper aGil; + std::string cmd = "import paraview; paraview.fromGUI = True;"; + pyInterp->run(cmd.c_str()); + } + + for (int i = 0; i < argc; i++) + free(argv[i]); + delete[] argv; + } + + return true; +} + +void PVViewer_ViewManager::ParaviewInitBehaviors(bool fullSetup, SUIT_Desktop* aDesktop) +{ + PVViewer_Behaviors * behav = new PVViewer_Behaviors(aDesktop); + if(fullSetup) + behav->instanciateAllBehaviors(aDesktop); + else + behav->instanciateMinimalBehaviors(aDesktop); +} + +void PVViewer_ViewManager::ParaviewCleanup() +{ + // Disconnect from server + pqServer* server = pqActiveObjects::instance().activeServer(); + if (server && server->isRemote()) + { + MESSAGE("~PVViewer_Module(): Disconnecting from remote server ..."); + pqServerDisconnectReaction::disconnectFromServer(); + } + + pqApplicationCore::instance()->settings()->sync(); + + pqPVApplicationCore * app = GetPVApplication(); + // Schedule destruction of PVApplication singleton: + if (app) + app->deleteLater(); +} + +PARAVIS_ORB::PARAVIS_Gen_var PVViewer_ViewManager::GetEngine() +{ + // initialize PARAVIS module engine (load, if necessary) + if ( CORBA::is_nil( MyEngine ) ) { + Engines::EngineComponent_var comp = + SalomeApp_Application::lcc()->FindOrLoad_Component( "FactoryServer", "PARAVIS" ); + MyEngine = PARAVIS_ORB::PARAVIS_Gen::_narrow( comp ); + } + return MyEngine; +} + +bool PVViewer_ViewManager::ConnectToExternalPVServer(SUIT_Desktop* aDesktop) +{ + pqServer* server = pqActiveObjects::instance().activeServer(); + if (server && server->isRemote()) + { + // Already connected to an external server, do nothing + MESSAGE("connectToExternalPVServer(): Already connected to an external PVServer, won't reconnect."); + return false; + } + + if (GetEngine()->GetGUIConnected()) + { + // Should never be there as the above should already tell us that we are connected. + std::stringstream msg2; + msg2 << "Internal error while connecting to the pvserver."; + msg2 << "ParaView doesn't see a connection, but PARAVIS engine tells us there is already one!" << std::endl; + qWarning(msg2.str().c_str()); // will go to the ParaView console (see ParavisMessageOutput below) + SUIT_MessageBox::warning( aDesktop, + QString("Error connecting to PVServer"), QString(msg2.str().c_str())); + return false; + } + + std::stringstream msg; + + // Try to connect to the external PVServer - gives priority to an externally specified URL: + QString serverUrlEnv = getenv("PARAVIS_PVSERVER_URL"); + std::string serverUrl; + if (!serverUrlEnv.isEmpty()) + serverUrl = serverUrlEnv.toStdString(); + else + { + // Get the URL from the engine (possibly starting the pvserver) + CORBA::String_var url = GetEngine()->FindOrStartPVServer(0); // take the first free port + serverUrl = (char *)url; + } + + msg << "connectToExternalPVServer(): Trying to connect to the external PVServer '" << serverUrl << "' ..."; + MESSAGE(msg.str()); + + if (!pqServerConnectReaction::connectToServer(pqServerResource(serverUrl.c_str()))) + { + std::stringstream msg2; + msg2 << "Error while connecting to the requested pvserver '" << serverUrl; + msg2 << "'. Might use default built-in connection instead!" << std::endl; + qWarning(msg2.str().c_str()); // will go to the ParaView console (see ParavisMessageOutput below) + SUIT_MessageBox::warning( aDesktop, + QString("Error connecting to PVServer"), QString(msg2.str().c_str())); + return false; + } + else + { + MESSAGE("connectToExternalPVServer(): Connected!"); + GetEngine()->SetGUIConnected(true); + } + return true; +} diff --git a/src/PVGUI/view/PVViewer_ViewManager.h b/src/PVGUI/view/PVViewer_ViewManager.h new file mode 100644 index 00000000..fe389603 --- /dev/null +++ b/src/PVGUI/view/PVViewer_ViewManager.h @@ -0,0 +1,58 @@ +// Copyright (C) 2010-2014 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#ifndef PVViewer_VIEWMANAGER_H +#define PVViewer_VIEWMANAGER_H + +#include +#include +#include CORBA_SERVER_HEADER(PARAVIS_Gen) + +class SUIT_Desktop; +class SUIT_Study; +class pqTabbedMultiViewWidget; +class pqPVApplicationCore; + +class PVViewer_ViewManager : public SUIT_ViewManager +{ + Q_OBJECT + +public: + PVViewer_ViewManager( SUIT_Study*, SUIT_Desktop* ); + ~PVViewer_ViewManager() {} + + static pqPVApplicationCore * GetPVApplication(); + static PARAVIS_ORB::PARAVIS_Gen_var GetEngine(); + + //! Initialize ParaView if not yet done (once per session) + static bool ParaviewInitApp(SUIT_Desktop* aDesktop); + static void ParaviewInitBehaviors(bool fullSetup=false, SUIT_Desktop* aDesktop=0); + + static void ParaviewCleanup(); + + //! Connect to the external PVServer, using the PARAVIS engine to launch it if it is not + //! already up. + static bool ConnectToExternalPVServer(SUIT_Desktop* aDesktop); + +private: + static pqPVApplicationCore* MyCoreApp; + static PARAVIS_ORB::PARAVIS_Gen_var MyEngine; + +}; + +#endif diff --git a/src/PVGUI/view/PVViewer_ViewModel.cxx b/src/PVGUI/view/PVViewer_ViewModel.cxx new file mode 100644 index 00000000..ef1771eb --- /dev/null +++ b/src/PVGUI/view/PVViewer_ViewModel.cxx @@ -0,0 +1,45 @@ +// Copyright (C) 2010-2014 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "PVViewer_ViewModel.h" +#include "PVViewer_ViewWindow.h" + +#include +#include + +#include + +//---------------------------------------- +PVViewer_Viewer::PVViewer_Viewer() +:SUIT_ViewModel() +{ + MESSAGE("PVViewer_Viewer: creating view model ..."); +} + + +/*! + Create new instance of view window on desktop \a theDesktop. + \retval SUIT_ViewWindow* - created view window pointer. +*/ +SUIT_ViewWindow* PVViewer_Viewer::createView(SUIT_Desktop* theDesktop) +{ + PVViewer_ViewWindow* aPVView = new PVViewer_ViewWindow(theDesktop, this); + return aPVView; +} + diff --git a/src/PVGUI/view/PVViewer_ViewModel.h b/src/PVGUI/view/PVViewer_ViewModel.h new file mode 100644 index 00000000..6463c7ac --- /dev/null +++ b/src/PVGUI/view/PVViewer_ViewModel.h @@ -0,0 +1,43 @@ +// Copyright (C) 2010-2014 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#if !defined(_PVViewer_VIEWMODEL_H) +#define _PVViewer_VIEWMODEL_H + +#include + +class SUIT_ViewWindow; +class SUIT_Desktop; +class SUIT_Desktop; + +class PVViewer_Viewer: public SUIT_ViewModel +{ + Q_OBJECT + +public: + PVViewer_Viewer(); + virtual ~PVViewer_Viewer() {} + + virtual SUIT_ViewWindow* createView(SUIT_Desktop* theDesktop); + virtual QString getType() const { return Type(); } + static QString Type() { return "ParaView"; } + +}; + +#endif // !defined(_PVViewer_VIEWMODEL_H) + diff --git a/src/PVGUI/view/PVViewer_ViewWindow.cxx b/src/PVGUI/view/PVViewer_ViewWindow.cxx new file mode 100644 index 00000000..84e37f0e --- /dev/null +++ b/src/PVGUI/view/PVViewer_ViewWindow.cxx @@ -0,0 +1,98 @@ +// Copyright (C) 2010-2014 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : PVViewer_ViewWindow.cxx +// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) +// + +#include "PVViewer_ViewWindow.h" + +#include +#include +#include +#include + +#include +#include + +/*! + \class PVViewer_ViewWindow + \brief PVGUI view window. +*/ + +/*! + \brief Constructor. + \param theDesktop parent desktop window + \param theModel plt2d view model +*/ +PVViewer_ViewWindow::PVViewer_ViewWindow( SUIT_Desktop* theDesktop, PVViewer_Viewer* theModel ) + : SUIT_ViewWindow( theDesktop ), myPVMgr( 0 ) +{ + myModel = theModel; + myPVMgr = qobject_cast(pqApplicationCore::instance()->manager("MULTIVIEW_WIDGET")); + if (myPVMgr) { + myPVMgr->setParent( this ); + // This is mandatory, see setParent() method in Qt 4 documentation + myPVMgr->show(); + setCentralWidget( myPVMgr ); + } else + qDebug("No multiViewManager defined"); +} + +/*! + \brief Destructor. + As pqViewManager persists through the whole session, + the destructor first removes it from the children of this PVViewer_ViewWindow + to prevent its unexpected deletion. +*/ +PVViewer_ViewWindow::~PVViewer_ViewWindow() +{ + if ( myPVMgr ) { + myPVMgr->setParent( 0 ); + myPVMgr->hide(); + myPVMgr = 0; + setCentralWidget( 0 ); + } +} + +/*! + \brief Get the visual parameters of the view window. + \return visual parameters of this view window formatted to the string +*/ +QString PVViewer_ViewWindow::getVisualParameters() +{ + return SUIT_ViewWindow::getVisualParameters(); +} + +/*! + \brief Restore visual parameters of the view window from the formated string + \param parameters view window visual parameters +*/ +void PVViewer_ViewWindow::setVisualParameters( const QString& parameters ) +{ + SUIT_ViewWindow::setVisualParameters( parameters ); +} + + +/*! + \brief Returns the ParaView multi-view manager previously set with setMultiViewManager() +*/ +pqTabbedMultiViewWidget* PVViewer_ViewWindow::getMultiViewManager() const +{ + return myPVMgr; +} diff --git a/src/PVGUI/view/PVViewer_ViewWindow.h b/src/PVGUI/view/PVViewer_ViewWindow.h new file mode 100644 index 00000000..fb5dd106 --- /dev/null +++ b/src/PVGUI/view/PVViewer_ViewWindow.h @@ -0,0 +1,51 @@ +// Copyright (C) 2010-2014 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : Plot2d_ViewWindow.h +// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) +// + +#ifndef PVViewer_VIEWWINDOW_H +#define PVViewer_VIEWWINDOW_H + +#include +#include + +class SUIT_Desktop; +class PVViewer_Viewer; +class pqTabbedMultiViewWidget; + +class PVViewer_ViewWindow : public SUIT_ViewWindow +{ + Q_OBJECT + +public: + PVViewer_ViewWindow( SUIT_Desktop*, PVViewer_Viewer* ); + virtual ~PVViewer_ViewWindow(); + + virtual QString getVisualParameters(); + virtual void setVisualParameters( const QString& ); + + pqTabbedMultiViewWidget* getMultiViewManager() const; + +private: + PVViewer_Viewer* myModel; + pqTabbedMultiViewWidget* myPVMgr; +}; + +#endif // PLOT2D_VIEWWINDOW_H