1 // PARAVIS : ParaView wrapper SALOME module
3 // Copyright (C) 2010-2012 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.
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
22 // Author : Julia DOROVSKIKH
24 #include <Standard_math.hxx> // E.A. must be included before Python.h to fix compilation on windows
26 #undef HAVE_FINITE // VSR: avoid compilation warning on Linux : "HAVE_FINITE" redefined
28 #include <vtkPython.h> // Python first
29 #include "PVGUI_Module.h"
31 #include "SALOMEconfig.h"
33 #include CORBA_CLIENT_HEADER(VISU_Gen)
35 #include CORBA_SERVER_HEADER(SALOMEDS)
38 #include "PARAVIS_Gen_i.hh"
42 #include "PVGUI_ViewModel.h"
43 #include "PVGUI_ViewManager.h"
44 #include "PVGUI_ViewWindow.h"
45 #include "PVGUI_Tools.h"
46 #include "PVGUI_ParaViewSettingsPane.h"
47 #include "PVGUI_OutputWindowAdapter.h"
49 #include <SUIT_DataBrowser.h>
50 #include <SUIT_Desktop.h>
51 #include <SUIT_MessageBox.h>
52 #include <SUIT_ResourceMgr.h>
53 #include <SUIT_Session.h>
54 #include <SUIT_OverrideCursor.h>
55 #include <SUIT_ExceptionHandler.h>
58 #include "SALOME_LifeCycleCORBA.hxx"
59 #include "SALOMEDS_SObject.hxx"
61 #include "LightApp_SelectionMgr.h"
62 #include "LightApp_NameDlg.h"
64 #include <SalomeApp_Application.h>
65 #include <SalomeApp_Study.h>
66 #include <SALOME_ListIO.hxx>
67 #include <SALOMEDS_Tool.hxx>
68 #include <PyInterp_Dispatcher.h>
70 #include <QtxActionMenuMgr.h>
71 #include <QtxActionToolMgr.h>
74 #include <QApplication>
80 #include <QInputDialog>
84 #include <QStringList>
87 #include <QTextStream>
89 #include <QDockWidget>
90 #include <QHelpEngine>
92 #include <pqApplicationCore.h>
93 #include <pqPVApplicationCore.h>
94 #include <pqActiveView.h>
95 #include <pqObjectBuilder.h>
96 #include <pqOptions.h>
97 #include <pqRenderView.h>
99 #include <pqUndoStack.h>
100 #include <pqVCRController.h>
101 #include <pqTabbedMultiViewWidget.h>
102 #include <pqPipelineSource.h>
103 #include <pqActiveObjects.h>
104 #include <vtkProcessModule.h>
105 #include <vtkSMSession.h>
106 #include <vtkPVProgressHandler.h>
107 #include <pqParaViewBehaviors.h>
108 #include <pqHelpReaction.h>
109 #include <vtkOutputWindow.h>
110 #include <pqPluginManager.h>
111 //#include <vtkPVPluginInformation.h>
112 #include "pqInterfaceTracker.h"
113 #include <pqSettings.h>
114 #include <pqPythonDialog.h>
115 #include <pqPythonManager.h>
116 #include <pqPythonShell.h>
117 //#include <pqBrandPluginsLoader.h>
118 #include <pqLoadDataReaction.h>
119 #include <vtkEventQtSlotConnect.h>
120 #include <pqPythonScriptEditor.h>
121 #include <pqStandardSummaryPanelImplementation.h>
122 #include <pqCollaborationBehavior.h>
123 #include <pqDataRepresentation.h>
124 #include <pqPipelineRepresentation.h>
125 #include <pqLookupTableManager.h>
126 #include <pqDisplayColorWidget.h>
127 #include <pqColorToolbar.h>
128 #include <pqScalarBarVisibilityReaction.h>
129 #include <pqStandardPropertyWidgetInterface.h>
130 #include <pqMultiServerBehavior.h>
131 #include <pqViewStreamingBehavior.h>
133 #include <PARAVIS_version.h>
135 #include <vtkPVConfig.h>
137 #include <PVGUI_MatplotlibMathTextUtilities.h>
139 #include CORBA_SERVER_HEADER(SALOME_ModuleCatalog)
142 * Make sure all the kits register their classes with vtkInstantiator.
143 * Since ParaView uses Tcl wrapping, all of VTK is already compiled in
144 * anyway. The instantiators will add no more code for the linker to
148 //#include <vtkCommonInstantiator.h>
149 //#include <vtkFilteringInstantiator.h>
150 //#include <vtkGenericFilteringInstantiator.h>
151 //#include <vtkIOInstantiator.h>
152 //#include <vtkImagingInstantiator.h>
153 //#include <vtkInfovisInstantiator.h>
154 //#include <vtkGraphicsInstantiator.h>
156 //#include <vtkRenderingInstantiator.h>
157 //#include <vtkVolumeRenderingInstantiator.h>
158 //#include <vtkHybridInstantiator.h>
159 //#include <vtkParallelInstantiator.h>
161 #include <pqAlwaysConnectedBehavior.h>
162 #include <pqApplicationCore.h>
163 #include <pqAutoLoadPluginXMLBehavior.h>
164 #include <pqCommandLineOptionsBehavior.h>
165 #include <pqCrashRecoveryBehavior.h>
166 #include <pqDataTimeStepBehavior.h>
167 #include <pqDefaultViewBehavior.h>
168 #include <pqDeleteBehavior.h>
169 #include <pqObjectPickingBehavior.h>
170 #include <pqPersistentMainWindowStateBehavior.h>
171 #include <pqPipelineContextMenuBehavior.h>
172 #include <pqPluginActionGroupBehavior.h>
173 #include <pqPluginDockWidgetsBehavior.h>
174 #include <pqPluginManager.h>
175 #include <pqPVNewSourceBehavior.h>
176 #include <pqSpreadSheetVisibilityBehavior.h>
177 #include <pqStandardViewModules.h>
178 #include <pqUndoRedoBehavior.h>
179 #include <pqViewFrameActionsBehavior.h>
180 #include <pqServerManagerObserver.h>
182 #include <vtkClientServerInterpreterInitializer.h>
185 //----------------------------------------------------------------------------
186 pqPVApplicationCore* PVGUI_Module::MyCoreApp = 0;
187 //PVGUI_OutputWindowAdapter* PVGUI_Module::pqImplementation::OutputWindowAdapter = 0;
188 //QPointer<pqHelpWindow> PVGUI_Module::pqImplementation::helpWindow = 0;
190 PVGUI_Module* ParavisModule = 0;
195 <h2>Building and installing PARAVIS</h2>
196 As any other SALOME module, PARAVIS requires PARAVIS_ROOT_DIR environment variable to be set to PARAVIS
197 installation directory.
198 Other variables needed for correct detection of ParaView location:
199 \li PVHOME - points at the ParaView installation directory tree
200 \li PVVERSION - number of ParaView version
202 It also requires common SALOME environment including GUI_ROOT_DIR and other prerequsites.
205 PARAVIS module can be launched using the following commands:
206 \li Full SALOME configuration
208 runSalome --modules="PARAVIS"
211 <h2>ParaView GUI integration</h2>
212 <h3>ParaView GUI integration overview</h3>
214 The main idea is to reuse ParaView GUI internal logic as much as possible, providing a layer
215 between it and SALOME GUI that hides the following SALOME GUI implementation details from ParaView:
217 \li SALOME GUI executable and Qt event loop
218 \li SALOME GUI desktop
219 \li Dock windows areas
220 \li SALOME menu and toolbar managers
222 Major part of the integration is implemented in PVGUI_Module class.
224 <h3>ParaView client initalization</h3>
226 ParaView client initalization is performed when an instance of PVGUI_Module class has been created
227 and \link PVGUI_Module::initialize() PVGUI_Module::initialize()\endlink method is called by SALOME GUI.
228 The actual client start-up is done in \link PVGUI_Module::pvInit() PVGUI_Module::pvInit()\endlink method.
231 <h3>Multi-view manager</h3>
233 SALOME GUI requires that each kind of view be implemnted with help of (at least) three classes. For ParaView multi-view manager
236 \li PVGUI_ViewManager - view manager class
237 \li PVGUI_Viewer - view model class
238 \li PVGUI_ViewWindow - view window class that acts as a parent for %pqViewManager
240 Single instances of PVGUI_ViewManager and PVGUI_ViewWindow classes are created by \link PVGUI_Module::showView()
241 PVGUI_Module::showView()\endlink method upon the first PARAVIS module activation. The same method hides the multi-view manager
242 when the module is deactivated (the user switches to another module or a study is closed).
243 A special trick is used to make PVGUI_ViewWindow the parent of %pqViewManager widget. It is created initally by %pqMainWindowCore
244 with the desktop as a parent, so when it is shown PVGUI_ViewWindow instance is passed to its setParent() method. In
245 \link PVGUI_ViewWindow::~PVGUI_ViewWindow() PVGUI_ViewWindow::~PVGUI_ViewWindow()\endlink the parent is nullified to avoid deletion
246 of %pqViewManager widget that would break %pqMainWindowCore class.
248 <h3>ParaView plugins</h3>
249 ParaView server and client plugins are managed by %pqMainWindowCore slots that has full access to PARAVIS menus and toolbars.
250 As a result they appears automatically in PARAVIS menus and toolbars if loaded successfully.
255 \brief Implementation
256 SALOME module wrapping ParaView GUI.
261 Fix for the issue 21730: [CEA 596] Slice of polyhedron in PARAVIS returns no cell.
262 Wrap vtkEDFCutter filter.
265 extern "C" void vtkEDFCutterCS_Initialize(vtkClientServerInterpreter*);
266 static void vtkEDFHelperInit();
268 void vtkEDFHelperInit(vtkClientServerInterpreter* interp){
269 vtkEDFCutterCS_Initialize(interp);
272 void vtkEDFHelperInit() {
273 vtkClientServerInterpreterInitializer::GetInitializer()->
274 RegisterCallback(&vtkEDFHelperInit);
279 ClientFindOrCreateParavisComponent(_PTR(Study) theStudyDocument)
281 _PTR(SComponent) aSComponent = theStudyDocument->FindComponent("PARAVIS");
283 _PTR(StudyBuilder) aStudyBuilder = theStudyDocument->NewBuilder();
284 aStudyBuilder->NewCommand();
285 int aLocked = theStudyDocument->GetProperties()->IsLocked();
286 if (aLocked) theStudyDocument->GetProperties()->SetLocked(false);
287 aSComponent = aStudyBuilder->NewComponent("PARAVIS");
288 _PTR(GenericAttribute) anAttr =
289 aStudyBuilder->FindOrCreateAttribute(aSComponent, "AttributeName");
290 _PTR(AttributeName) aName (anAttr);
292 CORBA::ORB_var anORB = PARAVIS::PARAVIS_Gen_i::GetORB();
293 SALOME_NamingService *NamingService = new SALOME_NamingService( anORB );
294 CORBA::Object_var objVarN = NamingService->Resolve("/Kernel/ModulCatalog");
295 SALOME_ModuleCatalog::ModuleCatalog_var Catalogue =
296 SALOME_ModuleCatalog::ModuleCatalog::_narrow(objVarN);
297 SALOME_ModuleCatalog::Acomponent_var Comp = Catalogue->GetComponent( "PARAVIS" );
298 if (!Comp->_is_nil()) {
299 aName->SetValue(Comp->componentusername());
302 anAttr = aStudyBuilder->FindOrCreateAttribute(aSComponent, "AttributePixMap");
303 _PTR(AttributePixMap) aPixmap (anAttr);
304 aPixmap->SetPixMap( "pqAppIcon16.png" );
306 // Create Attribute parameters for future using
307 anAttr = aStudyBuilder->FindOrCreateAttribute(aSComponent, "AttributeParameter");
310 PARAVIS::PARAVIS_Gen_var aPARAVIS = PARAVIS::PARAVIS_Gen_i::GetParavisGenImpl()->_this();
312 aStudyBuilder->DefineComponentInstance(aSComponent, aPARAVIS->GetIOR());
313 if (aLocked) theStudyDocument->GetProperties()->SetLocked(true);
314 aStudyBuilder->CommitCommand();
320 Clean up function; used to stop ParaView progress events when
321 exception is caught by global exception handler.
323 void paravisCleanUp()
325 if ( pqApplicationCore::instance() ) {
326 pqServer* s = pqApplicationCore::instance()->getActiveServer();
327 if ( s ) s->session()->GetProgressHandler()->CleanupPendingProgress();
332 \brief Constructor. Sets the default name for the module.
334 PVGUI_Module::PVGUI_Module()
335 : SalomeApp_Module( "PARAVIS" ),
336 // Implementation( 0 ),
337 mySelectionControlsTb( -1 ),
338 mySourcesMenuId( -1 ),
339 myFiltersMenuId( -1 ),
341 myToolbarsMenuId(-1),
348 Q_INIT_RESOURCE( PVGUI );
350 ParavisModule = this;
353 QString aDestPath = QString( "%1/.config/%2/Macros" ).arg( QDir::homePath() ).arg( QApplication::applicationName() );
357 QDir aDestDir(aDestPath);
358 QStringList aDestFiles = aDestDir.entryList(aFilter, QDir::Files);
359 foreach (QString aStr, aDestFiles) {
360 aDestDir.remove(aStr);
367 PVGUI_Module::~PVGUI_Module()
374 \brief Initialize module. Creates menus, prepares context menu, etc.
375 \param app SALOME GUI application instance
377 void PVGUI_Module::initialize( CAM_Application* app )
379 //VTN: Disable conflict with python initialization for MatPlot.
380 PVGUI_MatplotlibMathTextUtilities::Disable();
382 SalomeApp_Module::initialize( app );
384 // Create ParaViS actions
386 // Create ParaViS menus
389 // Uncomment to debug ParaView initialization
390 // "aa" used instead of "i" as GDB doesn't like "i" variables :)
398 // Initialize ParaView client
401 // Create GUI elements (menus, toolbars, dock widgets)
402 //if ( !Implementation ){
403 SalomeApp_Application* anApp = getApp();
404 SUIT_Desktop* aDesktop = anApp->desktop();
406 // connect(aDesktop, SIGNAL()
408 // Remember current state of desktop toolbars
409 QList<QToolBar*> foreignToolbars = aDesktop->findChildren<QToolBar*>();
411 // Simulate ParaView client main window
412 //Implementation = new pqImplementation( aDesktop );
420 // new pqParaViewBehaviors(anApp->desktop(), this);
421 // Has to be replaced in order to exclude using of pqQtMessageHandlerBehaviour
422 // Start pqParaViewBehaviors
423 // Register ParaView interfaces.
424 //pqPluginManager* pgm = pqApplicationCore::instance()->getPluginManager();
425 pqInterfaceTracker* pgm = pqApplicationCore::instance()->interfaceTracker();
427 // * adds support for standard paraview views.
428 pgm->addInterface(new pqStandardViewModules(pgm));
429 pgm->addInterface(new pqStandardSummaryPanelImplementation(pgm));
430 pgm->addInterface(new pqStandardPropertyWidgetInterface(pgm));
432 // Load plugins distributed with application.
433 pqApplicationCore::instance()->loadDistributedPlugins();
435 // Define application behaviors.
436 //new pqQtMessageHandlerBehavior(this);
437 new pqDataTimeStepBehavior(this);
438 new pqViewFrameActionsBehavior(this);
439 new pqSpreadSheetVisibilityBehavior(this);
440 new pqPipelineContextMenuBehavior(this);
441 new pqDefaultViewBehavior(this);
442 new pqAlwaysConnectedBehavior(this);
443 new pqPVNewSourceBehavior(this);
444 new pqDeleteBehavior(this);
445 new pqUndoRedoBehavior(this);
446 new pqCrashRecoveryBehavior(this);
447 new pqAutoLoadPluginXMLBehavior(this);
448 new pqPluginDockWidgetsBehavior(aDesktop);
449 //new pqVerifyRequiredPluginBehavior(this);
450 new pqPluginActionGroupBehavior(aDesktop);
451 //new pqFixPathsInStateFilesBehavior(this);
452 new pqCommandLineOptionsBehavior(this);
453 new pqPersistentMainWindowStateBehavior(aDesktop);
454 new pqObjectPickingBehavior(aDesktop);
455 new pqCollaborationBehavior(this);
456 new pqMultiServerBehavior(this);
457 new pqViewStreamingBehavior(this);
459 // Setup quick-launch shortcuts.
460 QShortcut *ctrlSpace = new QShortcut(Qt::CTRL + Qt::Key_Space, aDesktop);
461 QObject::connect(ctrlSpace, SIGNAL(activated()),
462 pqApplicationCore::instance(), SLOT(quickLaunch()));
463 QShortcut *altSpace = new QShortcut(Qt::ALT + Qt::Key_Space, aDesktop);
464 QObject::connect(altSpace, SIGNAL(activated()),
465 pqApplicationCore::instance(), SLOT(quickLaunch()));
466 // End pqParaViewBehaviors
469 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
470 QString aPath = resMgr->stringValue("resources", "PARAVIS", QString());
471 if (!aPath.isNull()) {
472 MyCoreApp->loadConfiguration(aPath + QDir::separator() + "ParaViewFilters.xml");
473 MyCoreApp->loadConfiguration(aPath + QDir::separator() + "ParaViewReaders.xml");
474 MyCoreApp->loadConfiguration(aPath + QDir::separator() + "ParaViewSources.xml");
475 MyCoreApp->loadConfiguration(aPath + QDir::separator() + "ParaViewWriters.xml");
478 // Force creation of engine
479 PARAVIS::GetParavisGen(this);
482 // Find created toolbars
483 QCoreApplication::processEvents();
485 QList<QToolBar*> allToolbars = aDesktop->findChildren<QToolBar*>();
486 foreach(QToolBar* aBar, allToolbars) {
487 if (!foreignToolbars.contains(aBar)) {
488 myToolbars[aBar] = true;
489 myToolbarBreaks[aBar] = false;
490 aBar->setVisible(false);
491 aBar->toggleViewAction()->setVisible(false);
498 // we need to start trace after connection is done
499 connect(pqApplicationCore::instance()->getObjectBuilder(), SIGNAL(finishedAddingServer(pqServer*)),
500 this, SLOT(onFinishedAddingServer(pqServer*)));
502 connect(pqApplicationCore::instance()->getObjectBuilder(), SIGNAL(dataRepresentationCreated(pqDataRepresentation*)),
503 this, SLOT(onDataRepresentationCreated(pqDataRepresentation*)));
506 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
507 bool isStop = aResourceMgr->booleanValue( "PARAVIS", "stop_trace", false );
508 // start timer to activate trace in a proper moment
512 this->VTKConnect = vtkEventQtSlotConnect::New();
513 vtkProcessModule* pm = vtkProcessModule::GetProcessModule();
515 this->VTKConnect->Connect(pm, vtkCommand::StartEvent,
516 this, SLOT(onStartProgress()));
517 this->VTKConnect->Connect(pm, vtkCommand::EndEvent,
518 this, SLOT(onEndProgress()));
520 connect(&pqActiveObjects::instance(),
521 SIGNAL(representationChanged(pqRepresentation*)),
522 this, SLOT(onRepresentationChanged(pqRepresentation*)));
525 void PVGUI_Module::onStartProgress()
527 QApplication::setOverrideCursor(Qt::WaitCursor);
530 void PVGUI_Module::onEndProgress()
532 QApplication::restoreOverrideCursor();
535 void PVGUI_Module::onFinishedAddingServer(pqServer* /*server*/)
537 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
538 bool isStop = aResourceMgr->booleanValue( "PARAVIS", "stop_trace", false );
543 void PVGUI_Module::onDataRepresentationCreated(pqDataRepresentation* data) {
547 if(!data->getLookupTable())
550 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
554 bool visible = aResourceMgr->booleanValue( "PARAVIS", "show_color_legend", false );
555 pqLookupTableManager* lut_mgr = pqApplicationCore::instance()->getLookupTableManager();
558 lut_mgr->setScalarBarVisibility(data,visible);
561 connect(data, SIGNAL(dataUpdated()), this, SLOT(onDataRepresentationUpdated()));
564 void PVGUI_Module::onDataRepresentationUpdated() {
565 SalomeApp_Study* activeStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
566 if(!activeStudy) return;
568 activeStudy->Modified();
571 void PVGUI_Module::onVariableChanged(pqVariableType t, const QString) {
573 pqDisplayColorWidget* colorWidget = qobject_cast<pqDisplayColorWidget*>(sender());
577 if( t == VARIABLE_TYPE_NONE )
580 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
585 bool visible = aResourceMgr->booleanValue( "PARAVIS", "show_color_legend", false );
590 /*//VTN: getRepresentation is protected
591 pqDataRepresentation* data = colorWidget->getRepresentation();
593 if( !data->getLookupTable() )
596 pqLookupTableManager* lut_mgr = pqApplicationCore::instance()->getLookupTableManager();
599 lut_mgr->setScalarBarVisibility(data,visible);
602 pqColorToolbar* colorTooBar = qobject_cast<pqColorToolbar*>(colorWidget->parent());
606 pqScalarBarVisibilityReaction* scalarBarVisibility = colorTooBar->findChild<pqScalarBarVisibilityReaction *>();
607 if(scalarBarVisibility) {
608 scalarBarVisibility->setScalarBarVisibility(visible);
614 \brief Launches a tracing of current server
616 void PVGUI_Module::timerEvent(QTimerEvent* te )
619 PyInterp_Dispatcher* aDispatcher = PyInterp_Dispatcher::Get();
620 if ( !aDispatcher->IsBusy() ) {
621 pqPythonManager* manager = qobject_cast<pqPythonManager*>
622 ( pqApplicationCore::instance()->manager( "PYTHON_MANAGER" ) );
624 pqPythonDialog* pyDiag = manager->pythonShellDialog();
626 pqPythonShell* shell = pyDiag->shell();
628 QString script = "from paraview import smtrace\nsmtrace.start_trace()\n";
629 shell->executeScript(script);
630 killTimer( te->timerId() );
638 void PVGUI_Module::updateMacros()
640 pqPythonManager* aPythonManager = pqPVApplicationCore::instance()->pythonManager();
641 if(!aPythonManager) {
645 QString aRootDir = getenv("PARAVIS_ROOT_DIR");
647 QString aSourcePath = aRootDir + "/bin/salome/Macro";
652 QDir aSourceDir(aSourcePath);
653 QStringList aSourceFiles = aSourceDir.entryList(aFilter, QDir::Files);
654 foreach (QString aStr, aSourceFiles) {
655 aPythonManager->addMacro(aSourcePath + "/" + aStr);
661 \brief Get list of compliant dockable GUI elements
662 \param m map to be filled in ("type":"default_position")
664 void PVGUI_Module::windows( QMap<int, int>& m ) const
666 m.insert( LightApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
667 m.insert( LightApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
668 // ParaView diagnostic output redirected here
669 m.insert( LightApp_Application::WT_LogWindow, Qt::BottomDockWidgetArea );
673 \brief Static method, performs initialization of ParaView session.
674 \return \c true if ParaView has been initialized successfully, otherwise false
676 bool PVGUI_Module::pvInit()
678 // if ( !pqImplementation::Core ){
680 // Obtain command-line arguments
683 QString aOptions = getenv("PARAVIS_OPTIONS");
684 QStringList aOptList = aOptions.split(":", QString::SkipEmptyParts);
685 argv = new char*[aOptList.size() + 1];
686 QStringList args = QApplication::arguments();
687 argv[0] = (args.size() > 0)? strdup(args[0].toLatin1().constData()) : strdup("paravis");
690 foreach (QString aStr, aOptList) {
691 argv[argc] = strdup( aStr.toLatin1().constData() );
694 MyCoreApp = new pqPVApplicationCore (argc, argv);
695 if (MyCoreApp->getOptions()->GetHelpSelected() ||
696 MyCoreApp->getOptions()->GetUnknownArgument() ||
697 MyCoreApp->getOptions()->GetErrorMessage() ||
698 MyCoreApp->getOptions()->GetTellVersion()) {
702 /* VTN: Looks like trash. For porting see branded_paraview_initializer.cxx.in
703 // Not sure why this is needed. Andy added this ages ago with comment saying
704 // needed for Mac apps. Need to check that it's indeed still required.
705 QDir dir(QApplication::applicationDirPath());
708 QApplication::addLibraryPath(dir.absolutePath());
709 // Load required application plugins.
710 QString plugin_string = "";
711 QStringList plugin_list = plugin_string.split(';',QString::SkipEmptyParts);
712 pqBrandPluginsLoader loader;
713 if (loader.loadPlugins(plugin_list) == false) {
714 printf("Failed to load required plugins for this application\n");
718 // Load optional plugins.
720 plugin_list = plugin_string.split(';',QString::SkipEmptyParts);
721 loader.loadPlugins(plugin_list, true); //quietly skip not-found plugins.
723 // End of Initializer code
725 vtkOutputWindow::SetInstance(PVGUI_OutputWindowAdapter::New());
727 new pqTabbedMultiViewWidget(); // it registers as "MULTIVIEW_WIDGET on creation
729 for (int i = 0; i < argc; i++)
738 \brief Shows (toShow = true) or hides ParaView view window
740 void PVGUI_Module::showView( bool toShow )
742 SalomeApp_Application* anApp = getApp();
743 PVGUI_ViewManager* viewMgr =
744 dynamic_cast<PVGUI_ViewManager*>( anApp->getViewManager( PVGUI_Viewer::Type(), false ) );
746 viewMgr = new PVGUI_ViewManager( anApp->activeStudy(), anApp->desktop() );
747 anApp->addViewManager( viewMgr );
748 connect( viewMgr, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
749 anApp, SLOT( onCloseView( SUIT_ViewManager* ) ) );
752 PVGUI_ViewWindow* pvWnd = dynamic_cast<PVGUI_ViewWindow*>( viewMgr->getActiveView() );
754 pvWnd = dynamic_cast<PVGUI_ViewWindow*>( viewMgr->createViewWindow() );
757 pvWnd->setShown( toShow );
758 if ( toShow ) pvWnd->setFocus();
762 \brief Slot to show help for proxy.
764 void PVGUI_Module::showHelpForProxy( const QString& groupname, const QString& proxyname )
766 pqHelpReaction::showProxyHelp(groupname, proxyname);
771 \brief Slot to show the waiting state.
773 void PVGUI_Module::onPreAccept()
775 getApp()->desktop()->statusBar()->showMessage(tr("STB_PREACCEPT"));
776 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
780 \brief Slot to show the ready state.
782 void PVGUI_Module::onPostAccept()
784 getApp()->desktop()->statusBar()->showMessage(tr("STB_POSTACCEPT"), 2000);
785 QTimer::singleShot(0, this, SLOT(endWaitCursor()));
789 \brief Slot to switch off wait cursor.
791 void PVGUI_Module::endWaitCursor()
793 QApplication::restoreOverrideCursor();
797 \brief Returns the ParaView multi-view manager.
799 pqTabbedMultiViewWidget* PVGUI_Module::getMultiViewManager() const
801 return qobject_cast<pqTabbedMultiViewWidget*>(pqApplicationCore::instance()->manager("MULTIVIEW_WIDGET"));
805 static void ParavisMessageOutput(QtMsgType type, const char *msg)
810 vtkOutputWindow::GetInstance()->DisplayText(msg);
813 vtkOutputWindow::GetInstance()->DisplayErrorText(msg);
816 vtkOutputWindow::GetInstance()->DisplayErrorText(msg);
819 vtkOutputWindow::GetInstance()->DisplayErrorText(msg);
827 \brief Activate module.
828 \param study current study
829 \return \c true if activaion is done successfully or 0 to prevent
832 bool PVGUI_Module::activateModule( SUIT_Study* study )
834 myOldMsgHandler = qInstallMsgHandler(ParavisMessageOutput);
836 SUIT_ExceptionHandler::addCleanUpRoutine( paravisCleanUp );
838 bool isDone = SalomeApp_Module::activateModule( study );
839 if ( !isDone ) return false;
842 if ( mySourcesMenuId != -1 ) menuMgr()->show(mySourcesMenuId);
843 if ( myFiltersMenuId != -1 ) menuMgr()->show(myFiltersMenuId);
844 if ( myFiltersMenuId != -1 ) menuMgr()->show(myMacrosMenuId);
845 if ( myFiltersMenuId != -1 ) menuMgr()->show(myToolbarsMenuId);
846 setMenuShown( true );
847 setToolShown( true );
849 restoreDockWidgetsState();
851 QMenu* aMenu = menuMgr()->findMenu( myRecentMenuId );
853 QList<QAction*> anActns = aMenu->actions();
854 for (int i = 0; i < anActns.size(); ++i) {
855 QAction* a = anActns.at(i);
861 if ( myRecentMenuId != -1 ) menuMgr()->show(myRecentMenuId);
863 ClientFindOrCreateParavisComponent(PARAVIS::GetCStudy(this));
870 \brief Deactivate module.
871 \param study current study
872 \return \c true if deactivaion is done successfully or 0 to prevent
873 deactivation on error
875 bool PVGUI_Module::deactivateModule( SUIT_Study* study )
877 QMenu* aMenu = menuMgr()->findMenu( myRecentMenuId );
879 QList<QAction*> anActns = aMenu->actions();
880 for (int i = 0; i < anActns.size(); ++i) {
881 QAction* a = anActns.at(i);
883 a->setVisible(false);
887 QList<QDockWidget*> aStreamingViews = application()->desktop()->findChildren<QDockWidget*>("pqStreamingControls");
888 foreach(QDockWidget* aView, aStreamingViews) {
889 if (!myDockWidgets.contains(aView))
890 myDockWidgets[aView] = aView->isVisible();
893 /*if (pqImplementation::helpWindow) {
894 pqImplementation::helpWindow->hide();
898 menuMgr()->hide(myRecentMenuId);
899 menuMgr()->hide(mySourcesMenuId);
900 menuMgr()->hide(myFiltersMenuId);
901 menuMgr()->hide(myMacrosMenuId);
902 menuMgr()->hide(myToolbarsMenuId);
903 setMenuShown( false );
904 setToolShown( false );
907 saveDockWidgetsState();
909 SUIT_ExceptionHandler::removeCleanUpRoutine( paravisCleanUp );
912 qInstallMsgHandler(myOldMsgHandler);
914 return SalomeApp_Module::deactivateModule( study );
919 \brief Called when application is closed.
921 Process finalize application functionality from ParaView in order to save server settings
922 and nullify application pointer if the application is being closed.
924 \param theApp application
926 void PVGUI_Module::onApplicationClosed( SUIT_Application* theApp )
928 pqApplicationCore::instance()->settings()->sync();
929 int aAppsNb = SUIT_Session::session()->applications().size();
931 deleteTemporaryFiles();
932 MyCoreApp->deleteLater();
934 CAM_Module::onApplicationClosed(theApp);
939 \brief Called when study is closed.
941 Removes data model from the \a study.
943 \param study study being closed
945 void PVGUI_Module::studyClosed(SUIT_Study* study)
947 clearParaviewState();
949 SalomeApp_Module::studyClosed(study);
953 \brief Called when study is opened.
955 void PVGUI_Module::onModelOpened()
957 _PTR(Study) studyDS = PARAVIS::GetCStudy(this);
962 _PTR(SComponent) paravisComp =
963 studyDS->FindComponent(PARAVIS::GetParavisGen(this)->ComponentDataType());
968 _PTR(ChildIterator) anIter(studyDS->NewChildIterator(paravisComp));
969 for (; anIter->More(); anIter->Next()) {
970 _PTR(SObject) aSObj = anIter->Value();
971 _PTR(GenericAttribute) anAttr;
972 if (!aSObj->FindAttribute(anAttr, "AttributeLocalID")) {
975 _PTR(AttributeLocalID) anID(anAttr);
976 if (anID->Value() == PVSTATEID) {
983 \brief Returns IOR of current engine
985 QString PVGUI_Module::engineIOR() const
987 CORBA::String_var anIOR = PARAVIS::GetParavisGen(this)->GetIOR();
988 return QString(anIOR.in());
993 \brief Open file of format supported by ParaView
995 void PVGUI_Module::openFile(const char* theName)
999 pqLoadDataReaction::loadData(aFiles);
1002 void PVGUI_Module::executeScript(const char *script)
1005 pqPythonManager* manager = qobject_cast<pqPythonManager*>(
1006 pqApplicationCore::instance()->manager("PYTHON_MANAGER"));
1008 pqPythonDialog* pyDiag = manager->pythonShellDialog();
1010 pyDiag->runString(script);
1017 \brief Returns trace string
1019 static const QString MYReplaceStr("paraview.simple");
1020 static const QString MYReplaceImportStr("except: from pvsimple import *");
1021 QString PVGUI_Module::getTraceString()
1023 QString traceString;
1025 pqPythonManager* manager = qobject_cast<pqPythonManager*>(
1026 pqApplicationCore::instance()->manager("PYTHON_MANAGER"));
1028 pqPythonDialog* pyDiag = manager->pythonShellDialog();
1030 pyDiag->runString("from paraview import smtrace\n"
1031 "__smtraceString = smtrace.get_trace_string()\n");
1032 pyDiag->shell()->makeCurrent();
1033 PyObject* main_module = PyImport_AddModule((char*)"__main__");
1034 PyObject* global_dict = PyModule_GetDict(main_module);
1035 PyObject* string_object = PyDict_GetItemString(global_dict, "__smtraceString");
1036 char* string_ptr = string_object ? PyString_AsString(string_object) : 0;
1038 traceString = string_ptr;
1040 pyDiag->shell()->releaseControl();
1043 if ((!traceString.isNull()) && traceString.length() != 0) {
1044 int aPos = traceString.indexOf(MYReplaceStr);
1045 while (aPos != -1) {
1046 traceString = traceString.replace(aPos, MYReplaceStr.length(), "pvsimple");
1047 aPos = traceString.indexOf(MYReplaceStr, aPos);
1049 int aImportPos = traceString.indexOf(MYReplaceImportStr);
1050 if(aImportPos != -1)
1052 traceString = traceString.replace(aImportPos, MYReplaceImportStr.length(), "except:\n import pvsimple\n from pvsimple import *");
1060 \brief Saves trace string to disk file
1062 void PVGUI_Module::saveTrace(const char* theName)
1064 QFile file(theName);
1065 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
1066 MESSAGE( "Could not open file:" << theName );
1069 QTextStream out(&file);
1070 out << getTraceString();
1075 \brief Saves ParaView state to a disk file
1077 void PVGUI_Module::saveParaviewState(const char* theFileName)
1079 pqApplicationCore::instance()->saveState(theFileName);
1083 \brief Delete all objects for Paraview Pipeline Browser
1085 void PVGUI_Module::clearParaviewState()
1087 QAction* deleteAllAction = action(DeleteAllId);
1088 if (deleteAllAction) {
1089 deleteAllAction->activate(QAction::Trigger);
1094 \brief Restores ParaView state from a disk file
1096 If toClear == true, the current ojects will be deleted
1098 void PVGUI_Module::loadParaviewState(const char* theFileName)
1100 pqApplicationCore::instance()->loadState(theFileName, getActiveServer());
1104 \brief Imports MED data from VISU module by data entry
1106 void PVGUI_Module::onImportFromVisu(QString theEntry)
1109 SUIT_OverrideCursor aWaitCursor;
1112 SalomeApp_Study* activeStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
1113 if(!activeStudy) return;
1115 // get SALOMEDS client study
1116 _PTR(Study) aStudy = activeStudy->studyDS();
1119 // find VISU component in a study
1120 _PTR(SComponent) aVisuComp = aStudy->FindComponent( "VISU" );
1121 if(!aVisuComp) return;
1123 // get SObject client by entry
1124 _PTR(SObject) aSObj = aStudy->FindObjectID(qPrintable(theEntry));
1127 // get CORBA SObject
1128 SALOMEDS_SObject* aSObject = _CAST(SObject, aSObj);
1129 if ( !aSObject ) return;
1132 SALOME_NamingService* aNamingService = SalomeApp_Application::namingService();
1133 SALOME_LifeCycleCORBA aLCC(aNamingService);
1135 Engines::EngineComponent_var aComponent = aLCC.FindOrLoad_Component("FactoryServer","VISU");
1136 VISU::VISU_Gen_var aVISU = VISU::VISU_Gen::_narrow(aComponent);
1137 if(CORBA::is_nil(aVISU)) return;
1139 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
1140 aStudyBuilder->LoadWith( aVisuComp, SalomeApp_Application::orb()->object_to_string(aVISU) );
1142 // get VISU result object
1143 CORBA::Object_var aResultObject = aSObject->GetObject();
1144 if (CORBA::is_nil(aResultObject)) return;
1145 VISU::Result_var aResult = VISU::Result::_narrow( aResultObject );
1146 if (CORBA::is_nil(aResult)) return;
1148 // export VISU result to the MED file
1149 std::string aTmpDir = SALOMEDS_Tool::GetTmpDir();
1150 std::string aFileName = aSObject->GetName();
1151 std::string aFilePath = aTmpDir + aFileName;
1153 if (aResult->ExportMED(aFilePath.c_str())) {
1154 openFile(aFilePath.c_str());
1155 myTemporaryFiles.append(QString(aFilePath.c_str()));
1158 MESSAGE("Visu module is not found.");
1163 \brief Deletes temporary files created during import operation from VISU
1165 void PVGUI_Module::deleteTemporaryFiles()
1167 foreach(QString aFile, myTemporaryFiles) {
1168 if (QFile::exists(aFile)) {
1169 QFile::remove(aFile);
1176 \brief Returns current active ParaView server
1178 pqServer* PVGUI_Module::getActiveServer()
1180 return pqApplicationCore::instance()->getActiveServer();
1185 \brief Creates PARAVIS preference pane
1187 void PVGUI_Module::createPreferences()
1189 // Paraview settings tab
1190 int aParaViewSettingsTab = addPreference( tr( "TIT_PVIEWSETTINGS" ) );
1191 int aPanel = addPreference(QString(), aParaViewSettingsTab, LightApp_Preferences::UserDefined, "PARAVIS", "");
1192 setPreferenceProperty(aPanel, "content", (qint64)(new PVGUI_ParaViewSettingsPane()));
1194 // Paravis settings tab
1195 int aParaVisSettingsTab = addPreference( tr( "TIT_PVISSETTINGS" ) );
1196 addPreference( tr( "PREF_STOP_TRACE" ), aParaVisSettingsTab, LightApp_Preferences::Bool, "PARAVIS", "stop_trace");
1198 int aSaveType = addPreference(tr( "PREF_SAVE_TYPE_LBL" ), aParaVisSettingsTab,
1199 LightApp_Preferences::Selector,
1200 "PARAVIS", "savestate_type");
1201 QList<QVariant> aIndices;
1202 QStringList aStrings;
1204 aStrings<<tr("PREF_SAVE_TYPE_0");
1205 aStrings<<tr("PREF_SAVE_TYPE_1");
1206 aStrings<<tr("PREF_SAVE_TYPE_2");
1207 setPreferenceProperty(aSaveType, "strings", aStrings);
1208 setPreferenceProperty(aSaveType, "indexes", aIndices);
1210 //rnv: imp 21712: [CEA 581] Preference to display legend by default
1211 int aDispColoreLegend = addPreference( tr( "PREF_SHOW_COLOR_LEGEND" ), aParaVisSettingsTab,
1212 LightApp_Preferences::Bool, "PARAVIS", "show_color_legend");
1216 \brief Creates ParaViS context menu popup
1218 void PVGUI_Module::contextMenuPopup(const QString& theClient, QMenu* theMenu, QString& theTitle)
1220 SalomeApp_Module::contextMenuPopup(theClient, theMenu, theTitle);
1222 // Check if we are in Object Browser
1223 SUIT_DataBrowser* ob = getApp()->objectBrowser();
1224 bool isOBClient = (ob && theClient == ob->popupClientType());
1229 // Get list of selected objects
1230 LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr();
1231 SALOME_ListIO aListIO;
1232 aSelectionMgr->selectedObjects(aListIO);
1233 if (aListIO.Extent() == 1 && aListIO.First()->hasEntry()) {
1234 QString entry = QString(aListIO.First()->getEntry());
1237 SalomeApp_Study* activeStudy =
1238 dynamic_cast<SalomeApp_Study*>(getApp()->activeStudy());
1243 // Get SALOMEDS client study
1244 _PTR(Study) studyDS = activeStudy->studyDS();
1249 QString paravisDataType(PARAVIS::GetParavisGen(this)->ComponentDataType());
1250 if(activeStudy && activeStudy->isComponent(entry) &&
1251 activeStudy->componentDataType(entry) == paravisDataType) {
1252 // ParaViS module object
1253 theMenu->addSeparator();
1254 theMenu->addAction(action(SaveStatePopupId));
1257 // Try to get state object
1258 _PTR(SObject) stateSObj =
1259 studyDS->FindObjectID(entry.toLatin1().constData());
1265 _PTR(GenericAttribute) anAttr;
1266 if (!stateSObj->FindAttribute(anAttr, "AttributeLocalID")) {
1270 _PTR(AttributeLocalID) anID(anAttr);
1272 if (anID->Value() == PVSTATEID) {
1273 // Paraview state object
1274 theMenu->addSeparator();
1275 theMenu->addAction(action(AddStatePopupId));
1276 theMenu->addAction(action(CleanAndAddStatePopupId));
1277 theMenu->addSeparator();
1278 theMenu->addAction(action(ParaVisRenameId));
1279 theMenu->addAction(action(ParaVisDeleteId));
1285 void PVGUI_Module::onShowTrace()
1287 if (!myTraceWindow) {
1288 myTraceWindow = new pqPythonScriptEditor(getApp()->desktop());
1290 myTraceWindow->setText(getTraceString());
1291 myTraceWindow->show();
1292 myTraceWindow->raise();
1293 myTraceWindow->activateWindow();
1297 \brief Show ParaView view.
1299 void PVGUI_Module::onNewParaViewWindow()
1305 \brief Save state under the module root object.
1307 void PVGUI_Module::onSaveMultiState()
1309 // Create state study object
1311 // Get SALOMEDS client study
1312 _PTR(Study) studyDS = PARAVIS::GetCStudy(this);
1317 _PTR(SComponent) paravisComp =
1318 studyDS->FindComponent(PARAVIS::GetParavisGen(this)->ComponentDataType());
1323 // Unlock the study if it is locked
1324 bool isLocked = studyDS->GetProperties()->IsLocked();
1326 studyDS->GetProperties()->SetLocked(false);
1329 QString stateName = tr("SAVED_PARAVIEW_STATE_NAME") +
1330 QString::number(myStateCounter + 1);
1332 _PTR(StudyBuilder) studyBuilder = studyDS->NewBuilder();
1333 _PTR(SObject) newSObj = studyBuilder->NewObject(paravisComp);
1336 _PTR(GenericAttribute) anAttr;
1337 anAttr = studyBuilder->FindOrCreateAttribute(newSObj, "AttributeName");
1338 _PTR(AttributeName) nameAttr(anAttr);
1340 nameAttr->SetValue(stateName.toLatin1().constData());
1343 anAttr = studyBuilder->FindOrCreateAttribute(newSObj, "AttributeLocalID");
1344 _PTR(AttributeLocalID) localIdAttr(anAttr);
1346 localIdAttr->SetValue(PVSTATEID);
1349 QString stateEntry = QString::fromStdString(newSObj->GetID());
1351 // File name for state saving
1352 QString tmpDir = QString::fromStdString(SALOMEDS_Tool::GetTmpDir());
1353 QString fileName = QString("%1_paravisstate:%2").arg(tmpDir,
1356 anAttr = studyBuilder->FindOrCreateAttribute(newSObj, "AttributeString");
1357 _PTR(AttributeString) stringAttr(anAttr);
1359 stringAttr->SetValue(fileName.toLatin1().constData());
1361 // Lock the study back if necessary
1363 studyDS->GetProperties()->SetLocked(true);
1367 saveParaviewState(fileName.toLatin1().constData());
1368 myTemporaryFiles.append(fileName);
1370 // Increment the counter
1377 \brief Restore the selected state by merging with the current one.
1379 void PVGUI_Module::onAddState()
1381 loadSelectedState(false);
1385 \brief Clean the current state and restore the selected one.
1387 void PVGUI_Module::onCleanAddState()
1389 loadSelectedState(true);
1393 \brief Rename the selected object.
1395 void PVGUI_Module::onRename()
1397 LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr();
1398 SALOME_ListIO aListIO;
1399 aSelectionMgr->selectedObjects(aListIO);
1401 if (aListIO.Extent() == 1 && aListIO.First()->hasEntry()) {
1402 std::string entry = aListIO.First()->getEntry();
1404 // Get SALOMEDS client study
1405 _PTR(Study) studyDS = PARAVIS::GetCStudy(this);
1410 // Unlock the study if it is locked
1411 bool isLocked = studyDS->GetProperties()->IsLocked();
1413 studyDS->GetProperties()->SetLocked(false);
1416 // Rename the selected state object
1417 _PTR(SObject) stateSObj = studyDS->FindObjectID(entry);
1422 _PTR(GenericAttribute) anAttr;
1423 if (stateSObj->FindAttribute(anAttr, "AttributeName")) {
1424 _PTR(AttributeName) nameAttr (anAttr);
1426 LightApp_NameDlg::getName(getApp()->desktop(), nameAttr->Value().c_str());
1427 if (!newName.isEmpty()) {
1428 nameAttr->SetValue(newName.toLatin1().constData());
1429 aListIO.First()->setName(newName.toLatin1().constData());
1433 // Lock the study back if necessary
1435 studyDS->GetProperties()->SetLocked(true);
1438 // Update object browser
1445 \brief Delete the selected objects.
1447 void PVGUI_Module::onDelete()
1449 LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr();
1450 SALOME_ListIO aListIO;
1451 aSelectionMgr->selectedObjects(aListIO);
1453 if (aListIO.Extent() == 1 && aListIO.First()->hasEntry()) {
1454 std::string entry = aListIO.First()->getEntry();
1456 // Get SALOMEDS client study
1457 _PTR(Study) studyDS = PARAVIS::GetCStudy(this);
1462 // Unlock the study if it is locked
1463 bool isLocked = studyDS->GetProperties()->IsLocked();
1465 studyDS->GetProperties()->SetLocked(false);
1468 // Remove the selected state from the study
1469 _PTR(StudyBuilder) studyBuilder = studyDS->NewBuilder();
1470 _PTR(SObject) stateSObj = studyDS->FindObjectID(entry);
1471 studyBuilder->RemoveObject(stateSObj);
1473 // Lock the study back if necessary
1475 studyDS->GetProperties()->SetLocked(true);
1478 // Update object browser
1484 \brief Discover help project files from the resources.
1485 \return name of the help file.
1487 QString PVGUI_Module::getHelpFileName() {
1488 QString aPVHome(getenv("PVHOME"));
1489 if (aPVHome.isNull()) {
1490 qWarning("Wariable PVHOME is not defined");
1493 QChar aSep = QDir::separator();
1494 //PARAVIEW_VERSION from the vtkPVConfig.h file
1495 QString aFileName = aPVHome + aSep + "share" + aSep + "doc" + aSep + "paraview-"+ PARAVIEW_VERSION + aSep + "paraview.qch";
1501 \brief Load selected paraview state
1503 If toClear == true, the current state will be cleared
1505 void PVGUI_Module::loadSelectedState(bool toClear)
1509 LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr();
1510 SALOME_ListIO aListIO;
1511 aSelectionMgr->selectedObjects(aListIO);
1513 if (aListIO.Extent() == 1 && aListIO.First()->hasEntry()) {
1514 std::string entry = aListIO.First()->getEntry();
1516 // Get SALOMEDS client study
1517 _PTR(Study) studyDS = PARAVIS::GetCStudy(this);
1523 _PTR(SObject) stateSObj = studyDS->FindObjectID(entry);
1524 _PTR(GenericAttribute) anAttr;
1525 if (!stateSObj->FindAttribute(anAttr, "AttributeLocalID")) {
1528 _PTR(AttributeLocalID) anID(anAttr);
1529 if (!anID->Value() == PVSTATEID) {
1533 // Get state file name
1534 if (stateSObj->FindAttribute(anAttr, "AttributeString")) {
1535 _PTR(AttributeString) aStringAttr(anAttr);
1536 QString stringValue(aStringAttr->Value().c_str());
1538 if (QFile::exists(stringValue)) {
1539 fileName = stringValue;
1544 if (!fileName.isEmpty()) {
1546 clearParaviewState();
1549 loadParaviewState(fileName.toLatin1().constData());
1552 SUIT_MessageBox::critical(getApp()->desktop(),
1554 tr("ERR_STATE_CANNOT_BE_RESTORED"));
1558 void PVGUI_Module::onRepresentationChanged(pqRepresentation*) {
1561 //rnv: to fix the issue "21712: [CEA 581] Preference to display legend by default"
1562 // find the pqDisplayColorWidget instances and connect the variableChanged SIGNAL on the
1563 // onVariableChanged slot of this class. This connection needs to change visibility
1564 // of the "Colored Legend" after change the "Color By" array.
1565 QList<pqDisplayColorWidget*> aWidget = getApp()->desktop()->findChildren<pqDisplayColorWidget*>();
1567 for (int i = 0; i < aWidget.size() ; i++ ) {
1569 connect( aWidget[i], SIGNAL ( variableChanged ( pqVariableType, const QString ) ),
1570 this, SLOT(onVariableChanged( pqVariableType, const QString) ), Qt::UniqueConnection );
1577 \fn CAM_Module* createModule();
1578 \brief Export module instance (factory function).
1579 \return new created instance of the module
1583 #define PVGUI_EXPORT __declspec(dllexport)
1585 #define PVGUI_EXPORT
1591 PVGUI_EXPORT CAM_Module* createModule() {
1596 return new PVGUI_Module();
1599 PVGUI_EXPORT char* getModuleVersion() {
1600 return (char*)PARAVIS_VERSION_STR;