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
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_Interp.h>
69 #include <PyInterp_Dispatcher.h>
70 #include <PyConsole_Console.h>
72 #include <QtxActionMenuMgr.h>
73 #include <QtxActionToolMgr.h>
76 #include <QApplication>
82 #include <QInputDialog>
86 #include <QStringList>
89 #include <QTextStream>
91 #include <QDockWidget>
92 #include <QHelpEngine>
94 #include <pqApplicationCore.h>
95 #include <pqPVApplicationCore.h>
96 #include <pqActiveView.h>
97 #include <pqObjectBuilder.h>
98 #include <pqOptions.h>
99 #include <pqRenderView.h>
100 #include <pqServer.h>
101 #include <pqUndoStack.h>
102 #include <pqVCRController.h>
103 #include <pqTabbedMultiViewWidget.h>
104 #include <pqPipelineSource.h>
105 #include <pqActiveObjects.h>
106 #include <vtkProcessModule.h>
107 #include <vtkSMSession.h>
108 #include <vtkPVSession.h>
109 #include <vtkPVProgressHandler.h>
110 #include <pqParaViewBehaviors.h>
111 #include <pqHelpReaction.h>
112 #include <vtkOutputWindow.h>
113 #include <pqPluginManager.h>
114 #include "pqInterfaceTracker.h"
115 #include <pqSettings.h>
116 #include <pqPythonDialog.h>
117 #include <pqPythonManager.h>
118 #include <pqPythonShell.h>
119 #include <pqLoadDataReaction.h>
120 #include <vtkEventQtSlotConnect.h>
121 #include <pqPythonScriptEditor.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 <pqStandardViewFrameActionsImplementation.h>
131 #include <pqViewStreamingBehavior.h>
133 #include <PARAVIS_version.h>
135 #include <vtkPVConfig.h>
138 #include CORBA_SERVER_HEADER(SALOME_ModuleCatalog)
140 #include <pqAlwaysConnectedBehavior.h>
141 #include <pqApplicationCore.h>
142 #include <pqAutoLoadPluginXMLBehavior.h>
143 #include <pqCommandLineOptionsBehavior.h>
144 #include <pqCrashRecoveryBehavior.h>
145 #include <pqDataTimeStepBehavior.h>
146 #include <pqDefaultViewBehavior.h>
147 #include <pqObjectPickingBehavior.h>
148 #include <pqPersistentMainWindowStateBehavior.h>
149 #include <pqPipelineContextMenuBehavior.h>
150 #include <pqPluginActionGroupBehavior.h>
151 #include <pqPluginDockWidgetsBehavior.h>
152 #include <pqPluginManager.h>
153 #include <pqSpreadSheetVisibilityBehavior.h>
154 #include <pqUndoRedoBehavior.h>
155 #include <pqServerManagerObserver.h>
156 #include <pqVerifyRequiredPluginBehavior.h>
157 #include <pqFixPathsInStateFilesBehavior.h>
158 #include <pqPluginSettingsBehavior.h>
159 #include <pqPropertiesPanel.h>
161 #include <pqApplyBehavior.h>
163 #include <vtkClientServerInterpreterInitializer.h>
167 #include <vtkSMTrace.h>
168 #include <vtkSMSessionProxyManager.h>
169 #include <vtkSMParaViewPipelineController.h>
171 //----------------------------------------------------------------------------
172 pqPVApplicationCore* PVGUI_Module::MyCoreApp = 0;
173 //PVGUI_OutputWindowAdapter* PVGUI_Module::pqImplementation::OutputWindowAdapter = 0;
174 //QPointer<pqHelpWindow> PVGUI_Module::pqImplementation::helpWindow = 0;
176 PVGUI_Module* ParavisModule = 0;
181 <h2>Building and installing PARAVIS</h2>
182 As any other SALOME module, PARAVIS requires PARAVIS_ROOT_DIR environment variable to be set to PARAVIS
183 installation directory.
184 Other variables needed for correct detection of ParaView location:
185 \li PVHOME - points at the ParaView installation directory tree
186 \li PVVERSION - number of ParaView version
188 It also requires common SALOME environment including GUI_ROOT_DIR and other prerequsites.
191 PARAVIS module can be launched using the following commands:
192 \li Full SALOME configuration
194 runSalome --modules="PARAVIS"
197 <h2>ParaView GUI integration</h2>
198 <h3>ParaView GUI integration overview</h3>
200 The main idea is to reuse ParaView GUI internal logic as much as possible, providing a layer
201 between it and SALOME GUI that hides the following SALOME GUI implementation details from ParaView:
203 \li SALOME GUI executable and Qt event loop
204 \li SALOME GUI desktop
205 \li Dock windows areas
206 \li SALOME menu and toolbar managers
208 Major part of the integration is implemented in PVGUI_Module class.
210 <h3>ParaView client initalization</h3>
212 ParaView client initalization is performed when an instance of PVGUI_Module class has been created
213 and \link PVGUI_Module::initialize() PVGUI_Module::initialize()\endlink method is called by SALOME GUI.
214 The actual client start-up is done in \link PVGUI_Module::pvInit() PVGUI_Module::pvInit()\endlink method.
217 <h3>Multi-view manager</h3>
219 SALOME GUI requires that each kind of view be implemnted with help of (at least) three classes. For ParaView multi-view manager
222 \li PVGUI_ViewManager - view manager class
223 \li PVGUI_Viewer - view model class
224 \li PVGUI_ViewWindow - view window class that acts as a parent for %pqViewManager
226 Single instances of PVGUI_ViewManager and PVGUI_ViewWindow classes are created by \link PVGUI_Module::showView()
227 PVGUI_Module::showView()\endlink method upon the first PARAVIS module activation. The same method hides the multi-view manager
228 when the module is deactivated (the user switches to another module or a study is closed).
229 A special trick is used to make PVGUI_ViewWindow the parent of %pqViewManager widget. It is created initally by %pqMainWindowCore
230 with the desktop as a parent, so when it is shown PVGUI_ViewWindow instance is passed to its setParent() method. In
231 \link PVGUI_ViewWindow::~PVGUI_ViewWindow() PVGUI_ViewWindow::~PVGUI_ViewWindow()\endlink the parent is nullified to avoid deletion
232 of %pqViewManager widget that would break %pqMainWindowCore class.
234 <h3>ParaView plugins</h3>
235 ParaView server and client plugins are managed by %pqMainWindowCore slots that has full access to PARAVIS menus and toolbars.
236 As a result they appears automatically in PARAVIS menus and toolbars if loaded successfully.
241 \brief Implementation
242 SALOME module wrapping ParaView GUI.
247 Fix for the issue 21730: [CEA 596] Slice of polyhedron in PARAVIS returns no cell.
248 Wrap vtkEDFCutter filter.
251 extern "C" void vtkEDFCutterCS_Initialize(vtkClientServerInterpreter*);
252 static void vtkEDFHelperInit();
254 void vtkEDFHelperInit(vtkClientServerInterpreter* interp){
255 vtkEDFCutterCS_Initialize(interp);
258 void vtkEDFHelperInit() {
259 vtkClientServerInterpreterInitializer::GetInitializer()->
260 RegisterCallback(&vtkEDFHelperInit);
265 ClientFindOrCreateParavisComponent(_PTR(Study) theStudyDocument)
267 _PTR(SComponent) aSComponent = theStudyDocument->FindComponent("PARAVIS");
269 _PTR(StudyBuilder) aStudyBuilder = theStudyDocument->NewBuilder();
270 aStudyBuilder->NewCommand();
271 int aLocked = theStudyDocument->GetProperties()->IsLocked();
272 if (aLocked) theStudyDocument->GetProperties()->SetLocked(false);
273 aSComponent = aStudyBuilder->NewComponent("PARAVIS");
274 _PTR(GenericAttribute) anAttr =
275 aStudyBuilder->FindOrCreateAttribute(aSComponent, "AttributeName");
276 _PTR(AttributeName) aName (anAttr);
278 CORBA::ORB_var anORB = PARAVIS::PARAVIS_Gen_i::GetORB();
279 SALOME_NamingService *NamingService = new SALOME_NamingService( anORB );
280 CORBA::Object_var objVarN = NamingService->Resolve("/Kernel/ModulCatalog");
281 SALOME_ModuleCatalog::ModuleCatalog_var Catalogue =
282 SALOME_ModuleCatalog::ModuleCatalog::_narrow(objVarN);
283 SALOME_ModuleCatalog::Acomponent_var Comp = Catalogue->GetComponent( "PARAVIS" );
284 if (!Comp->_is_nil()) {
285 aName->SetValue(Comp->componentusername());
288 anAttr = aStudyBuilder->FindOrCreateAttribute(aSComponent, "AttributePixMap");
289 _PTR(AttributePixMap) aPixmap (anAttr);
290 aPixmap->SetPixMap( "pqAppIcon16.png" );
292 // Create Attribute parameters for future using
293 anAttr = aStudyBuilder->FindOrCreateAttribute(aSComponent, "AttributeParameter");
296 PARAVIS::PARAVIS_Gen_var aPARAVIS = PARAVIS::PARAVIS_Gen_i::GetParavisGenImpl()->_this();
298 aStudyBuilder->DefineComponentInstance(aSComponent, aPARAVIS->GetIOR());
299 if (aLocked) theStudyDocument->GetProperties()->SetLocked(true);
300 aStudyBuilder->CommitCommand();
306 Clean up function; used to stop ParaView progress events when
307 exception is caught by global exception handler.
309 void paravisCleanUp()
311 if ( pqApplicationCore::instance() ) {
312 pqServer* s = pqApplicationCore::instance()->getActiveServer();
313 if ( s ) s->session()->GetProgressHandler()->CleanupPendingProgress();
318 \brief Constructor. Sets the default name for the module.
320 PVGUI_Module::PVGUI_Module()
321 : SalomeApp_Module( "PARAVIS" ),
322 // Implementation( 0 ),
323 mySelectionControlsTb( -1 ),
324 mySourcesMenuId( -1 ),
325 myFiltersMenuId( -1 ),
327 myToolbarsMenuId(-1),
334 Q_INIT_RESOURCE( PVGUI );
336 ParavisModule = this;
338 // Clear old copies of embedded macros files
339 QString aDestPath = QString( "%1/.config/%2/Macros" ).arg( QDir::homePath() ).arg( QApplication::applicationName() );
343 QDir aDestDir(aDestPath);
344 QStringList aDestFiles = aDestDir.entryList(aFilter, QDir::Files);
345 foreach (QString aMacrosPath, getEmbeddedMacrosList()) {
346 QString aMacrosName = QFileInfo(aMacrosPath).fileName();
347 if (aDestFiles.contains(aMacrosName)) {
348 aDestDir.remove(aMacrosName);
356 PVGUI_Module::~PVGUI_Module()
361 \brief Initialize module. Creates menus, prepares context menu, etc.
362 \param app SALOME GUI application instance
364 void PVGUI_Module::initialize( CAM_Application* app )
366 // [ABN]: patched in ParaView's sources.
367 // PVGUI_MatplotlibMathTextUtilities::Disable();
369 SalomeApp_Module::initialize( app );
371 // Create ParaViS actions
373 // Create ParaViS menus
376 // Uncomment to debug ParaView initialization
377 // "aa" used instead of "i" as GDB doesn't like "i" variables :)
385 // Initialize ParaView client
388 // Create GUI elements (menus, toolbars, dock widgets)
389 //if ( !Implementation ){
390 SalomeApp_Application* anApp = getApp();
391 SUIT_Desktop* aDesktop = anApp->desktop();
393 // connect(aDesktop, SIGNAL()
395 // Remember current state of desktop toolbars
396 QList<QToolBar*> foreignToolbars = aDesktop->findChildren<QToolBar*>();
398 // Simulate ParaView client main window
399 //Implementation = new pqImplementation( aDesktop );
407 QList<QDockWidget*> activeDocks = aDesktop->findChildren<QDockWidget*>();
408 QList<QMenu*> activeMenus = aDesktop->findChildren<QMenu*>();
410 // new pqParaViewBehaviors(anApp->desktop(), this);
411 // Has to be replaced in order to exclude using of pqQtMessageHandlerBehaviour
412 // Start pqParaViewBehaviors
413 // Register ParaView interfaces.
414 //pqPluginManager* pgm = pqApplicationCore::instance()->getPluginManager();
415 pqInterfaceTracker* pgm = pqApplicationCore::instance()->interfaceTracker();
417 // Register standard types of property widgets.
418 pgm->addInterface(new pqStandardPropertyWidgetInterface(pgm));
419 // Register standard types of view-frame actions.
420 pgm->addInterface(new pqStandardViewFrameActionsImplementation(pgm));
422 // Load plugins distributed with application.
423 pqApplicationCore::instance()->loadDistributedPlugins();
425 // Define application behaviors.
426 //new pqQtMessageHandlerBehavior(this);
427 new pqDataTimeStepBehavior(this);
428 new pqSpreadSheetVisibilityBehavior(this);
429 new pqPipelineContextMenuBehavior(this);
430 new pqObjectPickingBehavior(this);
431 new pqDefaultViewBehavior(this);
432 new pqUndoRedoBehavior(this);
433 new pqAlwaysConnectedBehavior(this);
434 new pqCrashRecoveryBehavior(this);
435 new pqAutoLoadPluginXMLBehavior(this);
436 new pqPluginDockWidgetsBehavior(aDesktop);
437 new pqVerifyRequiredPluginBehavior(this);
438 new pqPluginActionGroupBehavior(aDesktop);
439 new pqFixPathsInStateFilesBehavior(this);
440 new pqCommandLineOptionsBehavior(this);
441 new pqPersistentMainWindowStateBehavior(aDesktop);
442 new pqCollaborationBehavior(this);
443 new pqViewStreamingBehavior(this);
444 new pqPluginSettingsBehavior(this);
446 pqApplyBehavior* applyBehavior = new pqApplyBehavior(this);
447 foreach (pqPropertiesPanel* ppanel, aDesktop->findChildren<pqPropertiesPanel*>())
449 applyBehavior->registerPanel(ppanel);
453 // Setup quick-launch shortcuts.
454 QShortcut *ctrlSpace = new QShortcut(Qt::CTRL + Qt::Key_Space, aDesktop);
455 QObject::connect(ctrlSpace, SIGNAL(activated()),
456 pqApplicationCore::instance(), SLOT(quickLaunch()));
458 // Find Plugin Dock Widgets
459 QList<QDockWidget*> currentDocks = aDesktop->findChildren<QDockWidget*>();
460 QList<QDockWidget*>::iterator i;
461 for (i = currentDocks.begin(); i != currentDocks.end(); ++i) {
462 if(!activeDocks.contains(*i)) {
463 myDockWidgets[*i] = false; // hidden by default
469 // [ABN] TODO: fix this - triggers a SEGFAULT at deactivation() time.
470 // QList<QMenu*> currentMenus = aDesktop->findChildren<QMenu*>();
471 // QList<QMenu*>::iterator im;
472 // for (im = currentMenus.begin(); im != currentMenus.end(); ++im) {
473 // if(!activeMenus.contains(*im)) {
474 // QString s = (*im)->title();
475 // std::cout << " MENU "<< s.toStdString() << std::endl;
476 // myMenus.append(*im);
480 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
481 QString aPath = resMgr->stringValue("resources", "PARAVIS", QString());
482 if (!aPath.isNull()) {
483 MyCoreApp->loadConfiguration(aPath + QDir::separator() + "ParaViewFilters.xml");
484 MyCoreApp->loadConfiguration(aPath + QDir::separator() + "ParaViewReaders.xml");
485 MyCoreApp->loadConfiguration(aPath + QDir::separator() + "ParaViewSources.xml");
486 MyCoreApp->loadConfiguration(aPath + QDir::separator() + "ParaViewWriters.xml");
489 // Force creation of engine
490 PARAVIS::GetParavisGen(this);
493 // Find created toolbars
494 QCoreApplication::processEvents();
496 QList<QToolBar*> allToolbars = aDesktop->findChildren<QToolBar*>();
497 foreach(QToolBar* aBar, allToolbars) {
498 if (!foreignToolbars.contains(aBar)) {
499 myToolbars[aBar] = true;
500 myToolbarBreaks[aBar] = false;
501 aBar->setVisible(false);
502 aBar->toggleViewAction()->setVisible(false);
509 // we need to start trace after connection is done
510 connect(pqApplicationCore::instance()->getObjectBuilder(), SIGNAL(finishedAddingServer(pqServer*)),
511 this, SLOT(onFinishedAddingServer(pqServer*)));
513 connect(pqApplicationCore::instance()->getObjectBuilder(), SIGNAL(dataRepresentationCreated(pqDataRepresentation*)),
514 this, SLOT(onDataRepresentationCreated(pqDataRepresentation*)));
517 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
518 bool isStop = aResourceMgr->booleanValue( "PARAVIS", "stop_trace", false );
519 // start a timer to schedule the trace start asap:
523 this->VTKConnect = vtkEventQtSlotConnect::New();
525 vtkProcessModule* pm = vtkProcessModule::GetProcessModule();
527 vtkPVSession* pvs = dynamic_cast<vtkPVSession*>(pm->GetSession());
529 vtkPVProgressHandler* ph = pvs->GetProgressHandler();
531 this->VTKConnect->Connect(ph, vtkCommand::StartEvent,
532 this, SLOT(onStartProgress()));
533 this->VTKConnect->Connect(ph, vtkCommand::EndEvent,
534 this, SLOT(onEndProgress()));
539 connect(&pqActiveObjects::instance(),
540 SIGNAL(representationChanged(pqRepresentation*)),
541 this, SLOT(onRepresentationChanged(pqRepresentation*)));
544 void PVGUI_Module::onStartProgress()
546 QApplication::setOverrideCursor(Qt::WaitCursor);
549 void PVGUI_Module::onEndProgress()
551 QApplication::restoreOverrideCursor();
554 void PVGUI_Module::onFinishedAddingServer(pqServer* /*server*/)
556 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
557 bool isStop = aResourceMgr->booleanValue( "PARAVIS", "stop_trace", false );
562 void PVGUI_Module::onDataRepresentationCreated(pqDataRepresentation* data) {
566 // if(!data->getLookupTable())
569 // SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
573 // bool visible = aResourceMgr->booleanValue( "PARAVIS", "show_color_legend", false );
574 // pqLookupTableManager* lut_mgr = pqApplicationCore::instance()->getLookupTableManager();
577 // lut_mgr->setScalarBarVisibility(data,visible);
580 // connect(data, SIGNAL(dataUpdated()), this, SLOT(onDataRepresentationUpdated()));
583 void PVGUI_Module::onDataRepresentationUpdated() {
584 SalomeApp_Study* activeStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
585 if(!activeStudy) return;
587 activeStudy->Modified();
590 void PVGUI_Module::onVariableChanged(pqVariableType t, const QString) {
592 pqDisplayColorWidget* colorWidget = qobject_cast<pqDisplayColorWidget*>(sender());
596 if( t == VARIABLE_TYPE_NONE )
599 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
604 bool visible = aResourceMgr->booleanValue( "PARAVIS", "show_color_legend", false );
609 /*//VTN: getRepresentation is protected
610 pqDataRepresentation* data = colorWidget->getRepresentation();
612 if( !data->getLookupTable() )
615 pqLookupTableManager* lut_mgr = pqApplicationCore::instance()->getLookupTableManager();
618 lut_mgr->setScalarBarVisibility(data,visible);
621 pqColorToolbar* colorTooBar = qobject_cast<pqColorToolbar*>(colorWidget->parent());
625 pqScalarBarVisibilityReaction* scalarBarVisibility = colorTooBar->findChild<pqScalarBarVisibilityReaction *>();
626 if(scalarBarVisibility) {
627 scalarBarVisibility->setScalarBarVisibility(visible);
632 \brief Launches a tracing of current server
634 void PVGUI_Module::timerEvent(QTimerEvent* te )
637 // if ( PyInterp_Dispatcher::Get()->IsBusy() )
639 // // Reschedule for later
640 // MESSAGE("interpreter busy -> rescheduling trace start.");
645 MESSAGE("about to start trace....");
647 MESSAGE("trace STARTED....");
649 killTimer( te->timerId() );
654 \brief Get list of embedded macros files
656 QStringList PVGUI_Module::getEmbeddedMacrosList()
658 QString aRootDir = getenv("PARAVIS_ROOT_DIR");
660 QString aSourcePath = aRootDir + "/bin/salome/Macro";
665 QDir aSourceDir(aSourcePath);
666 QStringList aSourceFiles = aSourceDir.entryList(aFilter, QDir::Files);
667 QStringList aFullPathSourceFiles;
668 foreach (QString aMacrosName, aSourceFiles) {
669 aFullPathSourceFiles << aSourceDir.absoluteFilePath(aMacrosName);
671 return aFullPathSourceFiles;
674 void PVGUI_Module::updateMacros()
676 pqPythonManager* aPythonManager = pqPVApplicationCore::instance()->pythonManager();
677 if(!aPythonManager) {
681 foreach (QString aStr, getEmbeddedMacrosList()) {
682 aPythonManager->addMacro(aStr);
688 \brief Get list of compliant dockable GUI elements
689 \param m map to be filled in ("type":"default_position")
691 void PVGUI_Module::windows( QMap<int, int>& m ) const
693 m.insert( LightApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
694 m.insert( LightApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
695 // ParaView diagnostic output redirected here
696 m.insert( LightApp_Application::WT_LogWindow, Qt::BottomDockWidgetArea );
700 \brief Static method, performs initialization of ParaView session.
701 \return \c true if ParaView has been initialized successfully, otherwise false
703 bool PVGUI_Module::pvInit()
705 // if ( !pqImplementation::Core ){
707 // Obtain command-line arguments
710 QString aOptions = getenv("PARAVIS_OPTIONS");
711 QStringList aOptList = aOptions.split(":", QString::SkipEmptyParts);
712 argv = new char*[aOptList.size() + 1];
713 QStringList args = QApplication::arguments();
714 argv[0] = (args.size() > 0)? strdup(args[0].toLatin1().constData()) : strdup("paravis");
717 foreach (QString aStr, aOptList) {
718 argv[argc] = strdup( aStr.toLatin1().constData() );
721 MyCoreApp = new pqPVApplicationCore (argc, argv);
722 if (MyCoreApp->getOptions()->GetHelpSelected() ||
723 MyCoreApp->getOptions()->GetUnknownArgument() ||
724 MyCoreApp->getOptions()->GetErrorMessage() ||
725 MyCoreApp->getOptions()->GetTellVersion()) {
729 /* VTN: Looks like trash. For porting see branded_paraview_initializer.cxx.in
730 // Not sure why this is needed. Andy added this ages ago with comment saying
731 // needed for Mac apps. Need to check that it's indeed still required.
732 QDir dir(QApplication::applicationDirPath());
735 QApplication::addLibraryPath(dir.absolutePath());
736 // Load required application plugins.
737 QString plugin_string = "";
738 QStringList plugin_list = plugin_string.split(';',QString::SkipEmptyParts);
739 pqBrandPluginsLoader loader;
740 if (loader.loadPlugins(plugin_list) == false) {
741 printf("Failed to load required plugins for this application\n");
745 // Load optional plugins.
747 plugin_list = plugin_string.split(';',QString::SkipEmptyParts);
748 loader.loadPlugins(plugin_list, true); //quietly skip not-found plugins.
750 // End of Initializer code
752 MyCoreApp->settings();
754 vtkOutputWindow::SetInstance(PVGUI_OutputWindowAdapter::New());
756 new pqTabbedMultiViewWidget(); // it registers as "MULTIVIEW_WIDGET on creation
758 for (int i = 0; i < argc; i++)
767 \brief Shows (toShow = true) or hides ParaView view window
769 void PVGUI_Module::showView( bool toShow )
771 SalomeApp_Application* anApp = getApp();
772 PVGUI_ViewManager* viewMgr =
773 dynamic_cast<PVGUI_ViewManager*>( anApp->getViewManager( PVGUI_Viewer::Type(), false ) );
775 viewMgr = new PVGUI_ViewManager( anApp->activeStudy(), anApp->desktop() );
776 anApp->addViewManager( viewMgr );
777 connect( viewMgr, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
778 anApp, SLOT( onCloseView( SUIT_ViewManager* ) ) );
781 PVGUI_ViewWindow* pvWnd = dynamic_cast<PVGUI_ViewWindow*>( viewMgr->getActiveView() );
783 pvWnd = dynamic_cast<PVGUI_ViewWindow*>( viewMgr->createViewWindow() );
786 pvWnd->setShown( toShow );
787 if ( toShow ) pvWnd->setFocus();
791 \brief Slot to show help for proxy.
793 void PVGUI_Module::showHelpForProxy( const QString& groupname, const QString& proxyname )
795 pqHelpReaction::showProxyHelp(groupname, proxyname);
800 \brief Slot to show the waiting state.
802 void PVGUI_Module::onPreAccept()
804 getApp()->desktop()->statusBar()->showMessage(tr("STB_PREACCEPT"));
805 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
809 \brief Slot to show the ready state.
811 void PVGUI_Module::onPostAccept()
813 getApp()->desktop()->statusBar()->showMessage(tr("STB_POSTACCEPT"), 2000);
814 QTimer::singleShot(0, this, SLOT(endWaitCursor()));
818 \brief Slot to switch off wait cursor.
820 void PVGUI_Module::endWaitCursor()
822 QApplication::restoreOverrideCursor();
826 \brief Returns the ParaView multi-view manager.
828 pqTabbedMultiViewWidget* PVGUI_Module::getMultiViewManager() const
830 return qobject_cast<pqTabbedMultiViewWidget*>(pqApplicationCore::instance()->manager("MULTIVIEW_WIDGET"));
834 static void ParavisMessageOutput(QtMsgType type, const char *msg)
839 vtkOutputWindow::GetInstance()->DisplayText(msg);
842 vtkOutputWindow::GetInstance()->DisplayErrorText(msg);
845 vtkOutputWindow::GetInstance()->DisplayErrorText(msg);
848 vtkOutputWindow::GetInstance()->DisplayErrorText(msg);
856 \brief Activate module.
857 \param study current study
858 \return \c true if activaion is done successfully or 0 to prevent
861 bool PVGUI_Module::activateModule( SUIT_Study* study )
863 myOldMsgHandler = qInstallMsgHandler(ParavisMessageOutput);
865 SUIT_ExceptionHandler::addCleanUpRoutine( paravisCleanUp );
867 storeCommonWindowsState();
869 bool isDone = SalomeApp_Module::activateModule( study );
870 if ( !isDone ) return false;
873 if ( mySourcesMenuId != -1 ) menuMgr()->show(mySourcesMenuId);
874 if ( myFiltersMenuId != -1 ) menuMgr()->show(myFiltersMenuId);
875 if ( myFiltersMenuId != -1 ) menuMgr()->show(myMacrosMenuId);
876 if ( myFiltersMenuId != -1 ) menuMgr()->show(myToolbarsMenuId);
877 setMenuShown( true );
878 setToolShown( true );
880 restoreDockWidgetsState();
882 QMenu* aMenu = menuMgr()->findMenu( myRecentMenuId );
884 QList<QAction*> anActns = aMenu->actions();
885 for (int i = 0; i < anActns.size(); ++i) {
886 QAction* a = anActns.at(i);
892 QList<QMenu*>::iterator it;
893 for (it = myMenus.begin(); it != myMenus.end(); ++it) {
894 QAction* a = (*it)->menuAction();
899 if ( myRecentMenuId != -1 ) menuMgr()->show(myRecentMenuId);
901 ClientFindOrCreateParavisComponent(PARAVIS::GetCStudy(this));
908 \brief Deactivate module.
909 \param study current study
910 \return \c true if deactivaion is done successfully or 0 to prevent
911 deactivation on error
913 bool PVGUI_Module::deactivateModule( SUIT_Study* study )
915 QMenu* aMenu = menuMgr()->findMenu( myRecentMenuId );
917 QList<QAction*> anActns = aMenu->actions();
918 for (int i = 0; i < anActns.size(); ++i) {
919 QAction* a = anActns.at(i);
921 a->setVisible(false);
925 QList<QMenu*>::iterator it;
926 for (it = myMenus.begin(); it != myMenus.end(); ++it) {
927 QAction* a = (*it)->menuAction();
929 a->setVisible(false);
932 QList<QDockWidget*> aStreamingViews = application()->desktop()->findChildren<QDockWidget*>("pqStreamingControls");
933 foreach(QDockWidget* aView, aStreamingViews) {
934 if (!myDockWidgets.contains(aView))
935 myDockWidgets[aView] = aView->isVisible();
938 /*if (pqImplementation::helpWindow) {
939 pqImplementation::helpWindow->hide();
943 menuMgr()->hide(myRecentMenuId);
944 menuMgr()->hide(mySourcesMenuId);
945 menuMgr()->hide(myFiltersMenuId);
946 menuMgr()->hide(myMacrosMenuId);
947 menuMgr()->hide(myToolbarsMenuId);
948 setMenuShown( false );
949 setToolShown( false );
952 saveDockWidgetsState();
954 SUIT_ExceptionHandler::removeCleanUpRoutine( paravisCleanUp );
957 qInstallMsgHandler(myOldMsgHandler);
959 restoreCommonWindowsState();
961 return SalomeApp_Module::deactivateModule( study );
966 \brief Called when application is closed.
968 Process finalize application functionality from ParaView in order to save server settings
969 and nullify application pointer if the application is being closed.
971 \param theApp application
973 void PVGUI_Module::onApplicationClosed( SUIT_Application* theApp )
975 pqApplicationCore::instance()->settings()->sync();
976 int aAppsNb = SUIT_Session::session()->applications().size();
978 deleteTemporaryFiles();
979 MyCoreApp->deleteLater();
981 CAM_Module::onApplicationClosed(theApp);
986 \brief Called when study is closed.
988 Removes data model from the \a study.
990 \param study study being closed
992 void PVGUI_Module::studyClosed(SUIT_Study* study)
994 clearParaviewState();
996 SalomeApp_Module::studyClosed(study);
1000 \brief Called when study is opened.
1002 void PVGUI_Module::onModelOpened()
1004 _PTR(Study) studyDS = PARAVIS::GetCStudy(this);
1009 _PTR(SComponent) paravisComp =
1010 studyDS->FindComponent(PARAVIS::GetParavisGen(this)->ComponentDataType());
1015 _PTR(ChildIterator) anIter(studyDS->NewChildIterator(paravisComp));
1016 for (; anIter->More(); anIter->Next()) {
1017 _PTR(SObject) aSObj = anIter->Value();
1018 _PTR(GenericAttribute) anAttr;
1019 if (!aSObj->FindAttribute(anAttr, "AttributeLocalID")) {
1022 _PTR(AttributeLocalID) anID(anAttr);
1023 if (anID->Value() == PVSTATEID) {
1030 \brief Returns IOR of current engine
1032 QString PVGUI_Module::engineIOR() const
1034 CORBA::String_var anIOR = PARAVIS::GetParavisGen(this)->GetIOR();
1035 return QString(anIOR.in());
1040 \brief Open file of format supported by ParaView
1042 void PVGUI_Module::openFile(const char* theName)
1046 pqLoadDataReaction::loadData(aFiles);
1050 * Start trace invoking the newly introduced C++ API (PV 4.2)
1051 * (inspired from pqTraceReaction::start())
1053 void PVGUI_Module::startTrace()
1055 vtkSMSessionProxyManager* pxm = pqActiveObjects::instance().activeServer()->proxyManager();
1057 vtkSmartPointer<vtkSMProxy> proxy;
1058 proxy.TakeReference(pxm->NewProxy("pythontracing", "PythonTraceOptions"));
1061 vtkNew<vtkSMParaViewPipelineController> controller;
1062 controller->InitializeProxy(proxy);
1064 vtkSMTrace* trace = vtkSMTrace::StartTrace();
1067 // Set manually the properties entered via the dialog box poping-up when requiring
1068 // a trace start in PV4.2 (trace options)
1069 trace->SetPropertiesToTraceOnCreate(vtkSMTrace::RECORD_USER_MODIFIED_PROPERTIES);
1070 trace->SetFullyTraceSupplementalProxies(false);
1074 void PVGUI_Module::stopTrace()
1076 vtkSMTrace::StopTrace();
1079 void PVGUI_Module::executeScript(const char *script)
1082 pqPythonManager* manager = qobject_cast<pqPythonManager*>(
1083 pqApplicationCore::instance()->manager("PYTHON_MANAGER"));
1085 pqPythonDialog* pyDiag = manager->pythonShellDialog();
1087 pyDiag->runString(script);
1094 // * Debug function printing out the given interpreter's execution context
1096 //void printInterpContext(PyInterp_Interp * interp )
1098 // // Extract __smtraceString from interpreter's context
1099 // const PyObject* ctxt = interp->getExecutionContext();
1101 // PyObject* lst = PyDict_Keys((PyObject *)ctxt);
1102 // Py_ssize_t siz = PyList_GET_SIZE(lst);
1103 // for (Py_ssize_t i = 0; i < siz; i++)
1105 // PyObject * elem = PyList_GetItem(lst, i);
1106 // if (PyString_Check(elem))
1108 // std::cout << "At pos:" << i << ", " << PyString_AsString(elem) << std::endl;
1111 // std::cout << "At pos:" << i << ", not a string!" << std::endl;
1117 \brief Returns trace string
1119 static const QString MYReplaceStr("paraview.simple");
1120 static const QString MYReplaceImportStr("except: from pvsimple import *");
1121 QString PVGUI_Module::getTraceString()
1123 vtkSMTrace *tracer = vtkSMTrace::GetActiveTracer();
1124 if (!tracer) // trace is not started
1127 QString traceString(tracer->GetCurrentTrace());
1129 // Replace import "paraview.simple" by "pvsimple"
1130 if ((!traceString.isNull()) && traceString.length() != 0) {
1131 int aPos = traceString.indexOf(MYReplaceStr);
1132 while (aPos != -1) {
1133 traceString = traceString.replace(aPos, MYReplaceStr.length(), "pvsimple");
1134 aPos = traceString.indexOf(MYReplaceStr, aPos);
1136 int aImportPos = traceString.indexOf(MYReplaceImportStr);
1137 if(aImportPos != -1)
1139 traceString = traceString.replace(aImportPos, MYReplaceImportStr.length(), "except:\n import pvsimple\n from pvsimple import *");
1147 \brief Saves trace string to disk file
1149 void PVGUI_Module::saveTrace(const char* theName)
1151 QFile file(theName);
1152 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
1153 MESSAGE( "Could not open file:" << theName );
1156 QTextStream out(&file);
1157 out << getTraceString();
1162 \brief Saves ParaView state to a disk file
1164 void PVGUI_Module::saveParaviewState(const char* theFileName)
1166 pqApplicationCore::instance()->saveState(theFileName);
1170 \brief Delete all objects for Paraview Pipeline Browser
1172 void PVGUI_Module::clearParaviewState()
1174 QAction* deleteAllAction = action(DeleteAllId);
1175 if (deleteAllAction) {
1176 deleteAllAction->activate(QAction::Trigger);
1181 \brief Restores ParaView state from a disk file
1183 If toClear == true, the current ojects will be deleted
1185 void PVGUI_Module::loadParaviewState(const char* theFileName)
1187 pqApplicationCore::instance()->loadState(theFileName, getActiveServer());
1191 \brief Imports MED data from VISU module by data entry
1193 void PVGUI_Module::onImportFromVisu(QString theEntry)
1196 SUIT_OverrideCursor aWaitCursor;
1199 SalomeApp_Study* activeStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
1200 if(!activeStudy) return;
1202 // get SALOMEDS client study
1203 _PTR(Study) aStudy = activeStudy->studyDS();
1206 // find VISU component in a study
1207 _PTR(SComponent) aVisuComp = aStudy->FindComponent( "VISU" );
1208 if(!aVisuComp) return;
1210 // get SObject client by entry
1211 _PTR(SObject) aSObj = aStudy->FindObjectID(qPrintable(theEntry));
1214 // get CORBA SObject
1215 SALOMEDS_SObject* aSObject = _CAST(SObject, aSObj);
1216 if ( !aSObject ) return;
1219 SALOME_NamingService* aNamingService = SalomeApp_Application::namingService();
1220 SALOME_LifeCycleCORBA aLCC(aNamingService);
1222 Engines::EngineComponent_var aComponent = aLCC.FindOrLoad_Component("FactoryServer","VISU");
1223 VISU::VISU_Gen_var aVISU = VISU::VISU_Gen::_narrow(aComponent);
1224 if(CORBA::is_nil(aVISU)) return;
1226 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
1227 aStudyBuilder->LoadWith( aVisuComp, SalomeApp_Application::orb()->object_to_string(aVISU) );
1229 // get VISU result object
1230 CORBA::Object_var aResultObject = aSObject->GetObject();
1231 if (CORBA::is_nil(aResultObject)) return;
1232 VISU::Result_var aResult = VISU::Result::_narrow( aResultObject );
1233 if (CORBA::is_nil(aResult)) return;
1235 // export VISU result to the MED file
1236 std::string aTmpDir = SALOMEDS_Tool::GetTmpDir();
1237 std::string aFileName = aSObject->GetName();
1238 std::string aFilePath = aTmpDir + aFileName;
1240 if (aResult->ExportMED(aFilePath.c_str())) {
1241 openFile(aFilePath.c_str());
1242 myTemporaryFiles.append(QString(aFilePath.c_str()));
1245 MESSAGE("Visu module is not found.");
1250 \brief Deletes temporary files created during import operation from VISU
1252 void PVGUI_Module::deleteTemporaryFiles()
1254 foreach(QString aFile, myTemporaryFiles) {
1255 if (QFile::exists(aFile)) {
1256 QFile::remove(aFile);
1263 \brief Returns current active ParaView server
1265 pqServer* PVGUI_Module::getActiveServer()
1267 return pqApplicationCore::instance()->getActiveServer();
1272 \brief Creates PARAVIS preference pane
1274 void PVGUI_Module::createPreferences()
1276 // Paraview settings tab
1277 int aParaViewSettingsTab = addPreference( tr( "TIT_PVIEWSETTINGS" ) );
1278 int aPanel = addPreference(QString(), aParaViewSettingsTab, LightApp_Preferences::UserDefined, "PARAVIS", "");
1279 setPreferenceProperty(aPanel, "content", (qint64)(new PVGUI_ParaViewSettingsPane()));
1281 // Paravis settings tab
1282 int aParaVisSettingsTab = addPreference( tr( "TIT_PVISSETTINGS" ) );
1283 addPreference( tr( "PREF_STOP_TRACE" ), aParaVisSettingsTab, LightApp_Preferences::Bool, "PARAVIS", "stop_trace");
1285 int aSaveType = addPreference(tr( "PREF_SAVE_TYPE_LBL" ), aParaVisSettingsTab,
1286 LightApp_Preferences::Selector,
1287 "PARAVIS", "savestate_type");
1288 QList<QVariant> aIndices;
1289 QStringList aStrings;
1291 aStrings<<tr("PREF_SAVE_TYPE_0");
1292 aStrings<<tr("PREF_SAVE_TYPE_1");
1293 aStrings<<tr("PREF_SAVE_TYPE_2");
1294 setPreferenceProperty(aSaveType, "strings", aStrings);
1295 setPreferenceProperty(aSaveType, "indexes", aIndices);
1297 //rnv: imp 21712: [CEA 581] Preference to display legend by default
1298 // [ABN]: now fixed in ParaView.
1299 // int aDispColoreLegend = addPreference( tr( "PREF_SHOW_COLOR_LEGEND" ), aParaVisSettingsTab,
1300 // LightApp_Preferences::Bool, "PARAVIS", "show_color_legend");
1304 \brief Creates ParaViS context menu popup
1306 void PVGUI_Module::contextMenuPopup(const QString& theClient, QMenu* theMenu, QString& theTitle)
1308 SalomeApp_Module::contextMenuPopup(theClient, theMenu, theTitle);
1310 // Check if we are in Object Browser
1311 SUIT_DataBrowser* ob = getApp()->objectBrowser();
1312 bool isOBClient = (ob && theClient == ob->popupClientType());
1317 // Get list of selected objects
1318 LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr();
1319 SALOME_ListIO aListIO;
1320 aSelectionMgr->selectedObjects(aListIO);
1321 if (aListIO.Extent() == 1 && aListIO.First()->hasEntry()) {
1322 QString entry = QString(aListIO.First()->getEntry());
1325 SalomeApp_Study* activeStudy =
1326 dynamic_cast<SalomeApp_Study*>(getApp()->activeStudy());
1331 // Get SALOMEDS client study
1332 _PTR(Study) studyDS = activeStudy->studyDS();
1337 QString paravisDataType(PARAVIS::GetParavisGen(this)->ComponentDataType());
1338 if(activeStudy && activeStudy->isComponent(entry) &&
1339 activeStudy->componentDataType(entry) == paravisDataType) {
1340 // ParaViS module object
1341 theMenu->addSeparator();
1342 theMenu->addAction(action(SaveStatePopupId));
1345 // Try to get state object
1346 _PTR(SObject) stateSObj =
1347 studyDS->FindObjectID(entry.toLatin1().constData());
1353 _PTR(GenericAttribute) anAttr;
1354 if (!stateSObj->FindAttribute(anAttr, "AttributeLocalID")) {
1358 _PTR(AttributeLocalID) anID(anAttr);
1360 if (anID->Value() == PVSTATEID) {
1361 // Paraview state object
1362 theMenu->addSeparator();
1363 theMenu->addAction(action(AddStatePopupId));
1364 theMenu->addAction(action(CleanAndAddStatePopupId));
1365 theMenu->addSeparator();
1366 theMenu->addAction(action(ParaVisRenameId));
1367 theMenu->addAction(action(ParaVisDeleteId));
1374 \brief. Show ParaView python trace.
1376 void PVGUI_Module::onShowTrace()
1378 if (!myTraceWindow) {
1379 myTraceWindow = new pqPythonScriptEditor(getApp()->desktop());
1381 myTraceWindow->setText(getTraceString());
1382 myTraceWindow->show();
1383 myTraceWindow->raise();
1384 myTraceWindow->activateWindow();
1389 \brief. Re-initialize ParaView python trace.
1391 void PVGUI_Module::onRestartTrace()
1398 \brief Show ParaView view.
1400 void PVGUI_Module::onNewParaViewWindow()
1406 \brief Save state under the module root object.
1408 void PVGUI_Module::onSaveMultiState()
1410 // Create state study object
1412 // Get SALOMEDS client study
1413 _PTR(Study) studyDS = PARAVIS::GetCStudy(this);
1418 _PTR(SComponent) paravisComp =
1419 studyDS->FindComponent(PARAVIS::GetParavisGen(this)->ComponentDataType());
1424 // Unlock the study if it is locked
1425 bool isLocked = studyDS->GetProperties()->IsLocked();
1427 studyDS->GetProperties()->SetLocked(false);
1430 QString stateName = tr("SAVED_PARAVIEW_STATE_NAME") +
1431 QString::number(myStateCounter + 1);
1433 _PTR(StudyBuilder) studyBuilder = studyDS->NewBuilder();
1434 _PTR(SObject) newSObj = studyBuilder->NewObject(paravisComp);
1437 _PTR(GenericAttribute) anAttr;
1438 anAttr = studyBuilder->FindOrCreateAttribute(newSObj, "AttributeName");
1439 _PTR(AttributeName) nameAttr(anAttr);
1441 nameAttr->SetValue(stateName.toLatin1().constData());
1444 anAttr = studyBuilder->FindOrCreateAttribute(newSObj, "AttributeLocalID");
1445 _PTR(AttributeLocalID) localIdAttr(anAttr);
1447 localIdAttr->SetValue(PVSTATEID);
1450 QString stateEntry = QString::fromStdString(newSObj->GetID());
1452 // File name for state saving
1453 QString tmpDir = QString::fromStdString(SALOMEDS_Tool::GetTmpDir());
1454 QString fileName = QString("%1_paravisstate:%2").arg(tmpDir,
1457 anAttr = studyBuilder->FindOrCreateAttribute(newSObj, "AttributeString");
1458 _PTR(AttributeString) stringAttr(anAttr);
1460 stringAttr->SetValue(fileName.toLatin1().constData());
1462 // Lock the study back if necessary
1464 studyDS->GetProperties()->SetLocked(true);
1468 saveParaviewState(fileName.toLatin1().constData());
1469 myTemporaryFiles.append(fileName);
1471 // Increment the counter
1478 \brief Restore the selected state by merging with the current one.
1480 void PVGUI_Module::onAddState()
1482 loadSelectedState(false);
1486 \brief Clean the current state and restore the selected one.
1488 void PVGUI_Module::onCleanAddState()
1490 loadSelectedState(true);
1494 \brief Rename the selected object.
1496 void PVGUI_Module::onRename()
1498 LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr();
1499 SALOME_ListIO aListIO;
1500 aSelectionMgr->selectedObjects(aListIO);
1502 if (aListIO.Extent() == 1 && aListIO.First()->hasEntry()) {
1503 std::string entry = aListIO.First()->getEntry();
1505 // Get SALOMEDS client study
1506 _PTR(Study) studyDS = PARAVIS::GetCStudy(this);
1511 // Unlock the study if it is locked
1512 bool isLocked = studyDS->GetProperties()->IsLocked();
1514 studyDS->GetProperties()->SetLocked(false);
1517 // Rename the selected state object
1518 _PTR(SObject) stateSObj = studyDS->FindObjectID(entry);
1523 _PTR(GenericAttribute) anAttr;
1524 if (stateSObj->FindAttribute(anAttr, "AttributeName")) {
1525 _PTR(AttributeName) nameAttr (anAttr);
1527 LightApp_NameDlg::getName(getApp()->desktop(), nameAttr->Value().c_str());
1528 if (!newName.isEmpty()) {
1529 nameAttr->SetValue(newName.toLatin1().constData());
1530 aListIO.First()->setName(newName.toLatin1().constData());
1534 // Lock the study back if necessary
1536 studyDS->GetProperties()->SetLocked(true);
1539 // Update object browser
1546 \brief Delete the selected objects.
1548 void PVGUI_Module::onDelete()
1550 LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr();
1551 SALOME_ListIO aListIO;
1552 aSelectionMgr->selectedObjects(aListIO);
1554 if (aListIO.Extent() == 1 && aListIO.First()->hasEntry()) {
1555 std::string entry = aListIO.First()->getEntry();
1557 // Get SALOMEDS client study
1558 _PTR(Study) studyDS = PARAVIS::GetCStudy(this);
1563 // Unlock the study if it is locked
1564 bool isLocked = studyDS->GetProperties()->IsLocked();
1566 studyDS->GetProperties()->SetLocked(false);
1569 // Remove the selected state from the study
1570 _PTR(StudyBuilder) studyBuilder = studyDS->NewBuilder();
1571 _PTR(SObject) stateSObj = studyDS->FindObjectID(entry);
1572 studyBuilder->RemoveObject(stateSObj);
1574 // Lock the study back if necessary
1576 studyDS->GetProperties()->SetLocked(true);
1579 // Update object browser
1585 \brief Discover help project files from the resources.
1586 \return name of the help file.
1588 QString PVGUI_Module::getHelpFileName() {
1589 QString aPVHome(getenv("PVHOME"));
1590 if (aPVHome.isNull()) {
1591 qWarning("Wariable PVHOME is not defined");
1594 QChar aSep = QDir::separator();
1595 //PARAVIEW_VERSION from the vtkPVConfig.h file
1596 QString aFileName = aPVHome + aSep + "share" + aSep + "doc" + aSep + "paraview-"+ PARAVIEW_VERSION + aSep + "paraview.qch";
1602 \brief Load selected paraview state
1604 If toClear == true, the current state will be cleared
1606 void PVGUI_Module::loadSelectedState(bool toClear)
1610 LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr();
1611 SALOME_ListIO aListIO;
1612 aSelectionMgr->selectedObjects(aListIO);
1614 if (aListIO.Extent() == 1 && aListIO.First()->hasEntry()) {
1615 std::string entry = aListIO.First()->getEntry();
1617 // Get SALOMEDS client study
1618 _PTR(Study) studyDS = PARAVIS::GetCStudy(this);
1624 _PTR(SObject) stateSObj = studyDS->FindObjectID(entry);
1625 _PTR(GenericAttribute) anAttr;
1626 if (!stateSObj->FindAttribute(anAttr, "AttributeLocalID")) {
1629 _PTR(AttributeLocalID) anID(anAttr);
1630 if (!anID->Value() == PVSTATEID) {
1634 // Get state file name
1635 if (stateSObj->FindAttribute(anAttr, "AttributeString")) {
1636 _PTR(AttributeString) aStringAttr(anAttr);
1637 QString stringValue(aStringAttr->Value().c_str());
1639 if (QFile::exists(stringValue)) {
1640 fileName = stringValue;
1645 if (!fileName.isEmpty()) {
1647 clearParaviewState();
1650 loadParaviewState(fileName.toLatin1().constData());
1653 SUIT_MessageBox::critical(getApp()->desktop(),
1655 tr("ERR_STATE_CANNOT_BE_RESTORED"));
1659 void PVGUI_Module::onRepresentationChanged(pqRepresentation*) {
1662 //rnv: to fix the issue "21712: [CEA 581] Preference to display legend by default"
1663 // find the pqDisplayColorWidget instances and connect the variableChanged SIGNAL on the
1664 // onVariableChanged slot of this class. This connection needs to change visibility
1665 // of the "Colored Legend" after change the "Color By" array.
1666 QList<pqDisplayColorWidget*> aWidget = getApp()->desktop()->findChildren<pqDisplayColorWidget*>();
1668 for (int i = 0; i < aWidget.size() ; i++ ) {
1670 connect( aWidget[i], SIGNAL ( variableChanged ( pqVariableType, const QString ) ),
1671 this, SLOT(onVariableChanged( pqVariableType, const QString) ), Qt::UniqueConnection );
1678 \fn CAM_Module* createModule();
1679 \brief Export module instance (factory function).
1680 \return new created instance of the module
1684 #define PVGUI_EXPORT __declspec(dllexport)
1686 #define PVGUI_EXPORT
1692 PVGUI_EXPORT CAM_Module* createModule() {
1697 return new PVGUI_Module();
1700 PVGUI_EXPORT char* getModuleVersion() {
1701 return (char*)PARAVIS_VERSION_STR;