1 // PARAVIS : ParaView wrapper SALOME module
3 // Copyright (C) 2010-2014 CEA/DEN, EDF R&D
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 // File : PVGUI_Module.cxx
23 #include <Standard_math.hxx> // E.A. must be included before Python.h to fix compilation on windows
25 #undef HAVE_FINITE // VSR: avoid compilation warning on Linux : "HAVE_FINITE" redefined
27 #include <vtkPython.h> // Python first
28 #include "PVGUI_Module.h"
30 #ifdef PARAVIS_WITH_FULL_CORBA
31 # include "PARAVIS_Gen_i.hh"
34 #include CORBA_SERVER_HEADER(SALOME_ModuleCatalog)
35 #include CORBA_SERVER_HEADER(SALOMEDS)
37 #include "PVGUI_ViewModel.h"
38 #include "PVGUI_ViewManager.h"
39 #include "PVGUI_ViewWindow.h"
40 #include "PVGUI_Tools.h"
41 #include "PVGUI_ParaViewSettingsPane.h"
42 #include "PVGUI_OutputWindowAdapter.h"
43 #include "PVGUI_Behaviors.h"
45 #include <SUIT_DataBrowser.h>
46 #include <SUIT_Desktop.h>
47 #include <SUIT_MessageBox.h>
48 #include <SUIT_ResourceMgr.h>
49 #include <SUIT_Session.h>
50 #include <SUIT_OverrideCursor.h>
51 #include <SUIT_ExceptionHandler.h>
54 #include "SALOME_LifeCycleCORBA.hxx"
55 #include "SALOMEDS_SObject.hxx"
57 #include "LightApp_SelectionMgr.h"
58 #include "LightApp_NameDlg.h"
60 #include <SalomeApp_Application.h>
61 #include <SalomeApp_Study.h>
62 #include <SALOME_ListIO.hxx>
63 #include <SALOMEDS_Tool.hxx>
64 #include <PyInterp_Interp.h>
65 #include <PyInterp_Dispatcher.h>
66 #include <PyConsole_Console.h>
67 #include <PyConsole_Interp.h>
71 #include <QtxActionMenuMgr.h>
72 #include <QtxActionToolMgr.h>
75 #include <QApplication>
81 #include <QInputDialog>
85 #include <QStringList>
88 #include <QTextStream>
90 #include <QDockWidget>
91 #include <QHelpEngine>
93 #include <pqApplicationCore.h>
94 #include <pqPVApplicationCore.h>
95 #include <pqActiveView.h>
96 #include <pqObjectBuilder.h>
97 #include <pqOptions.h>
98 #include <pqRenderView.h>
100 #include <pqUndoStack.h>
101 #include <pqVCRController.h>
102 #include <pqTabbedMultiViewWidget.h>
103 #include <pqPipelineSource.h>
104 #include <pqActiveObjects.h>
105 #include <vtkProcessModule.h>
106 #include <vtkSMSession.h>
107 #include <vtkPVSession.h>
108 #include <vtkPVProgressHandler.h>
109 #include <pqParaViewBehaviors.h>
110 #include <pqHelpReaction.h>
111 #include <vtkOutputWindow.h>
112 #include <pqPluginManager.h>
113 #include <pqSettings.h>
114 #include <pqPythonDialog.h>
115 #include <pqPythonManager.h>
116 #include <pqPythonShell.h>
117 #include <pqLoadDataReaction.h>
118 #include <vtkEventQtSlotConnect.h>
119 #include <pqPythonScriptEditor.h>
120 #include <pqDataRepresentation.h>
121 #include <pqPipelineRepresentation.h>
122 //#include <pqLookupTableManager.h>
123 #include <pqDisplayColorWidget.h>
124 #include <pqColorToolbar.h>
125 #include <pqScalarBarVisibilityReaction.h>
126 #include <pqStandardPropertyWidgetInterface.h>
127 #include <pqStandardViewFrameActionsImplementation.h>
128 #include <pqViewStreamingBehavior.h>
130 #include <PARAVIS_version.h>
132 #include <vtkPVConfig.h>
134 #include <pqServerResource.h>
135 #include <pqServerConnectReaction.h>
136 #include <pqServerDisconnectReaction.h>
138 #include <pqApplicationCore.h>
139 #include <pqAutoLoadPluginXMLBehavior.h>
140 #include <pqCommandLineOptionsBehavior.h>
141 #include <pqCrashRecoveryBehavior.h>
142 #include <pqDataTimeStepBehavior.h>
143 #include <pqDefaultViewBehavior.h>
144 #include <pqObjectPickingBehavior.h>
145 #include <pqPersistentMainWindowStateBehavior.h>
146 #include <pqPipelineContextMenuBehavior.h>
147 #include <pqPluginActionGroupBehavior.h>
148 #include <pqPluginDockWidgetsBehavior.h>
149 #include <pqPluginManager.h>
150 #include <pqSpreadSheetVisibilityBehavior.h>
151 #include <pqUndoRedoBehavior.h>
152 #include <pqServerManagerObserver.h>
153 #include <pqVerifyRequiredPluginBehavior.h>
154 #include <pqFixPathsInStateFilesBehavior.h>
155 #include <pqPluginSettingsBehavior.h>
156 #include <pqPropertiesPanel.h>
158 #include <pqApplyBehavior.h>
160 #include <vtkClientServerInterpreterInitializer.h>
161 #include <vtkPVConfig.h>
165 #include <vtkSMTrace.h>
166 #include <vtkSMSessionProxyManager.h>
167 #include <vtkSMParaViewPipelineController.h>
169 //----------------------------------------------------------------------------
170 pqPVApplicationCore* PVGUI_Module::MyCoreApp = 0;
172 PVGUI_Module* ParavisModule = 0;
174 PARAVIS_ORB::PARAVIS_Gen_var PVGUI_Module::myEngine;
179 <h2>Building and installing PARAVIS</h2>
180 As any other SALOME module, PARAVIS requires PARAVIS_ROOT_DIR environment variable to be set to PARAVIS
181 installation directory.
182 Other variables needed for correct detection of ParaView location:
183 \li PVHOME - points at the ParaView installation directory tree
184 \li PVVERSION - number of ParaView version
186 It also requires common SALOME environment including GUI_ROOT_DIR and other prerequsites.
189 PARAVIS module can be launched using the following commands:
190 \li Full SALOME configuration
192 runSalome --modules="PARAVIS"
195 <h2>ParaView GUI integration</h2>
196 <h3>ParaView GUI integration overview</h3>
198 The main idea is to reuse ParaView GUI internal logic as much as possible, providing a layer
199 between it and SALOME GUI that hides the following SALOME GUI implementation details from ParaView:
201 \li SALOME GUI executable and Qt event loop
202 \li SALOME GUI desktop
203 \li Dock windows areas
204 \li SALOME menu and toolbar managers
206 Major part of the integration is implemented in PVGUI_Module class.
208 <h3>ParaView client initalization</h3>
210 ParaView client initalization is performed when an instance of PVGUI_Module class has been created
211 and \link PVGUI_Module::initialize() PVGUI_Module::initialize()\endlink method is called by SALOME GUI.
212 The actual client start-up is done in \link PVGUI_Module::pvInit() PVGUI_Module::pvInit()\endlink method.
215 <h3>Multi-view manager</h3>
217 SALOME GUI requires that each kind of view be implemnted with help of (at least) three classes. For ParaView multi-view manager
220 \li PVGUI_ViewManager - view manager class
221 \li PVGUI_Viewer - view model class
222 \li PVGUI_ViewWindow - view window class that acts as a parent for %pqViewManager
224 Single instances of PVGUI_ViewManager and PVGUI_ViewWindow classes are created by \link PVGUI_Module::showView()
225 PVGUI_Module::showView()\endlink method upon the first PARAVIS module activation. The same method hides the multi-view manager
226 when the module is deactivated (the user switches to another module or a study is closed).
227 A special trick is used to make PVGUI_ViewWindow the parent of %pqViewManager widget. It is created initally by %pqMainWindowCore
228 with the desktop as a parent, so when it is shown PVGUI_ViewWindow instance is passed to its setParent() method. In
229 \link PVGUI_ViewWindow::~PVGUI_ViewWindow() PVGUI_ViewWindow::~PVGUI_ViewWindow()\endlink the parent is nullified to avoid deletion
230 of %pqViewManager widget that would break %pqMainWindowCore class.
232 <h3>ParaView plugins</h3>
233 ParaView server and client plugins are managed by %pqMainWindowCore slots that has full access to PARAVIS menus and toolbars.
234 As a result they appears automatically in PARAVIS menus and toolbars if loaded successfully.
239 \brief Implementation
240 SALOME module wrapping ParaView GUI.
244 ClientFindOrCreateParavisComponent(_PTR(Study) theStudyDocument)
246 _PTR(SComponent) aSComponent = theStudyDocument->FindComponent("PARAVIS");
248 _PTR(StudyBuilder) aStudyBuilder = theStudyDocument->NewBuilder();
249 aStudyBuilder->NewCommand();
250 int aLocked = theStudyDocument->GetProperties()->IsLocked();
251 if (aLocked) theStudyDocument->GetProperties()->SetLocked(false);
252 aSComponent = aStudyBuilder->NewComponent("PARAVIS");
253 _PTR(GenericAttribute) anAttr =
254 aStudyBuilder->FindOrCreateAttribute(aSComponent, "AttributeName");
255 _PTR(AttributeName) aName (anAttr);
257 //CORBA::ORB_var anORB = PARAVIS::PARAVIS_Gen_i::GetORB();
259 CORBA::ORB_var anORB = CORBA::ORB_init(dnu, 0); // suppose ORB was already initialized
260 SALOME_NamingService *NamingService = new SALOME_NamingService( anORB );
261 CORBA::Object_var objVarN = NamingService->Resolve("/Kernel/ModulCatalog");
262 SALOME_ModuleCatalog::ModuleCatalog_var Catalogue =
263 SALOME_ModuleCatalog::ModuleCatalog::_narrow(objVarN);
264 SALOME_ModuleCatalog::Acomponent_var Comp = Catalogue->GetComponent( "PARAVIS" );
265 if (!Comp->_is_nil()) {
266 aName->SetValue(Comp->componentusername());
269 anAttr = aStudyBuilder->FindOrCreateAttribute(aSComponent, "AttributePixMap");
270 _PTR(AttributePixMap) aPixmap (anAttr);
271 aPixmap->SetPixMap( "pqAppIcon16.png" );
273 // Create Attribute parameters for future using
274 anAttr = aStudyBuilder->FindOrCreateAttribute(aSComponent, "AttributeParameter");
276 aStudyBuilder->DefineComponentInstance(aSComponent, PVGUI_Module::GetEngine()->GetIOR());
277 if (aLocked) theStudyDocument->GetProperties()->SetLocked(true);
278 aStudyBuilder->CommitCommand();
284 Clean up function; used to stop ParaView progress events when
285 exception is caught by global exception handler.
287 void paravisCleanUp()
289 if ( pqApplicationCore::instance() ) {
290 pqServer* s = pqApplicationCore::instance()->getActiveServer();
291 if ( s ) s->session()->GetProgressHandler()->CleanupPendingProgress();
296 \brief Constructor. Sets the default name for the module.
298 PVGUI_Module::PVGUI_Module()
299 : SalomeApp_Module( "PARAVIS" ),
300 mySelectionControlsTb( -1 ),
301 mySourcesMenuId( -1 ),
302 myFiltersMenuId( -1 ),
304 myToolbarsMenuId(-1),
313 Q_INIT_RESOURCE( PVGUI );
315 ParavisModule = this;
317 // Clear old copies of embedded macros files
318 QString aDestPath = QString( "%1/.config/%2/Macros" ).arg( QDir::homePath() ).arg( QApplication::applicationName() );
322 QDir aDestDir(aDestPath);
323 QStringList aDestFiles = aDestDir.entryList(aFilter, QDir::Files);
324 foreach (QString aMacrosPath, getEmbeddedMacrosList()) {
325 QString aMacrosName = QFileInfo(aMacrosPath).fileName();
326 if (aDestFiles.contains(aMacrosName)) {
327 aDestDir.remove(aMacrosName);
335 PVGUI_Module::~PVGUI_Module()
337 if (myPushTraceTimer)
338 delete myPushTraceTimer;
341 // Disconnect from server
342 pqServer* server = pqActiveObjects::instance().activeServer();
343 if (server && server->isRemote())
345 MESSAGE("~PVGUI_Module(): Disconnecting from remote server ...");
346 pqServerDisconnectReaction::disconnectFromServer();
350 PARAVIS_ORB::PARAVIS_Gen_var PVGUI_Module::GetEngine()
352 // initialize PARAVIS module engine (load, if necessary)
353 if ( CORBA::is_nil( myEngine ) ) {
354 Engines::EngineComponent_var comp =
355 SalomeApp_Application::lcc()->FindOrLoad_Component( "FactoryServer", "PARAVIS" );
356 myEngine = PARAVIS_ORB::PARAVIS_Gen::_narrow( comp );
362 \brief Initialize module. Creates menus, prepares context menu, etc.
363 \param app SALOME GUI application instance
365 void PVGUI_Module::initialize( CAM_Application* app )
367 SalomeApp_Module::initialize( app );
369 // Create ParaViS actions
371 // Create ParaViS menus
374 // Uncomment to debug ParaView initialization
375 // "aa" used instead of "i" as GDB doesn't like "i" variables :)
383 // Initialize ParaView client
386 // Create GUI elements (menus, toolbars, dock widgets)
387 SalomeApp_Application* anApp = getApp();
388 SUIT_Desktop* aDesktop = anApp->desktop();
390 // Remember current state of desktop toolbars
391 QList<QToolBar*> foreignToolbars = aDesktop->findChildren<QToolBar*>();
399 QList<QDockWidget*> activeDocks = aDesktop->findChildren<QDockWidget*>();
400 QList<QMenu*> activeMenus = aDesktop->findChildren<QMenu*>();
402 PVGUI_Behaviors * behav = new PVGUI_Behaviors(this);
403 behav->instanciateAllBehaviors(aDesktop);
405 // Setup quick-launch shortcuts.
406 QShortcut *ctrlSpace = new QShortcut(Qt::CTRL + Qt::Key_Space, aDesktop);
407 QObject::connect(ctrlSpace, SIGNAL(activated()),
408 pqApplicationCore::instance(), SLOT(quickLaunch()));
410 // Find Plugin Dock Widgets
411 QList<QDockWidget*> currentDocks = aDesktop->findChildren<QDockWidget*>();
412 QList<QDockWidget*>::iterator i;
413 for (i = currentDocks.begin(); i != currentDocks.end(); ++i) {
414 if(!activeDocks.contains(*i)) {
415 myDockWidgets[*i] = false; // hidden by default
421 // [ABN] TODO: fix this - triggers a SEGFAULT at deactivation() time.
422 // QList<QMenu*> currentMenus = aDesktop->findChildren<QMenu*>();
423 // QList<QMenu*>::iterator im;
424 // for (im = currentMenus.begin(); im != currentMenus.end(); ++im) {
425 // if(!activeMenus.contains(*im)) {
426 // QString s = (*im)->title();
427 // std::cout << " MENU "<< s.toStdString() << std::endl;
428 // myMenus.append(*im);
432 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
433 QString aPath = resMgr->stringValue("resources", "PARAVIS", QString());
434 if (!aPath.isNull()) {
435 MyCoreApp->loadConfiguration(aPath + QDir::separator() + "ParaViewFilters.xml");
436 MyCoreApp->loadConfiguration(aPath + QDir::separator() + "ParaViewReaders.xml");
437 MyCoreApp->loadConfiguration(aPath + QDir::separator() + "ParaViewSources.xml");
438 MyCoreApp->loadConfiguration(aPath + QDir::separator() + "ParaViewWriters.xml");
441 // Force creation of the PARAVIS engine
445 // Find created toolbars
446 QCoreApplication::processEvents();
448 QList<QToolBar*> allToolbars = aDesktop->findChildren<QToolBar*>();
449 foreach(QToolBar* aBar, allToolbars) {
450 if (!foreignToolbars.contains(aBar)) {
451 myToolbars[aBar] = true;
452 myToolbarBreaks[aBar] = false;
453 aBar->setVisible(false);
454 aBar->toggleViewAction()->setVisible(false);
460 // we need to start trace after connection is done
461 connect(pqApplicationCore::instance()->getObjectBuilder(), SIGNAL(finishedAddingServer(pqServer*)),
462 this, SLOT(onFinishedAddingServer(pqServer*)));
464 connect(pqApplicationCore::instance()->getObjectBuilder(), SIGNAL(dataRepresentationCreated(pqDataRepresentation*)),
465 this, SLOT(onDataRepresentationCreated(pqDataRepresentation*)));
467 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
468 bool isStop = aResourceMgr->booleanValue( "PARAVIS", "stop_trace", false );
471 // Start a timer to schedule asap:
472 // - the connection to the server
474 myInitTimer = new QTimer(aDesktop);
475 QObject::connect(myInitTimer, SIGNAL(timeout()), this, SLOT(onInitTimer()) );
476 myInitTimer->setSingleShot(true);
477 myInitTimer->start(0);
479 // Another timer to regularly push the trace onto the engine:
480 myPushTraceTimer = new QTimer(aDesktop);
481 QObject::connect(myPushTraceTimer, SIGNAL(timeout()), this, SLOT(onPushTraceTimer()) );
482 myPushTraceTimer->setSingleShot(false);
483 myPushTraceTimer->start(500);
486 this->VTKConnect = vtkEventQtSlotConnect::New();
488 vtkProcessModule* pm = vtkProcessModule::GetProcessModule();
490 vtkPVSession* pvs = dynamic_cast<vtkPVSession*>(pm->GetSession());
492 vtkPVProgressHandler* ph = pvs->GetProgressHandler();
494 this->VTKConnect->Connect(ph, vtkCommand::StartEvent,
495 this, SLOT(onStartProgress()));
496 this->VTKConnect->Connect(ph, vtkCommand::EndEvent,
497 this, SLOT(onEndProgress()));
502 connect(&pqActiveObjects::instance(),
503 SIGNAL(representationChanged(pqRepresentation*)),
504 this, SLOT(onRepresentationChanged(pqRepresentation*)));
507 bool PVGUI_Module::connectToExternalPVServer()
509 pqServer* server = pqActiveObjects::instance().activeServer();
510 if (server && server->isRemote())
512 // Already connected to an external server, do nothing
513 MESSAGE("connectToExternalPVServer(): Already connected to an external PVServer, won't reconnect.");
517 std::stringstream msg;
519 // Try to connect to the external PVServer - gives priority to an externally specified URL:
520 QString serverUrlEnv = getenv("PARAVIS_PVSERVER_URL");
521 std::string serverUrl;
522 if (!serverUrlEnv.isEmpty())
523 serverUrl = serverUrlEnv.toStdString();
526 // Get the URL from the engine (possibly starting the pvserver)
527 CORBA::String_var url = GetEngine()->FindOrStartPVServer(0); // take the first free port
528 serverUrl = (char *)url;
531 msg << "connectToExternalPVServer(): Trying to connect to the external PVServer '" << serverUrl << "' ...";
534 if (!pqServerConnectReaction::connectToServer(pqServerResource(serverUrl.c_str())))
536 std::stringstream msg2;
537 msg2 << "Error while connecting to the requested pvserver '" << serverUrl;
538 msg2 << "'. Might use default built-in connection instead!" << std::endl;
539 qWarning(msg2.str().c_str()); // will go to the ParaView console (see ParavisMessageOutput below)
540 SUIT_MessageBox::warning( getApp()->desktop(),
541 QString("Error connecting to PVServer"), QString(msg2.str().c_str()));
545 MESSAGE("connectToExternalPVServer(): Connected!");
549 void PVGUI_Module::onStartProgress()
551 QApplication::setOverrideCursor(Qt::WaitCursor);
554 void PVGUI_Module::onEndProgress()
556 QApplication::restoreOverrideCursor();
559 void PVGUI_Module::onFinishedAddingServer(pqServer* /*server*/)
561 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
562 bool isStop = aResourceMgr->booleanValue( "PARAVIS", "stop_trace", false );
567 void PVGUI_Module::onDataRepresentationCreated(pqDataRepresentation* data) {
571 // if(!data->getLookupTable())
574 // SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
578 // bool visible = aResourceMgr->booleanValue( "PARAVIS", "show_color_legend", false );
579 // pqLookupTableManager* lut_mgr = pqApplicationCore::instance()->getLookupTableManager();
582 // lut_mgr->setScalarBarVisibility(data,visible);
585 // connect(data, SIGNAL(dataUpdated()), this, SLOT(onDataRepresentationUpdated()));
588 void PVGUI_Module::onDataRepresentationUpdated() {
589 SalomeApp_Study* activeStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
590 if(!activeStudy) return;
592 activeStudy->Modified();
595 void PVGUI_Module::onVariableChanged(pqVariableType t, const QString) {
597 pqDisplayColorWidget* colorWidget = qobject_cast<pqDisplayColorWidget*>(sender());
601 if( t == VARIABLE_TYPE_NONE )
604 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
609 bool visible = aResourceMgr->booleanValue( "PARAVIS", "show_color_legend", false );
614 /*//VTN: getRepresentation is protected
615 pqDataRepresentation* data = colorWidget->getRepresentation();
617 if( !data->getLookupTable() )
620 pqLookupTableManager* lut_mgr = pqApplicationCore::instance()->getLookupTableManager();
623 lut_mgr->setScalarBarVisibility(data,visible);
626 pqColorToolbar* colorTooBar = qobject_cast<pqColorToolbar*>(colorWidget->parent());
630 pqScalarBarVisibilityReaction* scalarBarVisibility = colorTooBar->findChild<pqScalarBarVisibilityReaction *>();
631 if(scalarBarVisibility) {
632 scalarBarVisibility->setScalarBarVisibility(visible);
637 \brief Initialisation timer event - fired only once, after the GUI loop is ready.
638 See creation in initialize().
640 void PVGUI_Module::onInitTimer()
642 #ifndef PARAVIS_WITH_FULL_CORBA
643 connectToExternalPVServer();
648 \brief Get list of embedded macros files
650 QStringList PVGUI_Module::getEmbeddedMacrosList()
652 QString aRootDir = getenv("PARAVIS_ROOT_DIR");
654 QString aSourcePath = aRootDir + "/bin/salome/Macro";
659 QDir aSourceDir(aSourcePath);
660 QStringList aSourceFiles = aSourceDir.entryList(aFilter, QDir::Files);
661 QStringList aFullPathSourceFiles;
662 foreach (QString aMacrosName, aSourceFiles) {
663 aFullPathSourceFiles << aSourceDir.absoluteFilePath(aMacrosName);
665 return aFullPathSourceFiles;
668 void PVGUI_Module::updateMacros()
670 pqPythonManager* aPythonManager = pqPVApplicationCore::instance()->pythonManager();
671 if(!aPythonManager) {
675 foreach (QString aStr, getEmbeddedMacrosList()) {
676 aPythonManager->addMacro(aStr);
682 \brief Get list of compliant dockable GUI elements
683 \param m map to be filled in ("type":"default_position")
685 void PVGUI_Module::windows( QMap<int, int>& m ) const
687 m.insert( LightApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
688 m.insert( LightApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
689 // ParaView diagnostic output redirected here
690 m.insert( LightApp_Application::WT_LogWindow, Qt::BottomDockWidgetArea );
694 \brief Static method, performs initialization of ParaView session.
695 \return \c true if ParaView has been initialized successfully, otherwise false
697 bool PVGUI_Module::pvInit()
699 // if ( !pqImplementation::Core ){
701 // Obtain command-line arguments
704 QString aOptions = getenv("PARAVIS_OPTIONS");
705 QStringList aOptList = aOptions.split(":", QString::SkipEmptyParts);
706 argv = new char*[aOptList.size() + 1];
707 QStringList args = QApplication::arguments();
708 argv[0] = (args.size() > 0)? strdup(args[0].toLatin1().constData()) : strdup("paravis");
711 foreach (QString aStr, aOptList) {
712 argv[argc] = strdup( aStr.toLatin1().constData() );
715 MyCoreApp = new pqPVApplicationCore (argc, argv);
716 if (MyCoreApp->getOptions()->GetHelpSelected() ||
717 MyCoreApp->getOptions()->GetUnknownArgument() ||
718 MyCoreApp->getOptions()->GetErrorMessage() ||
719 MyCoreApp->getOptions()->GetTellVersion()) {
723 /* VTN: Looks like trash. For porting see branded_paraview_initializer.cxx.in
724 // Not sure why this is needed. Andy added this ages ago with comment saying
725 // needed for Mac apps. Need to check that it's indeed still required.
726 QDir dir(QApplication::applicationDirPath());
729 QApplication::addLibraryPath(dir.absolutePath());
730 // Load required application plugins.
731 QString plugin_string = "";
732 QStringList plugin_list = plugin_string.split(';',QString::SkipEmptyParts);
733 pqBrandPluginsLoader loader;
734 if (loader.loadPlugins(plugin_list) == false) {
735 printf("Failed to load required plugins for this application\n");
739 // Load optional plugins.
741 plugin_list = plugin_string.split(';',QString::SkipEmptyParts);
742 loader.loadPlugins(plugin_list, true); //quietly skip not-found plugins.
744 // End of Initializer code
746 MyCoreApp->settings();
748 vtkOutputWindow::SetInstance(PVGUI_OutputWindowAdapter::New());
750 new pqTabbedMultiViewWidget(); // it registers as "MULTIVIEW_WIDGET on creation
752 for (int i = 0; i < argc; i++)
761 \brief Shows (toShow = true) or hides ParaView view window
763 void PVGUI_Module::showView( bool toShow )
765 SalomeApp_Application* anApp = getApp();
766 PVGUI_ViewManager* viewMgr =
767 dynamic_cast<PVGUI_ViewManager*>( anApp->getViewManager( PVGUI_Viewer::Type(), false ) );
769 viewMgr = new PVGUI_ViewManager( anApp->activeStudy(), anApp->desktop() );
770 anApp->addViewManager( viewMgr );
771 connect( viewMgr, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
772 anApp, SLOT( onCloseView( SUIT_ViewManager* ) ) );
775 PVGUI_ViewWindow* pvWnd = dynamic_cast<PVGUI_ViewWindow*>( viewMgr->getActiveView() );
777 pvWnd = dynamic_cast<PVGUI_ViewWindow*>( viewMgr->createViewWindow() );
780 pvWnd->setShown( toShow );
781 if ( toShow ) pvWnd->setFocus();
785 \brief Slot to show help for proxy.
787 void PVGUI_Module::showHelpForProxy( const QString& groupname, const QString& proxyname )
789 pqHelpReaction::showProxyHelp(groupname, proxyname);
794 \brief Slot to show the waiting state.
796 void PVGUI_Module::onPreAccept()
798 getApp()->desktop()->statusBar()->showMessage(tr("STB_PREACCEPT"));
799 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
803 \brief Slot to show the ready state.
805 void PVGUI_Module::onPostAccept()
807 getApp()->desktop()->statusBar()->showMessage(tr("STB_POSTACCEPT"), 2000);
808 QTimer::singleShot(0, this, SLOT(endWaitCursor()));
812 \brief Slot to switch off wait cursor.
814 void PVGUI_Module::endWaitCursor()
816 QApplication::restoreOverrideCursor();
820 \brief Returns the ParaView multi-view manager.
822 pqTabbedMultiViewWidget* PVGUI_Module::getMultiViewManager() const
824 return qobject_cast<pqTabbedMultiViewWidget*>(pqApplicationCore::instance()->manager("MULTIVIEW_WIDGET"));
828 static void ParavisMessageOutput(QtMsgType type, const char *msg)
833 vtkOutputWindow::GetInstance()->DisplayText(msg);
836 vtkOutputWindow::GetInstance()->DisplayErrorText(msg);
839 vtkOutputWindow::GetInstance()->DisplayErrorText(msg);
842 vtkOutputWindow::GetInstance()->DisplayErrorText(msg);
850 \brief Activate module.
851 \param study current study
852 \return \c true if activaion is done successfully or 0 to prevent
855 bool PVGUI_Module::activateModule( SUIT_Study* study )
857 myOldMsgHandler = qInstallMsgHandler(ParavisMessageOutput);
859 SUIT_ExceptionHandler::addCleanUpRoutine( paravisCleanUp );
861 storeCommonWindowsState();
863 bool isDone = SalomeApp_Module::activateModule( study );
864 if ( !isDone ) return false;
867 if ( mySourcesMenuId != -1 ) menuMgr()->show(mySourcesMenuId);
868 if ( myFiltersMenuId != -1 ) menuMgr()->show(myFiltersMenuId);
869 if ( myFiltersMenuId != -1 ) menuMgr()->show(myMacrosMenuId);
870 if ( myFiltersMenuId != -1 ) menuMgr()->show(myToolbarsMenuId);
871 setMenuShown( true );
872 setToolShown( true );
874 restoreDockWidgetsState();
876 QMenu* aMenu = menuMgr()->findMenu( myRecentMenuId );
878 QList<QAction*> anActns = aMenu->actions();
879 for (int i = 0; i < anActns.size(); ++i) {
880 QAction* a = anActns.at(i);
886 QList<QMenu*>::iterator it;
887 for (it = myMenus.begin(); it != myMenus.end(); ++it) {
888 QAction* a = (*it)->menuAction();
893 if ( myRecentMenuId != -1 ) menuMgr()->show(myRecentMenuId);
895 ClientFindOrCreateParavisComponent(PARAVIS::GetCStudy(this));
902 \brief Deactivate module.
903 \param study current study
904 \return \c true if deactivaion is done successfully or 0 to prevent
905 deactivation on error
907 bool PVGUI_Module::deactivateModule( SUIT_Study* study )
909 MESSAGE("PARAVIS deactivation ...")
911 QMenu* aMenu = menuMgr()->findMenu( myRecentMenuId );
913 QList<QAction*> anActns = aMenu->actions();
914 for (int i = 0; i < anActns.size(); ++i) {
915 QAction* a = anActns.at(i);
917 a->setVisible(false);
921 QList<QMenu*>::iterator it;
922 for (it = myMenus.begin(); it != myMenus.end(); ++it) {
923 QAction* a = (*it)->menuAction();
925 a->setVisible(false);
928 QList<QDockWidget*> aStreamingViews = application()->desktop()->findChildren<QDockWidget*>("pqStreamingControls");
929 foreach(QDockWidget* aView, aStreamingViews) {
930 if (!myDockWidgets.contains(aView))
931 myDockWidgets[aView] = aView->isVisible();
934 /*if (pqImplementation::helpWindow) {
935 pqImplementation::helpWindow->hide();
939 menuMgr()->hide(myRecentMenuId);
940 menuMgr()->hide(mySourcesMenuId);
941 menuMgr()->hide(myFiltersMenuId);
942 menuMgr()->hide(myMacrosMenuId);
943 menuMgr()->hide(myToolbarsMenuId);
944 setMenuShown( false );
945 setToolShown( false );
947 saveDockWidgetsState();
949 SUIT_ExceptionHandler::removeCleanUpRoutine( paravisCleanUp );
952 qInstallMsgHandler(myOldMsgHandler);
954 restoreCommonWindowsState();
956 return SalomeApp_Module::deactivateModule( study );
961 \brief Called when application is closed.
963 Process finalize application functionality from ParaView in order to save server settings
964 and nullify application pointer if the application is being closed.
966 \param theApp application
968 void PVGUI_Module::onApplicationClosed( SUIT_Application* theApp )
970 pqApplicationCore::instance()->settings()->sync();
971 int aAppsNb = SUIT_Session::session()->applications().size();
973 deleteTemporaryFiles();
974 MyCoreApp->deleteLater();
976 CAM_Module::onApplicationClosed(theApp);
981 \brief Deletes temporary files created during import operation from VISU
983 void PVGUI_Module::deleteTemporaryFiles()
985 foreach(QString aFile, myTemporaryFiles) {
986 if (QFile::exists(aFile)) {
987 QFile::remove(aFile);
994 \brief Called when study is closed.
996 Removes data model from the \a study.
998 \param study study being closed
1000 void PVGUI_Module::studyClosed(SUIT_Study* study)
1002 clearParaviewState();
1004 SalomeApp_Module::studyClosed(study);
1008 \brief Called when study is opened.
1010 void PVGUI_Module::onModelOpened()
1012 _PTR(Study) studyDS = PARAVIS::GetCStudy(this);
1017 _PTR(SComponent) paravisComp =
1018 studyDS->FindComponent(GetEngine()->ComponentDataType());
1023 _PTR(ChildIterator) anIter(studyDS->NewChildIterator(paravisComp));
1024 for (; anIter->More(); anIter->Next()) {
1025 _PTR(SObject) aSObj = anIter->Value();
1026 _PTR(GenericAttribute) anAttr;
1027 if (!aSObj->FindAttribute(anAttr, "AttributeLocalID")) {
1030 _PTR(AttributeLocalID) anID(anAttr);
1031 if (anID->Value() == PVSTATEID) {
1038 \brief Returns IOR of current engine
1040 QString PVGUI_Module::engineIOR() const
1042 CORBA::String_var anIOR = GetEngine()->GetIOR();
1043 return QString(anIOR.in());
1048 \brief Open file of format supported by ParaView
1050 void PVGUI_Module::openFile(const char* theName)
1054 pqLoadDataReaction::loadData(aFiles);
1058 * Start trace invoking the newly introduced C++ API (PV 4.2)
1059 * (inspired from pqTraceReaction::start())
1061 void PVGUI_Module::startTrace()
1063 vtkSMSessionProxyManager* pxm = pqActiveObjects::instance().activeServer()->proxyManager();
1065 vtkSmartPointer<vtkSMProxy> proxy;
1066 proxy.TakeReference(pxm->NewProxy("pythontracing", "PythonTraceOptions"));
1069 vtkNew<vtkSMParaViewPipelineController> controller;
1070 controller->InitializeProxy(proxy);
1072 vtkSMTrace* trace = vtkSMTrace::StartTrace();
1075 // Set manually the properties entered via the dialog box poping-up when requiring
1076 // a trace start in PV4.2 (trace options)
1077 trace->SetPropertiesToTraceOnCreate(vtkSMTrace::RECORD_USER_MODIFIED_PROPERTIES);
1078 trace->SetFullyTraceSupplementalProxies(false);
1082 void PVGUI_Module::stopTrace()
1084 vtkSMTrace::StopTrace();
1087 void PVGUI_Module::executeScript(const char *script)
1090 pqPythonManager* manager = qobject_cast<pqPythonManager*>(
1091 pqApplicationCore::instance()->manager("PYTHON_MANAGER"));
1093 pqPythonDialog* pyDiag = manager->pythonShellDialog();
1095 pyDiag->runString(script);
1102 // * Debug function printing out the given interpreter's execution context
1104 //void printInterpContext(PyInterp_Interp * interp )
1106 // // Extract __smtraceString from interpreter's context
1107 // const PyObject* ctxt = interp->getExecutionContext();
1109 // PyObject* lst = PyDict_Keys((PyObject *)ctxt);
1110 // Py_ssize_t siz = PyList_GET_SIZE(lst);
1111 // for (Py_ssize_t i = 0; i < siz; i++)
1113 // PyObject * elem = PyList_GetItem(lst, i);
1114 // if (PyString_Check(elem))
1116 // std::cout << "At pos:" << i << ", " << PyString_AsString(elem) << std::endl;
1119 // std::cout << "At pos:" << i << ", not a string!" << std::endl;
1125 \brief Returns trace string
1127 static const QString MYReplaceStr("paraview.simple");
1128 static const QString MYReplaceImportStr("except: from pvsimple import *");
1129 QString PVGUI_Module::getTraceString()
1131 vtkSMTrace *tracer = vtkSMTrace::GetActiveTracer();
1132 if (!tracer) // trace is not started
1135 QString traceString(tracer->GetCurrentTrace());
1137 // Replace import "paraview.simple" by "pvsimple"
1138 if ((!traceString.isNull()) && traceString.length() != 0) {
1139 int aPos = traceString.indexOf(MYReplaceStr);
1140 while (aPos != -1) {
1141 traceString = traceString.replace(aPos, MYReplaceStr.length(), "pvsimple");
1142 aPos = traceString.indexOf(MYReplaceStr, aPos);
1144 int aImportPos = traceString.indexOf(MYReplaceImportStr);
1145 if(aImportPos != -1)
1147 traceString = traceString.replace(aImportPos, MYReplaceImportStr.length(), "except:\n import pvsimple\n from pvsimple import *");
1155 \brief Saves trace string to disk file
1157 void PVGUI_Module::saveTrace(const char* theName)
1159 QFile file(theName);
1160 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
1161 MESSAGE( "Could not open file:" << theName );
1164 QTextStream out(&file);
1165 out << getTraceString();
1170 \brief Saves ParaView state to a disk file
1172 void PVGUI_Module::saveParaviewState(const char* theFileName)
1174 pqApplicationCore::instance()->saveState(theFileName);
1178 \brief Delete all objects for Paraview Pipeline Browser
1180 void PVGUI_Module::clearParaviewState()
1182 QAction* deleteAllAction = action(DeleteAllId);
1183 if (deleteAllAction) {
1184 deleteAllAction->activate(QAction::Trigger);
1189 \brief Restores ParaView state from a disk file
1191 If toClear == true, the current ojects will be deleted
1193 void PVGUI_Module::loadParaviewState(const char* theFileName)
1195 pqApplicationCore::instance()->loadState(theFileName, getActiveServer());
1199 \brief Returns current active ParaView server
1201 pqServer* PVGUI_Module::getActiveServer()
1203 return pqApplicationCore::instance()->getActiveServer();
1208 \brief Creates PARAVIS preference pane
1210 void PVGUI_Module::createPreferences()
1212 // Paraview settings tab
1213 int aParaViewSettingsTab = addPreference( tr( "TIT_PVIEWSETTINGS" ) );
1214 int aPanel = addPreference(QString(), aParaViewSettingsTab, LightApp_Preferences::UserDefined, "PARAVIS", "");
1215 setPreferenceProperty(aPanel, "content", (qint64)(new PVGUI_ParaViewSettingsPane()));
1217 // Paravis settings tab
1218 int aParaVisSettingsTab = addPreference( tr( "TIT_PVISSETTINGS" ) );
1219 addPreference( tr( "PREF_STOP_TRACE" ), aParaVisSettingsTab, LightApp_Preferences::Bool, "PARAVIS", "stop_trace");
1221 int aSaveType = addPreference(tr( "PREF_SAVE_TYPE_LBL" ), aParaVisSettingsTab,
1222 LightApp_Preferences::Selector,
1223 "PARAVIS", "savestate_type");
1224 QList<QVariant> aIndices;
1225 QStringList aStrings;
1227 aStrings<<tr("PREF_SAVE_TYPE_0");
1228 aStrings<<tr("PREF_SAVE_TYPE_1");
1229 aStrings<<tr("PREF_SAVE_TYPE_2");
1230 setPreferenceProperty(aSaveType, "strings", aStrings);
1231 setPreferenceProperty(aSaveType, "indexes", aIndices);
1233 //rnv: imp 21712: [CEA 581] Preference to display legend by default
1234 // [ABN]: now fixed in ParaView.
1235 // int aDispColoreLegend = addPreference( tr( "PREF_SHOW_COLOR_LEGEND" ), aParaVisSettingsTab,
1236 // LightApp_Preferences::Bool, "PARAVIS", "show_color_legend");
1240 \brief Creates ParaViS context menu popup
1242 void PVGUI_Module::contextMenuPopup(const QString& theClient, QMenu* theMenu, QString& theTitle)
1244 SalomeApp_Module::contextMenuPopup(theClient, theMenu, theTitle);
1246 // Check if we are in Object Browser
1247 SUIT_DataBrowser* ob = getApp()->objectBrowser();
1248 bool isOBClient = (ob && theClient == ob->popupClientType());
1253 // Get list of selected objects
1254 LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr();
1255 SALOME_ListIO aListIO;
1256 aSelectionMgr->selectedObjects(aListIO);
1257 if (aListIO.Extent() == 1 && aListIO.First()->hasEntry()) {
1258 QString entry = QString(aListIO.First()->getEntry());
1261 SalomeApp_Study* activeStudy =
1262 dynamic_cast<SalomeApp_Study*>(getApp()->activeStudy());
1267 // Get SALOMEDS client study
1268 _PTR(Study) studyDS = activeStudy->studyDS();
1273 QString paravisDataType(GetEngine()->ComponentDataType());
1274 if(activeStudy && activeStudy->isComponent(entry) &&
1275 activeStudy->componentDataType(entry) == paravisDataType) {
1276 // ParaViS module object
1277 theMenu->addSeparator();
1278 theMenu->addAction(action(SaveStatePopupId));
1281 // Try to get state object
1282 _PTR(SObject) stateSObj =
1283 studyDS->FindObjectID(entry.toLatin1().constData());
1289 _PTR(GenericAttribute) anAttr;
1290 if (!stateSObj->FindAttribute(anAttr, "AttributeLocalID")) {
1294 _PTR(AttributeLocalID) anID(anAttr);
1296 if (anID->Value() == PVSTATEID) {
1297 // Paraview state object
1298 theMenu->addSeparator();
1299 theMenu->addAction(action(AddStatePopupId));
1300 theMenu->addAction(action(CleanAndAddStatePopupId));
1301 theMenu->addSeparator();
1302 theMenu->addAction(action(ParaVisRenameId));
1303 theMenu->addAction(action(ParaVisDeleteId));
1310 \brief. Show ParaView python trace.
1312 void PVGUI_Module::onShowTrace()
1314 if (!myTraceWindow) {
1315 myTraceWindow = new pqPythonScriptEditor(getApp()->desktop());
1317 myTraceWindow->setText(getTraceString());
1318 myTraceWindow->show();
1319 myTraceWindow->raise();
1320 myTraceWindow->activateWindow();
1325 \brief. Re-initialize ParaView python trace.
1327 void PVGUI_Module::onRestartTrace()
1334 \brief Show ParaView view.
1336 void PVGUI_Module::onNewParaViewWindow()
1342 \brief Save state under the module root object.
1344 void PVGUI_Module::onSaveMultiState()
1346 // Create state study object
1348 // Get SALOMEDS client study
1349 _PTR(Study) studyDS = PARAVIS::GetCStudy(this);
1354 _PTR(SComponent) paravisComp =
1355 studyDS->FindComponent(GetEngine()->ComponentDataType());
1360 // Unlock the study if it is locked
1361 bool isLocked = studyDS->GetProperties()->IsLocked();
1363 studyDS->GetProperties()->SetLocked(false);
1366 QString stateName = tr("SAVED_PARAVIEW_STATE_NAME") +
1367 QString::number(myStateCounter + 1);
1369 _PTR(StudyBuilder) studyBuilder = studyDS->NewBuilder();
1370 _PTR(SObject) newSObj = studyBuilder->NewObject(paravisComp);
1373 _PTR(GenericAttribute) anAttr;
1374 anAttr = studyBuilder->FindOrCreateAttribute(newSObj, "AttributeName");
1375 _PTR(AttributeName) nameAttr(anAttr);
1377 nameAttr->SetValue(stateName.toLatin1().constData());
1380 anAttr = studyBuilder->FindOrCreateAttribute(newSObj, "AttributeLocalID");
1381 _PTR(AttributeLocalID) localIdAttr(anAttr);
1383 localIdAttr->SetValue(PVSTATEID);
1386 QString stateEntry = QString::fromStdString(newSObj->GetID());
1388 // File name for state saving
1389 QString tmpDir = QString::fromStdString(SALOMEDS_Tool::GetTmpDir());
1390 QString fileName = QString("%1_paravisstate:%2").arg(tmpDir, stateEntry);
1392 anAttr = studyBuilder->FindOrCreateAttribute(newSObj, "AttributeString");
1393 _PTR(AttributeString) stringAttr(anAttr);
1395 stringAttr->SetValue(fileName.toLatin1().constData());
1397 // Lock the study back if necessary
1399 studyDS->GetProperties()->SetLocked(true);
1403 saveParaviewState(fileName.toLatin1().constData());
1404 myTemporaryFiles.append(fileName);
1406 // Increment the counter
1413 \brief Restore the selected state by merging with the current one.
1415 void PVGUI_Module::onAddState()
1417 loadSelectedState(false);
1421 \brief Clean the current state and restore the selected one.
1423 void PVGUI_Module::onCleanAddState()
1425 loadSelectedState(true);
1429 \brief Rename the selected object.
1431 void PVGUI_Module::onRename()
1433 LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr();
1434 SALOME_ListIO aListIO;
1435 aSelectionMgr->selectedObjects(aListIO);
1437 if (aListIO.Extent() == 1 && aListIO.First()->hasEntry()) {
1438 std::string entry = aListIO.First()->getEntry();
1440 // Get SALOMEDS client study
1441 _PTR(Study) studyDS = PARAVIS::GetCStudy(this);
1446 // Unlock the study if it is locked
1447 bool isLocked = studyDS->GetProperties()->IsLocked();
1449 studyDS->GetProperties()->SetLocked(false);
1452 // Rename the selected state object
1453 _PTR(SObject) stateSObj = studyDS->FindObjectID(entry);
1458 _PTR(GenericAttribute) anAttr;
1459 if (stateSObj->FindAttribute(anAttr, "AttributeName")) {
1460 _PTR(AttributeName) nameAttr (anAttr);
1462 LightApp_NameDlg::getName(getApp()->desktop(), nameAttr->Value().c_str());
1463 if (!newName.isEmpty()) {
1464 nameAttr->SetValue(newName.toLatin1().constData());
1465 aListIO.First()->setName(newName.toLatin1().constData());
1469 // Lock the study back if necessary
1471 studyDS->GetProperties()->SetLocked(true);
1474 // Update object browser
1481 \brief Delete the selected objects.
1483 void PVGUI_Module::onDelete()
1485 LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr();
1486 SALOME_ListIO aListIO;
1487 aSelectionMgr->selectedObjects(aListIO);
1489 if (aListIO.Extent() == 1 && aListIO.First()->hasEntry()) {
1490 std::string entry = aListIO.First()->getEntry();
1492 // Get SALOMEDS client study
1493 _PTR(Study) studyDS = PARAVIS::GetCStudy(this);
1498 // Unlock the study if it is locked
1499 bool isLocked = studyDS->GetProperties()->IsLocked();
1501 studyDS->GetProperties()->SetLocked(false);
1504 // Remove the selected state from the study
1505 _PTR(StudyBuilder) studyBuilder = studyDS->NewBuilder();
1506 _PTR(SObject) stateSObj = studyDS->FindObjectID(entry);
1507 studyBuilder->RemoveObject(stateSObj);
1509 // Lock the study back if necessary
1511 studyDS->GetProperties()->SetLocked(true);
1514 // Update object browser
1519 void PVGUI_Module::onPushTraceTimer()
1521 // MESSAGE("onPushTraceTimer(): Pushing trace to engine...");
1522 GetEngine()->PutPythonTraceStringToEngine(getTraceString().toStdString().c_str());
1526 \brief Discover help project files from the resources.
1527 \return name of the help file.
1529 QString PVGUI_Module::getHelpFileName() {
1530 QString aPVHome(getenv("PVHOME"));
1531 if (aPVHome.isNull()) {
1532 qWarning("Wariable PVHOME is not defined");
1535 QChar aSep = QDir::separator();
1536 //PARAVIEW_VERSION from the vtkPVConfig.h file
1537 QString aFileName = aPVHome + aSep + "share" + aSep + "doc" + aSep + "paraview-"+ PARAVIEW_VERSION + aSep + "paraview.qch";
1543 \brief Load selected paraview state
1545 If toClear == true, the current state will be cleared
1547 void PVGUI_Module::loadSelectedState(bool toClear)
1551 LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr();
1552 SALOME_ListIO aListIO;
1553 aSelectionMgr->selectedObjects(aListIO);
1555 if (aListIO.Extent() == 1 && aListIO.First()->hasEntry()) {
1556 std::string entry = aListIO.First()->getEntry();
1558 // Get SALOMEDS client study
1559 _PTR(Study) studyDS = PARAVIS::GetCStudy(this);
1565 _PTR(SObject) stateSObj = studyDS->FindObjectID(entry);
1566 _PTR(GenericAttribute) anAttr;
1567 if (!stateSObj->FindAttribute(anAttr, "AttributeLocalID")) {
1570 _PTR(AttributeLocalID) anID(anAttr);
1571 if (!anID->Value() == PVSTATEID) {
1575 // Get state file name
1576 if (stateSObj->FindAttribute(anAttr, "AttributeString")) {
1577 _PTR(AttributeString) aStringAttr(anAttr);
1578 QString stringValue(aStringAttr->Value().c_str());
1580 if (QFile::exists(stringValue)) {
1581 fileName = stringValue;
1586 if (!fileName.isEmpty()) {
1588 clearParaviewState();
1591 loadParaviewState(fileName.toLatin1().constData());
1594 SUIT_MessageBox::critical(getApp()->desktop(),
1596 tr("ERR_STATE_CANNOT_BE_RESTORED"));
1600 void PVGUI_Module::onRepresentationChanged(pqRepresentation*) {
1603 //rnv: to fix the issue "21712: [CEA 581] Preference to display legend by default"
1604 // find the pqDisplayColorWidget instances and connect the variableChanged SIGNAL on the
1605 // onVariableChanged slot of this class. This connection needs to change visibility
1606 // of the "Colored Legend" after change the "Color By" array.
1607 QList<pqDisplayColorWidget*> aWidget = getApp()->desktop()->findChildren<pqDisplayColorWidget*>();
1609 for (int i = 0; i < aWidget.size() ; i++ ) {
1611 connect( aWidget[i], SIGNAL ( variableChanged ( pqVariableType, const QString ) ),
1612 this, SLOT(onVariableChanged( pqVariableType, const QString) ), Qt::UniqueConnection );
1619 \fn CAM_Module* createModule();
1620 \brief Export module instance (factory function).
1621 \return new created instance of the module
1625 #define PVGUI_EXPORT __declspec(dllexport)
1627 #define PVGUI_EXPORT
1633 PVGUI_EXPORT CAM_Module* createModule() {
1635 // vtkEDFHelperInit();
1638 return new PVGUI_Module();
1641 PVGUI_EXPORT char* getModuleVersion() {
1642 return (char*)PARAVIS_VERSION_STR;