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 vtkOutputWindow::SetInstance(PVGUI_OutputWindowAdapter::New());
754 new pqTabbedMultiViewWidget(); // it registers as "MULTIVIEW_WIDGET on creation
756 for (int i = 0; i < argc; i++)
765 \brief Shows (toShow = true) or hides ParaView view window
767 void PVGUI_Module::showView( bool toShow )
769 SalomeApp_Application* anApp = getApp();
770 PVGUI_ViewManager* viewMgr =
771 dynamic_cast<PVGUI_ViewManager*>( anApp->getViewManager( PVGUI_Viewer::Type(), false ) );
773 viewMgr = new PVGUI_ViewManager( anApp->activeStudy(), anApp->desktop() );
774 anApp->addViewManager( viewMgr );
775 connect( viewMgr, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
776 anApp, SLOT( onCloseView( SUIT_ViewManager* ) ) );
779 PVGUI_ViewWindow* pvWnd = dynamic_cast<PVGUI_ViewWindow*>( viewMgr->getActiveView() );
781 pvWnd = dynamic_cast<PVGUI_ViewWindow*>( viewMgr->createViewWindow() );
784 pvWnd->setShown( toShow );
785 if ( toShow ) pvWnd->setFocus();
789 \brief Slot to show help for proxy.
791 void PVGUI_Module::showHelpForProxy( const QString& groupname, const QString& proxyname )
793 pqHelpReaction::showProxyHelp(groupname, proxyname);
798 \brief Slot to show the waiting state.
800 void PVGUI_Module::onPreAccept()
802 getApp()->desktop()->statusBar()->showMessage(tr("STB_PREACCEPT"));
803 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
807 \brief Slot to show the ready state.
809 void PVGUI_Module::onPostAccept()
811 getApp()->desktop()->statusBar()->showMessage(tr("STB_POSTACCEPT"), 2000);
812 QTimer::singleShot(0, this, SLOT(endWaitCursor()));
816 \brief Slot to switch off wait cursor.
818 void PVGUI_Module::endWaitCursor()
820 QApplication::restoreOverrideCursor();
824 \brief Returns the ParaView multi-view manager.
826 pqTabbedMultiViewWidget* PVGUI_Module::getMultiViewManager() const
828 return qobject_cast<pqTabbedMultiViewWidget*>(pqApplicationCore::instance()->manager("MULTIVIEW_WIDGET"));
832 static void ParavisMessageOutput(QtMsgType type, const char *msg)
837 vtkOutputWindow::GetInstance()->DisplayText(msg);
840 vtkOutputWindow::GetInstance()->DisplayErrorText(msg);
843 vtkOutputWindow::GetInstance()->DisplayErrorText(msg);
846 vtkOutputWindow::GetInstance()->DisplayErrorText(msg);
854 \brief Activate module.
855 \param study current study
856 \return \c true if activaion is done successfully or 0 to prevent
859 bool PVGUI_Module::activateModule( SUIT_Study* study )
861 myOldMsgHandler = qInstallMsgHandler(ParavisMessageOutput);
863 SUIT_ExceptionHandler::addCleanUpRoutine( paravisCleanUp );
865 storeCommonWindowsState();
867 bool isDone = SalomeApp_Module::activateModule( study );
868 if ( !isDone ) return false;
871 if ( mySourcesMenuId != -1 ) menuMgr()->show(mySourcesMenuId);
872 if ( myFiltersMenuId != -1 ) menuMgr()->show(myFiltersMenuId);
873 if ( myFiltersMenuId != -1 ) menuMgr()->show(myMacrosMenuId);
874 if ( myFiltersMenuId != -1 ) menuMgr()->show(myToolbarsMenuId);
875 setMenuShown( true );
876 setToolShown( true );
878 restoreDockWidgetsState();
880 QMenu* aMenu = menuMgr()->findMenu( myRecentMenuId );
882 QList<QAction*> anActns = aMenu->actions();
883 for (int i = 0; i < anActns.size(); ++i) {
884 QAction* a = anActns.at(i);
890 QList<QMenu*>::iterator it;
891 for (it = myMenus.begin(); it != myMenus.end(); ++it) {
892 QAction* a = (*it)->menuAction();
897 if ( myRecentMenuId != -1 ) menuMgr()->show(myRecentMenuId);
899 ClientFindOrCreateParavisComponent(PARAVIS::GetCStudy(this));
906 \brief Deactivate module.
907 \param study current study
908 \return \c true if deactivaion is done successfully or 0 to prevent
909 deactivation on error
911 bool PVGUI_Module::deactivateModule( SUIT_Study* study )
913 QMenu* aMenu = menuMgr()->findMenu( myRecentMenuId );
915 QList<QAction*> anActns = aMenu->actions();
916 for (int i = 0; i < anActns.size(); ++i) {
917 QAction* a = anActns.at(i);
919 a->setVisible(false);
923 QList<QMenu*>::iterator it;
924 for (it = myMenus.begin(); it != myMenus.end(); ++it) {
925 QAction* a = (*it)->menuAction();
927 a->setVisible(false);
930 QList<QDockWidget*> aStreamingViews = application()->desktop()->findChildren<QDockWidget*>("pqStreamingControls");
931 foreach(QDockWidget* aView, aStreamingViews) {
932 if (!myDockWidgets.contains(aView))
933 myDockWidgets[aView] = aView->isVisible();
936 /*if (pqImplementation::helpWindow) {
937 pqImplementation::helpWindow->hide();
941 menuMgr()->hide(myRecentMenuId);
942 menuMgr()->hide(mySourcesMenuId);
943 menuMgr()->hide(myFiltersMenuId);
944 menuMgr()->hide(myMacrosMenuId);
945 menuMgr()->hide(myToolbarsMenuId);
946 setMenuShown( false );
947 setToolShown( false );
950 saveDockWidgetsState();
952 SUIT_ExceptionHandler::removeCleanUpRoutine( paravisCleanUp );
955 qInstallMsgHandler(myOldMsgHandler);
957 restoreCommonWindowsState();
959 return SalomeApp_Module::deactivateModule( study );
964 \brief Called when application is closed.
966 Process finalize application functionality from ParaView in order to save server settings
967 and nullify application pointer if the application is being closed.
969 \param theApp application
971 void PVGUI_Module::onApplicationClosed( SUIT_Application* theApp )
973 pqApplicationCore::instance()->settings()->sync();
974 int aAppsNb = SUIT_Session::session()->applications().size();
976 deleteTemporaryFiles();
977 MyCoreApp->deleteLater();
979 CAM_Module::onApplicationClosed(theApp);
984 \brief Called when study is closed.
986 Removes data model from the \a study.
988 \param study study being closed
990 void PVGUI_Module::studyClosed(SUIT_Study* study)
992 clearParaviewState();
994 SalomeApp_Module::studyClosed(study);
998 \brief Called when study is opened.
1000 void PVGUI_Module::onModelOpened()
1002 _PTR(Study) studyDS = PARAVIS::GetCStudy(this);
1007 _PTR(SComponent) paravisComp =
1008 studyDS->FindComponent(PARAVIS::GetParavisGen(this)->ComponentDataType());
1013 _PTR(ChildIterator) anIter(studyDS->NewChildIterator(paravisComp));
1014 for (; anIter->More(); anIter->Next()) {
1015 _PTR(SObject) aSObj = anIter->Value();
1016 _PTR(GenericAttribute) anAttr;
1017 if (!aSObj->FindAttribute(anAttr, "AttributeLocalID")) {
1020 _PTR(AttributeLocalID) anID(anAttr);
1021 if (anID->Value() == PVSTATEID) {
1028 \brief Returns IOR of current engine
1030 QString PVGUI_Module::engineIOR() const
1032 CORBA::String_var anIOR = PARAVIS::GetParavisGen(this)->GetIOR();
1033 return QString(anIOR.in());
1038 \brief Open file of format supported by ParaView
1040 void PVGUI_Module::openFile(const char* theName)
1044 pqLoadDataReaction::loadData(aFiles);
1048 * Start trace invoking the newly introduced C++ API (PV 4.2)
1049 * (inspired from pqTraceReaction::start())
1051 void PVGUI_Module::startTrace()
1053 vtkSMSessionProxyManager* pxm = pqActiveObjects::instance().activeServer()->proxyManager();
1055 vtkSmartPointer<vtkSMProxy> proxy;
1056 proxy.TakeReference(pxm->NewProxy("pythontracing", "PythonTraceOptions"));
1059 vtkNew<vtkSMParaViewPipelineController> controller;
1060 controller->InitializeProxy(proxy);
1062 vtkSMTrace* trace = vtkSMTrace::StartTrace();
1065 // Set manually the properties entered via the dialog box poping-up when requiring
1066 // a trace start in PV4.2 (trace options)
1067 trace->SetPropertiesToTraceOnCreate(vtkSMTrace::RECORD_USER_MODIFIED_PROPERTIES);
1068 trace->SetFullyTraceSupplementalProxies(false);
1072 void PVGUI_Module::stopTrace()
1074 vtkSMTrace::StopTrace();
1077 void PVGUI_Module::executeScript(const char *script)
1080 pqPythonManager* manager = qobject_cast<pqPythonManager*>(
1081 pqApplicationCore::instance()->manager("PYTHON_MANAGER"));
1083 pqPythonDialog* pyDiag = manager->pythonShellDialog();
1085 pyDiag->runString(script);
1092 // * Debug function printing out the given interpreter's execution context
1094 //void printInterpContext(PyInterp_Interp * interp )
1096 // // Extract __smtraceString from interpreter's context
1097 // const PyObject* ctxt = interp->getExecutionContext();
1099 // PyObject* lst = PyDict_Keys((PyObject *)ctxt);
1100 // Py_ssize_t siz = PyList_GET_SIZE(lst);
1101 // for (Py_ssize_t i = 0; i < siz; i++)
1103 // PyObject * elem = PyList_GetItem(lst, i);
1104 // if (PyString_Check(elem))
1106 // std::cout << "At pos:" << i << ", " << PyString_AsString(elem) << std::endl;
1109 // std::cout << "At pos:" << i << ", not a string!" << std::endl;
1115 \brief Returns trace string
1117 static const QString MYReplaceStr("paraview.simple");
1118 static const QString MYReplaceImportStr("except: from pvsimple import *");
1119 QString PVGUI_Module::getTraceString()
1121 vtkSMTrace *tracer = vtkSMTrace::GetActiveTracer();
1122 if (!tracer) // trace is not started
1125 QString traceString(tracer->GetCurrentTrace());
1127 // Replace import "paraview.simple" by "pvsimple"
1128 if ((!traceString.isNull()) && traceString.length() != 0) {
1129 int aPos = traceString.indexOf(MYReplaceStr);
1130 while (aPos != -1) {
1131 traceString = traceString.replace(aPos, MYReplaceStr.length(), "pvsimple");
1132 aPos = traceString.indexOf(MYReplaceStr, aPos);
1134 int aImportPos = traceString.indexOf(MYReplaceImportStr);
1135 if(aImportPos != -1)
1137 traceString = traceString.replace(aImportPos, MYReplaceImportStr.length(), "except:\n import pvsimple\n from pvsimple import *");
1145 \brief Saves trace string to disk file
1147 void PVGUI_Module::saveTrace(const char* theName)
1149 QFile file(theName);
1150 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
1151 MESSAGE( "Could not open file:" << theName );
1154 QTextStream out(&file);
1155 out << getTraceString();
1160 \brief Saves ParaView state to a disk file
1162 void PVGUI_Module::saveParaviewState(const char* theFileName)
1164 pqApplicationCore::instance()->saveState(theFileName);
1168 \brief Delete all objects for Paraview Pipeline Browser
1170 void PVGUI_Module::clearParaviewState()
1172 QAction* deleteAllAction = action(DeleteAllId);
1173 if (deleteAllAction) {
1174 deleteAllAction->activate(QAction::Trigger);
1179 \brief Restores ParaView state from a disk file
1181 If toClear == true, the current ojects will be deleted
1183 void PVGUI_Module::loadParaviewState(const char* theFileName)
1185 pqApplicationCore::instance()->loadState(theFileName, getActiveServer());
1189 \brief Imports MED data from VISU module by data entry
1191 void PVGUI_Module::onImportFromVisu(QString theEntry)
1194 SUIT_OverrideCursor aWaitCursor;
1197 SalomeApp_Study* activeStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
1198 if(!activeStudy) return;
1200 // get SALOMEDS client study
1201 _PTR(Study) aStudy = activeStudy->studyDS();
1204 // find VISU component in a study
1205 _PTR(SComponent) aVisuComp = aStudy->FindComponent( "VISU" );
1206 if(!aVisuComp) return;
1208 // get SObject client by entry
1209 _PTR(SObject) aSObj = aStudy->FindObjectID(qPrintable(theEntry));
1212 // get CORBA SObject
1213 SALOMEDS_SObject* aSObject = _CAST(SObject, aSObj);
1214 if ( !aSObject ) return;
1217 SALOME_NamingService* aNamingService = SalomeApp_Application::namingService();
1218 SALOME_LifeCycleCORBA aLCC(aNamingService);
1220 Engines::EngineComponent_var aComponent = aLCC.FindOrLoad_Component("FactoryServer","VISU");
1221 VISU::VISU_Gen_var aVISU = VISU::VISU_Gen::_narrow(aComponent);
1222 if(CORBA::is_nil(aVISU)) return;
1224 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
1225 aStudyBuilder->LoadWith( aVisuComp, SalomeApp_Application::orb()->object_to_string(aVISU) );
1227 // get VISU result object
1228 CORBA::Object_var aResultObject = aSObject->GetObject();
1229 if (CORBA::is_nil(aResultObject)) return;
1230 VISU::Result_var aResult = VISU::Result::_narrow( aResultObject );
1231 if (CORBA::is_nil(aResult)) return;
1233 // export VISU result to the MED file
1234 std::string aTmpDir = SALOMEDS_Tool::GetTmpDir();
1235 std::string aFileName = aSObject->GetName();
1236 std::string aFilePath = aTmpDir + aFileName;
1238 if (aResult->ExportMED(aFilePath.c_str())) {
1239 openFile(aFilePath.c_str());
1240 myTemporaryFiles.append(QString(aFilePath.c_str()));
1243 MESSAGE("Visu module is not found.");
1248 \brief Deletes temporary files created during import operation from VISU
1250 void PVGUI_Module::deleteTemporaryFiles()
1252 foreach(QString aFile, myTemporaryFiles) {
1253 if (QFile::exists(aFile)) {
1254 QFile::remove(aFile);
1261 \brief Returns current active ParaView server
1263 pqServer* PVGUI_Module::getActiveServer()
1265 return pqApplicationCore::instance()->getActiveServer();
1270 \brief Creates PARAVIS preference pane
1272 void PVGUI_Module::createPreferences()
1274 // Paraview settings tab
1275 int aParaViewSettingsTab = addPreference( tr( "TIT_PVIEWSETTINGS" ) );
1276 int aPanel = addPreference(QString(), aParaViewSettingsTab, LightApp_Preferences::UserDefined, "PARAVIS", "");
1277 setPreferenceProperty(aPanel, "content", (qint64)(new PVGUI_ParaViewSettingsPane()));
1279 // Paravis settings tab
1280 int aParaVisSettingsTab = addPreference( tr( "TIT_PVISSETTINGS" ) );
1281 addPreference( tr( "PREF_STOP_TRACE" ), aParaVisSettingsTab, LightApp_Preferences::Bool, "PARAVIS", "stop_trace");
1283 int aSaveType = addPreference(tr( "PREF_SAVE_TYPE_LBL" ), aParaVisSettingsTab,
1284 LightApp_Preferences::Selector,
1285 "PARAVIS", "savestate_type");
1286 QList<QVariant> aIndices;
1287 QStringList aStrings;
1289 aStrings<<tr("PREF_SAVE_TYPE_0");
1290 aStrings<<tr("PREF_SAVE_TYPE_1");
1291 aStrings<<tr("PREF_SAVE_TYPE_2");
1292 setPreferenceProperty(aSaveType, "strings", aStrings);
1293 setPreferenceProperty(aSaveType, "indexes", aIndices);
1295 //rnv: imp 21712: [CEA 581] Preference to display legend by default
1296 int aDispColoreLegend = addPreference( tr( "PREF_SHOW_COLOR_LEGEND" ), aParaVisSettingsTab,
1297 LightApp_Preferences::Bool, "PARAVIS", "show_color_legend");
1301 \brief Creates ParaViS context menu popup
1303 void PVGUI_Module::contextMenuPopup(const QString& theClient, QMenu* theMenu, QString& theTitle)
1305 SalomeApp_Module::contextMenuPopup(theClient, theMenu, theTitle);
1307 // Check if we are in Object Browser
1308 SUIT_DataBrowser* ob = getApp()->objectBrowser();
1309 bool isOBClient = (ob && theClient == ob->popupClientType());
1314 // Get list of selected objects
1315 LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr();
1316 SALOME_ListIO aListIO;
1317 aSelectionMgr->selectedObjects(aListIO);
1318 if (aListIO.Extent() == 1 && aListIO.First()->hasEntry()) {
1319 QString entry = QString(aListIO.First()->getEntry());
1322 SalomeApp_Study* activeStudy =
1323 dynamic_cast<SalomeApp_Study*>(getApp()->activeStudy());
1328 // Get SALOMEDS client study
1329 _PTR(Study) studyDS = activeStudy->studyDS();
1334 QString paravisDataType(PARAVIS::GetParavisGen(this)->ComponentDataType());
1335 if(activeStudy && activeStudy->isComponent(entry) &&
1336 activeStudy->componentDataType(entry) == paravisDataType) {
1337 // ParaViS module object
1338 theMenu->addSeparator();
1339 theMenu->addAction(action(SaveStatePopupId));
1342 // Try to get state object
1343 _PTR(SObject) stateSObj =
1344 studyDS->FindObjectID(entry.toLatin1().constData());
1350 _PTR(GenericAttribute) anAttr;
1351 if (!stateSObj->FindAttribute(anAttr, "AttributeLocalID")) {
1355 _PTR(AttributeLocalID) anID(anAttr);
1357 if (anID->Value() == PVSTATEID) {
1358 // Paraview state object
1359 theMenu->addSeparator();
1360 theMenu->addAction(action(AddStatePopupId));
1361 theMenu->addAction(action(CleanAndAddStatePopupId));
1362 theMenu->addSeparator();
1363 theMenu->addAction(action(ParaVisRenameId));
1364 theMenu->addAction(action(ParaVisDeleteId));
1371 \brief. Show ParaView python trace.
1373 void PVGUI_Module::onShowTrace()
1375 if (!myTraceWindow) {
1376 myTraceWindow = new pqPythonScriptEditor(getApp()->desktop());
1378 myTraceWindow->setText(getTraceString());
1379 myTraceWindow->show();
1380 myTraceWindow->raise();
1381 myTraceWindow->activateWindow();
1386 \brief. Re-initialize ParaView python trace.
1388 void PVGUI_Module::onRestartTrace()
1395 \brief Show ParaView view.
1397 void PVGUI_Module::onNewParaViewWindow()
1403 \brief Save state under the module root object.
1405 void PVGUI_Module::onSaveMultiState()
1407 // Create state study object
1409 // Get SALOMEDS client study
1410 _PTR(Study) studyDS = PARAVIS::GetCStudy(this);
1415 _PTR(SComponent) paravisComp =
1416 studyDS->FindComponent(PARAVIS::GetParavisGen(this)->ComponentDataType());
1421 // Unlock the study if it is locked
1422 bool isLocked = studyDS->GetProperties()->IsLocked();
1424 studyDS->GetProperties()->SetLocked(false);
1427 QString stateName = tr("SAVED_PARAVIEW_STATE_NAME") +
1428 QString::number(myStateCounter + 1);
1430 _PTR(StudyBuilder) studyBuilder = studyDS->NewBuilder();
1431 _PTR(SObject) newSObj = studyBuilder->NewObject(paravisComp);
1434 _PTR(GenericAttribute) anAttr;
1435 anAttr = studyBuilder->FindOrCreateAttribute(newSObj, "AttributeName");
1436 _PTR(AttributeName) nameAttr(anAttr);
1438 nameAttr->SetValue(stateName.toLatin1().constData());
1441 anAttr = studyBuilder->FindOrCreateAttribute(newSObj, "AttributeLocalID");
1442 _PTR(AttributeLocalID) localIdAttr(anAttr);
1444 localIdAttr->SetValue(PVSTATEID);
1447 QString stateEntry = QString::fromStdString(newSObj->GetID());
1449 // File name for state saving
1450 QString tmpDir = QString::fromStdString(SALOMEDS_Tool::GetTmpDir());
1451 QString fileName = QString("%1_paravisstate:%2").arg(tmpDir,
1454 anAttr = studyBuilder->FindOrCreateAttribute(newSObj, "AttributeString");
1455 _PTR(AttributeString) stringAttr(anAttr);
1457 stringAttr->SetValue(fileName.toLatin1().constData());
1459 // Lock the study back if necessary
1461 studyDS->GetProperties()->SetLocked(true);
1465 saveParaviewState(fileName.toLatin1().constData());
1466 myTemporaryFiles.append(fileName);
1468 // Increment the counter
1475 \brief Restore the selected state by merging with the current one.
1477 void PVGUI_Module::onAddState()
1479 loadSelectedState(false);
1483 \brief Clean the current state and restore the selected one.
1485 void PVGUI_Module::onCleanAddState()
1487 loadSelectedState(true);
1491 \brief Rename the selected object.
1493 void PVGUI_Module::onRename()
1495 LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr();
1496 SALOME_ListIO aListIO;
1497 aSelectionMgr->selectedObjects(aListIO);
1499 if (aListIO.Extent() == 1 && aListIO.First()->hasEntry()) {
1500 std::string entry = aListIO.First()->getEntry();
1502 // Get SALOMEDS client study
1503 _PTR(Study) studyDS = PARAVIS::GetCStudy(this);
1508 // Unlock the study if it is locked
1509 bool isLocked = studyDS->GetProperties()->IsLocked();
1511 studyDS->GetProperties()->SetLocked(false);
1514 // Rename the selected state object
1515 _PTR(SObject) stateSObj = studyDS->FindObjectID(entry);
1520 _PTR(GenericAttribute) anAttr;
1521 if (stateSObj->FindAttribute(anAttr, "AttributeName")) {
1522 _PTR(AttributeName) nameAttr (anAttr);
1524 LightApp_NameDlg::getName(getApp()->desktop(), nameAttr->Value().c_str());
1525 if (!newName.isEmpty()) {
1526 nameAttr->SetValue(newName.toLatin1().constData());
1527 aListIO.First()->setName(newName.toLatin1().constData());
1531 // Lock the study back if necessary
1533 studyDS->GetProperties()->SetLocked(true);
1536 // Update object browser
1543 \brief Delete the selected objects.
1545 void PVGUI_Module::onDelete()
1547 LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr();
1548 SALOME_ListIO aListIO;
1549 aSelectionMgr->selectedObjects(aListIO);
1551 if (aListIO.Extent() == 1 && aListIO.First()->hasEntry()) {
1552 std::string entry = aListIO.First()->getEntry();
1554 // Get SALOMEDS client study
1555 _PTR(Study) studyDS = PARAVIS::GetCStudy(this);
1560 // Unlock the study if it is locked
1561 bool isLocked = studyDS->GetProperties()->IsLocked();
1563 studyDS->GetProperties()->SetLocked(false);
1566 // Remove the selected state from the study
1567 _PTR(StudyBuilder) studyBuilder = studyDS->NewBuilder();
1568 _PTR(SObject) stateSObj = studyDS->FindObjectID(entry);
1569 studyBuilder->RemoveObject(stateSObj);
1571 // Lock the study back if necessary
1573 studyDS->GetProperties()->SetLocked(true);
1576 // Update object browser
1582 \brief Discover help project files from the resources.
1583 \return name of the help file.
1585 QString PVGUI_Module::getHelpFileName() {
1586 QString aPVHome(getenv("PVHOME"));
1587 if (aPVHome.isNull()) {
1588 qWarning("Wariable PVHOME is not defined");
1591 QChar aSep = QDir::separator();
1592 //PARAVIEW_VERSION from the vtkPVConfig.h file
1593 QString aFileName = aPVHome + aSep + "share" + aSep + "doc" + aSep + "paraview-"+ PARAVIEW_VERSION + aSep + "paraview.qch";
1599 \brief Load selected paraview state
1601 If toClear == true, the current state will be cleared
1603 void PVGUI_Module::loadSelectedState(bool toClear)
1607 LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr();
1608 SALOME_ListIO aListIO;
1609 aSelectionMgr->selectedObjects(aListIO);
1611 if (aListIO.Extent() == 1 && aListIO.First()->hasEntry()) {
1612 std::string entry = aListIO.First()->getEntry();
1614 // Get SALOMEDS client study
1615 _PTR(Study) studyDS = PARAVIS::GetCStudy(this);
1621 _PTR(SObject) stateSObj = studyDS->FindObjectID(entry);
1622 _PTR(GenericAttribute) anAttr;
1623 if (!stateSObj->FindAttribute(anAttr, "AttributeLocalID")) {
1626 _PTR(AttributeLocalID) anID(anAttr);
1627 if (!anID->Value() == PVSTATEID) {
1631 // Get state file name
1632 if (stateSObj->FindAttribute(anAttr, "AttributeString")) {
1633 _PTR(AttributeString) aStringAttr(anAttr);
1634 QString stringValue(aStringAttr->Value().c_str());
1636 if (QFile::exists(stringValue)) {
1637 fileName = stringValue;
1642 if (!fileName.isEmpty()) {
1644 clearParaviewState();
1647 loadParaviewState(fileName.toLatin1().constData());
1650 SUIT_MessageBox::critical(getApp()->desktop(),
1652 tr("ERR_STATE_CANNOT_BE_RESTORED"));
1656 void PVGUI_Module::onRepresentationChanged(pqRepresentation*) {
1659 //rnv: to fix the issue "21712: [CEA 581] Preference to display legend by default"
1660 // find the pqDisplayColorWidget instances and connect the variableChanged SIGNAL on the
1661 // onVariableChanged slot of this class. This connection needs to change visibility
1662 // of the "Colored Legend" after change the "Color By" array.
1663 QList<pqDisplayColorWidget*> aWidget = getApp()->desktop()->findChildren<pqDisplayColorWidget*>();
1665 for (int i = 0; i < aWidget.size() ; i++ ) {
1667 connect( aWidget[i], SIGNAL ( variableChanged ( pqVariableType, const QString ) ),
1668 this, SLOT(onVariableChanged( pqVariableType, const QString) ), Qt::UniqueConnection );
1675 \fn CAM_Module* createModule();
1676 \brief Export module instance (factory function).
1677 \return new created instance of the module
1681 #define PVGUI_EXPORT __declspec(dllexport)
1683 #define PVGUI_EXPORT
1689 PVGUI_EXPORT CAM_Module* createModule() {
1694 return new PVGUI_Module();
1697 PVGUI_EXPORT char* getModuleVersion() {
1698 return (char*)PARAVIS_VERSION_STR;