Salome HOME
a60d3e7816fb42e2fb9f93f48b08e1d2a2f46968
[modules/visu.git] / src / VISUGUI / VisuGUI.cxx
1 //  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 //  This library is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU Lesser General Public
8 //  License as published by the Free Software Foundation; either
9 //  version 2.1 of the License.
10 //
11 //  This library is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 //  Lesser General Public License for more details.
15 //
16 //  You should have received a copy of the GNU Lesser General Public
17 //  License along with this library; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 //  VISU VISUGUI : GUI of VISU component
24 //  File   : VisuGUI.cxx
25 //  Author :
26 //  Module : VISU
27
28 #include <Standard_math.hxx>  // E.A. must be included before Python.h to fix compilation on windows
29 #include "Python.h"
30
31 #include "VisuGUI.h"
32
33 // STL Includes
34 #include <exception>
35 #include <typeinfo>
36 #include <vector>
37
38 // QT Includes
39 #include <QList>
40 #include <QVector>
41 #include <QColorDialog>
42 #include <QDateTime>
43 #include <QMenu>
44
45 // VTK Includes
46 #include <vtkRenderer.h>
47 #include <vtkRenderWindow.h>
48 #include <vtkActorCollection.h>
49 #include <vtkTimerLog.h>
50
51 // SALOME Includes
52 #include "SALOME_LifeCycleCORBA.hxx"
53
54 #include "SUIT_ResourceMgr.h"
55 #include "SUIT_MessageBox.h"
56
57 #include "SUIT_ViewWindow.h"
58 #include "SUIT_ViewManager.h"
59 #include "SUIT_Desktop.h"
60 #include "SUIT_DataBrowser.h"
61 #include "SUIT_OverrideCursor.h"
62
63 #include "CAM_Module.h"
64
65 #include "SVTK_ViewWindow.h"
66 #include "SVTK_ViewModel.h"
67 #include "SVTK_Functor.h"
68 //#include "SVTK_MainWindow.h"
69
70 #include "VTKViewer_Algorithm.h"
71 #include "VTKViewer_MarkerDlg.h"
72
73 #include "SPlot2d_ViewModel.h"
74 #include "VisuGUI_SetupPlot2dDlg.h"
75 #include "Plot2d_SetupCurveDlg.h"
76 #include "Plot2d_ViewManager.h"
77
78 #include "QtxPagePrefMgr.h"
79 #include "OB_Browser.h"
80
81 #include "SALOME_ListIteratorOfListIO.hxx"
82
83 #include "SalomeApp_Application.h"
84 #include "SalomeApp_DataModel.h"
85 #include "SalomeApp_Study.h"
86 #include "SalomeApp_CheckFileDlg.h"
87
88 #include "LightApp_SelectionMgr.h"
89 #include "LightApp_Selection.h"
90 #include "LightApp_Preferences.h"
91 #include "LightApp_DataOwner.h"
92
93 #include "QtxAction.h"
94 #include "QtxFontEdit.h"
95
96 #include "VISUConfig.hh"
97 #include "VISU_Gen_i.hh"
98 #include "VISU_Mesh_i.hh"
99 #include "VISU_Table_i.hh"
100 #include "VISU_PointMap3d_i.hh"
101 #include "VISU_Result_i.hh"
102 #include "VISU_View_i.hh"
103 #include "VISU_ViewManager_i.hh"
104 #include "VISU_Plot3D_i.hh"
105
106 #include "VISU_Actor.h"
107
108 #include "VisuGUI_Prs3dTools.h"
109 #include "VisuGUI_Tools.h"
110
111 #include "VisuGUI_SelectionPanel.h"
112 #include "VisuGUI_FeatureEdgesPanel.h"
113 #include "VisuGUI_NameDlg.h"
114 #include "VisuGUI_CursorDlg.h"
115 #include "VisuGUI_Selection.h"
116 #include "VisuGUI_TimeAnimation.h"
117 #include "VisuGUI_EvolutionDlg.h"
118 #include "VisuGUI_EditContainerDlg.h"
119 #include "VisuGUI_ClippingDlg.h"
120 #include "VisuGUI_Plot3DDlg.h"
121 #include "VisuGUI_OffsetDlg.h"
122 #include "VisuGUI_Displayer.h"
123 #include "VisuGUI_BuildProgressDlg.h"
124 #include "VisuGUI_TransparencyDlg.h"
125 #include "VisuGUI_ShrinkFactorDlg.h"
126 //#include "VisuGUI_CacheDlg.h"
127 #include "VisuGUI_Table3dDlg.h"
128 #include "VisuGUI_ClippingPanel.h"
129 #include "VisuGUI_FilterScalarsDlg.h"
130
131 #include "VISU_ScalarMap_i.hh"
132 #include "VisuGUI_ScalarBarDlg.h"
133
134 #include "VISU_DeformedShape_i.hh"
135 #include "VisuGUI_DeformedShapeDlg.h"
136
137 #include "VISU_DeformedShapeAndScalarMap_i.hh"
138 #include "VisuGUI_DeformedShapeAndScalarMapDlg.h"
139
140 #include "VISU_IsoSurfaces_i.hh"
141 #include "VisuGUI_IsoSurfacesDlg.h"
142
143 #include "VISU_CutPlanes_i.hh"
144 #include "VisuGUI_CutPlanesDlg.h"
145
146 #include "VISU_CutLines_i.hh"
147 #include "VisuGUI_CutLinesDlg.h"
148
149 #include "VISU_CutSegment_i.hh"
150 #include "VisuGUI_CutSegmentDlg.h"
151
152 #include "VISU_StreamLines_i.hh"
153 #include "VisuGUI_StreamLinesDlg.h"
154
155 #include "VISU_Vectors_i.hh"
156 #include "VisuGUI_VectorsDlg.h"
157
158 #include "VISU_TableDlg.h"
159 #include "VisuGUI_FileInfoDlg.h"
160
161 #include "SALOMEconfig.h"
162 #include CORBA_SERVER_HEADER(MED_Gen)
163
164 #include "utilities.h"
165
166 #include "VisuGUI_ActionsDef.h"
167
168 #include "VisuGUI_Timer.h"
169
170 //#include "VVTK_ViewModel.h"
171
172 #include "VisuGUI_Slider.h"
173 #include "VisuGUI_Sweep.h"
174 #include <VISU_ScalarMapAct.h>
175 #include <VISU_GaussPtsAct.h>
176 #include "VisuGUI_ValuesLabelingDlg.h"
177
178 using namespace VISU;
179
180 #ifdef _DEBUG_
181 static int MYDEBUG = 0;
182 #else
183 static int MYDEBUG = 0;
184 #endif
185
186 #ifdef WIN32
187 #define usleep(A) _sleep(A/1000)
188 #endif
189
190 //////////////////////////////////////////////////
191 // Class: VisuGUI
192 //////////////////////////////////////////////////
193
194 VisuGUI
195 ::VisuGUI():
196   SalomeApp_Module( "VISU" ),
197   LightApp_Module("VISU"),
198   myDisplayer( 0 ),
199   mySlider( NULL ),
200   mySweep( NULL )
201 {
202 }
203
204 VisuGUI
205 ::~VisuGUI()
206 {
207   if( myDisplayer ) {
208     delete myDisplayer;
209     myDisplayer = 0;
210   }
211
212   if( mySlider ) {
213     delete mySlider;
214     mySlider = 0;
215   }
216
217   if( mySweep ) {
218     delete mySweep;
219     mySweep = 0;
220   }
221 }
222
223 void
224 VisuGUI
225 ::OnImportFromFile()
226 {
227   if(MYDEBUG) MESSAGE("VisuGUI::OnImportFromFile()");
228
229   if ( CheckLock(GetCStudy(GetAppStudy(this)),GetDesktop(this)) )
230     return;
231
232   SUIT_ResourceMgr* aResourceMgr = GetResourceMgr();
233
234   // Get file name(s)
235   QStringList aFilter;
236   aFilter.append( tr( "FLT_MED_FILES" ) );
237   aFilter.append( tr( "FLT_DISTRIBUTED_MED_FILES" ) );
238   aFilter.append( tr( "FLT_ALL_FILES" ) );
239
240   bool toUseBuildProgress = aResourceMgr->booleanValue("VISU", "use_build_progress", false);
241
242   SalomeApp_CheckFileDlg fd( GetDesktop(this), true, tr("USE_BUILD_PROGRESS") );
243   fd.setWindowTitle( tr( "IMPORT_FROM_FILE" ) );
244   fd.setFileMode( SalomeApp_CheckFileDlg::ExistingFiles );
245   fd.setFilters( aFilter );
246   fd.SetChecked( toUseBuildProgress );
247   if ( SalomeApp_CheckFileDlg::getLastVisitedPath().isEmpty() )
248     fd.setDirectory( QDir::currentPath() );
249
250   QStringList fileNames;
251   if ( !fd.exec() )
252     return; // cancelled, return
253
254   fileNames = fd.selectedFiles();
255   toUseBuildProgress = fd.IsChecked();
256
257   if ( fileNames.count() == 0 )
258     return; // nothing selected, return
259
260   SUIT_OverrideCursor wc;
261   QStringList errors;
262   QStringList anEntryList;
263
264   for ( QStringList::ConstIterator it = fileNames.begin(); it != fileNames.end(); ++it ) {
265     QFileInfo aFileInfo( *it );
266
267     if ( !aFileInfo.exists() ) {
268       // file not exist
269       errors.append( QString( "%1 :\n\t%2" ).arg( aFileInfo.filePath() ).
270                      arg( tr( "ERR_FILE_NOT_EXISTS" ) ) );
271     }
272     else {
273       try {
274         if ( !toUseBuildProgress ) {
275           // build progress is not used, use build flags from settings
276           bool toBuildFields = aResourceMgr->booleanValue( "VISU", "build_fields",     true );
277           bool toBuildMinMax = aResourceMgr->booleanValue( "VISU", "build_min_max",    true );
278           bool toBuildGroups = aResourceMgr->booleanValue( "VISU", "build_groups",     true );
279           bool toBuildAll    = aResourceMgr->booleanValue( "VISU", "full_med_loading", false );
280           bool toBuildAtOnce = aResourceMgr->booleanValue( "VISU", "build_at_once",    false );
281
282           QString anInfo( tr( "IMPORT_FROM_FILE" ) + " " + aFileInfo.filePath() + " ... " );
283           application()->putInfo( anInfo );
284
285           VISU::Result_var aResult = GetVisuGen( this )->CreateResult( aFileInfo.filePath().toLatin1().constData() );
286
287           if ( CORBA::is_nil( aResult.in() ) ) {
288             errors.append( QString( "%1 :\n\t%2" ).arg( aFileInfo.filePath() ).
289                            arg( tr( "ERR_ERROR_IN_THE_FILE" ) ) );
290           }
291           else {
292             aResult->SetBuildFields( toBuildFields, toBuildMinMax );
293             aResult->SetBuildGroups( toBuildGroups );
294             aResult->Build( toBuildAll, toBuildAtOnce );
295             if( VISU::Result_i* aCResult = dynamic_cast<VISU::Result_i*>( VISU::GetServant( aResult ).in() ) )
296               anEntryList.append( aCResult->GetEntry().c_str() );
297             application()->putInfo( anInfo + tr("INF_DONE") );
298           }
299         } // if ( !toUseBuildProgress )
300         else {
301           // use build progress
302           wc.suspend();
303           VisuGUI_BuildProgressDlg* aBuildProgressDlg = new VisuGUI_BuildProgressDlg( GetDesktop(this) );
304           aBuildProgressDlg->setFileName( aFileInfo.filePath() );
305           aBuildProgressDlg->setGenerator( GetVisuGen(this) );
306           aBuildProgressDlg->exec();
307           wc.resume();
308         }
309       } // try
310       catch(...) {
311         errors.append( QString( "%1 :\n\t%2" ).arg( aFileInfo.filePath() ).arg( tr( "UNKNOWN_IMPORT_ERROR" ) ) );
312       }
313     } // else // if ( !aFileInfo.exists() )
314   } // for (...)
315
316   if ( errors.count() > 0 ) {
317     SUIT_MessageBox::critical( GetDesktop(this),
318                                tr("ERR_ERROR"),
319                                tr("IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
320   }
321   else {
322     UpdateObjBrowser(this);
323     if( getApp() )
324       getApp()->browseObjects( anEntryList );
325   }
326 }
327
328 void
329 VisuGUI
330 ::OnImportTableFromFile()
331 {
332   if(MYDEBUG) MESSAGE("VisuGUI::OnImportTableFromFile()");
333   if ( CheckLock(GetCStudy(GetAppStudy(this)),GetDesktop(this)) )
334     return;
335
336   QStringList aFilter;
337   aFilter.append( tr("FLT_TABLE_FILES") );
338   aFilter.append( tr("FLT_ALL_FILES") );
339
340   //QString anInitialPath = "";
341   //if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
342   //  anInitialPath = QDir::currentPath();
343
344   //QStringList aFiles = SUIT_FileDlg::getOpenFileNames(GetDesktop(this),
345   //                                                    anInitialPath,
346   //                                                    aFilter,
347   //                                                    tr("TLT_IMPORT_TABLE"));
348
349   SUIT_ResourceMgr* aResourceMgr = GetResourceMgr();
350   bool aFirstStrAsTitle = aResourceMgr->booleanValue("VISU", "first_str_as_title", false);
351
352   SalomeApp_CheckFileDlg fd( GetDesktop(this), true, tr("FIRST_STR_AS_TITLE") );
353   fd.setWindowTitle( tr( "IMPORT_FROM_FILE" ) );
354   fd.setFileMode( SalomeApp_CheckFileDlg::ExistingFiles );
355   fd.setFilters( aFilter );
356   fd.SetChecked( aFirstStrAsTitle );
357   if ( SalomeApp_CheckFileDlg::getLastVisitedPath().isEmpty() )
358     fd.setDirectory( QDir::currentPath() );
359
360   QStringList aFiles;
361   if ( !fd.exec() )
362     return; // cancelled, return
363   aFiles = fd.selectedFiles();
364   aFirstStrAsTitle = fd.IsChecked();
365
366   if ( aFiles.count() == 0 )
367     return; // nothing selected
368
369   QStringList errors;
370   QStringList anEntryList;
371   for ( QStringList::ConstIterator it = aFiles.begin(); it != aFiles.end(); ++it ) {
372     QFileInfo aFileInfo( *it );
373
374     if ( !aFileInfo.exists() ) {
375       errors.append( QString( "%1 :\n\t%2" ).arg( aFileInfo.filePath() ).
376                      arg( tr( "ERR_FILE_NOT_EXISTS" ) ) );
377     }
378     else {
379       try {
380         QString anInfo( tr("TLT_IMPORT_TABLE") + " " + aFileInfo.filePath() + " ..." );
381         application()->putInfo( anInfo );
382
383         SALOMEDS::SObject_var anObject =
384           GetVisuGen(this)->ImportTables(aFileInfo.filePath().toLatin1().constData(),
385                                          aFirstStrAsTitle);
386
387         if (CORBA::is_nil(anObject.in())) {
388           errors.append( QString( "%1 :\n\t%2" ).arg( aFileInfo.filePath() ).
389                          arg( tr( "ERR_ERROR_IN_THE_FILE" ) ) );
390         }
391         else {
392           anEntryList.append( anObject->GetID() );
393           application()->putInfo( anInfo + tr("INF_DONE") );
394         }
395       }
396       catch(...) {
397         errors.append( QString( "%1 :\n\t%2" ).arg( aFileInfo.filePath() ).arg( tr( "UNKNOWN_IMPORT_ERROR" ) ) );
398       }
399     }
400   }
401
402   if ( errors.count() > 0 ) {
403     SUIT_MessageBox::critical( GetDesktop(this),
404                                tr("ERR_ERROR"),
405                                tr("IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
406   }
407   else {
408     UpdateObjBrowser(this);
409     if( getApp() )
410       getApp()->browseObjects( anEntryList );
411   }
412 }
413
414 void
415 VisuGUI
416 ::OnExportTableToFile()
417 {
418   if(MYDEBUG) MESSAGE("VisuGUI::OnExportTableToFile()");
419
420   _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
421
422   LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
423   SALOME_ListIO aListIO;
424   aSelectionMgr->selectedObjects(aListIO);
425
426   if (aListIO.Extent() > 0) {
427     const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
428     if (anIO->hasEntry()) {
429       _PTR(SObject) aSObj = aCStudy->FindObjectID(anIO->getEntry());
430       if (!aSObj) return;
431
432       // find table attribute
433       bool isTOR = true;
434       _PTR(GenericAttribute) anAttr;
435
436       if (!aSObj->FindAttribute(anAttr, "AttributeTableOfReal")) {
437         isTOR = false;
438         if (!aSObj->FindAttribute(anAttr, "AttributeTableOfInteger")) {
439           // if the current SObject is a table title
440           // we take a father contaning the table
441           aSObj = aSObj->GetFather();
442
443           if (aSObj->FindAttribute(anAttr, "AttributeTableOfReal")) {
444             isTOR = true;
445           } else {
446             if (!aSObj->FindAttribute(anAttr, "AttributeTableOfInteger")) {
447               return;
448             }
449           }
450         }
451       }
452
453       // get table title in order to have default name of the file
454       QString aTitle;
455       if (isTOR) {
456         _PTR(AttributeTableOfReal) aTabAttr (anAttr);
457         if (!aTabAttr) return;
458         aTitle = aTabAttr->GetTitle().c_str();
459       } else {
460         _PTR(AttributeTableOfInteger) aTabAttr (anAttr);
461         if (!aTabAttr) return;
462         aTitle = aTabAttr->GetTitle().c_str();
463       }
464       aTitle.simplified();
465       aTitle = aTitle.replace(QRegExp(" "), "_").replace(QRegExp("\\*"), "" );
466
467       // get default path for the file
468       SUIT_ResourceMgr* aResourceMgr = GetResourceMgr();
469       QString aDir = aResourceMgr->stringValue("VISU","OutputDir","");
470       if (aDir.isEmpty()) {
471         aDir = aResourceMgr->stringValue("VISU","InputDir","");
472         if (aDir.isEmpty()) {
473           aDir = getenv("CSF_PATHData");
474         }
475       }
476       QString aPath = Qtx::addSlash(aDir) + aTitle;
477
478       // get name for the file
479       QStringList aFilter;
480       aFilter.append("Table Files (*.txt *.tab)");
481       aFilter.append("CSV Table Files (*.csv)");
482
483       QFileInfo aFileInfo =
484         SUIT_FileDlg::getFileName(GetDesktop(this),
485                                   aPath,
486                                   aFilter,
487                                   tr("MEN_EXPORT_TABLE"), // "Export Table To File"
488                                   false);
489
490       // export
491       QString aFile = aFileInfo.filePath();
492       if (!aFile.isEmpty()) {
493         application()->putInfo(tr("MEN_EXPORT_TABLE") + " " + aFile + " ...");
494         aDir = Qtx::dir(aFile, true);
495         aResourceMgr->setValue("VISU", "OutputDir", aDir);
496
497         try {
498           GetVisuGen(this)->ExportTableToFile(GetSObject(aSObj), (const char*)aFile.toLatin1());
499           application()->putInfo(aFile + " " + tr("INF_DONE"));
500         } catch(std::exception& exc) {
501           INFOS(exc.what());
502           SUIT_MessageBox::warning(GetDesktop(this),
503                                    tr("WRN_VISU"),
504                                    tr("ERR_ERROR_DURING_EXPORT") + " " + tr(exc.what()) );
505
506         } catch(...) {
507           INFOS((const char*)tr("ERR_ERROR_DURING_EXPORT").toLatin1());
508           SUIT_MessageBox::warning( GetDesktop(this),
509                                     tr("WRN_VISU"),
510                                     tr("ERR_ERROR_DURING_EXPORT") );
511
512         }
513       }
514     }
515   }
516 }
517
518 void
519 VisuGUI
520 ::OnImportMedField()
521 {
522   _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
523   if (CheckLock(aCStudy,GetDesktop(this)))
524     return;
525   SALOMEDS::Study_var aStudy = GetDSStudy(aCStudy);
526
527   LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
528   SALOME_ListIO aListIO;
529   aSelectionMgr->selectedObjects(aListIO);
530
531   QStringList anEntryList;
532   SALOME_ListIteratorOfListIO It (aListIO);
533   QApplication::setOverrideCursor(Qt::WaitCursor);
534   for (; It.More(); It.Next()) {
535     Handle(SALOME_InteractiveObject) anIO = It.Value();
536     SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(anIO->getEntry());
537     if (!aSObject->_is_nil()) {
538
539       // try to load a component data from an opened (presumably) study
540       // The same in SUPERVISION: NPAL14522
541       {
542         SALOMEDS::SComponent_ptr aSComp = aSObject->GetFatherComponent();
543         CORBA::String_var aCompIOR;
544         if (!aSComp->ComponentIOR(aCompIOR)) { // not loaded
545           CORBA::String_var aCompDataType = aSComp->ComponentDataType();
546
547           // obtain a driver by a component data type
548           // like it is done in SALOMEDS_DriverFactory_i::GetDriverByType
549           SALOMEDS::Driver_var anEngine = SALOMEDS::Driver::_nil();
550           SALOME_LifeCycleCORBA * LCC = getApp()->lcc();
551           try {
552             CORBA::Object_var
553               anEngineObj = LCC->FindOrLoad_Component("FactoryServer", aCompDataType);
554             if (CORBA::is_nil(anEngineObj))
555               anEngineObj = LCC->FindOrLoad_Component("FactoryServerPy", aCompDataType);
556
557             if (!CORBA::is_nil(anEngineObj))
558               anEngine = SALOMEDS::Driver::_narrow(anEngineObj);
559
560             if (!CORBA::is_nil(anEngine)) {
561               // try to load
562               SALOMEDS::StudyBuilder_ptr aStudyBuilder = aStudy->NewBuilder();
563               aStudyBuilder->LoadWith(aSComp, anEngine);
564             }
565           }
566           catch (...) {
567           }
568         }
569       }
570
571       VISU::Result_var aResult;
572       CORBA::Object_var anObject = VISU::SObjectToObject(aSObject);
573       if (!CORBA::is_nil(anObject)) {
574         SALOME_MED::MED_var aMED = SALOME_MED::MED::_narrow(anObject);
575         if (!CORBA::is_nil(aMED.in()))
576           aResult = GetVisuGen(this)->ImportMed(aSObject);
577         SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow(anObject);
578         if (!CORBA::is_nil(aField.in()))
579           aResult = GetVisuGen(this)->ImportMedField(aField);
580       } else {
581         SALOMEDS::SObject_var aSFather = aSObject->GetFather();
582         SALOMEDS::GenericAttribute_var anAttr;
583         aSFather->FindAttribute(anAttr, "AttributeName");
584         SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
585         CORBA::String_var aValue = aName->Value();
586         if (strcmp(aValue.in(), "MEDFIELD") == 0)
587           aResult = GetVisuGen(this)->ImportMed(aSObject);
588       }
589
590       if( !CORBA::is_nil( aResult ) )
591         if( VISU::Result_i* aCResult = dynamic_cast<VISU::Result_i*>( VISU::GetServant( aResult ).in() ) )
592           anEntryList.append( aCResult->GetEntry().c_str() );
593     }
594   }
595   UpdateObjBrowser(this, true);
596   if( getApp() )
597     getApp()->browseObjects( anEntryList );
598   QApplication::restoreOverrideCursor();
599 }
600
601 void VisuGUI::OnLoadComponentData()
602 {
603   _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
604   if (CheckLock(aCStudy,GetDesktop(this)))
605     return;
606   SALOMEDS::Study_var aStudy = GetDSStudy(aCStudy);
607
608   LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
609   SALOME_ListIO aListIO;
610   aSelectionMgr->selectedObjects(aListIO);
611
612   SALOME_ListIteratorOfListIO It (aListIO);
613   QApplication::setOverrideCursor(Qt::WaitCursor);
614   for (; It.More(); It.Next()) {
615     Handle(SALOME_InteractiveObject) anIO = It.Value();
616     SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(anIO->getEntry());
617     if (!aSObject->_is_nil()) {
618
619       // try to load a component data from an opened (presumably) study
620       // The same in SUPERVISION: NPAL14522
621       {
622         SALOMEDS::SComponent_ptr aSComp = aSObject->GetFatherComponent();
623         CORBA::String_var aCompIOR;
624         if (!aSComp->ComponentIOR(aCompIOR)) { // not loaded
625           CORBA::String_var aCompDataType = aSComp->ComponentDataType();
626
627           QString anInfo ("Loading ");
628           anInfo = anInfo + aCompDataType.in() + " Component Data ...";
629           application()->putInfo( anInfo );
630
631           // obtain a driver by a component data type
632           // like it is done in SALOMEDS_DriverFactory_i::GetDriverByType
633           SALOMEDS::Driver_var anEngine = SALOMEDS::Driver::_nil();
634           SALOME_LifeCycleCORBA * LCC = getApp()->lcc();
635           try {
636             CORBA::Object_var
637               anEngineObj = LCC->FindOrLoad_Component("FactoryServer", aCompDataType);
638             if (CORBA::is_nil(anEngineObj))
639               anEngineObj = LCC->FindOrLoad_Component("FactoryServerPy", aCompDataType);
640
641             if (!CORBA::is_nil(anEngineObj))
642               anEngine = SALOMEDS::Driver::_narrow(anEngineObj);
643
644             if (!CORBA::is_nil(anEngine)) {
645               // try to load
646               SALOMEDS::StudyBuilder_ptr aStudyBuilder = aStudy->NewBuilder();
647               aStudyBuilder->LoadWith(aSComp, anEngine);
648             }
649
650             application()->putInfo( anInfo + tr("INF_DONE"));
651           }
652           catch (...) {
653             application()->putInfo( anInfo + tr("INF_FAILED"));
654           }
655         }
656       }
657     }
658   }
659   QApplication::restoreOverrideCursor();
660 }
661
662 void
663 CreateCurves( SalomeApp_Module* theModule,
664               VISU::CutLinesBase_i* thePrs,
665               QDialog* theDlg,
666               const bool theCreate = true )
667 {
668   if ( !thePrs )
669     return;
670
671   // temporary code, to be revised (VisuGUI_CutLinesDlg and VisuGUI_CutSegmentDlg classes
672   // should have common intermediate interface with at least two methods called below)
673   bool isGenerateTable = false;
674   bool isGenerateCurves = false;
675   if ( VisuGUI_CutLinesDlg* aCutDlg = dynamic_cast<VisuGUI_CutLinesDlg*>( theDlg ) ) {
676     isGenerateTable = aCutDlg->isGenerateTable();
677     isGenerateCurves = aCutDlg->isGenerateCurves();
678   }
679   else if ( VisuGUI_CutSegmentDlg* aCutDlg = dynamic_cast<VisuGUI_CutSegmentDlg*>( theDlg ) ) {
680     isGenerateTable = aCutDlg->isGenerateTable();
681     isGenerateCurves = aCutDlg->isGenerateCurves();
682   }
683   else
684     return;
685
686   _PTR(Study)   aStudy = GetCStudy( GetAppStudy( theModule ) );
687   _PTR(SObject) aSObject = aStudy->FindObjectID( thePrs->GetEntry() );
688
689   if ( !theCreate && aSObject ) {
690     // Remove old Table
691     _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
692     _PTR(ChildIterator) aIter = aStudy->NewChildIterator(aSObject);
693     for (; aIter->More(); aIter->Next()) {
694       _PTR(SObject) aTblObj = aIter->Value();
695       if( aTblObj ) {
696         _PTR(GenericAttribute) anAttr;
697         if (aTblObj->FindAttribute( anAttr, "AttributeName" ) ) {
698           _PTR(ChildIterator) aChildIter = aStudy->NewChildIterator( aTblObj );
699           SalomeApp_Study* salome_study = GetAppStudy( theModule );
700           for( aChildIter->InitEx( false ); aChildIter->More(); aChildIter->Next() ){
701             salome_study->deleteReferencesTo( aChildIter->Value() );
702             _PTR(SObject) aSO = aChildIter->Value();
703             if(aSO){
704               Storable::TRestoringMap aRestoringMap = Storable::GetStorableMap(aSO);
705               if (aRestoringMap["myComment"] == "CURVE") {
706                 CORBA::Object_var aCORBAObject = VISU::ClientSObjectToObject(aSO);
707                 if(!CORBA::is_nil(aCORBAObject)){
708                   PortableServer::ServantBase_var aServant = VISU::GetServant(aCORBAObject);
709                   if(VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(aServant.in())){
710                     PlotRemoveCurve(theModule, aCurve);
711                   }
712                 }
713               }
714             }
715
716           }
717
718           aBuilder->RemoveObjectWithChildren( aTblObj ); // We should have only one child
719
720           //UpdateObjBrowser(theModule,true,aTblObj);
721           break;
722         }
723       }
724     }
725   }
726
727   if ( isGenerateTable ) {
728     GetVisuGen( theModule )->CreateTable( thePrs->GetEntry().c_str() );
729     if ( isGenerateCurves ) {
730       if ( aSObject ) {
731         _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
732         _PTR(ChildIterator) aIter = aStudy->NewChildIterator(aSObject);
733         for (; aIter->More(); aIter->Next()) {
734           _PTR(SObject) aTblObj = aIter->Value();
735           if ( aTblObj ) {
736             _PTR(GenericAttribute) anAttr;
737             if ( aTblObj->FindAttribute( anAttr, "AttributeName" ) ) {
738               CreatePlot( theModule, aTblObj );
739             }
740           }
741         }
742       }
743     }
744   }
745
746   if (!theCreate && aSObject) {
747     UpdateObjBrowser(theModule);
748   }
749 }
750
751 void
752 VisuGUI
753 ::OnCreateMesh()
754 {
755   _PTR(Study) aStudy = GetCStudy(GetAppStudy(this));
756   if (CheckLock(aStudy,GetDesktop(this)))
757     return;
758
759   VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(this);
760   if(aSelectionInfo.empty())
761     return;
762
763   // Get selected SObject
764   VISU::TSelectionItem aSelectionItem = aSelectionInfo.front();
765   Handle(SALOME_InteractiveObject) anIO = aSelectionItem.myIO;
766   if (anIO.IsNull() || !anIO->hasEntry())
767     return;
768
769   // create a VTK view window if it does not exist
770   SVTK_ViewWindow* aViewWindow = GetViewWindow<SVTK_Viewer>(this);
771
772   // create mesh presentation and display it in aViewWindow
773   VISU::Mesh_i* aPrs = CreateMesh(this, anIO, aViewWindow);
774   aViewWindow->highlight(anIO, 1);
775   processPresentationCreated(aPrs);
776 }
777
778 void
779 VisuGUI
780 ::OnCreateManyMesh()
781 {
782   _PTR(Study) aStudy = GetCStudy(GetAppStudy(this));
783   if (CheckLock(aStudy,GetDesktop(this)))
784     return;
785
786   // create a VTK view window if it does not exist
787   SVTK_ViewWindow* aViewWindow = GetViewWindow<SVTK_Viewer>(this);
788
789   // Get selected SObject
790   LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
791   SALOME_ListIO aListIO;
792   aSelectionMgr->selectedObjects(aListIO);
793   SALOME_ListIteratorOfListIO anIter (aListIO);
794   for (; anIter.More(); anIter.Next()) {
795     Handle(SALOME_InteractiveObject) anIO = anIter.Value();
796     if (anIO.IsNull() || !anIO->hasEntry())
797       return;
798
799     // create mesh presentation and display it in aViewWindow
800     VISU::Mesh_i* aPrs = CreateMesh(this, anIO, aViewWindow);
801     aViewWindow->highlight(anIO, 1);
802     processPresentationCreated(aPrs);
803   }
804 }
805
806 void
807 VisuGUI
808 ::OnCreateScalarMap()
809 {
810   Prs3d_i* aPrs = CreatePrs3d<VISU::ScalarMap_i,VisuGUI_ScalarBarDlg,1>(this);
811   processPresentationCreated(aPrs);
812 }
813
814
815 void
816 VisuGUI
817 ::OnCreateDeformedShape()
818 {
819   Prs3d_i* aPrs = CreatePrs3d<VISU::DeformedShape_i,VisuGUI_DeformedShapeDlg,1>(this);
820   processPresentationCreated(aPrs);
821 }
822
823 void
824 VisuGUI
825 ::OnCreateDeformedShapeAndScalarMap()
826 {
827   Prs3d_i* aPrs = CreatePrs3d<VISU::DeformedShapeAndScalarMap_i,VisuGUI_DeformedShapeAndScalarMapDlg,1>(this);
828   processPresentationCreated(aPrs);
829 }
830
831 void
832 VisuGUI
833 ::OnCreateVectors()
834 {
835   Prs3d_i* aPrs = CreatePrs3d<VISU::Vectors_i,VisuGUI_VectorsDlg,1>(this);
836   processPresentationCreated(aPrs);
837 }
838
839 void
840 VisuGUI
841 ::OnCreateIsoSurfaces()
842 {
843   Prs3d_i* aPrs = CreatePrs3d<VISU::IsoSurfaces_i,VisuGUI_IsoSurfacesDlg,1>(this);
844   processPresentationCreated(aPrs);
845 }
846
847 void
848 VisuGUI
849 ::OnCreateCutPlanes()
850 {
851   Prs3d_i* aPrs = CreatePrs3d<VISU::CutPlanes_i,VisuGUI_CutPlanesDlg,0>(this);
852   processPresentationCreated(aPrs);
853 }
854
855 void
856 VisuGUI
857 ::OnCreateCutLines()
858 {
859   Prs3d_i* aPrs = CreatePrs3d<VISU::CutLines_i,VisuGUI_CutLinesDlg,0>(this);
860   processPresentationCreated(aPrs);
861 }
862
863 void
864 VisuGUI
865 ::OnCreateCutSegment()
866 {
867   Prs3d_i* aPrs = CreatePrs3d<VISU::CutSegment_i,VisuGUI_CutSegmentDlg,0>(this);
868   processPresentationCreated(aPrs);
869 }
870
871 void
872 VisuGUI
873 ::OnCreateStreamLines()
874 {
875   Prs3d_i* aPrs = CreatePrs3d<VISU::StreamLines_i,VisuGUI_StreamLinesDlg,1>(this);
876   processPresentationCreated(aPrs);
877 }
878
879 void
880 VisuGUI
881 ::OnCreatePlot3D()
882 {
883   Prs3d_i* aPrs = CreatePrs3d<VISU::Plot3D_i,VisuGUI_Plot3DDlg,0>(this);
884   processPresentationCreated(aPrs);
885 }
886
887 void
888 VisuGUI
889 ::OnCreatePlot2dView()
890 {
891   CheckLock(GetCStudy(GetAppStudy(this)),GetDesktop(this));
892   VISU::Container_var aContainer = GetVisuGen( this )->CreateContainer();
893   UpdateObjBrowser(this);
894
895   if( !CORBA::is_nil( aContainer.in() ) ) {
896     if( VISU::Container_i* aCContainer = dynamic_cast<VISU::Container_i*>( VISU::GetServant( aContainer ).in() ) ) {
897       QStringList anEntryList;
898       anEntryList.append( aCContainer->GetEntry().c_str() );
899       if( getApp() )
900         getApp()->browseObjects( anEntryList );
901     }
902   }
903 }
904
905 void
906 VisuGUI
907 ::OnDisplayPrs()
908 {
909   if(MYDEBUG) MESSAGE("VisuGUI::OnDisplayPrs");
910
911   LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
912   if (!aSelectionMgr)
913     return;
914
915   QApplication::setOverrideCursor(Qt::WaitCursor);
916
917   SALOME_ListIO aSel, aList;
918   aSelectionMgr->selectedObjects(aSel);
919   extractContainers(aSel, aList);
920
921   for (SALOME_ListIteratorOfListIO it (aList); it.More(); it.Next()) {
922     Handle(SALOME_InteractiveObject) anIO = it.Value();
923     TObjectInfo anObjectInfo = VISU::GetObjectByEntry(GetAppStudy(this), anIO->getEntry());
924     VISU::Base_i* aBase = anObjectInfo.myBase;
925     if(!aBase)
926       continue;
927
928     VISU::VISUType aType = aBase->GetType();
929     switch (aType) {
930     case VISU::TPOINTMAP3D:
931       if(SVTK_ViewWindow* aViewWindow = GetActiveViewWindow<SVTK_ViewWindow>(this)){
932         displayer()->Display(anIO->getEntry());
933         aViewWindow->highlight(anIO, 1);
934         aViewWindow->getRenderer()->ResetCameraClippingRange();
935         aViewWindow->Repaint();
936         break;
937       }
938       else {
939         if (SPlot2d_Viewer* aPlot2d = GetPlot2dViewer(this, false))
940           aPlot2d->Repaint();
941         displayer()->Display(anIO->getEntry());
942       }
943     case VISU::TCURVE:
944     case VISU::TCONTAINER:
945     case VISU::TTABLE:
946       getViewManager(SPlot2d_Viewer::Type(), true);
947       displayer()->Display(anIO->getEntry());
948       break;
949     default: {
950       VISU::Prs3d_i* aPrs3d = VISU::GetPrs3dFromBase(aBase);
951       if(aPrs3d){
952         if(SVTK_ViewWindow* aViewWindow = GetActiveViewWindow<SVTK_ViewWindow>(this)){
953           displayer()->Display(anIO->getEntry());
954           aViewWindow->highlight(anIO, 1);
955           aViewWindow->getRenderer()->ResetCameraClippingRange();
956           aViewWindow->Repaint();
957         }
958       }
959     }
960     }
961   }
962
963   QApplication::restoreOverrideCursor();
964 }
965
966 void
967 VisuGUI
968 ::OnDisplayOnlyPrs()
969 {
970   /// to correct IMP 0016100
971   LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
972   if (!aSelectionMgr)
973     return;
974
975   SALOME_ListIO aSel, aList;
976   aSelectionMgr->selectedObjects(aSel);
977   extractContainers(aSel, aList);
978   Handle(SALOME_InteractiveObject) anIO = aList.First();
979   activateAppropriateViewer(anIO);
980   OnEraseAll();
981   OnDisplayPrs();
982 }
983
984 void VisuGUI::activateAppropriateViewer( Handle(SALOME_InteractiveObject) theIO )
985 {
986   TObjectInfo anObjectInfo = VISU::GetObjectByEntry(GetAppStudy(this), theIO->getEntry());
987   VISU::Base_i* aBase = anObjectInfo.myBase;
988   if(!aBase)
989     return;
990
991   std::string anEntry = theIO->getEntry();
992   _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
993   _PTR(SObject) SO = aCStudy->FindObjectID( theIO->getEntry() );
994
995   CORBA::Object_var aCORBAObject = VISU::ClientSObjectToObject(SO);
996   if(CORBA::is_nil(aCORBAObject))
997     return;
998
999   VISU::VISUType aType = aBase->GetType();
1000
1001   if ( VISU::GetPrs3dFromBase(aBase) ) {
1002     // activate SVTK Viewer
1003     getApp()->getViewManager( SVTK_Viewer::Type(), true );
1004     return;
1005   }
1006
1007   switch (aType) {
1008   case VISU::TCURVE:
1009   case VISU::TCONTAINER:
1010   case VISU::TTABLE: {
1011     // Activate Plot2d
1012     GetPlot2dViewer(this, true);
1013     break;
1014   }
1015   case VISU::TCOLOREDPRS3DHOLDER :
1016   case VISU::TPOINTMAP3D : {
1017     //find curves under pointmap 3d
1018     bool hasCurvesChildren = false;
1019
1020     SUIT_ViewManager* aViewMgr = getApp()->activeViewManager();
1021     QString aViewerType = aViewMgr->getType();
1022
1023     _PTR(ChildIterator) anIter = aCStudy->NewChildIterator(SO);
1024     _PTR(SObject) aChild;
1025     for (; anIter->More(); anIter->Next()) {
1026       aChild = anIter->Value();
1027       CORBA::Object_var aCORBAObject = VISU::ClientSObjectToObject(aChild);
1028       if(!CORBA::is_nil(aCORBAObject)){
1029         PortableServer::ServantBase_var aServant = VISU::GetServant(aCORBAObject);
1030         if( dynamic_cast<VISU::Curve_i*>(aServant.in()))
1031           hasCurvesChildren = true;
1032       }
1033     }
1034
1035     if (hasCurvesChildren && ( aViewerType == SPlot2d_Viewer::Type() || aViewerType == SVTK_Viewer::Type() ) ) {
1036       return;
1037     } else {
1038       // activate SVTK Viewer
1039       getApp()->getViewManager( SVTK_Viewer::Type(), true );
1040       return;
1041     }
1042     break;
1043   }
1044   }
1045 }
1046
1047 void
1048 VisuGUI
1049 ::OnErasePrs()
1050 {
1051   if(MYDEBUG) MESSAGE("OnErasePrs");
1052   QApplication::setOverrideCursor(Qt::WaitCursor);
1053
1054   SALOME_ListIO aList, aSel;
1055   LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1056   aSelectionMgr->selectedObjects(aSel);
1057   extractContainers(aSel, aList);
1058
1059   for (SALOME_ListIteratorOfListIO it (aList); it.More(); it.Next()) {
1060     Handle(SALOME_InteractiveObject) anIO = it.Value();
1061     TObjectInfo anObjectInfo = VISU::GetObjectByEntry(GetAppStudy(this), anIO->getEntry());
1062     VISU::Base_i* aBase = anObjectInfo.myBase;
1063     ErasePrs(this, aBase, /*repaint_view_window = */true);
1064   }
1065
1066   QApplication::restoreOverrideCursor();
1067 }
1068
1069 //----------------------------------------------------------------------------
1070 void
1071 VisuGUI
1072 ::OnEraseAll()
1073 {
1074   startOperation( myEraseAll );
1075   if (SVTK_ViewWindow* vw = GetActiveViewWindow<SVTK_ViewWindow>(this)) {
1076     vw->unHighlightAll();
1077     if (vtkRenderer *aRen = vw->getRenderer()) {
1078       vtkActor *anActor;
1079       VTK::ActorCollectionCopy aCopy(aRen->GetActors());
1080       vtkActorCollection *anActColl = aCopy.GetActors();
1081       for (anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL; ) {
1082         if (anActor->GetVisibility() > 0)
1083           if (VISU_Actor* anVISUActor = VISU_Actor::SafeDownCast(anActor)) {
1084             RemoveScalarBarPosition(this, vw, anVISUActor->GetPrs3d());
1085             anVISUActor->VisibilityOff();
1086           }
1087       }
1088       vw->Repaint();
1089     }
1090   } else if (SPlot2d_Viewer* aPlot2d = GetPlot2dViewer(this, false)) {
1091     aPlot2d->EraseAll();
1092   }
1093 }
1094
1095
1096 namespace
1097 {
1098   //----------------------------------------------------------------------------
1099   VISU::Prs3d_i*
1100   GetPrsToModify(const SalomeApp_Module* theModule,
1101                  Handle(SALOME_InteractiveObject)& theIO)
1102   {
1103     VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(theModule);
1104     if(aSelectionInfo.empty())
1105       return NULL;
1106
1107     VISU::TSelectionItem aSelectionItem = aSelectionInfo.front();
1108     theIO = aSelectionItem.myIO;
1109     return VISU::GetPrs3dToModify(theModule, aSelectionItem.myObjectInfo.myBase);
1110   }
1111 }
1112
1113 //----------------------------------------------------------------------------
1114 void
1115 VisuGUI
1116 ::OnEditScalarMap()
1117 {
1118   Handle(SALOME_InteractiveObject) anIO;
1119   if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, anIO))
1120     EditPrs3d<VISU::ScalarMap_i, VisuGUI_ScalarBarDlg, 1>(this, anIO, aPrs3d);
1121 }
1122
1123 //----------------------------------------------------------------------------
1124 void
1125 VisuGUI
1126 ::OnEditDeformedShape()
1127 {
1128   Handle(SALOME_InteractiveObject) anIO;
1129   if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, anIO))
1130     VisuGUI_DeformedShapeDlg::EditPrs3d(this, aPrs3d, anIO);
1131   //    EditPrs3d<VISU::DeformedShape_i, VisuGUI_DeformedShapeDlg, 1>(this, anIO, aPrs3d);
1132 }
1133
1134 //----------------------------------------------------------------------------
1135 void
1136 VisuGUI
1137 ::OnEditDeformedShapeAndScalarMap()
1138 {
1139   Handle(SALOME_InteractiveObject) anIO;
1140   if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, anIO))
1141     EditPrs3d<VISU::DeformedShapeAndScalarMap_i, VisuGUI_DeformedShapeAndScalarMapDlg, 1>(this, anIO, aPrs3d);
1142 }
1143
1144 //----------------------------------------------------------------------------
1145 void
1146 VisuGUI
1147 ::OnEditCutPlanes()
1148 {
1149   Handle(SALOME_InteractiveObject) anIO;
1150   if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, anIO))
1151     EditPrs3d<VISU::CutPlanes_i, VisuGUI_CutPlanesDlg, 0>(this, anIO, aPrs3d);
1152 }
1153
1154 //----------------------------------------------------------------------------
1155 void
1156 VisuGUI
1157 ::OnEditCutLines()
1158 {
1159   Handle(SALOME_InteractiveObject) anIO;
1160   if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, anIO))
1161     EditPrs3d<VISU::CutLines_i, VisuGUI_CutLinesDlg, 0>(this, anIO, aPrs3d);
1162 }
1163
1164 //----------------------------------------------------------------------------
1165 void
1166 VisuGUI
1167 ::OnEditCutSegment()
1168 {
1169   Handle(SALOME_InteractiveObject) anIO;
1170   if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, anIO))
1171     EditPrs3d<VISU::CutSegment_i, VisuGUI_CutSegmentDlg, 0>(this, anIO, aPrs3d);
1172 }
1173
1174 //----------------------------------------------------------------------------
1175 void
1176 VisuGUI
1177 ::OnEditIsoSurfaces()
1178 {
1179   Handle(SALOME_InteractiveObject) anIO;
1180   if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, anIO))
1181     EditPrs3d<VISU::IsoSurfaces_i, VisuGUI_IsoSurfacesDlg, 1>(this, anIO, aPrs3d);
1182 }
1183
1184 //----------------------------------------------------------------------------
1185 void
1186 VisuGUI
1187 ::OnEditVectors()
1188 {
1189   Handle(SALOME_InteractiveObject) anIO;
1190   if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, anIO))
1191     EditPrs3d<VISU::Vectors_i, VisuGUI_VectorsDlg, 1>(this, anIO, aPrs3d);
1192 }
1193
1194 //----------------------------------------------------------------------------
1195 void
1196 VisuGUI
1197 ::OnEditStreamLines()
1198 {
1199   Handle(SALOME_InteractiveObject) anIO;
1200   if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, anIO))
1201     EditPrs3d<VISU::StreamLines_i, VisuGUI_StreamLinesDlg, 1>(this, anIO, aPrs3d);
1202 }
1203
1204 //----------------------------------------------------------------------------
1205 void
1206 VisuGUI
1207 ::OnEditPlot3D()
1208 {
1209   Handle(SALOME_InteractiveObject) anIO;
1210   if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, anIO))
1211     EditPrs3d<VISU::Plot3D_i, VisuGUI_Plot3DDlg, 0>(this, anIO, aPrs3d);
1212 }
1213
1214
1215 //----------------------------------------------------------------------------
1216 void
1217 VisuGUI
1218 ::OnMakeSurfaceframe()
1219 {
1220   ChangeRepresentation(this, VISU::SURFACEFRAME);
1221 }
1222
1223 //----------------------------------------------------------------------------
1224 void
1225 VisuGUI
1226 ::OnMakeInsideframe()
1227 {
1228   ChangeRepresentation(this, VISU::INSIDEFRAME);
1229 }
1230
1231 //----------------------------------------------------------------------------
1232 void
1233 VisuGUI
1234 ::OnMakeWireframe()
1235 {
1236   ChangeRepresentation(this, VISU::WIREFRAME);
1237 }
1238
1239 //----------------------------------------------------------------------------
1240 void
1241 VisuGUI
1242 ::OnMakeSurface()
1243 {
1244   ChangeRepresentation(this, VISU::SHADED);
1245 }
1246
1247 //----------------------------------------------------------------------------
1248 void
1249 VisuGUI
1250 ::OnMakePoints()
1251 {
1252   ChangeRepresentation(this, VISU::POINT);
1253 }
1254
1255 //----------------------------------------------------------------------------
1256 void
1257 VisuGUI
1258 ::OnMakeShrink()
1259 {
1260   ChangeRepresentation(this, VISU::SHRINK);
1261 }
1262
1263 //----------------------------------------------------------------------------
1264 void
1265 VisuGUI
1266 ::OnMakeFeatureEdges()
1267 {
1268   ChangeRepresentation(this, VISU::FEATURE_EDGES);
1269 }
1270
1271 //----------------------------------------------------------------------------
1272 void
1273 VisuGUI
1274 ::OnSetShadingOn()
1275 {
1276   SetShading(this, true);
1277 }
1278
1279 //----------------------------------------------------------------------------
1280 void
1281 VisuGUI
1282 ::OnSetShadingOff()
1283 {
1284   SetShading(this, false);
1285 }
1286
1287
1288 //----------------------------------------------------------------------------
1289 void
1290 VisuGUI
1291 ::OnChangeColor()
1292 {
1293   VISU_Actor* anActor = NULL;
1294   VISU::Prs3d_i* aPrs3d = NULL;
1295   SVTK_ViewWindow* aViewWindow = NULL;
1296   if(!GetPrs3dSelectionInfo(this, aPrs3d, aViewWindow, anActor))
1297     return;
1298
1299   VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrs3d);
1300   VISU::DeformedShape_i* aDeformedShape = dynamic_cast<VISU::DeformedShape_i*>(aPrs3d);
1301
1302   SALOMEDS::Color anOldColor, aNewColor;
1303   int aRepresent = anActor->GetRepresentation();
1304   if (aMesh) {
1305     switch (aRepresent) {
1306       case VISU::POINT :
1307         anOldColor = aMesh->GetNodeColor();
1308         break;
1309       case VISU::WIREFRAME :
1310       case VISU::INSIDEFRAME :
1311         anOldColor = aMesh->GetLinkColor();
1312         break;
1313       case VISU::SHADED :
1314       case VISU::SURFACEFRAME :
1315         anOldColor = aMesh->GetCellColor();
1316         break;
1317     }
1318   } else if (aDeformedShape) {
1319     anOldColor = aDeformedShape->GetColor();
1320   } else {
1321     return;
1322   }
1323
1324   QColor aColor (int(255*anOldColor.R),
1325                  int(255*anOldColor.G),
1326                  int(255*anOldColor.B));
1327   QColor aColorNew = QColorDialog::getColor(aColor, GetDesktop(this));
1328   if (aColorNew.isValid()) {
1329     aNewColor.R = aColorNew.red()/255.;
1330     aNewColor.G = aColorNew.green()/255.;
1331     aNewColor.B = aColorNew.blue()/255.;
1332     if (aMesh) {
1333       switch (aRepresent) {
1334         case VISU::POINT :
1335           aMesh->SetNodeColor(aNewColor);
1336           break;
1337         case VISU::WIREFRAME :
1338         case VISU::INSIDEFRAME :
1339           aMesh->SetLinkColor(aNewColor);
1340           break;
1341         case VISU::SHADED :
1342         case VISU::SURFACEFRAME :
1343           aMesh->SetCellColor(aNewColor);
1344           break;
1345       }
1346     } else {
1347       aDeformedShape->SetColor(aNewColor);
1348     }
1349     RecreateActor(this, aPrs3d);
1350   }
1351 }
1352
1353 //----------------------------------------------------------------------------
1354 void
1355 VisuGUI
1356 ::OnChangeWireframeColor()
1357 {
1358   VISU_Actor* anActor = NULL;
1359   VISU::Prs3d_i* aPrs3d = NULL;
1360   SVTK_ViewWindow* aViewWindow = NULL;
1361   if(!GetPrs3dSelectionInfo(this, aPrs3d, aViewWindow, anActor))
1362     return;
1363
1364   VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrs3d);
1365   VISU::ScalarMap_i* aScalarMap = dynamic_cast<VISU::ScalarMap_i*>(aPrs3d);
1366   if(!aMesh && !aScalarMap)
1367     return;
1368
1369   SALOMEDS::Color anOldColor, aNewColor;
1370   if (aMesh)
1371     anOldColor = aMesh->GetLinkColor();
1372   else if (aScalarMap)
1373     anOldColor = aScalarMap->GetLinkColor();
1374
1375
1376   QColor aColor (int(255*anOldColor.R),
1377                  int(255*anOldColor.G),
1378                  int(255*anOldColor.B));
1379   QColor aColorNew = QColorDialog::getColor(aColor, GetDesktop(this));
1380   if (aColorNew.isValid()) {
1381     aNewColor.R = aColorNew.red()/255.;
1382     aNewColor.G = aColorNew.green()/255.;
1383     aNewColor.B = aColorNew.blue()/255.;
1384     if (aMesh)
1385       aMesh->SetLinkColor(aNewColor);
1386     else
1387       aScalarMap->SetLinkColor(aNewColor);
1388     RecreateActor(this, aPrs3d);
1389   }
1390 }
1391
1392 //----------------------------------------------------------------------------
1393 void
1394 VisuGUI
1395 ::OnChangeOpacity()
1396 {
1397   VisuGUI_TransparencyDlg* aDialog = new VisuGUI_TransparencyDlg( this );
1398   aDialog->show();
1399 }
1400
1401 //----------------------------------------------------------------------------
1402 void
1403 VisuGUI
1404 ::OnChangeLines()
1405 {
1406   VISU_Actor* anActor = NULL;
1407   VISU_ActorBase* anActorBase = NULL;
1408   VISU::Prs3d_i* aPrs3d = NULL;
1409   SVTK_ViewWindow* aViewWindow = NULL;
1410   float oldlwid = 1;
1411   bool isPrs3d = false;
1412
1413   if (GetPrs3dSelectionInfo(this, aPrs3d, aViewWindow, anActor)) {
1414     isPrs3d = true;
1415     oldlwid = anActor->GetLineWidth();
1416   }
1417   else {
1418     aViewWindow = GetActiveViewWindow<SVTK_ViewWindow>(this);
1419     VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(this);
1420     VISU::TSelectionItem aSelectionItem = aSelectionInfo.front();
1421     VISU::PointMap3d_i* aTable = dynamic_cast<VISU::PointMap3d_i*>(aSelectionItem.myObjectInfo.myBase);
1422     anActorBase = VISU::FindActorBase(aViewWindow, aTable);
1423     oldlwid = anActorBase->GetLineWidth();
1424   }
1425
1426
1427   VisuGUI_CursorDlg* CursorDlg =
1428     new VisuGUI_CursorDlg (GetDesktop(this), (const char*)tr("DLG_LINEWIDTH_TITLE").toLatin1(), TRUE);
1429
1430   CursorDlg->helpFileName = "viewing_3d_presentations_page.html#width_opacity_anchor";
1431   CursorDlg->Comment1->setText(tr("DLG_LINEWIDTH_CMT1"));
1432   CursorDlg->Comment2->setText(tr("DLG_LINEWIDTH_CMT2"));
1433   CursorDlg->SpinBox1->setMinimum(1);
1434   CursorDlg->SpinBox1->setMaximum(10);
1435
1436   int intlwid = int(oldlwid);
1437   CursorDlg->SpinBox1->setValue(intlwid);
1438
1439   int ret = CursorDlg->exec();
1440   if (ret == 1) {
1441     intlwid  = CursorDlg->SpinBox1->value();
1442     float newlwid = intlwid;
1443     if (isPrs3d)
1444       anActor->SetLineWidth(newlwid);
1445     else
1446       anActorBase->SetLineWidth(newlwid);
1447   }
1448   delete CursorDlg;
1449 }
1450
1451 //----------------------------------------------------------------------------
1452 void
1453 VisuGUI
1454 ::OnChangePointMarker()
1455 {
1456   SALOME_ListIO aListIO;
1457   GetSelectionMgr( this )->selectedObjects( aListIO );
1458   if( aListIO.Extent() < 1 )
1459     return;
1460
1461   VISU::StudyId2MarkerMap& aMarkerMap = GetVisuGen( this )->GetMarkerMap();
1462   _PTR(Study) aCStudy = GetCStudy( GetAppStudy( this ) );
1463   int aStudyId = aCStudy->StudyId();
1464
1465   QPixmap aPointSpritePixmap;
1466   if( SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr() )
1467     aPointSpritePixmap = aResourceMgr->loadPixmap( "VISU", tr( "ICON_POINT_SPRITE" ) );
1468
1469   bool update = false;
1470   for( SALOME_ListIteratorOfListIO It( aListIO ); It.More(); It.Next() )
1471   {
1472     Handle(SALOME_InteractiveObject)& anIO = It.Value();
1473     std::vector<VISU::Prs3d_i*> aPrsList = GetPrs3dList( this, anIO );
1474     for( int i = 0, n = aPrsList.size(); i < n; i++ )
1475     {
1476       if( VISU::Prs3d_i* aPrs = aPrsList[i] )
1477       {
1478         VTKViewer_MarkerDlg* aDlg = new VTKViewer_MarkerDlg( GetDesktop( this ) );
1479         aDlg->setHelpData( "VISU", "point_marker_page.html" );
1480
1481         aDlg->setCustomMarkerMap( aMarkerMap[ aStudyId ] );
1482
1483         aDlg->addExtraStdMarker( VTK::MT_POINT_SPRITE, aPointSpritePixmap );
1484
1485         VISU::MarkerType aMarkerTypeCurrent = aPrs->GetMarkerType();
1486         VISU::MarkerScale aMarkerScaleCurrent = aPrs->GetMarkerScale();
1487         int aMarkerTextureCurrent = aPrs->GetMarkerTexture();
1488         if( aMarkerTypeCurrent != VISU::MT_USER )
1489           aDlg->setStandardMarker( (VTK::MarkerType)aMarkerTypeCurrent, (VTK::MarkerScale)aMarkerScaleCurrent );
1490         else
1491           aDlg->setCustomMarker( aMarkerTextureCurrent );
1492
1493         if( aDlg->exec() )
1494         {
1495           aMarkerMap[ aStudyId ] = aDlg->getCustomMarkerMap();
1496
1497           VISU::MarkerType aMarkerTypeNew = (VISU::MarkerType)aDlg->getMarkerType();
1498           VISU::MarkerScale aMarkerScaleNew = (VISU::MarkerScale)aDlg->getStandardMarkerScale();
1499           int aMarkerTextureNew = aDlg->getCustomMarkerID();
1500           if( aMarkerTypeNew != VISU::MT_USER )
1501             aPrs->SetMarkerStd( aMarkerTypeNew, aMarkerScaleNew );
1502           else
1503             aPrs->SetMarkerTexture( aMarkerTextureNew );
1504
1505           aPrs->UpdateActors();
1506           update = true;
1507         }
1508
1509         delete aDlg;
1510       }
1511     }
1512   }
1513
1514   if( update )
1515     if( SVTK_ViewWindow* vw = GetActiveViewWindow<SVTK_ViewWindow>( this ) )
1516       vw->Repaint();
1517 }
1518
1519 //----------------------------------------------------------------------------
1520 void
1521 VisuGUI
1522 ::OnChangeShrinkFactor()
1523 {
1524   VisuGUI_ShrinkFactorDlg* aDialog = new VisuGUI_ShrinkFactorDlg( this );
1525   aDialog->show();
1526 }
1527
1528 //----------------------------------------------------------------------------
1529 void
1530 VisuGUI
1531 ::OnShowTable()
1532 {
1533   VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(this);
1534   if(aSelectionInfo.empty())
1535     return;
1536
1537   VISU::TSelectionItem aSelectionItem = aSelectionInfo.front();
1538   Handle(SALOME_InteractiveObject) anIO = aSelectionItem.myIO;
1539   VISU::Base_i* aBase = aSelectionItem.myObjectInfo.myBase;
1540   _PTR(SObject) aSObject = aSelectionItem.myObjectInfo.mySObject;
1541   if(VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(aBase)) {
1542     aSObject = GetCStudy( GetAppStudy( this ) )->FindObjectID( aTable->GetObjectEntry() );
1543     if( IsSObjectTable( aSObject ) ) {
1544       VISU_TableDlg* dlg = new VISU_TableDlg( GetDesktop( this ),
1545                                               GetCStudy( GetAppStudy( this ) ),
1546                                               aTable,
1547                                               false,
1548                                               //SAL2670 Orientation of show tables
1549                                               VISU_TableDlg::ttAuto,
1550                                               Qt::Vertical );
1551       dlg->show();
1552     }
1553   }
1554 }
1555
1556 //----------------------------------------------------------------------------
1557 void
1558 VisuGUI
1559 ::OnShowTablePlot()
1560 {
1561   VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(this);
1562   if(aSelectionInfo.empty())
1563     return;
1564
1565   VISU::TSelectionItem aSelectionItem = aSelectionInfo.front();
1566   Handle(SALOME_InteractiveObject) anIO = aSelectionItem.myIO;
1567   VISU::Base_i* aBase = aSelectionItem.myObjectInfo.myBase;
1568   _PTR(SObject) aSObject = aSelectionItem.myObjectInfo.mySObject;
1569   if(VISU::PointMap3d_i* aTable = dynamic_cast<VISU::PointMap3d_i*>(aBase)) {
1570     VisuGUI_Table3DDlg*aDlg = new VisuGUI_Table3DDlg( this );
1571     aDlg->initFromPrsObject( aTable );
1572     if ( runAndWait(aDlg, 0) > 0 ) {
1573       aDlg->storeToPrsObject(aTable);
1574       aTable->UpdateActors();
1575     }
1576     delete aDlg;
1577   }
1578 }
1579
1580 //----------------------------------------------------------------------------
1581 void
1582 VisuGUI
1583 ::OnShowScalarBar()
1584 {
1585   SetScalarBarVisibility(true);
1586 }
1587
1588 void
1589 VisuGUI
1590 ::OnHideScalarBar()
1591 {
1592   SetScalarBarVisibility(false);
1593 }
1594
1595 void
1596 VisuGUI
1597 ::SetScalarBarVisibility(bool theVisibility)
1598 {
1599   LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1600   SALOME_ListIO aListIO;
1601   aSelectionMgr->selectedObjects(aListIO);
1602
1603   SALOME_ListIteratorOfListIO It (aListIO);
1604
1605   bool update = false;
1606   for (; It.More(); It.Next()) {
1607     Handle(SALOME_InteractiveObject)& anIO = It.Value();
1608     std::vector<VISU::Prs3d_i*> aPrsList = GetPrs3dList(this, anIO, true);
1609     if ( aPrsList.size()>0 ) {
1610       for (int i = 0, n = aPrsList.size(); i < n; i++) {
1611         VISU::Prs3d_i* aPrsObject = aPrsList[i];
1612         if (aPrsObject) {
1613           if (VISU::ScalarMap_i* aScalar = dynamic_cast<VISU::ScalarMap_i*>(aPrsObject)) {
1614             aScalar->SetBarVisible( theVisibility );
1615             RecreateActor(this, aScalar);
1616             update = true;
1617           } else if (VISU::GaussPoints_i* aGauss = dynamic_cast<VISU::GaussPoints_i*>(aPrsObject)) {
1618             aGauss->SetBarVisible( theVisibility );
1619             RecreateActor(this, aGauss);
1620             update = true;
1621           }
1622         }
1623       }
1624     }
1625   }
1626   if (update) {
1627     if (SVTK_ViewWindow* vw = GetActiveViewWindow<SVTK_ViewWindow>(this))
1628       vw->Repaint();
1629   }
1630 }
1631
1632 //----------------------------------------------------------------------------
1633 void
1634 VisuGUI
1635 ::OnCreateTable()
1636 {
1637   VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(this);
1638   if(aSelectionInfo.empty())
1639     return;
1640
1641   VISU::TSelectionItem aSelectionItem = aSelectionInfo.front();
1642   _PTR(SObject) aSObject = aSelectionItem.myObjectInfo.mySObject;
1643   VISU::Base_i* aBase = aSelectionItem.myObjectInfo.myBase;
1644
1645   if(aBase &&
1646      (aBase->GetType() == VISU::TCUTLINES || aBase->GetType() == VISU::TCUTSEGMENT) ||
1647      IsSObjectTable(aSObject)) {
1648     GetVisuGen( this )->CreateTable( aSObject->GetID().c_str() );
1649     UpdateObjBrowser(this);
1650   }
1651 }
1652
1653 //----------------------------------------------------------------------------
1654 void
1655 VisuGUI
1656 ::OnDeleteObjects()
1657 {
1658   SalomeApp_Study* anAppStudy = GetAppStudy(this);
1659   _PTR(Study) aCStudy = GetCStudy(anAppStudy);
1660   if (CheckLock(aCStudy,GetDesktop(this)))
1661     return;
1662
1663   SALOME_ListIO aList;
1664   LightApp_SelectionMgr* mgr = GetSelectionMgr(this);
1665   mgr->selectedObjects(aList,QString::null,false);
1666   int i = 0, nbSelected = aList.Extent();
1667   if (nbSelected < 1) return;
1668
1669   std::vector<std::string> anEntries (nbSelected);
1670   QString aNameList;
1671   Handle(SALOME_InteractiveObject) anIO;
1672   for (SALOME_ListIteratorOfListIO it (aList); it.More(); it.Next()) {
1673     anIO = it.Value();
1674     if (anIO->hasEntry()) {
1675       if (IsRemovable(anIO->getEntry(), this)) {
1676         aNameList.append("\n    - ");
1677         // Get Name Of the Main Object if it's a referenced object
1678         VISU::TObjectInfo anObjectInfo = GetObjectByEntry(GetAppStudy(this), anIO->getEntry());
1679         if(_PTR(SObject) aSObject = anObjectInfo.mySObject){
1680           _PTR(SObject) aRefSObject;
1681           if (aSObject->ReferencedObject(aRefSObject)) {
1682             QString aRefName = QString::fromStdString ( aRefSObject->GetName() );
1683             aNameList.append( aRefName );
1684           }
1685           else
1686             aNameList.append(anIO->getName());
1687         }
1688         anEntries[i++] = anIO->getEntry();
1689       }
1690     }
1691   }
1692   nbSelected = i;
1693   if (nbSelected < 1) {
1694     SUIT_MessageBox::warning(GetDesktop(this),
1695                              QObject::tr("WRN_VISU"),
1696                              QObject::tr("WRN_NO_APPROPRIATE_SELECTION"));
1697     return;
1698   }
1699
1700   if ( SUIT_MessageBox::question( GetDesktop(this),
1701                                   QObject::tr( "WRN_VISU" ),
1702                                   QObject::tr( "VISU_REALLY_DELETE" ).arg( nbSelected ).arg( aNameList ),
1703                                   SUIT_MessageBox::Yes | SUIT_MessageBox::No ) != SUIT_MessageBox::Yes )
1704     return;
1705
1706   // There is a transaction
1707   _PTR(StudyBuilder) aStudyBuilder = aCStudy->NewBuilder();
1708   aStudyBuilder->NewCommand();
1709
1710   for (i = 0; i < nbSelected; i++) {
1711     VISU::TObjectInfo anObjectInfo = GetObjectByEntry(GetAppStudy(this), anEntries[i]);
1712     if(_PTR(SObject) aSObject = anObjectInfo.mySObject){
1713       emit beforeObjectDelete(QString(aSObject->GetID().c_str()));
1714       _PTR(SObject) aRefSObject;
1715       if (aSObject->ReferencedObject(aRefSObject)) {
1716         // It can be a reference on curve, published under a container.
1717         // In this case the curve should be removed from the container.
1718         // See bug 10441.
1719         VISU::TObjectInfo aRefObjectInfo = GetObjectByEntry(GetAppStudy(this), aRefSObject->GetID());
1720         VISU::Base_i* aRefBase = aRefObjectInfo.myBase;
1721         if(aRefBase && aRefBase->GetType() == VISU::TMESH){
1722           DeleteSObject(this, aCStudy, aRefSObject);
1723           UpdateObjBrowser(this, true, aRefSObject);
1724         }else if(aRefBase && aRefBase->GetType() == VISU::TCURVE){
1725           CORBA::Object_var anObject = ClientSObjectToObject(aRefSObject);
1726           VISU::Curve_var aCurve = VISU::Curve::_narrow(anObject);
1727           _PTR(SObject) aParentSO = aSObject->GetFather();
1728           VISU::TObjectInfo aParentObjectInfo = GetObjectByEntry(GetAppStudy(this), aParentSO->GetID());
1729           if(VISU::Base_i* aParentBase = aParentObjectInfo.myBase){
1730             if(VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(aParentBase)){
1731               if(aContainer->GetNbCurves() > 0){
1732                 aContainer->RemoveCurve(aCurve);
1733                 UpdateObjBrowser(this, true, aParentSO);
1734               }
1735             }
1736           }
1737         }
1738       }
1739       else{
1740         DeleteSObject(this, aCStudy, aSObject);
1741         UpdateObjBrowser(this, true, aSObject);
1742       }
1743     }
1744   }
1745
1746   // Finish transaction
1747   aStudyBuilder->CommitCommand();
1748   mgr->clearSelected();
1749 }
1750
1751 //----------------------------------------------------------------------------
1752 void
1753 VisuGUI
1754 ::OnPlotData()
1755 {
1756   VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(this);
1757   if(aSelectionInfo.empty())
1758     return;
1759
1760   VISU::TSelectionItem aSelectionItem = aSelectionInfo.front();
1761   if(VISU::Base_i* aBase = aSelectionItem.myObjectInfo.myBase){
1762     if(aBase->GetType() == VISU::TTABLE || aBase->GetType() == VISU::TPOINTMAP3D) {
1763       if(VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(aBase)){
1764         _PTR(Study) aStudy = GetCStudy(GetAppStudy(this));
1765         _PTR(SObject) aSObject = aStudy->FindObjectID( aTable->GetObjectEntry() );
1766         if(IsSObjectTable(aSObject)){
1767           VisuGUI_SetupPlot2dDlg* aDlg = new VisuGUI_SetupPlot2dDlg(aSObject, GetDesktop(this));
1768           if(aDlg->exec() == QDialog::Accepted){
1769             if(!IsStudyLocked(aStudy)){
1770               // if study is not locked - create new container, create curves and insert them
1771               // into container, then plot container if current viewer is of VIEW_PLOT2D type
1772               int horIndex;
1773               QList<int> verIndices, ver1Indices, ver2Indices, zIndices;
1774               aDlg->getCurvesSource( horIndex, ver1Indices, ver2Indices, zIndices );
1775               verIndices = ver1Indices + ver2Indices;
1776               if( horIndex >= 0 && verIndices.count() > 0 ){
1777                 CORBA::Object_var aContainerObj = GetVisuGen(this)->CreateContainer();
1778                 if(VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainerObj).in())){
1779                   for( int i = 0; i < verIndices.count(); i++ ){
1780                     bool isV2 = ver2Indices.contains(verIndices[i]);
1781                     VISU::Curve_var aCurveObject =
1782                       GetVisuGen(this)->CreateCurveWithZExt(aTable->_this(), horIndex+1, verIndices[i]+1, zIndices[i]+1, isV2 );
1783                     if(VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurveObject).in())){
1784                       bool isAuto;
1785                       int  marker, line, lineWidth;
1786                       QColor color;
1787                       if ( aDlg->getCurveAttributes(verIndices[i], isAuto, marker,
1788                                                     line, lineWidth, color) && !isAuto )
1789                       {
1790                         SALOMEDS::Color c;
1791                         c.R = color.red()  /255.;
1792                         c.G = color.green()/255.;
1793                         c.B = color.blue() /255.;
1794                         aCurve->SetColor( c );
1795                         aCurve->SetMarker( ( VISU::Curve::MarkerType )marker );
1796                         aCurve->SetLine( ( VISU::Curve::LineType )line, lineWidth );
1797                       }
1798                       aContainer->AddCurve(aCurveObject);
1799                     }
1800                   }
1801                   UpdateObjBrowser(this);
1802                   PlotContainer( this, aContainer, VISU::eDisplay );
1803                 }
1804               }
1805             } else {
1806               // get name of SObject
1807               QString aSObjectName;
1808               _PTR(GenericAttribute) anAttr;
1809               if(aSObject->FindAttribute( anAttr, "AttributeName" )){
1810                 _PTR(AttributeName) aName = anAttr;
1811                 aSObjectName = QString( aName->Value().c_str() );
1812               }
1813               // if study is locked just get curves info and plot them
1814               // if current viewer is of VIEW_PLOT2D type
1815               QList<Plot2d_Curve*> container;
1816               aDlg->getCurves( container );
1817               if ( !container.isEmpty() ) {
1818                 GetPlot2dViewer( this )->getActiveViewFrame()->displayCurves( container, true );
1819                 GetPlot2dViewer( this )->getActiveViewFrame()->setTitle( aSObjectName );
1820               }
1821             }
1822           }
1823           delete aDlg;
1824         }
1825       }
1826     }
1827   }else if(!aSelectionItem.myIO.IsNull()){
1828     // check if Table SObject is selected
1829     _PTR(SObject) aSObject = aSelectionItem.myObjectInfo.mySObject;
1830     if(IsSObjectTable(aSObject)){
1831       VisuGUI_SetupPlot2dDlg* aDlg = new VisuGUI_SetupPlot2dDlg(aSObject, GetDesktop(this));
1832       if(aDlg->exec() == QDialog::Accepted){
1833         _PTR(Study) aStudy = GetCStudy(GetAppStudy(this));
1834         if(!IsStudyLocked(aStudy)){
1835           // if study is not locked - create new table and container objects, create curves
1836           // and insert them into container, then plot container if current viewer is of VIEW_PLOT2D type
1837           int horIndex;
1838           QList<int> verIndices, ver1Indices, ver2Indices, zIndices;
1839           aDlg->getCurvesSource( horIndex, verIndices, ver2Indices, zIndices );
1840           verIndices = ver1Indices + ver2Indices;
1841           if ( horIndex >= 0 && verIndices.count() > 0 ) {
1842             VISU::Table_var aTableObject = GetVisuGen(this)->CreateTable(aSObject->GetID().c_str());
1843             if(!CORBA::is_nil(aTableObject)){
1844               VISU::Container_var aContainerObject = GetVisuGen(this)->CreateContainer();
1845               VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainerObject).in());
1846               for ( int i = 0; i < verIndices.count(); i++ ) {
1847                 bool isV2 = ver2Indices.contains(verIndices[i]);
1848                 VISU::Curve_var aCurveObject = GetVisuGen(this)->CreateCurveWithZExt
1849                   ( aTableObject, horIndex+1, verIndices[i]+1, zIndices[i]+1, isV2 );
1850                 if(VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurveObject).in())){
1851                   bool isAuto;
1852                   int  marker, line, lineWidth;
1853                   QColor color;
1854                   if ( aDlg->getCurveAttributes(verIndices[i], isAuto, marker,
1855                                                 line, lineWidth, color) && !isAuto )
1856                   {
1857                     SALOMEDS::Color c;
1858                     c.R = color.red()/255.;
1859                     c.G = color.green()/255.;
1860                     c.B = color.blue()/255.;
1861                     aCurve->SetColor( c );
1862                     aCurve->SetMarker( ( VISU::Curve::MarkerType )marker );
1863                     aCurve->SetLine( ( VISU::Curve::LineType )line, lineWidth );
1864                   }
1865                   aContainerObject->AddCurve(aCurveObject);
1866                 }
1867               }
1868               UpdateObjBrowser(this);
1869               PlotContainer( this, aContainer, VISU::eDisplay );
1870             }
1871           }
1872         } else {
1873           // get name of SObject
1874           QString aSObjectName;
1875           _PTR(GenericAttribute) anAttr;
1876           if(aSObject->FindAttribute(anAttr, "AttributeName")){
1877             _PTR(AttributeName) aName = anAttr;
1878             aSObjectName = QString( aName->Value().c_str() );
1879           }
1880           // if study is locked just get curves info and plot them
1881           QList<Plot2d_Curve*> container;
1882           aDlg->getCurves( container );
1883           if ( !container.isEmpty() ) {
1884             GetPlot2dViewer( this )->getActiveViewFrame()->displayCurves( container, true );
1885             GetPlot2dViewer( this )->getActiveViewFrame()->setTitle( aSObjectName );
1886           }
1887         }
1888       }
1889       delete aDlg;
1890     }
1891   }
1892 }
1893
1894 //----------------------------------------------------------------------------
1895 void
1896 VisuGUI
1897 ::OnCurveProperties()
1898 {
1899   VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(this);
1900   if(aSelectionInfo.size() != 1)
1901     return;
1902
1903   VISU::TSelectionItem aSelectionItem = aSelectionInfo.front();
1904   Handle(SALOME_InteractiveObject) anIO = aSelectionItem.myIO;
1905   VISU::Base_i* aBase = aSelectionItem.myObjectInfo.myBase;
1906   if(!aBase)
1907     return;
1908
1909   if(aBase->GetType() == VISU::TCURVE) {
1910     // Curve object
1911     if(VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(aBase)){
1912       if(!IsStudyLocked(GetCStudy(GetAppStudy(this)))){
1913         Plot2d_SetupCurveDlg aDlg(GetDesktop( this ));
1914
1915         aDlg.setLine( (Plot2d::LineType)aCurve->GetLine(), aCurve->GetLineWidth() );
1916         aDlg.setMarker( (Plot2d::MarkerType)aCurve->GetMarker() );
1917         SALOMEDS::Color aColor = aCurve->GetColor();
1918         aDlg.setColor( QColor( (int)(aColor.R*255.), (int)(aColor.G*255.), (int)(aColor.B*255.) ) );
1919         if( aDlg.exec() == QDialog::Accepted ) {
1920           aCurve->SetLine( (VISU::Curve::LineType)aDlg.getLine(), aDlg.getLineWidth() );
1921           aCurve->SetMarker( (VISU::Curve::MarkerType)aDlg.getMarker());
1922           SALOMEDS::Color newColor;
1923           newColor.R = aDlg.getColor().red()/255.;
1924           newColor.G = aDlg.getColor().green()/255.;
1925           newColor.B = aDlg.getColor().blue()/255.;
1926           aCurve->SetColor( newColor );
1927           PlotCurve(this, aCurve, VISU::eDisplay);
1928         }
1929       }
1930     }
1931   }
1932 }
1933
1934 //----------------------------------------------------------------------------
1935 void
1936 VisuGUI
1937 ::OnClearContainer()
1938 {
1939   _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1940   if (CheckLock(aCStudy,GetDesktop(this)))
1941     return;
1942
1943   VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(this);
1944   if(aSelectionInfo.empty())
1945     return;
1946
1947   VISU::TSelectionItem aSelectionItem = aSelectionInfo.front();
1948   VISU::Base_i* aBase = aSelectionItem.myObjectInfo.myBase;
1949   if(!aBase)
1950     return;
1951
1952   if(aBase->GetType() == VISU::TCONTAINER){
1953     // Container object
1954     if(VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(aBase)){
1955       if(aContainer && aContainer->GetNbCurves() > 0){
1956         aContainer->Clear();
1957         VISU::updateContainerVisibility(aContainer);
1958         UpdateObjBrowser(this);
1959       }
1960     }
1961   }
1962 }
1963
1964 //----------------------------------------------------------------------------
1965 void
1966 VisuGUI
1967 ::OnEditContainer()
1968 {
1969   VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(this);
1970   if(aSelectionInfo.empty())
1971     return;
1972
1973   VISU::TSelectionItem aSelectionItem = aSelectionInfo.front();
1974   VISU::Base_i* aBase = aSelectionItem.myObjectInfo.myBase;
1975   if(!aBase)
1976     return;
1977
1978   VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(aBase);
1979   if(!aContainer)
1980     return;
1981
1982   VisuGUI_EditContainerDlg* aDlg = new VisuGUI_EditContainerDlg (this);
1983   aDlg->initFromPrsObject(aContainer);
1984   if (aDlg->exec()) {
1985     aDlg->storeToPrsObject(aContainer);
1986     UpdateObjBrowser(this, true);
1987     delete aDlg;
1988     VISU::updateContainerVisibility(aContainer);
1989   }
1990 }
1991
1992 //----------------------------------------------------------------------------
1993 void
1994 VisuGUI
1995 ::OnSaveViewParams()
1996 {
1997   _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1998   if (CheckLock(aCStudy,GetDesktop(this)))
1999     return;
2000
2001   SUIT_ViewManager* aViewMgr = getApp()->activeViewManager();
2002   if (aViewMgr->getType() != SVTK_Viewer::Type())
2003     return;
2004
2005   LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
2006   SALOME_ListIO aListIO;
2007   aSelectionMgr->selectedObjects(aListIO);
2008   if (aListIO.Extent() > 1)
2009     return;
2010
2011   if (aListIO.Extent() == 0) {
2012     VISU::View3D_i::SaveViewParams(aViewMgr, (const char*)VISU::View3D_i::GenerateViewParamsName().toLatin1());
2013   } else {
2014     const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
2015     VISU::View3D_i::SaveViewParams(aViewMgr, anIO->getName());
2016   }
2017   UpdateObjBrowser(this);
2018 }
2019
2020 //----------------------------------------------------------------------------
2021 void
2022 VisuGUI
2023 ::OnRestoreViewParams()
2024 {
2025   SUIT_ViewManager* aViewMgr = getApp()->activeViewManager();
2026   if (aViewMgr->getType() != SVTK_Viewer::Type())
2027     return;
2028
2029   LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
2030   SALOME_ListIO aListIO;
2031   aSelectionMgr->selectedObjects(aListIO);
2032   if (aListIO.Extent() != 1)
2033     return;
2034
2035   const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
2036   //jfa tmp:VISU::View3D_i::RestoreViewParams(aViewMgr, anIO->getName());
2037   _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));//jfa tmp
2038   _PTR(SObject) aSObj = aCStudy->FindObjectID(anIO->getEntry());//jfa tmp
2039   if ( aSObj )
2040     VISU::View3D_i::RestoreViewParams(aViewMgr, aSObj->GetName().c_str());//jfa tmp
2041 }
2042
2043 //----------------------------------------------------------------------------
2044 void
2045 VisuGUI
2046 ::OnRename()
2047 {
2048   _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
2049   if (CheckLock(aCStudy,GetDesktop(this)))
2050     return;
2051
2052   VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(this);
2053   if (aSelectionInfo.empty())
2054     return;
2055
2056   VisuGUI_Selection aSel (this);
2057   aSel.init("", getApp()->selectionMgr());
2058   if (aSel.count() < 1) return;
2059
2060   bool isAny = false; // is there any appropriate object selected
2061   for (int i = 0; i < aSelectionInfo.size(); i++) {
2062     VISU::TSelectionItem aSelectionItem = aSelectionInfo[i];
2063     VISU::TObjectInfo anObjectInfo = aSelectionItem.myObjectInfo;
2064
2065     _PTR(SObject) aSObject = anObjectInfo.mySObject;
2066     if (!aSObject)
2067       continue;
2068
2069     // Check, if the selected object can be renamed
2070     QString aStr = aSel.parameter(i, "type" ).toString();
2071     if (aStr == "VISU::TSCALARMAP" || aStr == "VISU::TISOSURFACES" ||
2072         aStr == "VISU::TDEFORMEDSHAPE" || aStr == "VISU::TCUTPLANES" ||
2073         aStr == "VISU::TCUTLINES" || aStr == "VISU::TCUTSEGMENT" || aStr == "VISU::TVECTORS" ||
2074         aStr == "VISU::TSTREAMLINES" || aStr == "VISU::TPLOT3D" ||
2075         aStr == "VISU::TSCALARMAPONDEFORMEDSHAPE" || aStr == "VISU::TCOLOREDPRS3DHOLDER" ||
2076         aStr == "VISU::TTABLE" || aStr == "VISU::TCURVE" || aStr == "VISU::TCONTAINER" ||
2077         aStr == "VISU::POINTMAP3D" || aStr == "VISU::TVIEW3D" ||
2078         aStr == "VISU::TPOINTMAP3D" || aStr == "VISU::TGAUSSPOINTS")
2079     {
2080       _PTR(GenericAttribute) anAttr;
2081       if (aSObject->FindAttribute(anAttr, "AttributeName")) {
2082         isAny = true;
2083         _PTR(AttributeName) aName (anAttr);
2084         QString Name = VisuGUI_NameDlg::getName( GetDesktop( this ), aName->Value().c_str() );
2085         if (!Name.isEmpty()) {
2086           QApplication::setOverrideCursor(Qt::WaitCursor);
2087
2088           // rename specific objects
2089           if (VISU::Base_i* aBase = anObjectInfo.myBase) {
2090             switch (aBase->GetType()) {
2091             case VISU::TCURVE: { // Curve object
2092               if (VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(aBase))
2093                 aCurve->SetName(Name.toLatin1().constData(), true);
2094               break;
2095             }
2096             case VISU::TTABLE: { // Table object
2097               if (VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(aBase))
2098                 aTable->SetName(Name.toLatin1().constData(), true);
2099               break;
2100             }
2101             case VISU::TPOINTMAP3D: { // Table object
2102               if (VISU::PointMap3d_i* aTable3d = dynamic_cast<VISU::PointMap3d_i*>(aBase)) {
2103                 aTable3d->SetTitle(Name.toLatin1().constData());
2104                 aTable3d->UpdateActors();
2105               }
2106               break;
2107             }
2108             case VISU::TCONTAINER: { // Container object
2109               if (VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(aBase))
2110                 aContainer->SetName(Name.toLatin1().constData(), true);
2111               break;
2112             }
2113             default: {
2114             }}
2115           }
2116
2117           // rename the study object
2118           Handle(SALOME_InteractiveObject) anIO = aSelectionItem.myIO;
2119           aName->SetValue(Name.toLatin1().constData()); // rename the SObject
2120           anIO->setName(Name.toLatin1().constData()); // rename the InteractiveObject
2121
2122           ViewManagerList aViewManagerList;
2123           getApp()->viewManagers(SPlot2d_Viewer::Type(), aViewManagerList);
2124           SUIT_ViewManager* aViewManager;
2125           foreach( aViewManager, aViewManagerList ) {
2126             if (Plot2d_ViewManager* aManager = dynamic_cast<Plot2d_ViewManager*>(aViewManager)) {
2127               if (SPlot2d_Viewer* aViewer = dynamic_cast<SPlot2d_Viewer*>(aManager->getViewModel()))
2128                 aViewer->renameAll( anIO, Name.toLatin1().constData() );
2129             }
2130           }
2131
2132           UpdateObjBrowser(this, false);
2133           QApplication::restoreOverrideCursor();
2134         }
2135       }
2136     }
2137   } // for
2138
2139   if (!isAny) {
2140     SUIT_MessageBox::warning(GetDesktop(this),
2141                              QObject::tr("WRN_VISU"),
2142                              QObject::tr("WRN_NO_APPROPRIATE_SELECTION"));
2143   }
2144 }
2145
2146 //----------------------------------------------------------------------------
2147 void
2148 VisuGUI
2149 ::OnClippingPlanes()
2150 {
2151   new VisuGUI_ClippingDlg (this, false);
2152 }
2153
2154 //----------------------------------------------------------------------------
2155 void
2156 VisuGUI
2157 ::OnSweep()
2158 {
2159   OnDisplayPrs();
2160   if ( !mySweep->toggleViewAction()->isChecked() )
2161     mySweep->toggleViewAction()->trigger();
2162   mySweep->onSelectionChanged();
2163   mySweep->onFirst();
2164   mySweep->onPlay(true);
2165 }
2166
2167 //----------------------------------------------------------------------------
2168 void
2169 VisuGUI
2170 ::OnTimeAnimation(VISU::Animation::AnimationMode theMode)
2171 {
2172   if (!VISU::GetActiveViewWindow<SVTK_ViewWindow>(this))
2173     return;
2174
2175   _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
2176   VisuGUI_TimeAnimationDlg* aAnimationDlg =
2177     new VisuGUI_TimeAnimationDlg (this, aCStudy, theMode);
2178
2179   LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
2180   SALOME_ListIO aListIO;
2181   aSelectionMgr->selectedObjects(aListIO);
2182
2183   SALOME_ListIteratorOfListIO It (aListIO);
2184   for (; It.More(); It.Next()) {
2185     _PTR(SObject) aSObject = aCStudy->FindObjectID(It.Value()->getEntry());
2186     if ( !aAnimationDlg->addField(aSObject) ) {
2187       SUIT_MessageBox::warning(GetDesktop(this),
2188                                tr("WRN_VISU"),
2189                                tr("ERR_CANT_CREATE_ANIMATION") );
2190       delete aAnimationDlg;
2191       return;
2192     }
2193   }
2194   aAnimationDlg->show();
2195 }
2196
2197 //----------------------------------------------------------------------------
2198 void
2199 VisuGUI::
2200 OnParallelTimeAnimation()
2201 {
2202   OnTimeAnimation(VISU::Animation::PARALLEL);
2203 }
2204
2205 void
2206 VisuGUI::
2207 OnSucccessiveTimeAnimation()
2208 {
2209   OnTimeAnimation(VISU::Animation::SUCCESSIVE);
2210 }
2211
2212 //----------------------------------------------------------------------------
2213 void
2214 VisuGUI
2215 ::OnShowAnimation()
2216 {
2217   if (!VISU::GetActiveViewWindow<SVTK_ViewWindow>(this))
2218     return;
2219
2220   LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
2221   SALOME_ListIO aListIO;
2222   aSelectionMgr->selectedObjects(aListIO);
2223
2224   if (aListIO.Extent() != 1)
2225     return;
2226
2227   const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
2228
2229   _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
2230
2231   _PTR(SObject) aSObj = aCStudy->FindObjectID(anIO->getEntry());
2232   if (!aSObj)
2233     return;
2234
2235   VISU::VISUType aType = VISU::Storable::SObject2Type( aSObj );
2236   if (aType != VISU::TANIMATION)
2237     return;
2238
2239   VisuGUI_TimeAnimationDlg* aAnimationDlg =
2240     new VisuGUI_TimeAnimationDlg(this, aCStudy);
2241   aAnimationDlg->restoreFromStudy(aSObj);
2242   aAnimationDlg->show();
2243 }
2244
2245 //----------------------------------------------------------------------------
2246 void
2247 VisuGUI
2248 ::OnPointEvolution()
2249 {
2250   _PTR(Study) aCStudy = GetCStudy( GetAppStudy( this ) );
2251   VisuGUI_EvolutionDlg* aDlg = new VisuGUI_EvolutionDlg( this, aCStudy );
2252
2253   LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr( this );
2254   SALOME_ListIO aListIO;
2255   aSelectionMgr->selectedObjects( aListIO );
2256
2257   SALOME_ListIteratorOfListIO It( aListIO );
2258   for( ; It.More(); It.Next() )
2259   {
2260     _PTR(SObject) aSObject = aCStudy->FindObjectID( It.Value()->getEntry() );
2261     if( !aDlg->setField( aSObject ) )
2262     {
2263       SUIT_MessageBox::warning( GetDesktop( this ),
2264                                 tr( "WRN_VISU" ),
2265                                 tr( "ERR_CANT_CREATE_EVOLUTION" ) );
2266       delete aDlg;
2267       return;
2268     }
2269   }
2270   aDlg->show();
2271 }
2272
2273 //----------------------------------------------------------------------------
2274 void
2275 VisuGUI
2276 ::OnShowEvolution()
2277 {
2278   LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr( this );
2279   SALOME_ListIO aListIO;
2280   aSelectionMgr->selectedObjects( aListIO );
2281
2282   if( aListIO.Extent() != 1 )
2283     return;
2284
2285   const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
2286
2287   _PTR(Study) aCStudy = GetCStudy( GetAppStudy( this ) );
2288   _PTR(SObject) aSObj = aCStudy->FindObjectID( anIO->getEntry() );
2289   if( !aSObj )
2290     return;
2291
2292   VISU::VISUType aType = VISU::Storable::SObject2Type( aSObj );
2293   if( aType != VISU::TEVOLUTION )
2294     return;
2295
2296   VisuGUI_EvolutionDlg* aDlg = new VisuGUI_EvolutionDlg( this, aCStudy );
2297   aDlg->restoreFromStudy( aSObj );
2298   aDlg->show();
2299 }
2300
2301 //----------------------------------------------------------------------------
2302 void
2303 VisuGUI
2304 ::OnCopyPresentation()
2305 {
2306   _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
2307   if (CheckLock(aCStudy,GetDesktop(this)))
2308     return;
2309
2310   VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(this);
2311   if(aSelectionInfo.empty())
2312     return;
2313
2314   VISU::TSelectionItem aSelectionItem = aSelectionInfo.front();
2315   VISU::Base_i* aBase = aSelectionItem.myObjectInfo.myBase;
2316   if(!aBase)
2317     return;
2318
2319   VISU::Prs3d_i* aPrs3d = VISU::GetPrs3dToModify(this, aBase);
2320   if(!aPrs3d)
2321     return;
2322
2323   if(aBase->GetType() != VISU::TMESH){
2324     VISU::ColoredPrs3d_i* aColoredPrs3d = dynamic_cast<VISU::ColoredPrs3d_i*>(aBase);
2325     switch (aBase->GetType()) {
2326     case VISU::TSCALARMAP:
2327       TSameAsFactory<VISU::TSCALARMAP>().Create(aColoredPrs3d, ColoredPrs3d_i::EPublishUnderTimeStamp, false);
2328       break;
2329     case VISU::TDEFORMEDSHAPE:
2330       TSameAsFactory<VISU::TDEFORMEDSHAPE>().Create(aColoredPrs3d, ColoredPrs3d_i::EPublishUnderTimeStamp, false);
2331       break;
2332     case VISU::TSCALARMAPONDEFORMEDSHAPE:
2333     case VISU::TDEFORMEDSHAPEANDSCALARMAP:
2334       TSameAsFactory<VISU::TDEFORMEDSHAPEANDSCALARMAP>().Create(aColoredPrs3d, ColoredPrs3d_i::EPublishUnderTimeStamp, false);
2335       break;
2336     case VISU::TCUTPLANES:
2337       TSameAsFactory<VISU::TCUTPLANES>().Create(aColoredPrs3d, ColoredPrs3d_i::EPublishUnderTimeStamp, false);
2338       break;
2339     case VISU::TCUTLINES:
2340       TSameAsFactory<VISU::TCUTLINES>().Create(aColoredPrs3d, ColoredPrs3d_i::EPublishUnderTimeStamp, false);
2341       break;
2342     case VISU::TCUTSEGMENT:
2343       TSameAsFactory<VISU::TCUTSEGMENT>().Create(aColoredPrs3d, ColoredPrs3d_i::EPublishUnderTimeStamp, false);
2344       break;
2345     case VISU::TISOSURFACES:
2346       TSameAsFactory<VISU::TISOSURFACES>().Create(aColoredPrs3d, ColoredPrs3d_i::EPublishUnderTimeStamp, false);
2347       break;
2348     case VISU::TSTREAMLINES:
2349       TSameAsFactory<VISU::TSTREAMLINES>().Create(aColoredPrs3d, ColoredPrs3d_i::EPublishUnderTimeStamp, false);
2350       break;
2351     case VISU::TVECTORS:
2352       TSameAsFactory<VISU::TVECTORS>().Create(aColoredPrs3d, ColoredPrs3d_i::EPublishUnderTimeStamp, false);
2353       break;
2354     case VISU::TPLOT3D:
2355       TSameAsFactory<VISU::TPLOT3D>().Create(aColoredPrs3d, ColoredPrs3d_i::EPublishUnderTimeStamp, false);
2356       break;
2357     }
2358     UpdateObjBrowser(this);
2359   }
2360 }
2361
2362 //----------------------------------------------------------------------------
2363 void
2364 VisuGUI
2365 ::OnToggleSelectionPanel()
2366 {
2367   if (GetActiveViewWindow<SVTK_ViewWindow>(this))
2368   {
2369     if( myPanels.find( SelectionPanelId ) != myPanels.end() )
2370     {
2371       if( VisuGUI_SelectionPanel* aSelectionPanel =
2372           dynamic_cast<VisuGUI_SelectionPanel*>( myPanels[ SelectionPanelId ] ) )
2373       {
2374         if( aSelectionPanel->isVisible() )
2375           aSelectionPanel->hide();
2376         else
2377           aSelectionPanel->show();
2378       }
2379     }
2380   }
2381   else
2382     SUIT_MessageBox::warning(GetDesktop(this),
2383                              tr("WRN_VISU"),
2384                              tr("ERR_ACTIVATE_VIEW3D") );
2385 }
2386
2387 //----------------------------------------------------------------------------
2388 void
2389 VisuGUI
2390 ::OnSwitchSelectionMode()
2391 {
2392   QAction* anAction = dynamic_cast<QAction*>( sender() );
2393   if( !anAction )
2394     return;
2395
2396   bool isAnyChecked = false;
2397   for( int anId = VISU_ACTOR_SELECTION; anId <= VISU_GAUSS_POINT_SELECTION; anId++ )
2398   {
2399     QAction* aRefAction = action( anId );
2400     isAnyChecked |= aRefAction->isChecked();
2401     if( anAction != aRefAction )
2402       aRefAction->setChecked( false );
2403     else if( myPanels.find( SelectionPanelId ) != myPanels.end() )
2404     {
2405       if( VisuGUI_SelectionPanel* aSelectionPanel =
2406           dynamic_cast<VisuGUI_SelectionPanel*>( myPanels[ SelectionPanelId ] ) )
2407         aSelectionPanel->setSelectionMode( anId - VISU_ACTOR_SELECTION );
2408     }
2409   }
2410   // At least one action must be checked
2411   if( !isAnyChecked )
2412     anAction->setChecked( true );
2413 }
2414
2415 //----------------------------------------------------------------------------
2416 void
2417 VisuGUI
2418 ::OnSwitchSelectionMode( int theId )
2419 {
2420   for( int anId = VISU_ACTOR_SELECTION; anId <= VISU_GAUSS_POINT_SELECTION; anId++ )
2421   {
2422     QAction* aRefAction = action( anId );
2423     aRefAction->setChecked( anId == VISU_ACTOR_SELECTION + theId );
2424   }
2425 }
2426
2427 //----------------------------------------------------------------------------
2428 void
2429 VisuGUI
2430 ::OnMergeScalarBars()
2431 {
2432   LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
2433   SALOME_ListIO aListIO;
2434   aSelectionMgr->selectedObjects(aListIO);
2435
2436   SALOME_ListIteratorOfListIO It (aListIO);
2437
2438   // first find the bounds
2439   double aMin, aMax; bool first = true;
2440   for (; It.More(); It.Next()) {
2441     Handle(SALOME_InteractiveObject)& anIO = It.Value();
2442     std::vector<VISU::Prs3d_i*> aPrsList = GetPrs3dList(this, anIO);
2443     if (!aPrsList.empty()) {
2444       for (int i = 0, n = aPrsList.size(); i < n; i++) {
2445         VISU::Prs3d_i* aPrsObject = aPrsList[i];
2446         if (aPrsObject) {
2447           VISU::ScalarMap_i* aScalar = dynamic_cast<VISU::ScalarMap_i*>(aPrsObject);
2448           if (aScalar) {
2449             if (first) {
2450               first = false;
2451               aMin = aScalar->GetMin(); aMax = aScalar->GetMax();
2452             } else {
2453               if (aScalar->GetMin() < aMin) aMin = aScalar->GetMin();
2454               if (aScalar->GetMax() > aMax) aMax = aScalar->GetMax();
2455             }
2456           }
2457         }
2458       }
2459     }
2460   }
2461
2462   // set the computed range to every selected ScalarMap
2463   bool update = false;
2464   for (It.Initialize(aListIO); It.More(); It.Next() ) {
2465     Handle(SALOME_InteractiveObject)& anIO = It.Value();
2466     std::vector<VISU::Prs3d_i*> aPrsList = GetPrs3dList(this, anIO);
2467     if (!aPrsList.empty()) {
2468       for (int i = 0, n = aPrsList.size(); i < n; i++) {
2469         VISU::Prs3d_i* aPrsObject = aPrsList[i];
2470         if(aPrsObject){
2471           VISU::ScalarMap_i* aScalar = dynamic_cast<VISU::ScalarMap_i*>(aPrsObject);
2472           if (aScalar) {
2473             aScalar->SetRange(aMin, aMax);
2474             RecreateActor(this, aScalar);
2475             update = true;
2476           }
2477         }
2478       }
2479     }
2480   }
2481   if (update) {
2482     if (SVTK_ViewWindow* vw = GetActiveViewWindow<SVTK_ViewWindow>(this)) {
2483       vw->getRenderer()->ResetCameraClippingRange();
2484       vw->Repaint();
2485     }
2486   }
2487 }
2488
2489 //----------------------------------------------------------------------------
2490 void
2491 VisuGUI
2492 ::OnFreeScalarBars()
2493 {
2494   LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
2495   SALOME_ListIO aListIO;
2496   aSelectionMgr->selectedObjects(aListIO);
2497
2498   SALOME_ListIteratorOfListIO It (aListIO);
2499
2500   // restore the source range for every ScalarMap
2501   bool update = false;
2502   for (; It.More(); It.Next()) {
2503     Handle(SALOME_InteractiveObject)& anIO = It.Value();
2504     std::vector<VISU::Prs3d_i*> aPrsList = GetPrs3dList(this, anIO);
2505     if (!aPrsList.empty()) {
2506       for (int i = 0, n = aPrsList.size(); i < n; i++) {
2507         VISU::Prs3d_i* aPrsObject = aPrsList[i];
2508         if (aPrsObject) {
2509           VISU::ScalarMap_i* aScalar = dynamic_cast<VISU::ScalarMap_i*>(aPrsObject);
2510           if (aScalar) {
2511             aScalar->SetSourceRange();
2512             RecreateActor(this, aScalar);
2513             update = true;
2514           }
2515         }
2516       }
2517     }
2518   }
2519   if (update) {
2520     if (SVTK_ViewWindow* vw = GetActiveViewWindow<SVTK_ViewWindow>(this)) {
2521       vw->getRenderer()->ResetCameraClippingRange();
2522       vw->Repaint();
2523     }
2524   }
2525 }
2526
2527 //----------------------------------------------------------------------------
2528 void
2529 VisuGUI
2530 ::OnTranslatePrs()
2531 {
2532   if(MYDEBUG) MESSAGE("VisuGUI::OnTranslatePrs");
2533   VisuGUI_OffsetDlg* aDlg = new VisuGUI_OffsetDlg (this);
2534   aDlg->exec();
2535 }
2536
2537 void
2538 VisuGUI
2539 ::OnArrangeActors()
2540 {
2541   if(SVTK_ViewWindow* aViewWindow = GetActiveViewWindow<SVTK_ViewWindow>(this)){
2542     ArrangeDlg* aDlg = new ArrangeDlg (GetDesktop(this), this, aViewWindow);
2543     aDlg->exec();
2544     delete aDlg;
2545   }
2546 }
2547
2548
2549 void
2550 VisuGUI
2551 ::initialize( CAM_Application* theApp )
2552 {
2553   SalomeApp_Module::initialize( theApp );
2554
2555   mySlider = new VisuGUI_Slider( this, getApp()->desktop(), getApp()->selectionMgr() );
2556
2557   mySweep = new VisuGUI_Sweep( this, getApp()->desktop(), getApp()->selectionMgr() );
2558
2559   createActions();
2560   createMenus();
2561   createToolBars();
2562   createPopupMenus();
2563   createPanels();
2564
2565   // tmp
2566   action( VISU_ACTOR_SELECTION )->setChecked( true );
2567 }
2568
2569 void
2570 VisuGUI
2571 ::createActions()
2572 {
2573   QPixmap aPixmap;
2574   QWidget* aParent = application()->desktop();
2575   SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
2576
2577   // Create actions
2578
2579   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_IMPORT_MED"));
2580   createAction( VISU_IMPORT_FROM_FILE, tr("IMPORT_FROM_FILE"), QIcon(aPixmap),
2581                 tr("MEN_IMPORT_FROM_FILE"), "", (Qt::CTRL + Qt::Key_I), aParent, false,
2582                 this, SLOT(OnImportFromFile()));
2583
2584   createAction( VISU_IMPORT_TABLE, "", QIcon(),
2585                 tr("MEN_IMPORT_TABLE"), "", 0, aParent, false,
2586                 this, SLOT(OnImportTableFromFile()));
2587
2588   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_SCALAR_MAP"));
2589   createAction( VISU_SCALAR_MAP, tr("MEN_SCALAR_MAP"), QIcon(aPixmap),
2590                 tr("MEN_SCALAR_MAP"), "", 0, aParent, false,
2591                 this, SLOT(OnCreateScalarMap()));
2592
2593   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_DEFORMED_SHAPE"));
2594   createAction( VISU_DEFORMED_SHAPE, tr("MEN_DEFORMED_SHAPE"), QIcon(aPixmap),
2595                 tr("MEN_DEFORMED_SHAPE"), "", 0, aParent, false,
2596                 this, SLOT(OnCreateDeformedShape()));
2597
2598   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_SCALAR_MAP_ON_DEFORMED_SHAPE"));
2599   createAction( VISU_DEFORMED_SHAPE_AND_SCALAR_MAP, tr("MEN_DEFORMED_SHAPE_AND_SCALAR_MAP"), QIcon(aPixmap),
2600                 tr("MEN_DEFORMED_SHAPE_AND_SCALAR_MAP"), "", 0, aParent, false,
2601                 this, SLOT(OnCreateDeformedShapeAndScalarMap()));
2602
2603   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_VECTORS"));
2604   createAction( VISU_VECTORS, tr("MEN_VECTORS"), QIcon(aPixmap),
2605                 tr("MEN_VECTORS"), "", 0, aParent, false,
2606                 this, SLOT(OnCreateVectors()));
2607
2608   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_ISO_SURFACES"));
2609   createAction( VISU_ISO_SURFACES, tr("MEN_ISO_SURFACES"), QIcon(aPixmap),
2610                 tr("MEN_ISO_SURFACES"), "", 0, aParent, false,
2611                 this, SLOT(OnCreateIsoSurfaces()));
2612
2613   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_CUT_PLANES"));
2614   createAction( VISU_CUT_PLANES, tr("MEN_CUT_PLANES"), QIcon(aPixmap),
2615                 tr("MEN_CUT_PLANES"), "", 0, aParent, false,
2616                 this, SLOT(OnCreateCutPlanes()));
2617
2618   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_STREAM_LINES"));
2619   createAction( VISU_STREAM_LINES, tr("MEN_STREAM_LINES"), QIcon(aPixmap),
2620                 tr("MEN_STREAM_LINES"), "", 0, aParent, false,
2621                 this, SLOT(OnCreateStreamLines()));
2622
2623   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_CUT_LINES"));
2624   createAction( VISU_CUT_LINES, tr("MEN_CUT_LINES"), QIcon(aPixmap),
2625                 tr("MEN_CUT_LINES"), "", 0, aParent, false,
2626                 this, SLOT(OnCreateCutLines()));
2627
2628   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_CUT_SEGMENT"));
2629   createAction( VISU_CUT_SEGMENT, tr("MEN_CUT_SEGMENT"), QIcon(aPixmap),
2630                 tr("MEN_CUT_SEGMENT"), "", 0, aParent, false,
2631                 this, SLOT(OnCreateCutSegment()));
2632
2633   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_PLOT_3D"));
2634   createAction( VISU_PLOT_3D, tr("MEN_PLOT_3D"), QIcon(aPixmap),
2635                 tr("MEN_PLOT_3D"), "", 0, aParent, false,
2636                 this, SLOT(OnCreatePlot3D()));
2637
2638   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_PLOT2D"));
2639   createAction( VISU_PLOT2D, tr("MEN_CREATE_PLOT2D"), QIcon(aPixmap),
2640                 tr("MEN_CREATE_PLOT2D"), "", 0, aParent, false,
2641                 this, SLOT(OnCreatePlot2dView()));
2642
2643   createAction( VISU_DELETE_OBJS, tr("MEN_DELETE_OBJS"), QIcon(),
2644                 tr("MEN_DELETE_OBJS"), "", Qt::Key_Delete, aParent, false,
2645                 this, SLOT(OnDeleteObjects()));
2646
2647   createAction( VISU_SHOW_TABLE, tr("MEN_SHOW_TABLE"), QIcon(),
2648                 tr("MEN_SHOW_TABLE"), "", 0, aParent, false,
2649                 this, SLOT(OnShowTable()));
2650
2651   createAction( VISU_EDIT_POINTMAP3D, tr("MEN_EDIT_PRS"), QIcon(),
2652                 tr("MEN_EDIT_PRS"), "", 0, aParent, false,
2653                 this, SLOT(OnShowTablePlot()));
2654
2655   createAction( VISU_CREATE_CURVES, tr("MEN_CREATE_CURVES"), QIcon(),
2656                 tr("MEN_CREATE_CURVES"), "", 0, aParent, false,
2657                 this, SLOT(OnPlotData()));
2658
2659   createAction( VISU_EXPORT_TABLE, tr("MEN_EXPORT_TABLE"), QIcon(),
2660                 tr("MEN_EXPORT_TABLE"), "", 0, aParent, false,
2661                 this, SLOT(OnExportTableToFile()));
2662
2663   createAction( VISU_IMPORT_MED_STRUCTURE, tr("MEN_IMPORT_MED_STRUCTURE"), QIcon(),
2664                 tr("MEN_IMPORT_MED_STRUCTURE"), "", 0, aParent, false,
2665                 this, SLOT(OnImportMedField()));
2666
2667   createAction( VISU_IMPORT_MED_TIMESTAMP, tr("MEN_IMPORT_MED_TIMESTAMP"), QIcon(),
2668                 tr("MEN_IMPORT_MED_TIMESTAMP"), "", 0, aParent, false,
2669                 this, SLOT(OnImportMedField()));
2670
2671   createAction( VISU_IMPORT_MED_FIELD, tr("MEN_IMPORT_MED_FIELD"), QIcon(),
2672                 tr("MEN_IMPORT_MED_FIELD"), "", 0, aParent, false,
2673                 this, SLOT(OnImportMedField()));
2674
2675   createAction( VISU_LOAD_COMPONENT_DATA, tr("MEN_LOAD_COMPONENT_DATA"), QIcon(),
2676                 tr("MEN_LOAD_COMPONENT_DATA"), "", 0, aParent, false,
2677                 this, SLOT(OnLoadComponentData()));
2678
2679   createAction( VISU_CREATE_PRS, tr("MEN_CREATE_PRS"), QIcon(),
2680                 tr("MEN_CREATE_PRS"), "", 0, aParent, false,
2681                 this, SLOT(OnCreateMesh()));
2682
2683   createAction( VISU_CREATE_MANY_PRS, tr("MEN_CREATE_MANY_PRS"), QIcon(),
2684                 tr("MEN_CREATE_MANY_PRS"), "", 0, aParent, false,
2685                 this, SLOT(OnCreateManyMesh()));
2686
2687   createAction( VISU_TRANSLATE_PRS, tr("MEN_TRANSLATE_PRS"), QIcon(),
2688                 tr("MEN_TRANSLATE_PRS"), "", 0, aParent, false,
2689                 this, SLOT(OnTranslatePrs()));
2690
2691   createAction( VISU_MERGE_SCALAR_BARS, tr("MEN_MERGE_SCALAR_BARS"), QIcon(),
2692                 tr("MEN_MERGE_SCALAR_BARS"), "", 0, aParent, false,
2693                 this, SLOT(OnMergeScalarBars()));
2694
2695   createAction( VISU_FREE_SCALAR_BARS, tr("MEN_FREE_SCALAR_BARS"), QIcon(),
2696                 tr("MEN_FREE_SCALAR_BARS"), "", 0, aParent, false,
2697                 this, SLOT(OnFreeScalarBars()));
2698
2699   createAction( VISU_ERASE, tr("MEN_HIDE"), QIcon(),
2700                 tr("MEN_HIDE"), "", 0, aParent, false,
2701                 this, SLOT(OnErasePrs()));
2702
2703   createAction( VISU_DISPLAY, tr("MEN_SHOW"), QIcon(),
2704                 tr("MEN_SHOW"), "", 0, aParent, false,
2705                 this, SLOT(OnDisplayPrs()));
2706
2707   createAction( VISU_DISPLAY_ONLY, tr("MEN_DISPLAY_ONLY"), QIcon(),
2708                 tr("MEN_DISPLAY_ONLY"), "", 0, aParent, false,
2709                 this, SLOT(OnDisplayOnlyPrs()));
2710
2711   createAction( VISU_SHOW_SCALAR_BAR, tr("MEN_SHOW_SCALAR_BAR"), QIcon(),
2712                 tr("MEN_SHOW_SCALAR_BAR"), "", 0, aParent, false,
2713                 this, SLOT(OnShowScalarBar()));
2714
2715   createAction( VISU_HIDE_SCALAR_BAR, tr("MEN_HIDE_SCALAR_BAR"), QIcon(),
2716                 tr("MEN_HIDE_SCALAR_BAR"), "", 0, aParent, false,
2717                 this, SLOT(OnHideScalarBar()));
2718
2719   createAction( VISU_COPY_PRS, tr("MEN_COPY_PRS"), QIcon(),
2720                 tr("MEN_COPY_PRS"), "", 0, aParent, false,
2721                 this, SLOT(OnCopyPresentation()));
2722
2723   createAction( VISU_CURVE_PROPS, tr("MEN_CURVE_PROPS"), QIcon(),
2724                 tr("MEN_CURVE_PROPS"), "", 0, aParent, false,
2725                 this, SLOT(OnCurveProperties()));
2726
2727   createAction( VISU_RENAME, tr("MEN_RENAME"), QIcon(),
2728                 tr("MEN_RENAME"), "", Qt::Key_F2, aParent, false,
2729                 this, SLOT(OnRename()));
2730
2731   createAction( VISU_EDIT_CONTAINER, tr("MEN_EDIT_CONTAINER"), QIcon(),
2732                 tr("MEN_EDIT_CONTAINER"), "", 0, aParent, false,
2733                 this, SLOT(OnEditContainer()));
2734
2735   createAction( VISU_CLEAR_CONTAINER, tr("MEN_CLEAR_CONTAINER"), QIcon(),
2736                 tr("MEN_CLEAR_CONTAINER"), "", 0, aParent, false,
2737                 this, SLOT(OnClearContainer()));
2738
2739   createAction( VISU_SAVE_VIEW_PARAMS, tr("MEN_SAVE_VIEWPARAMS"), QIcon(),
2740                 tr("MEN_SAVE_VIEWPARAMS"), "", 0, aParent, false,
2741                 this, SLOT(OnSaveViewParams()));
2742   createAction( VISU_SAVE_VIEW_PARAMS_1, tr("MEN_SAVE_VIEWPARAMS"), QIcon(),
2743                 tr("MEN_SAVE_VIEWPARAMS"), "", 0, aParent, false,
2744                 this, SLOT(OnSaveViewParams()));
2745
2746   createAction( VISU_RESTORE_VIEW_PARAMS, tr("MEN_RESTORE_VIEWPARAMS"), QIcon(),
2747                 tr("MEN_RESTORE_VIEWPARAMS"), "", 0, aParent, false,
2748                 this, SLOT(OnRestoreViewParams()));
2749
2750   //createAction( VISU_DELETE_VIEW_PARAMS, tr("MEN_DELETE_VIEWPARAMS"), QIcon(),
2751   //              tr("MEN_DELETE_VIEWPARAMS"), "", 0, aParent, false,
2752   //              this, SLOT(OnDeleteObjects()));
2753
2754   createAction( VISU_ARRANGE_ACTORS, tr("MEN_ARRANGE_ACTORS"), QIcon(),
2755                 tr("MEN_ARRANGE_ACTORS"), "", 0, aParent, false,
2756                 this, SLOT(OnArrangeActors()));
2757
2758   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_POINTS"));
2759   createAction( VISU_POINTS, tr("MEN_POINTS"), QIcon(aPixmap),
2760                 tr("MEN_POINTS"), "", 0, aParent, false,
2761                 this, SLOT(OnMakePoints()));
2762
2763   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_WIREFRAME"));
2764   createAction( VISU_WIREFRAME, tr("MEN_WIREFRAME"), QIcon(aPixmap),
2765                 tr("MEN_WIREFRAME"), "", 0, aParent, false,
2766                 this, SLOT(OnMakeWireframe()));
2767
2768   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_SURFACE"));
2769   createAction( VISU_SURFACE, tr("MEN_SURFACE"), QIcon(aPixmap),
2770                 tr("MEN_SURFACE"), "", 0, aParent, false,
2771                 this, SLOT(OnMakeSurface()));
2772
2773   createAction( VISU_INSIDEFRAME, tr("MEN_INSIDEFRAME"), QIcon(),
2774                 tr("MEN_INSIDEFRAME"), "", 0, aParent, false,
2775                 this, SLOT(OnMakeInsideframe()));
2776
2777   createAction( VISU_SURFACEFRAME, tr("MEN_SURFACEFRAME"), QIcon(),
2778                 tr("MEN_SURFACEFRAME"), "", 0, aParent, false,
2779                 this, SLOT(OnMakeSurfaceframe()));
2780
2781   createAction( VISU_SHRINK, tr("MEN_SHRINK"), QIcon(),
2782                 tr("MEN_SHRINK"), "", 0, aParent, false,
2783                 this, SLOT(OnMakeShrink()));
2784
2785   createAction( VISU_UNSHRINK, tr("MEN_UNSHRINK"), QIcon(),
2786                 tr("MEN_UNSHRINK"), "", 0, aParent, false,
2787                 this, SLOT(OnMakeShrink()));
2788
2789   createAction( VISU_FEATURE_EDGES, tr("MEN_FEATURE_EDGES"), QIcon(),
2790                 tr("MEN_FEATURE_EDGES"), "", 0, aParent, false,
2791                 this, SLOT(OnMakeFeatureEdges()));
2792
2793   createAction( VISU_SHADING, tr("MEN_SHADING"), QIcon(),
2794                 tr("MEN_SHADING"), "", 0, aParent, false,
2795                 this, SLOT(OnSetShadingOn()));
2796
2797   createAction( VISU_NOSHADING, tr("MEN_NOSHADING"), QIcon(),
2798                 tr("MEN_NOSHADING"), "", 0, aParent, false,
2799                 this, SLOT(OnSetShadingOff()));
2800
2801   createAction( VISU_CELL_COLOR, tr("MEN_CELL_COLOR"), QIcon(),
2802                 tr("MEN_CELL_COLOR"), "", 0, aParent, false,
2803                 this, SLOT(OnChangeColor()));
2804
2805   createAction( VISU_COLOR, tr("MEN_COLOR"), QIcon(),
2806                 tr("MEN_COLOR"), "", 0, aParent, false,
2807                 this, SLOT(OnChangeColor()));
2808
2809   createAction( VISU_EDGE_COLOR, tr("MEN_EDGE_COLOR"), QIcon(),
2810                 tr("MEN_EDGE_COLOR"), "", 0, aParent, false,
2811                 this, SLOT(OnChangeWireframeColor()));
2812
2813   createAction( VISU_OPACITY, tr("MEN_TRANSPARENCY"), QIcon(),
2814                 tr("MEN_TRANSPARENCY"), "", 0, aParent, false,
2815                 this, SLOT(OnChangeOpacity()));
2816
2817   createAction( VISU_LINE_WIDTH, tr("MEN_LINE_WIDTH"), QIcon(),
2818                 tr("MEN_LINE_WIDTH"), "", 0, aParent, false,
2819                 this, SLOT(OnChangeLines()));
2820
2821   createAction( VISU_POINT_MARKER, tr("MEN_POINT_MARKER"), QIcon(),
2822                 tr("MEN_POINT_MARKER"), "", 0, aParent, false,
2823                 this, SLOT(OnChangePointMarker()));
2824
2825   createAction( VISU_SHRINK_FACTOR, tr("MEN_SHRINK_FACTOR"), QIcon(),
2826                 tr("MEN_SHRINK_FACTOR"), "", 0, aParent, false,
2827                 this, SLOT(OnChangeShrinkFactor()));
2828
2829
2830   createAction( VISU_EDIT_SCALARMAP, tr("MEN_EDIT_PRS"), QIcon(),
2831                 tr("MEN_EDIT_PRS"), "", 0, aParent, false,
2832                 this, SLOT(OnEditScalarMap()));
2833
2834   createAction( VISU_EDIT_DEFORMEDSHAPE, tr("MEN_EDIT_PRS"), QIcon(),
2835                 tr("MEN_EDIT_PRS"), "", 0, aParent, false,
2836                 this, SLOT(OnEditDeformedShape()));
2837
2838   createAction( VISU_EDIT_CUTPLANES, tr("MEN_EDIT_PRS"), QIcon(),
2839                 tr("MEN_EDIT_PRS"), "", 0, aParent, false,
2840                 this, SLOT(OnEditCutPlanes()));
2841
2842   createAction( VISU_EDIT_CUTLINES, tr("MEN_EDIT_PRS"), QIcon(),
2843                 tr("MEN_EDIT_PRS"), "", 0, aParent, false,
2844                 this, SLOT(OnEditCutLines()));
2845
2846   createAction( VISU_EDIT_CUTSEGMENT, tr("MEN_EDIT_PRS"), QIcon(),
2847                 tr("MEN_EDIT_PRS"), "", 0, aParent, false,
2848                 this, SLOT(OnEditCutSegment()));
2849
2850   createAction( VISU_EDIT_ISOSURFACES, tr("MEN_EDIT_PRS"), QIcon(),
2851                 tr("MEN_EDIT_PRS"), "", 0, aParent, false,
2852                 this, SLOT(OnEditIsoSurfaces()));
2853
2854   createAction( VISU_EDIT_VECTORS, tr("MEN_EDIT_PRS"), QIcon(),
2855                 tr("MEN_EDIT_PRS"), "", 0, aParent, false,
2856                 this, SLOT(OnEditVectors()));
2857
2858   createAction( VISU_EDIT_STREAMLINES, tr("MEN_EDIT_PRS"), QIcon(),
2859                 tr("MEN_EDIT_PRS"), "", 0, aParent, false,
2860                 this, SLOT(OnEditStreamLines()));
2861
2862   createAction( VISU_EDIT_PLOT3D, tr("MEN_EDIT_PRS"), QIcon(),
2863                 tr("MEN_EDIT_PRS"), "", 0, aParent, false,
2864                 this, SLOT(OnEditPlot3D()));
2865
2866   createAction( VISU_EDIT_DEFORMEDSHAPEANDSCALARMAP, tr("MEN_EDIT_PRS"), QIcon(),
2867                 tr("MEN_EDIT_PRS"), "", 0, aParent, false,
2868                 this, SLOT(OnEditDeformedShapeAndScalarMap()));
2869
2870   createAction( VISU_CREATE_TABLE, tr("MEN_CREATE_TABLE"), QIcon(),
2871                 tr("MEN_CREATE_TABLE"), "", 0, aParent, false,
2872                 this, SLOT(OnCreateTable()));
2873
2874   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_SWEEP_PANEL"));
2875   createAction( VISU_SWEEP, tr("MEN_SWEEP"), QIcon(aPixmap),
2876                 tr("MEN_SWEEP"), "", 0, aParent, false,
2877                 this, SLOT(OnSweep()));
2878
2879   createAction( VISU_CLIPPING, tr("MEN_CLIPPING"), QIcon(),
2880                 tr("MEN_CLIPPING"), "", 0, aParent, false,
2881                 this, SLOT(OnClippingPlanes()));
2882
2883   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_TIMEANIMATION"));
2884   createAction( VISU_PARALLELANIMATION, tr("MEN_PARALLEL_ANIMATION"), QIcon(aPixmap),
2885                 tr("MEN_PARALLEL_ANIMATION"), "", 0, aParent, false,
2886                 this, SLOT(OnParallelTimeAnimation()));
2887
2888   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_TIMEANIMATION"));
2889   createAction( VISU_SUCCCESSIVEANIMATION, tr("MEN_SUCCCESSIVE_ANIMATION"), QIcon(aPixmap),
2890                 tr("MEN_SUCCCESSIVE_ANIMATION"), "", 0, aParent, false,
2891                 this, SLOT(OnSucccessiveTimeAnimation()));
2892
2893   createAction( VISU_POINT_EVOLUTION, tr("MEN_POINT_EVOLUTION"), QIcon(),
2894                 tr("MEN_POINT_EVOLUTION"), "", 0, aParent, false,
2895                 this, SLOT(OnPointEvolution()));
2896
2897   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_ERASE_ALL"));
2898   createAction( VISU_ERASE_ALL, tr("MEN_ERASE_ALL"), QIcon(aPixmap),
2899                 tr("MEN_ERASE_ALL"), "", 0, aParent, false,
2900                 this, SLOT(OnEraseAll()));
2901
2902   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_SELECTION_PANEL"));
2903   createAction( VISU_SELECTION_PANEL, tr("MEN_SELECTION_PANEL"), QIcon(aPixmap),
2904                 tr("MEN_SELECTION_PANEL"), "", 0, aParent, false,
2905                 this, SLOT(OnToggleSelectionPanel()));
2906
2907   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_ACTOR_SELECTION"));
2908   createAction( VISU_ACTOR_SELECTION, tr("MEN_ACTOR_SELECTION"), QIcon(aPixmap),
2909                 tr("MEN_ACTOR_SELECTION"), "", 0, aParent, true,
2910                 this, SLOT(OnSwitchSelectionMode()));
2911
2912   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_CELL_SELECTION"));
2913   createAction( VISU_CELL_SELECTION, tr("MEN_CELL_SELECTION"), QIcon(aPixmap),
2914                 tr("MEN_CELL_SELECTION"), "", 0, aParent, true,
2915                 this, SLOT(OnSwitchSelectionMode()));
2916
2917   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_POINT_SELECTION"));
2918   createAction( VISU_POINT_SELECTION, tr("MEN_POINT_SELECTION"), QIcon(aPixmap),
2919                 tr("MEN_POINT_SELECTION"), "", 0, aParent, true,
2920                 this, SLOT(OnSwitchSelectionMode()));
2921
2922   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_GAUSS_POINT_SELECTION"));
2923   createAction( VISU_GAUSS_POINT_SELECTION, tr("MEN_GAUSS_POINT_SELECTION"), QIcon(aPixmap),
2924                 tr("MEN_GAUSS_POINT_SELECTION"), "", 0, aParent, true,
2925                 this, SLOT(OnSwitchSelectionMode()));
2926
2927   // Definition of the actions for the "Navigation" tool bar
2928   registerAction( VISU_SLIDER_PANEL, mySlider->toggleViewAction() );
2929   registerAction( VISU_SWEEP_PANEL, mySweep->toggleViewAction() );
2930
2931   createAction( VISU_SHOW_ANIMATION, tr("MEN_SHOW_ANIMATION"), QIcon(),
2932                 tr("MEN_SHOW_ANIMATION"), "", 0, aParent, false,
2933                 this, SLOT(OnShowAnimation()));
2934
2935   createAction( VISU_SHOW_EVOLUTION, tr("MEN_SHOW_EVOLUTION"), QIcon(),
2936                 tr("MEN_SHOW_EVOLUTION"), "", 0, aParent, false,
2937                 this, SLOT(OnShowEvolution()));
2938
2939   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_PLOT_3D"));
2940   createAction( VISU_PLOT3D_FROM_CUTPLANE, tr("MEN_PLOT3D_FROM_CUTPLANE"), QIcon(aPixmap),
2941                 tr("MEN_PLOT3D_FROM_CUTPLANE"), "", 0, aParent, false,
2942                 this, SLOT(OnPlot3dFromCutPlane()));
2943
2944   createAction( VISU_MANAGE_CACHE, tr("MEN_MANAGE_CACHE"), QIcon(),
2945                 tr("MEN_MANAGE_CACHE"), "", 0, aParent, false,
2946                 this, SLOT( OnManageCache() ) );
2947
2948   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_MULTIPR_VIEW_FULL"));
2949   createAction( VISU_MULTIPR_FULL_RES, tr("MEN_MULTIPR_VIEW_FULL_RES"), QIcon(aPixmap),
2950                 tr("MEN_MULTIPR_VIEW_FULL_RES"), "", 0, aParent, false,
2951                 this, SLOT(OnMultiprViewFullRes()));
2952
2953   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_MULTIPR_VIEW_MEDIUM"));
2954   createAction( VISU_MULTIPR_MED_RES, tr("MEN_MULTIPR_VIEW_MEDIUM_RES"), QIcon(aPixmap),
2955                 tr("MEN_MULTIPR_VIEW_MEDIUM_RES"), "", 0, aParent, false,
2956                 this, SLOT(OnMultiprViewMediumRes()));
2957
2958   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_MULTIPR_VIEW_LOW"));
2959   createAction( VISU_MULTIPR_LOW_RES, tr("MEN_MULTIPR_VIEW_LOW_RES"), QIcon(aPixmap),
2960                 tr("MEN_MULTIPR_VIEW_LOW_RES"), "", 0, aParent, false,
2961                 this, SLOT(OnMultiprViewLowRes()));
2962
2963   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_MULTIPR_VIEW_HIDE"));
2964   createAction( VISU_MULTIPR_HIDE, tr("MEN_MULTIPR_VIEW_HIDE"), QIcon(aPixmap),
2965                 tr("MEN_MULTIPR_VIEW_HIDE"), "", 0, aParent, false,
2966                 this, SLOT(OnMultiprViewHide()));
2967
2968   createAction( VISU_FILE_INFO, tr("MEN_FILE_INFO"), QIcon(),
2969                 tr("MEN_FILE_INFO"), "", 0, aParent, false,
2970                 this, SLOT(OnFileInfo()));
2971
2972   createAction( VISU_EXPORT_MED, tr("VISU_MEN_EXPORT_MED"), QIcon(),
2973                 tr("VISU_MEN_EXPORT_MED"), "", 0, aParent, false,
2974                 this, SLOT(OnExportMED()));
2975
2976   createAction( VISU_FILTERSCALARS, tr("MEN_FILTER_SCALARS"), QIcon(),
2977                 tr("MEN_FILTER_SCALARS"), "", 0, aParent, false,
2978                 this, SLOT(OnFilterScalars()));
2979
2980   createAction( VISU_VALUES_LABELING, tr("MEN_VALUES_LABELING"), QIcon(),
2981                 tr("MEN_VALUES_LABELING"), "", 0, aParent, true,
2982                 this, SLOT(OnValuesLabeling()));
2983
2984   createAction( VISU_VALUES_LABELING_PARAMS, tr("VISU_VALUES_LABELING_PARAMS"), QIcon(),
2985                 tr("VISU_VALUES_LABELING_PARAMS"), "", 0, aParent, false,
2986                 this, SLOT(OnValuesLabelingParams()));
2987
2988   createAction(VISU_ARCQUAD_MODE, tr("MEN_VISU_ARCQUAD_MODE"), QIcon(),
2989                tr("MEN_VISU_ARCQUAD_MODE"), "",0, aParent, true,
2990                this, SLOT(OnArcQuadMode()));
2991
2992   createAction(VISU_LINEQUAD_MODE, tr("MEN_VISU_LINEQUAD_MODE"),QIcon(),
2993                tr("MEN_VISU_LINEQUAD_MODE"), "",0, aParent, true,
2994                this, SLOT(OnLineQuadMode()));
2995
2996 }
2997
2998 void
2999 VisuGUI
3000 ::createMenus()
3001 {
3002   // Add actions to menus
3003   int aMenuId;
3004   aMenuId = createMenu( tr( "MEN_DESK_FILE" ), -1 );
3005   createMenu( separator(), aMenuId, -1, 10 );
3006
3007   int anImportId = createMenu( tr( "MEN_IMPORT" ), aMenuId, -1, 10 );
3008   createMenu( VISU_IMPORT_FROM_FILE, anImportId ); // import from file
3009   createMenu( VISU_IMPORT_TABLE, anImportId ); // import table
3010
3011   aMenuId = createMenu( tr( "MEN_VISUALIZATION" ), -1, -1, 30 );
3012   createMenu( VISU_SCALAR_MAP, aMenuId, 10 ); // scalar map
3013   createMenu( VISU_DEFORMED_SHAPE, aMenuId, 10 ); // deformed shape
3014   createMenu( VISU_VECTORS, aMenuId, 10 ); // vectors
3015   createMenu( VISU_ISO_SURFACES, aMenuId, 10 ); // iso surfaces
3016   createMenu( VISU_CUT_PLANES, aMenuId, 10 ); // cut planes
3017   createMenu( VISU_CUT_LINES, aMenuId, 10 ); // cut lines
3018   createMenu( VISU_CUT_SEGMENT, aMenuId, 10 ); // cut segment
3019   createMenu( VISU_STREAM_LINES, aMenuId, 10 ); // stream lines
3020   createMenu( VISU_PLOT_3D, aMenuId, 10 ); // Plot3d
3021   createMenu( VISU_DEFORMED_SHAPE_AND_SCALAR_MAP, aMenuId, 10 ); // scalar map on deformed shape
3022
3023   aMenuId = createMenu( tr( "MEN_REPRESENTATION" ), -1, -1, 30 );
3024   int parentId =
3025     createMenu( tr( "MEN_DISPLAY_SELECTION" ), aMenuId, 10 ); // display selection
3026   createMenu( VISU_POINTS, parentId, 10 ); //   points
3027   createMenu( VISU_WIREFRAME, parentId, 10 ); //   wireframe
3028   createMenu( VISU_SURFACE, parentId, 10 ); //   surface
3029   createMenu( VISU_ERASE_ALL, aMenuId, 10 ); // erase all
3030
3031   parentId = createMenu( tr( "MEN_2D_QUADRATIC_MODE" ), aMenuId, 10 ); // 2D quadratic mode
3032   createMenu( VISU_LINEQUAD_MODE, parentId, 10 ); //   lines
3033   createMenu( VISU_ARCQUAD_MODE, parentId, 10 ); //   arcs
3034
3035 }
3036
3037 void
3038 VisuGUI
3039 ::createToolBars()
3040 {
3041   int aToolId = createTool( tr("TOOL_IMPORT") );
3042   createTool( VISU_IMPORT_FROM_FILE, aToolId );
3043
3044   aToolId = createTool(tr("TOOL_VISUALISATION"));
3045   createTool( VISU_SCALAR_MAP, aToolId );
3046   createTool( VISU_DEFORMED_SHAPE, aToolId );
3047   createTool( VISU_VECTORS, aToolId );
3048   createTool( VISU_ISO_SURFACES, aToolId );
3049   createTool( VISU_CUT_PLANES, aToolId );
3050   createTool( VISU_CUT_LINES, aToolId );
3051   createTool( VISU_CUT_SEGMENT, aToolId );
3052   createTool( VISU_STREAM_LINES, aToolId );
3053   createTool( VISU_PLOT_3D, aToolId );
3054   createTool( VISU_DEFORMED_SHAPE_AND_SCALAR_MAP, aToolId );
3055
3056   aToolId = createTool(tr("TOOL_REPRESENTATION"));
3057   createTool( VISU_POINTS, aToolId );
3058   createTool( VISU_WIREFRAME, aToolId );
3059   createTool( VISU_SURFACE, aToolId );
3060   createTool( VISU_ERASE_ALL, aToolId );
3061
3062   aToolId = createTool(tr("TOOL_SELECTION"));
3063   createTool( VISU_SELECTION_PANEL, aToolId );
3064   createTool( separator(), aToolId );
3065   createTool( VISU_ACTOR_SELECTION, aToolId );
3066   createTool( VISU_CELL_SELECTION, aToolId );
3067   createTool( VISU_POINT_SELECTION, aToolId );
3068   createTool( VISU_GAUSS_POINT_SELECTION, aToolId );
3069
3070   aToolId = createTool( tr( "TOOL_NAVIGATION" ) );
3071   createTool( VISU_SLIDER_PANEL, aToolId );
3072   createTool( separator(), aToolId );
3073   createTool( VISU_SWEEP_PANEL, aToolId );
3074 }
3075
3076 void
3077 VisuGUI
3078 ::createPopupMenus()
3079 {
3080   // Prepare popup menus
3081   QtxPopupMgr* mgr = popupMgr();
3082
3083   // VISU root commands
3084   mgr->insert( action( VISU_IMPORT_FROM_FILE ), -1, -1, -1 ); // import MED file
3085   mgr->insert( action( VISU_IMPORT_TABLE ), -1, -1, -1 ); // import tables from file
3086   mgr->insert( action( VISU_PLOT2D ), -1, -1, -1 ); // create Plot2d View
3087
3088   //mgr->insert( action( VISU_IMPORT_MED ), -1, -1, -1 ); // import MED structure from MED module
3089
3090   // create
3091   mgr->insert( action( VISU_SCALAR_MAP ), -1, -1, -1 ); // scalar bar
3092   mgr->insert( action( VISU_ISO_SURFACES ), -1, -1, -1 ); // iso surface
3093   mgr->insert( action( VISU_CUT_PLANES ), -1, -1, -1 ); // cut planes
3094   mgr->insert( action( VISU_CUT_LINES ), -1, -1, -1 ); // cut lines
3095   mgr->insert( action( VISU_CUT_SEGMENT ), -1, -1, -1 ); // cut segment
3096   mgr->insert( action( VISU_DEFORMED_SHAPE ), -1, -1, -1 ); // deformed shape
3097   mgr->insert( action( VISU_VECTORS ), -1, -1, -1 ); // vectors
3098   mgr->insert( action( VISU_STREAM_LINES ), -1, -1, -1 ); // stream lines
3099   mgr->insert( action( VISU_PLOT_3D ), -1, -1, -1 ); // Plot3d
3100   mgr->insert( action( VISU_DEFORMED_SHAPE_AND_SCALAR_MAP ), -1, -1, -1 ); // scalar map on deformed shape
3101
3102   mgr->insert( action( VISU_CREATE_PRS ), -1, -1, -1 ); // create presentation
3103   mgr->insert( action( VISU_CREATE_MANY_PRS ), -1, -1, -1 ); // create presentations
3104
3105   mgr->insert( action( VISU_CREATE_TABLE ), -1, -1, -1 ); // create table
3106
3107   // edit
3108   mgr->insert( action( VISU_EDIT_SCALARMAP ), -1, -1, -1 );
3109   mgr->insert( action( VISU_EDIT_DEFORMEDSHAPE ), -1, -1, -1 );
3110   mgr->insert( action( VISU_EDIT_CUTPLANES ), -1, -1, -1 );
3111   mgr->insert( action( VISU_EDIT_CUTLINES ), -1, -1, -1 );
3112   mgr->insert( action( VISU_EDIT_CUTSEGMENT ), -1, -1, -1 );
3113   mgr->insert( action( VISU_EDIT_ISOSURFACES ), -1, -1, -1 );
3114   mgr->insert( action( VISU_EDIT_VECTORS ), -1, -1, -1 );
3115   mgr->insert( action( VISU_EDIT_STREAMLINES ), -1, -1, -1 );
3116   mgr->insert( action( VISU_EDIT_PLOT3D ), -1, -1, -1 );
3117   mgr->insert( action( VISU_EDIT_DEFORMEDSHAPEANDSCALARMAP ), -1, -1, -1 );
3118   mgr->insert( action( VISU_EDIT_CONTAINER ), -1, -1, -1 );
3119   mgr->insert( action( VISU_EDIT_POINTMAP3D ), -1, -1, -1 );
3120
3121   mgr->insert( action( VISU_FILTERSCALARS ), -1, -1, -1 );
3122
3123   // rename
3124   mgr->insert( action( VISU_RENAME ), -1, -1, -1 );
3125
3126   // copy
3127   mgr->insert( action( VISU_COPY_PRS ), -1, -1, -1 );
3128
3129   // delete
3130   mgr->insert( action( VISU_CLEAR_CONTAINER ), -1, -1, -1 );
3131
3132   // labeling
3133   mgr->insert( separator(), -1, -1, -1 );
3134   mgr->insert( action( VISU_VALUES_LABELING ), -1, -1, -1 );
3135   mgr->insert( action( VISU_VALUES_LABELING_PARAMS ), -1, -1, -1 );
3136   mgr->insert( separator(), -1, -1, -1 );
3137
3138   // table commands
3139   mgr->insert( action( VISU_SHOW_TABLE ), -1, -1, -1 ); // show table
3140   mgr->insert( action( VISU_CREATE_CURVES ), -1, -1, -1 ); // create curves
3141   mgr->insert( action( VISU_EXPORT_TABLE ), -1, -1, -1 ); // export table
3142
3143   mgr->insert( separator(), -1, -1, -1 );
3144
3145   mgr->insert( action( VISU_ERASE ), -1, -1, -1 ); // erase
3146   mgr->insert( action( VISU_DISPLAY ), -1, -1, -1 ); // display
3147   mgr->insert( action( VISU_DISPLAY_ONLY ), -1, -1, -1 ); // display only
3148
3149   mgr->insert( action( VISU_HIDE_SCALAR_BAR ), -1, -1, -1 ); // hide scalar bar
3150   mgr->insert( action( VISU_SHOW_SCALAR_BAR ), -1, -1, -1 ); // show scalar bar
3151
3152   // "Representation" submenu
3153   int parentId = mgr->insert( tr( "MEN_REPRESENTATION" ), -1, -1 );
3154   mgr->insert( action( VISU_POINTS )      , parentId, -1, -1 ); // points
3155   mgr->insert( action( VISU_WIREFRAME )   , parentId, -1, -1 ); // wireframe
3156   mgr->insert( action( VISU_SURFACE )     , parentId, -1, -1 ); // surface
3157   mgr->insert( action( VISU_INSIDEFRAME ) , parentId, -1, -1 ); // insideframe
3158   mgr->insert( action( VISU_SURFACEFRAME ), parentId, -1, -1 ); // surfaceframe
3159   mgr->insert( action( VISU_FEATURE_EDGES ), parentId, -1, -1 ); // feature edges
3160   mgr->insert( action( VISU_SHRINK )      , parentId, -1, -1 ); // shrink
3161   mgr->insert( action( VISU_UNSHRINK )    , parentId, -1, -1 ); // unshrink
3162   mgr->insert( separator(), parentId, -1, -1 );
3163   mgr->insert( action( VISU_SHADING )     , parentId, -1, -1 ); // shading
3164   mgr->insert( action( VISU_NOSHADING )   , parentId, -1, -1 ); // noshading
3165
3166   //"2D Quadratic" submenu
3167   parentId = mgr->insert( tr( "MEN_2D_QUADRATIC_MODE" ), -1, -1 );
3168   mgr->insert( action( VISU_LINEQUAD_MODE ), parentId, -1, -1 ); // line representation
3169   mgr->insert( action( VISU_ARCQUAD_MODE ), parentId, -1, -1 ); // arc representation
3170
3171   // "Properties" submenu
3172   parentId = mgr->insert( tr( "MEN_PROPERTIES" ), -1, -1 );
3173   mgr->insert( action( VISU_CELL_COLOR ),    parentId, -1, -1 ); // cell color
3174   mgr->insert( action( VISU_EDGE_COLOR ),    parentId, -1, -1 ); // edge color
3175   mgr->insert( action( VISU_COLOR )     ,    parentId, -1, -1 ); // color
3176   mgr->insert( action( VISU_OPACITY )   ,    parentId, -1, -1 ); // opacity
3177   mgr->insert( action( VISU_LINE_WIDTH ),    parentId, -1, -1 ); // line width
3178   mgr->insert( action( VISU_POINT_MARKER ),  parentId, -1, -1 ); // point marker
3179   mgr->insert( action( VISU_SHRINK_FACTOR ), parentId, -1, -1 ); // shrink factor
3180
3181   mgr->insert( separator(), -1, -1, -1 );
3182
3183   // Other presentations management
3184   mgr->insert( action( VISU_TRANSLATE_PRS ), -1, -1, -1 );
3185   mgr->insert( action( VISU_CLIPPING ), -1, -1, -1 );
3186
3187   mgr->insert( action( VISU_MERGE_SCALAR_BARS ), -1, -1, -1 );
3188   mgr->insert( action( VISU_FREE_SCALAR_BARS ), -1, -1, -1 );
3189
3190   mgr->insert( action( VISU_SWEEP ), -1, -1, -1 );
3191   mgr->insert( action( VISU_PARALLELANIMATION ), -1, -1, -1 );
3192   mgr->insert( action( VISU_SUCCCESSIVEANIMATION ), -1, -1, -1 );
3193
3194   mgr->insert( separator(), -1, -1, -1 );
3195
3196   mgr->insert( action( VISU_POINT_EVOLUTION ), -1, -1, -1 );
3197
3198   mgr->insert( separator(), -1, -1, -1 );
3199
3200   // view parameters commands
3201   mgr->insert( action( VISU_SAVE_VIEW_PARAMS ), -1, -1, -1 ); // save view params
3202   mgr->insert( action( VISU_SAVE_VIEW_PARAMS_1 ), -1, -1, -1 ); // save view params
3203   mgr->insert( action( VISU_RESTORE_VIEW_PARAMS ), -1, -1, -1 ); // restore view params
3204   //mgr->insert( action( VISU_DELETE_VIEW_PARAMS ), -1, -1, -1 ); // delete view params
3205
3206   mgr->insert( action( VISU_ARRANGE_ACTORS ), -1, -1, -1 ); // arrange actors
3207
3208   mgr->insert( action( VISU_CURVE_PROPS ), -1, -1, -1 ); // curve properties
3209
3210   mgr->insert( action( VISU_MULTIPR_FULL_RES ), -1, -1, -1 );
3211   mgr->insert( action( VISU_MULTIPR_MED_RES ), -1, -1, -1 );
3212   mgr->insert( action( VISU_MULTIPR_LOW_RES ), -1, -1, -1 );
3213   mgr->insert( action( VISU_MULTIPR_HIDE ), -1, -1, -1 );
3214
3215   mgr->insert( action( VISU_FILE_INFO ), -1, -1, -1 );
3216   mgr->insert( action( VISU_EXPORT_MED ), -1, -1, -1 );
3217
3218   // Rules
3219
3220   QString aPrsAll ("'VISU::TSCALARMAP' 'VISU::TISOSURFACES' 'VISU::TDEFORMEDSHAPE' 'VISU::TCUTPLANES' "
3221                    "'VISU::TCUTLINES' 'VISU::TCUTSEGMENT' 'VISU::TVECTORS' 'VISU::TSTREAMLINES' 'VISU::TPLOT3D' "
3222                    "'VISU::TSCALARMAPONDEFORMEDSHAPE' 'VISU::TDEFORMEDSHAPEANDSCALARMAP' 'VISU::TCOLOREDPRS3DHOLDER'");
3223   QString aSimplePrsAll ("'VISU::TSCALARMAP' 'VISU::TISOSURFACES' 'VISU::TDEFORMEDSHAPE' 'VISU::TCUTPLANES' "
3224                          "'VISU::TCUTLINES' 'VISU::TCUTSEGMENT' 'VISU::TVECTORS' 'VISU::TSTREAMLINES' 'VISU::TPLOT3D' "
3225                          "'VISU::TSCALARMAPONDEFORMEDSHAPE'");
3226
3227   // VISU root commands
3228   QString aRule = "client='ObjectBrowser' and selcount=1 and type='VISU::TVISUGEN'";
3229   mgr->setRule( action( VISU_IMPORT_FROM_FILE ), aRule );
3230   mgr->setRule( action( VISU_IMPORT_TABLE ), aRule );
3231   mgr->setRule( action( VISU_PLOT2D ), aRule );
3232
3233   // timestamp commands
3234   aRule = "client='ObjectBrowser' and selcount=1 and type in {'VISU::TTIMESTAMP' 'VISU::TFIELD'}";
3235   mgr->setRule( action( VISU_SCALAR_MAP ), aRule );
3236   mgr->setRule( action( VISU_ISO_SURFACES ), aRule );
3237   mgr->setRule( action( VISU_CUT_PLANES ), aRule );
3238   mgr->setRule( action( VISU_CUT_LINES ), aRule );
3239   mgr->setRule( action( VISU_CUT_SEGMENT ), aRule );
3240   mgr->setRule( action( VISU_PLOT_3D ), aRule );
3241   aRule += " and nbComponents>1";
3242   mgr->setRule( action( VISU_DEFORMED_SHAPE ), aRule );
3243   mgr->setRule( action( VISU_VECTORS ), aRule );
3244   mgr->setRule( action( VISU_STREAM_LINES ), aRule );
3245   mgr->setRule( action( VISU_DEFORMED_SHAPE_AND_SCALAR_MAP ), aRule );
3246
3247   // display/erase commands
3248   QString andInvisible = " and (((not isVisible) and isActiveView) or (not isActiveView))";
3249   QString aTableOrContHide = "(($type in {'VISU::TTABLE' 'VISU::TPOINTMAP3D' 'VISU::TCONTAINER'}) and isPlot2dViewer and hasCurves and isThereAreVisibleCurves)";
3250   QString aTableOrContShow = "(($type in {'VISU::TTABLE' 'VISU::TPOINTMAP3D' 'VISU::TCONTAINER'}) and isPlot2dViewer and hasCurves and isThereAreHiddenCurves)";
3251   QString orCurveVisible   = "or (type='VISU::TCURVE' and isVisible)";
3252   QString orCurveInvisible = "or (type='VISU::TCURVE'" + andInvisible + ")";
3253   QString aPrsVisible   = "(($type in {'VISU::TMESH' 'VISU::TPOINTMAP3D' 'VISU::TGAUSSPOINTS'" + aPrsAll + "}) and isVisible and (not isPlot2dViewer))";
3254   QString aPrsInvisible = "(($type in {'VISU::TMESH' 'VISU::TPOINTMAP3D' 'VISU::TGAUSSPOINTS'" + aPrsAll + "})" + andInvisible + " and (not isPlot2dViewer))";
3255   QString aComponent = "( selcount=1 and canBeDisplayed and isVisuComponent )";
3256
3257   QString anEraseRule = "( selcount>0 and ({true} in $canBeDisplayed or type in {'VISU::TCONTAINER' 'VISU::TCURVE'}) and (" + aPrsVisible +
3258     " or (   (" + aTableOrContHide + orCurveVisible + "))) ) or " + aComponent;
3259
3260   QString aDisplayRule = "( selcount>0 and ({true} in $canBeDisplayed or type in {'VISU::TCONTAINER' 'VISU::TCURVE'}) and (" + aPrsInvisible +
3261     " or (   (" + aTableOrContShow + orCurveInvisible + "))) ) or " + aComponent;
3262
3263   QString aDOnlyRule = "( selcount>0 and ({true} in $canBeDisplayed or type in {'VISU::TCONTAINER' 'VISU::TCURVE'}) and (($type in {'VISU::TMESH' 'VISU::TPOINTMAP3D' 'VISU::TGAUSSPOINTS'" + aPrsAll + "})"
3264     " or (   ((type='VISU::TTABLE' and nbChildren>0) or (type='VISU::TCONTAINER' and hasCurves) or"
3265     " (type='VISU::TCURVE')))) ) or" + aComponent;
3266
3267   QString aScalarBarHideRule = "( selcount>0 and ($type in {'VISU::TMESH' 'VISU::TPOINTMAP3D' 'VISU::TGAUSSPOINTS'" + aPrsAll + "}) and (isScalarMapAct=1  or isGaussPtsAct=1 ) and " + aPrsVisible + " and isScalarBarVisible )";
3268   QString aScalarBarShowRule = "( selcount>0 and ($type in {'VISU::TMESH' 'VISU::TPOINTMAP3D' 'VISU::TGAUSSPOINTS'" + aPrsAll + "}) and ( isScalarMapAct=1 or isGaussPtsAct=1 ) and " + aPrsVisible + " and (not isScalarBarVisible) )";
3269
3270   mgr->setRule( action( VISU_ERASE ), anEraseRule );
3271   mgr->setRule( action( VISU_DISPLAY ), aDisplayRule );
3272   mgr->setRule( action( VISU_DISPLAY_ONLY ), aDOnlyRule );
3273
3274   mgr->setRule( action( VISU_HIDE_SCALAR_BAR ), aScalarBarHideRule );
3275   mgr->setRule( action( VISU_SHOW_SCALAR_BAR ), aScalarBarShowRule );
3276
3277   aRule = "selcount>0 and $type in {'VISU::TMESH' 'VISU::TPOINTMAP3D' 'VISU::TGAUSSPOINTS'" + aPrsAll + "}";
3278   mgr->setRule( action( VISU_TRANSLATE_PRS ), aRule );
3279
3280   aRule = "selcount>1 and $type in {'VISU::TMESH' " + aPrsAll + "}";
3281   mgr->setRule( action( VISU_MERGE_SCALAR_BARS ), aRule );
3282   mgr->setRule( action( VISU_FREE_SCALAR_BARS ), aRule );
3283
3284   aRule = "selcount=1 and $type in { " + aSimplePrsAll + "}";
3285   mgr->setRule( action( VISU_FILTERSCALARS ), aRule );
3286
3287   // labeling
3288
3289   aRule = "hasActor=1 and selcount=1 and $type in { 'VISU::TGAUSSPOINTS'"  + aPrsAll + " }";
3290   mgr->setRule( action( VISU_VALUES_LABELING ), aRule, QtxPopupMgr::VisibleRule );
3291   mgr->setRule( action( VISU_VALUES_LABELING ), "{true} in $isValuesLabeled", QtxPopupMgr::ToggleRule );
3292   mgr->setRule( action( VISU_VALUES_LABELING_PARAMS ), aRule, QtxPopupMgr::VisibleRule );
3293
3294   //2D quadratic
3295   aRule = "isVisible and hasActor=1 and selcount=1 and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TDEFORMEDSHAPE' 'VISU::TSCALARMAPONDEFORMEDSHAPE' 'VISU::TDEFORMEDSHAPEANDSCALARMAP'}";
3296   mgr->setRule (action(VISU_ARCQUAD_MODE), aRule , QtxPopupMgr::VisibleRule);
3297   mgr->setRule (action(VISU_LINEQUAD_MODE),aRule , QtxPopupMgr::VisibleRule);
3298
3299   mgr->setRule (action(VISU_ARCQUAD_MODE), aRule + " and quadratic2DMode='VISU::ARCS'", QtxPopupMgr::ToggleRule);
3300   mgr->setRule (action(VISU_LINEQUAD_MODE),aRule + " and quadratic2DMode='VISU::LINES'", QtxPopupMgr::ToggleRule);
3301
3302
3303   // view parameters
3304   aRule = "selcount=1 and type='VISU::TVIEW3D' and activeView='VTKViewer'";
3305   mgr->setRule( action( VISU_SAVE_VIEW_PARAMS_1 ), aRule );
3306   mgr->setRule( action( VISU_SAVE_VIEW_PARAMS ), "client='VTKViewer' and selcount=0 and activeView='VTKViewer'" );
3307   mgr->setRule( action( VISU_RESTORE_VIEW_PARAMS ), "selcount=1 and type='VISU::TVIEW3D' and activeView='VTKViewer'" );
3308   //mgr->setRule( action( VISU_DELETE_VIEW_PARAMS ), "selcount=1 and type='VISU::TVIEW3D'", true );
3309
3310   mgr->setRule( action( VISU_ARRANGE_ACTORS ), "$client in {'VTKViewer' 'SVTK'} and selcount=0" );
3311
3312   // 3D presentations commands
3313   QString aPrsType    = " and $type in {'VISU::TMESH' 'VISU::TGAUSSPOINTS' " + aPrsAll + "}";
3314   QString aPrsType2    = " and $type in {'VISU::TMESH' 'VISU::TPOINTMAP3D'" + aPrsAll + "}";
3315   QString anInsideType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TDEFORMEDSHAPE' 'VISU::TSCALARMAPONDEFORMEDSHAPE' 'VISU::TDEFORMEDSHAPEANDSCALARMAP'}";
3316   //QString aSurfFrameType   = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP''VISU::TDEFORMEDSHAPE' 'VISU::TSCALARMAPONDEFORMEDSHAPE' 'VISU::TDEFORMEDSHAPEANDSCALARMAP'}";
3317   QString aSurfFrameType   = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP''VISU::TDEFORMEDSHAPE' 'VISU::TSCALARMAPONDEFORMEDSHAPE' 'VISU::TDEFORMEDSHAPEANDSCALARMAP' 'VISU::TCUTPLANES' 'VISU::TISOSURFACES' 'VISU::TPLOT3D' }";
3318   //QString aPrsType    = " and $type in {'VISU::TMESH' " + aPrsAll + "}";
3319   QString aSurfType   = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TSCALARMAP' 'VISU::TISOSURFACES' 'VISU::TDEFORMEDSHAPE' 'VISU::TCUTPLANES' "
3320                         " 'VISU::TPLOT3D' 'VISU::TSCALARMAPONDEFORMEDSHAPE' 'VISU::TDEFORMEDSHAPEANDSCALARMAP' 'VISU::TPOINTMAP3D'}";
3321   QString aShrinkType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TDEFORMEDSHAPE' 'VISU::TSCALARMAPONDEFORMEDSHAPE' 'VISU::TDEFORMEDSHAPEANDSCALARMAP' 'VISU::TPOINTMAP3D'}";
3322   QString aLineType   = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TSCALARMAP' 'VISU::TISOSURFACES' 'VISU::TDEFORMEDSHAPE' "
3323                         "'VISU::TCUTPLANES' 'VISU::TCUTLINES' 'VISU::TCUTSEGMENT' 'VISU::TSTREAMLINES' 'VISU::TPLOT3D' 'VISU::TSCALARMAPONDEFORMEDSHAPE' 'VISU::TDEFORMEDSHAPEANDSCALARMAP' 'VISU::TPOINTMAP3D'}";
3324
3325   QString aFeatureEdgesType =  " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP''VISU::TDEFORMEDSHAPE' 'VISU::TSCALARMAPONDEFORMEDSHAPE'}";
3326
3327   aRule = "selcount=1";
3328   mgr->setRule( action( VISU_CLIPPING ), aRule + aPrsType );
3329   aPrsType = " and $type in {'VISU::TMESH' " + aPrsAll + "}";
3330
3331   // "Representation" submenu
3332   QString aNotPoints = " and $representation in {'VISU::WIREFRAME' 'VISU::SHADED' 'VISU::INSIDEFRAME' 'VISU::SURFACEFRAME' 'VISU::FEATURE_EDGES'}";
3333   QString aNotWirefr = " and $representation in {'VISU::POINT' 'VISU::SHADED' 'VISU::INSIDEFRAME' 'VISU::SURFACEFRAME' 'VISU::FEATURE_EDGES'}";
3334   QString aNotSurfac = " and $representation in {'VISU::POINT' 'VISU::WIREFRAME' 'VISU::INSIDEFRAME' 'VISU::SURFACEFRAME' 'VISU::FEATURE_EDGES'}";
3335   QString aNotInside = " and $representation in {'VISU::POINT' 'VISU::WIREFRAME' 'VISU::SHADED' 'VISU::SURFACEFRAME' 'VISU::FEATURE_EDGES'}";
3336   QString aNotSurffr = " and $representation in {'VISU::POINT' 'VISU::WIREFRAME' 'VISU::SHADED' 'VISU::INSIDEFRAME' 'VISU::FEATURE_EDGES'}";
3337   QString aNotFeatureEdges =  " and $representation in {'VISU::POINT' 'VISU::WIREFRAME' 'VISU::SHADED' 'VISU::INSIDEFRAME' 'VISU::SURFACEFRAME'}";
3338
3339   mgr->setRule( action( VISU_POINTS )      , aRule + aPrsType + aNotPoints );
3340   mgr->setRule( action( VISU_WIREFRAME )   , aRule + aPrsType2 + aNotWirefr );
3341   mgr->setRule( action( VISU_SURFACE )     , aRule + aSurfType + aNotSurfac );
3342   mgr->setRule( action( VISU_INSIDEFRAME ) , aRule + anInsideType + aNotInside );
3343   mgr->setRule( action( VISU_SURFACEFRAME ), aRule + aSurfFrameType + aNotSurffr );
3344   mgr->setRule( action( VISU_FEATURE_EDGES ), aRule + aFeatureEdgesType + aNotFeatureEdges );
3345
3346   mgr->setRule( action( VISU_SHRINK )  , aRule + aShrinkType + " and isShrunk=0" );
3347   mgr->setRule( action( VISU_UNSHRINK ), aRule + aShrinkType + " and isShrunk=1" );
3348
3349   mgr->setRule( action( VISU_SHADING )  , aRule + " and isScalarMapAct=1 and isShading=0" );
3350   mgr->setRule( action( VISU_NOSHADING ), aRule + " and isScalarMapAct=1 and isShading=1" );
3351
3352   // "Properties" submenu
3353   mgr->setRule( action( VISU_CELL_COLOR ), aRule + " and type='VISU::TMESH' and representation='VISU::SURFACEFRAME'" );
3354   mgr->setRule( action( VISU_EDGE_COLOR ), aRule + aSurfFrameType + " and representation='VISU::SURFACEFRAME'" );
3355   mgr->setRule( action( VISU_COLOR ), aRule + " and ((type='VISU::TMESH'"
3356                " and $representation in {'VISU::POINT' 'VISU::WIREFRAME' 'VISU::SHADED' 'VISU::INSIDEFRAME'}) "
3357                "or (type='VISU::TDEFORMEDSHAPE' and hasActor=1))" );
3358   mgr->setRule( action( VISU_OPACITY ), aRule + " and hasActor=1" );
3359   mgr->setRule( action( VISU_LINE_WIDTH ), aRule + aLineType + " and hasActor=1" );
3360   mgr->setRule( action( VISU_POINT_MARKER ), aRule + aLineType + " and hasActor=1 and representation='VISU::POINT'" );
3361   mgr->setRule( action( VISU_SHRINK_FACTOR ), aRule + aShrinkType + " and isShrunk=1" );
3362
3363   // rename command
3364   QString aCurveAll = "'VISU::TTABLE' 'VISU::TCURVE' 'VISU::TCONTAINER' 'VISU::POINTMAP3D'";
3365
3366   aRule = "selcount=1 and ($type in {'VISU::TVIEW3D' 'VISU::TPOINTMAP3D' " + aCurveAll + " " + aPrsAll + "})";
3367   mgr->setRule( action( VISU_RENAME ), aRule );
3368
3369   // copy presentation command
3370   aRule = "selcount=1 and ($type in {" + aPrsAll + "})";
3371   mgr->setRule( action( VISU_COPY_PRS ), aRule );
3372
3373   // Curve commands
3374   aRule = "selcount=1 and type='VISU::TCURVE'";
3375   mgr->setRule( action( VISU_CURVE_PROPS ), aRule );
3376
3377   // Table Commands
3378   aRule = "selcount=1 and ( type='VISU::TPOINTMAP3D' or type='VISU::TTABLE')";
3379   mgr->setRule( action( VISU_SHOW_TABLE ), aRule );
3380   mgr->setRule( action( VISU_CREATE_CURVES ), aRule );
3381   mgr->setRule( action( VISU_EXPORT_TABLE ), aRule );
3382
3383   // curve container commands
3384   aRule = "client='ObjectBrowser' and selcount=1 and type='VISU::TCONTAINER'";
3385   mgr->setRule( action( VISU_EDIT_CONTAINER ), aRule );
3386   mgr->setRule( action( VISU_CLEAR_CONTAINER ), aRule );
3387
3388   mgr->setRule( action( VISU_EDIT_SCALARMAP ),
3389                 "selcount=1 and type='VISU::TSCALARMAP'" );
3390   mgr->setRule( action( VISU_EDIT_DEFORMEDSHAPE ),
3391                 "selcount=1 and type='VISU::TDEFORMEDSHAPE'" );
3392   mgr->setRule( action( VISU_EDIT_DEFORMEDSHAPEANDSCALARMAP ),
3393                 "selcount=1 and $type in {'VISU::TSCALARMAPONDEFORMEDSHAPE' 'VISU::TDEFORMEDSHAPEANDSCALARMAP'}" );
3394   mgr->setRule( action( VISU_EDIT_CUTPLANES ),
3395                 "selcount=1 and type='VISU::TCUTPLANES'" );
3396   mgr->setRule( action( VISU_EDIT_CUTLINES ),
3397                 "selcount=1 and type='VISU::TCUTLINES'" );
3398   mgr->setRule( action( VISU_EDIT_CUTSEGMENT ),
3399                 "selcount=1 and type='VISU::TCUTSEGMENT'" );
3400   mgr->setRule( action( VISU_EDIT_ISOSURFACES ),
3401                 "selcount=1 and type='VISU::TISOSURFACES'" );
3402   mgr->setRule( action( VISU_EDIT_VECTORS ),
3403                 "selcount=1 and type='VISU::TVECTORS'" );
3404   mgr->setRule( action( VISU_EDIT_STREAMLINES ),
3405                 "selcount=1 and type='VISU::TSTREAMLINES'" );
3406   mgr->setRule( action( VISU_EDIT_PLOT3D ),
3407                 "selcount=1 and type='VISU::TPLOT3D'" );
3408   mgr->setRule( action( VISU_EDIT_POINTMAP3D ),
3409                 "selcount=1 and type='VISU::TPOINTMAP3D'" );
3410
3411   aRule = "selcount=1 and $type in {'VISU::TCUTLINES' 'VISU::TCUTSEGMENT'} and nbNamedChildren=0";
3412   mgr->setRule( action( VISU_CREATE_TABLE ), aRule );
3413
3414   aRule = "selcount=1 and ($type in {" + aSimplePrsAll + "}) and isFieldPrs=0";
3415   mgr->setRule( action( VISU_SWEEP ), aRule );
3416
3417   aRule = "client='ObjectBrowser' and selcount>0";
3418   aRule += " and $type in {'VISU::TFIELD'}";
3419   aRule += " and nbTimeStamps>1";
3420   aRule += " and activeView in {'VTKViewer' 'SVTK'}";
3421   mgr->setRule( action( VISU_PARALLELANIMATION ), aRule );
3422
3423   aRule = "client='ObjectBrowser'";
3424   aRule += " and (selcount=1 and nbTimeStamps>1 or selcount>1 and nbTimeStamps>0)";
3425   aRule += " and $type in {'VISU::TFIELD'}";
3426   aRule += " and activeView in {'VTKViewer' 'SVTK'}";
3427   mgr->setRule( action( VISU_SUCCCESSIVEANIMATION ), aRule );
3428
3429   aRule = "client='ObjectBrowser' and selcount>0";
3430   aRule += " and $type in {'VISU::TFIELD'}";
3431   aRule += " and medEntity='NODE_ENTITY'";
3432   aRule += " and nbTimeStamps>1";
3433   mgr->setRule( action( VISU_POINT_EVOLUTION ), aRule );
3434
3435   aRule = "client='ObjectBrowser' and $type in {'VISU::TENTITY' 'VISU::TFAMILY' 'VISU::TGROUP'}";
3436   mgr->setRule( action( VISU_CREATE_PRS ), aRule + " and selcount=1" );
3437   mgr->setRule( action( VISU_CREATE_MANY_PRS ), aRule + " and selcount>1" );
3438   mgr->setRule( action( VISU_EDIT_PLOT3D ),
3439                 "selcount=1 and type='VISU::TPLOT3D'" );
3440
3441   //aRule = "client='ObjectBrowser' and type='MEDFIELD'";
3442   //mgr->setRule( action( VISU_IMPORT_MED ), aRule, true );
3443
3444   aRule = "client='ObjectBrowser' and selcount>=1 and $type in {'VISU::TPART'} and ";
3445   {
3446     QString aCustomRule = aRule + "fullResolution=1 and resolutionState!='F'";
3447     mgr->setRule( action( VISU_MULTIPR_FULL_RES ), aCustomRule );
3448   }
3449   {
3450     QString aCustomRule = aRule + "mediumResolution=1 and resolutionState!='M'";
3451     mgr->setRule( action( VISU_MULTIPR_MED_RES ), aCustomRule );
3452   }
3453   {
3454     QString aCustomRule = aRule + "lowResolution=1 and resolutionState!='L'";
3455     mgr->setRule( action( VISU_MULTIPR_LOW_RES ), aCustomRule );
3456   }
3457   {
3458     QString aCustomRule = aRule + "resolutionState!='H'";
3459     mgr->setRule( action( VISU_MULTIPR_HIDE), aCustomRule );
3460   }
3461
3462   mgr->setRule( action( VISU_FILE_INFO ), "selcount=1 and type in {'VISU::TRESULT'}" );
3463   mgr->setRule( action( VISU_EXPORT_MED ), "selcount=1 and type in {'VISU::TRESULT'}" );
3464 }
3465
3466 void VisuGUI::createPanels()
3467 {
3468   myPanels[SelectionPanelId]      = new VisuGUI_SelectionPanel( this );
3469   myPanels[FeatureEdgesPanelId]   = new VisuGUI_FeatureEdgesPanel( this );
3470   myPanels[ClippingPlanesPanelId] = new VisuGUI_ClippingPanel( this );
3471
3472   VisuGUI_Panel* aPanel;
3473   foreach( aPanel, myPanels ) {
3474     getApp()->desktop()->addDockWidget( Qt::RightDockWidgetArea, aPanel );
3475     aPanel->setVisible( false );
3476   }
3477 }
3478
3479 //***************************************************************************
3480 void VisuGUI::contextMenuPopup( const QString& theClient, QMenu* theMenu, QString& theTitle )
3481 {
3482   SalomeApp_Module::contextMenuPopup(theClient, theMenu, theTitle);
3483
3484   //TODO: object Browser DONE
3485   SUIT_DataBrowser* ob = getApp()->objectBrowser();
3486   bool isOBClient = (ob && theClient == ob->popupClientType());
3487
3488   LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
3489   SALOME_ListIO aListIO;
3490   aSelectionMgr->selectedObjects(aListIO);
3491
3492   if (aListIO.Extent() < 1) return;
3493
3494   _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
3495
3496   // Check if "Merge Scalar Range" can be applied
3497   int nbPrs = 0;
3498   SALOME_ListIteratorOfListIO It (aListIO);
3499   for (; It.More(); It.Next()) {
3500     Handle(SALOME_InteractiveObject)& anIO = It.Value();
3501
3502     if (!anIO.IsNull() && anIO->hasEntry()) {
3503       _PTR(SObject) aSObject = aCStudy->FindObjectID(anIO->getEntry());
3504       if ( !aSObject )
3505         continue;
3506
3507       if ( !isOBClient ) {
3508         QString aName = QString( aSObject->GetName().c_str() );
3509         while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of popup
3510           aName.remove( (aName.length() - 1), 1 );
3511         theTitle = aName;
3512       }
3513
3514       CORBA::Object_var aCORBAObject = VISU::ClientSObjectToObject(aSObject);
3515       if (CORBA::is_nil(aCORBAObject)) {
3516         VISU::VISUType aType = VISU::Storable::SObject2Type( aSObject );
3517         if (aType == VISU::TTIMESTAMP) {
3518           _PTR(ChildIterator) anIter = aCStudy->NewChildIterator(aSObject);
3519           _PTR(SObject) aPrs;
3520           for (; anIter->More(); anIter->Next()) {
3521             aPrs = anIter->Value();
3522             if (!aPrs)
3523               continue;
3524             std::vector<VISU::Prs3d_i*> aSubList = GetPrs3dList(this, aPrs);
3525             nbPrs += aSubList.size();
3526           }
3527         }
3528       }
3529     }
3530   }
3531   if (nbPrs > 1) {
3532     theMenu->addSeparator();
3533     theMenu->addAction( action( VISU_MERGE_SCALAR_BARS ) );
3534     theMenu->addAction( action( VISU_FREE_SCALAR_BARS  ) );
3535   }
3536
3537   // Check if some curves selected (for bug PAL10611)
3538   bool isCurves = false;
3539   bool isOneCutPlane = false;
3540   SALOME_ListIteratorOfListIO It1 (aListIO);
3541   for (; It1.More() && !isCurves; It1.Next()) {
3542     Handle(SALOME_InteractiveObject)& anIO = It1.Value();
3543     if (!anIO.IsNull() && anIO->hasEntry()) {
3544       _PTR(SObject) aSObject = aCStudy->FindObjectID(anIO->getEntry());
3545       if ( !aSObject )
3546         continue;
3547       VISU::VISUType aType = VISU::Storable::SObject2Type( aSObject );
3548       if (aType == VISU::TCURVE) {
3549         isCurves = true;
3550       }  else {
3551         VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry(GetAppStudy(this), anIO->getEntry());
3552         if(VISU::Prs3d_i* aPrsObject = VISU::GetPrs3dFromBase(anObjectInfo.myBase)){
3553           if (aPrsObject->GetType() == VISU::TCUTPLANES) {
3554             if (VISU::CutPlanes_i* aCutPrs = dynamic_cast<VISU::CutPlanes_i*>(aPrsObject))
3555               isOneCutPlane = aCutPrs->GetNbPlanes() == 1;
3556           }
3557         }
3558       }
3559     }
3560   }
3561
3562   if (isOneCutPlane)
3563     theMenu->addAction( action( VISU_PLOT3D_FROM_CUTPLANE ) );
3564
3565   VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(this);
3566   if(aSelectionInfo.empty())
3567     return;
3568
3569   VISU::TSelectionItem aSelectionItem = aSelectionInfo.front();
3570   Handle(SALOME_InteractiveObject) anIO = aSelectionItem.myIO;
3571   _PTR(SObject) aSObject = aSelectionItem.myObjectInfo.mySObject;
3572   Storable::TRestoringMap aMap = Storable::GetStorableMap(aSObject);
3573   CORBA::Object_var anObject = VISU::ClientSObjectToObject(aSObject);
3574
3575   if(VISU::Base_i* aBase = aSelectionItem.myObjectInfo.myBase){
3576     if(aBase->GetType() == VISU::TCOLOREDPRS3DCACHE)
3577       theMenu->addAction( action( VISU_MANAGE_CACHE ) );
3578   }
3579
3580   theMenu->addSeparator();
3581
3582   // Check if some (nb > 0) removable objects selected
3583   if (isOBClient && IsRemovableSelected(this)) {
3584     theMenu->addAction( action( VISU_DELETE_OBJS ) );
3585   }
3586   if (isCurves) {
3587     theMenu->removeAction( action( myDisplay ) );
3588     theMenu->removeAction( action( myErase ) );
3589     theMenu->removeAction( action( myDisplayOnly ) );
3590     theMenu->removeAction( action( myEraseAll ) );
3591   }
3592
3593   // Check single selection
3594   if (aListIO.Extent() != 1)
3595     return;
3596
3597   // Check if the object's data is loaded
3598   _PTR(SComponent) aSComp = aSObject->GetFatherComponent();
3599   std::string aCompIOR;
3600   if (!aSComp->ComponentIOR(aCompIOR)) { // not loaded
3601     //std::string aCompDataType = aSComp->ComponentDataType();
3602     theMenu->addAction( action( VISU_LOAD_COMPONENT_DATA ) ); // "Load Component Data"
3603   }
3604
3605   VISU::VISUType aType = VISU::Storable::RestoringMap2Type( aMap );
3606   if (aType == VISU::TANIMATION) {
3607     theMenu->addAction( action( VISU_SHOW_ANIMATION ) );
3608   } else if (aType == VISU::TEVOLUTION) {
3609     theMenu->addAction( action( VISU_SHOW_EVOLUTION ) );
3610   } else if (isOBClient) {
3611     if (IsSObjectTable(aSObject)) {
3612       /*      action( VISU_SHOW_TABLE )->addTo(theMenu);
3613       theMenu->addAction( action( VISU_CREATE_CURVES ) );
3614       theMenu->addAction( action( VISU_EXPORT_TABLE ) );
3615       theMenu->addSeparator();
3616       action( VISU_DELETE_OBJS )->addTo(theMenu);*/// dmv - code was moved up
3617     } else {
3618       if (!CORBA::is_nil(anObject)) {
3619         SALOME_MED::MED_var aMED = SALOME_MED::MED::_narrow(anObject);
3620         if (!CORBA::is_nil(aMED.in())) {
3621           theMenu->addAction( action( VISU_IMPORT_MED_STRUCTURE ) ); // "Import Structure"
3622         }
3623
3624         SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow(anObject);
3625         if (!CORBA::is_nil(aField)) {
3626           theMenu->addAction( action( VISU_IMPORT_MED_TIMESTAMP ) ); // "Import TimeStamp"
3627         }
3628       } else {
3629         _PTR(SObject) aSFather1 = aSObject->GetFather();
3630         if (aSFather1) {
3631           std::string aValue = aSFather1->GetName();
3632           if (strcmp(aValue.c_str(), "MEDFIELD") == 0) {
3633             theMenu->addAction( action( VISU_IMPORT_MED_FIELD ) ); // "Import Field"
3634           }
3635         }
3636       }
3637     }
3638   }
3639 }
3640
3641
3642 //***************************************************************************
3643 void
3644 VisuGUI
3645 ::windows( QMap<int, int>& theMap ) const
3646 {
3647   theMap.clear();
3648   theMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
3649   theMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
3650 }
3651
3652
3653 void
3654 VisuGUI
3655 ::viewManagers( QStringList& theList ) const
3656 {
3657   theList.clear();
3658   // append SVTK viewer only if there is no opened VVTK
3659 //   SUIT_ViewManager* vm = getApp()->getViewManager( VVTK_Viewer::Type(), false );
3660 //   if( vm && vm->getViewsCount()>0 )
3661 //     theList.append( VVTK_Viewer::Type() );
3662 //   else
3663     theList.append( SVTK_Viewer::Type() );
3664 }
3665
3666
3667 QString
3668 VisuGUI
3669 ::engineIOR() const
3670 {
3671   CORBA::String_var anIOR = GetVisuGen(this)->GetID();
3672   return QString(anIOR.in());
3673 }
3674
3675
3676 bool
3677 VisuGUI
3678 ::activateModule( SUIT_Study* theStudy )
3679 {
3680   bool aResult = SalomeApp_Module::activateModule( theStudy );
3681
3682   studyActivated();
3683   setMenuShown( true );
3684   setToolShown( true );
3685
3686   // import Python module that manages VISU plugins (need to be here because SalomePyQt API uses active module)
3687   PyGILState_STATE gstate = PyGILState_Ensure();
3688   PyObject* pluginsmanager=PyImport_ImportModule((char*)"salome_pluginsmanager");
3689   if(pluginsmanager==NULL)
3690     PyErr_Print();
3691   else
3692     {
3693       PyObject* result=PyObject_CallMethod( pluginsmanager, (char*)"initialize", (char*)"isss",1,"visu",tr("MEN_VISUALIZATION").toStdString().c_str(),tr("VISU_PLUGINS_OTHER").toStdString().c_str());
3694       if(result==NULL)
3695         PyErr_Print();
3696       Py_XDECREF(result);
3697     }
3698   PyGILState_Release(gstate);
3699   // end of GEOM plugins loading
3700
3701   // Reset actions accelerator keys
3702   QList<QKeySequence> shortcuts;
3703   shortcuts.append( QKeySequence(Qt::CTRL + Qt::Key_I) );
3704   action(VISU_IMPORT_FROM_FILE)->setShortcuts(shortcuts);
3705
3706   action(VISU_DELETE_OBJS)->setEnabled(true); // Delete: Key_Delete
3707   action(VISU_RENAME     )->setEnabled(true); // Rename: Key_F2
3708
3709   ((VisuGUI_ClippingPanel*) myPanels[ClippingPlanesPanelId])->init();
3710   GetVisuGen( this )->GetClippingPlaneMgr().SetStudy(GetCStudy(dynamic_cast<SalomeApp_Study*>(theStudy)),true);
3711   emit moduleActivated();
3712
3713   return aResult;
3714 }
3715
3716
3717 bool
3718 VisuGUI
3719 ::deactivateModule( SUIT_Study* theStudy )
3720 {
3721   setMenuShown( false );
3722   setToolShown( false );
3723
3724   // Unset actions accelerator keys
3725   action(VISU_IMPORT_FROM_FILE)->setShortcuts(QKeySequence::UnknownKey); // Import: CTRL + Key_I
3726
3727   action(VISU_DELETE_OBJS)->setEnabled(false); // Delete: Key_Delete
3728   action(VISU_RENAME     )->setEnabled(false); // Rename: Key_F2
3729
3730   bool aResult = SalomeApp_Module::deactivateModule( theStudy );
3731
3732   emit moduleDeactivated();
3733
3734   return aResult;
3735 }
3736
3737 LightApp_Selection*
3738 VisuGUI
3739 ::createSelection() const
3740 {
3741   return new VisuGUI_Selection( (SalomeApp_Module*)this );
3742 }
3743
3744 void
3745 VisuGUI
3746 ::processPresentationCreated( VISU::Prs3d_i* thePrs )
3747 {
3748   if( thePrs )
3749   {
3750     QString anEntry = thePrs->GetEntry().c_str();
3751     if( anEntry.isEmpty() )
3752       if( VISU::ColoredPrs3d_i* aColoredPrs = dynamic_cast<VISU::ColoredPrs3d_i*>( thePrs ) )
3753         anEntry = aColoredPrs->GetHolderEntry().c_str();
3754
3755     QStringList anEntryList( anEntry );
3756     if( getApp() )
3757       getApp()->browseObjects( anEntryList );
3758
3759     emit presentationCreated( thePrs );
3760   }
3761 }
3762
3763 //******************************************************************
3764 void VisuGUI::studyActivated()
3765 {
3766   GetVisuGen(this)->SetCurrentStudy(GetDSStudy(GetCStudy(GetAppStudy(this))));
3767
3768 }
3769
3770 /*
3771 extern "C" {
3772   CAM_Module*
3773   createModule()
3774   {
3775     return new VisuGUI();
3776   }
3777 }
3778 */
3779
3780 void VisuGUI::createPreferences()
3781 {
3782   SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
3783
3784   // TAB: General
3785   int genTab   = addPreference( tr( "VISU_PREF_GENERAL" ) );
3786   // Quantities with individual precision settings
3787   int precGroup = addPreference( tr( "VISU_PREF_GROUP_PRECISION" ), genTab );
3788   setPreferenceProperty( precGroup, "columns", 2 );
3789
3790   // Default precision used by some input fieklds and data visualization code
3791   // Moved here from "Representation" tab to have all precisions in the same place
3792   int point_precision = addPreference( tr( "VISU_PREF_visual_data_precision" ), precGroup,
3793                                        LightApp_Preferences::IntSpin, "VISU", "visual_data_precision" );
3794   setPreferenceProperty( point_precision, "min", -16 );
3795   setPreferenceProperty( point_precision, "max", 16 );
3796   setPreferenceProperty( point_precision, "step", 1 );
3797   
3798   const int nbQuantities = 5;
3799   int precs[nbQuantities], ii = 0;
3800   precs[ii++] = addPreference( tr( "VISU_PREF_length_precision" ), precGroup,
3801                             LightApp_Preferences::IntSpin, "VISU", "length_precision" );  
3802   precs[ii++] = addPreference( tr( "VISU_PREF_angle_precision" ), precGroup,
3803                             LightApp_Preferences::IntSpin, "VISU", "angle_precision" );
3804   precs[ii++] = addPreference( tr( "VISU_PREF_len_tol_precision" ), precGroup,
3805                             LightApp_Preferences::IntSpin, "VISU", "len_tol_precision" );
3806   precs[ii++] = addPreference( tr( "VISU_PREF_parametric_precision" ), precGroup,
3807                             LightApp_Preferences::IntSpin, "VISU", "parametric_precision" );
3808   precs[ii  ] = addPreference( tr( "VISU_PREF_memory_precision" ), precGroup,
3809                             LightApp_Preferences::IntSpin, "VISU", "memory_precision" );
3810   
3811   // Set property for precision value for spinboxes
3812   for ( ii = 0; ii < nbQuantities; ii++ ){
3813     setPreferenceProperty( precs[ii], "min", ii == 2 ? 0 : -14 );
3814     setPreferenceProperty( precs[ii], "max", ii == 2 ? 3 : 14 );
3815     setPreferenceProperty( precs[ii], "precision", 2 );
3816   }   
3817
3818
3819   // TAB: "MED import"
3820   int importTab = addPreference( tr( "MED import" ) );
3821   //printf( "++++++++++++++++++ Tab index %d\n", importTab );
3822
3823   //int importFrame = addPreference( tr( "MED FRAME" ), importTab );
3824   //printf( "Frame index %d\n", importFrame );
3825
3826   // group: "MED files import"
3827   int importGr = addPreference( tr( "MED files import" ), importTab );
3828   //printf( "Group index %d\n", importGr );
3829   setPreferenceProperty( importGr, "columns", 2 );
3830
3831   addPreference( tr( "Use build progress" ), importGr, LightApp_Preferences::Bool, "VISU", "use_build_progress" );
3832   addPreference( tr( "Full MED loading" ), importGr, LightApp_Preferences::Bool, "VISU", "full_med_loading" );
3833   addPreference( tr( "Build at once" ), importGr, LightApp_Preferences::Bool, "VISU", "build_at_once" );
3834   addPreference( tr( "Build fields" ), importGr, LightApp_Preferences::Bool, "VISU", "build_fields" );
3835   addPreference( tr( "Build min/max" ), importGr, LightApp_Preferences::Bool, "VISU", "build_min_max" );
3836   addPreference( tr( "Build groups" ), importGr, LightApp_Preferences::Bool, "VISU", "build_groups" );
3837   addPreference( tr( "Close dialog at finish" ), importGr, LightApp_Preferences::Bool, "VISU", "close_at_finish" );
3838
3839   // TAB: "Scalar Bar"
3840   int sbarTab = addPreference( tr( "VISU_SCALAR_BAR" ) );
3841
3842   int rangeGr = addPreference( tr( "VISU_SCALAR_RANGE" ), sbarTab );
3843   setPreferenceProperty( rangeGr, "columns", 2 );
3844
3845   int mode = addPreference( tr( "VISU_SCALAR_MODE" ), rangeGr, LightApp_Preferences::Selector, "VISU", "scalar_bar_mode" );
3846   QStringList modes;
3847   modes.append( tr( "VISU_MODULUS" ) );
3848   modes.append( tr( "VISU_COMPONENT" ) + tr("1") );
3849   modes.append( tr( "VISU_COMPONENT" ) + tr("2") );
3850   modes.append( tr( "VISU_COMPONENT" ) + tr("3") );
3851   QList<QVariant> indices;
3852   indices.append( 0 );
3853   indices.append( 1 );
3854   indices.append( 2 );
3855   indices.append( 3 );
3856   setPreferenceProperty( mode, "strings", modes );
3857   setPreferenceProperty( mode, "indexes", indices );
3858
3859   addPreference( tr( "VISU_LOGARITHMIC_SCALING" ), rangeGr, LightApp_Preferences::Bool, "VISU", "scalar_bar_logarithmic" );
3860
3861   int rangetype = addPreference( tr( "VISU_RANGE_TO_USE" ), rangeGr, LightApp_Preferences::Selector, "VISU", "scalar_range_type" );
3862   QStringList types;
3863   types.append( tr( "VISU_FIELD_RANGE" ) );
3864   types.append( tr( "VISU_IMPOSED_RANGE" ) );
3865   indices.clear();
3866   indices.append( 0 );
3867   indices.append( 1 );
3868   setPreferenceProperty( rangetype, "strings", types );
3869   setPreferenceProperty( rangetype, "indexes", indices );
3870
3871   int gaussMetric = addPreference( tr( "VISU_GAUSS_METRIC" ), rangeGr, LightApp_Preferences::Selector, "VISU", "scalar_gauss_metric" );
3872   QStringList metrics;
3873   metrics.append( tr( "VISU_GAUSS_METRIC_AVERAGE" ) );
3874   metrics.append( tr( "VISU_GAUSS_METRIC_MINIMUM" ) );
3875   metrics.append( tr( "VISU_GAUSS_METRIC_MAXIMUM" ) );
3876   indices.clear();
3877   indices.append( 0 );
3878   indices.append( 1 );
3879   indices.append( 2 );
3880   setPreferenceProperty( gaussMetric, "strings", metrics );
3881   setPreferenceProperty( gaussMetric, "indexes", indices );
3882
3883   int imposedGr = addPreference( tr( "VISU_MINMAX_IMPOSED_RANGE" ), sbarTab );
3884   setPreferenceProperty( imposedGr, "columns", 4 );
3885
3886   int min = addPreference( tr( "VISU_MIN" ), imposedGr, LightApp_Preferences::Double, "VISU", "scalar_range_min" );
3887   int max = addPreference( tr( "VISU_MAX" ), imposedGr, LightApp_Preferences::Double, "VISU", "scalar_range_max" );
3888   setPreferenceProperty( min, "decimals", qAbs( aResourceMgr->integerValue( "VISU", "visual_data_precision", 0 ) ) );
3889   setPreferenceProperty( max, "decimals", qAbs( aResourceMgr->integerValue( "VISU", "visual_data_precision", 0 ) ) );
3890
3891   // group: "Font"
3892   int fontGr = addPreference( tr( "VISU_FONT" ), sbarTab );
3893   setPreferenceProperty( fontGr, "columns", 2 );
3894
3895   addVtkFontPref( tr( "VISU_TITLE" ), fontGr, "scalar_bar_title_font", false );
3896   addPreference( tr( "VISU_TITLE" ), fontGr, LightApp_Preferences::Color, "VISU", "scalar_bar_title_color" );
3897
3898   addVtkFontPref( tr( "VISU_LABELS" ), fontGr, "scalar_bar_label_font", false );
3899   addPreference( tr( "VISU_LABELS" ), fontGr, LightApp_Preferences::Color, "VISU", "scalar_bar_label_color" );
3900
3901   // group: "Colors & Labels"
3902   int colorsLabelsGr = addPreference( tr( "VISU_COLORS_AND_LABELS" ), sbarTab );
3903   setPreferenceProperty( colorsLabelsGr, "columns", 4 );
3904
3905   int numcol = addPreference( tr( "VISU_NB_COLORS" ), colorsLabelsGr,
3906                               LightApp_Preferences::IntSpin, "VISU", "scalar_bar_num_colors" );
3907   setPreferenceProperty( numcol, "min", 2 );
3908   setPreferenceProperty( numcol, "max", 256 );
3909
3910   addPreference( tr( "VISU_IS_UNITS" ), colorsLabelsGr,
3911                  LightApp_Preferences::Bool, "VISU", "scalar_bar_display_units" );
3912
3913   int numlab = addPreference( tr( "VISU_NB_LABELS" ), colorsLabelsGr,
3914                               LightApp_Preferences::IntSpin, "VISU", "scalar_bar_num_labels" );
3915   setPreferenceProperty( numlab, "min", 2 );
3916   setPreferenceProperty( numlab, "max", 65 );
3917
3918   int lPrec = addPreference( tr( "PRECISION" ), colorsLabelsGr,
3919     LightApp_Preferences::IntSpin, "VISU", "scalar_bar_label_precision" );
3920
3921   setPreferenceProperty( lPrec, "min", 1 );
3922   setPreferenceProperty( lPrec, "max", 100 );
3923
3924   int frame = addPreference( "", sbarTab, LightApp_Preferences::Frame, "", "" );
3925   //setPreferenceProperty( frame, "orientation", "vertical" );
3926   setPreferenceProperty( frame, "columns", "2" );
3927
3928   // group: "Orientation"
3929   int orientGr = addPreference( tr( "VISU_ORIENTATION" ), frame, LightApp_Preferences::GroupBox );
3930   setPreferenceProperty( orientGr, "columns", 2 );
3931   int orient = addPreference( tr( "VISU_ORIENTATION" ), orientGr,
3932                               LightApp_Preferences::Selector, "VISU", "scalar_bar_orientation" );
3933   QStringList orients;
3934   orients.append( tr( "VISU_VERTICAL" ) );
3935   orients.append( tr( "VISU_HORIZONTAL" ) );
3936   indices.clear();
3937   indices.append( 0 );
3938   indices.append( 1 );
3939   setPreferenceProperty( orient, "strings", orients );
3940   setPreferenceProperty( orient, "indexes", indices );
3941
3942   // group: "Scalar bars default position"
3943   int scalarBarGr = addPreference( tr( "Scalar bars default position" ), frame, LightApp_Preferences::GroupBox );
3944   addPreference( tr( "Arrange Scalar Bars" ), scalarBarGr, LightApp_Preferences::Bool, "VISU", "scalar_bars_default_position" );
3945
3946
3947   // group: "Origin & Size Vertical"
3948   //int psSzFrame = addPreference( "", sbarTab, LightApp_Preferences::Frame, "", "" );
3949   //setPreferenceProperty( psSzFrame, "orientation", "horizontal" );
3950   //setPreferenceProperty( psSzFrame, "columns", "2" );
3951
3952   int posVSizeGr = addPreference( tr( "VISU_ORIGIN_AND_SIZE" ) + " " + tr( "VISU_VERTICAL" ),
3953                                   frame, LightApp_Preferences::GroupBox );
3954   setPreferenceProperty( posVSizeGr, "columns", 2 );
3955   int xv = addPreference( tr( "VISU_X" ), posVSizeGr,
3956                           LightApp_Preferences::DblSpin, "VISU", "scalar_bar_vertical_x" );
3957   int yv = addPreference( tr( "VISU_Y" ), posVSizeGr,
3958                           LightApp_Preferences::DblSpin, "VISU", "scalar_bar_vertical_y" );
3959
3960   int wv = addPreference( tr( "VISU_WIDTH" ), posVSizeGr,
3961                           LightApp_Preferences::DblSpin, "VISU", "scalar_bar_vertical_width" );
3962   int hv = addPreference( tr( "VISU_HEIGHT" ), posVSizeGr,
3963                           LightApp_Preferences::DblSpin, "VISU", "scalar_bar_vertical_height" );
3964
3965   int twv = addPreference( tr( "VISU_TITLE_SIZE" ), posVSizeGr,
3966                           LightApp_Preferences::IntSpin, "VISU", "scalar_bar_vertical_title_size" );
3967
3968   int lwv = addPreference( tr( "VISU_LABEL_SIZE" ), posVSizeGr,
3969                           LightApp_Preferences::IntSpin, "VISU", "scalar_bar_vertical_label_size" );
3970
3971   int bwv = addPreference( tr( "VISU_BAR_WIDTH" ), posVSizeGr,
3972                           LightApp_Preferences::IntSpin, "VISU", "scalar_bar_vertical_bar_width" );
3973   int bhv = addPreference( tr( "VISU_BAR_HEIGHT" ), posVSizeGr,
3974                           LightApp_Preferences::IntSpin, "VISU", "scalar_bar_vertical_bar_height" );
3975
3976   setPreferenceProperty( xv, "step", 0.1 );
3977   setPreferenceProperty( yv, "step", 0.1 );
3978   setPreferenceProperty( wv, "step", 0.1 );
3979   setPreferenceProperty( hv, "step", 0.1 );
3980   setPreferenceProperty( xv, "min", 0.0 );
3981   setPreferenceProperty( yv, "min", 0.0 );
3982   setPreferenceProperty( wv, "min", 0.0 );
3983   setPreferenceProperty( hv, "min", 0.0 );
3984   setPreferenceProperty( twv, "min", 0 );
3985   setPreferenceProperty( twv, "special", "auto" );
3986   setPreferenceProperty( lwv, "min", 0 );
3987   setPreferenceProperty( lwv, "special", "auto" );
3988   setPreferenceProperty( bwv, "min", 0 );
3989   setPreferenceProperty( bwv, "special", "auto" );
3990   setPreferenceProperty( bhv, "min", 0 );
3991   setPreferenceProperty( bhv, "special", "auto" );
3992   setPreferenceProperty( xv, "max", 1.0 );
3993   setPreferenceProperty( yv, "max", 1.0 );
3994   setPreferenceProperty( wv, "max", 1.0 );
3995   setPreferenceProperty( hv, "max", 1.0 );
3996   setPreferenceProperty( twv, "max", 100 );
3997   setPreferenceProperty( lwv, "max", 100 );
3998   setPreferenceProperty( bwv, "max", 100 );
3999   setPreferenceProperty( bhv, "max", 100 );
4000
4001   // group: "Origin & Size Horizontal"
4002   int posHSizeGr = addPreference( tr( "VISU_ORIGIN_AND_SIZE" ) + " " + tr( "VISU_HORIZONTAL" ),
4003                                   frame, LightApp_Preferences::GroupBox );
4004   setPreferenceProperty( posHSizeGr, "columns", 2 );
4005
4006   int xh = addPreference( tr( "VISU_X" ), posHSizeGr,
4007                           LightApp_Preferences::DblSpin, "VISU", "scalar_bar_horizontal_x" );
4008   int yh = addPreference( tr( "VISU_Y" ), posHSizeGr,
4009                           LightApp_Preferences::DblSpin, "VISU", "scalar_bar_horizontal_y" );
4010
4011   int wh = addPreference( tr( "VISU_WIDTH" ), posHSizeGr,
4012                           LightApp_Preferences::DblSpin, "VISU", "scalar_bar_horizontal_width" );
4013   int hh = addPreference( tr( "VISU_HEIGHT" ), posHSizeGr,
4014                           LightApp_Preferences::DblSpin, "VISU", "scalar_bar_horizontal_height" );
4015
4016   int twh = addPreference( tr( "VISU_TITLE_SIZE" ), posHSizeGr,
4017                           LightApp_Preferences::IntSpin, "VISU", "scalar_bar_horizontal_title_size" );
4018
4019   int lwh = addPreference( tr( "VISU_LABEL_SIZE" ), posHSizeGr,
4020                           LightApp_Preferences::IntSpin, "VISU", "scalar_bar_horizontal_label_size" );
4021
4022   int bwh = addPreference( tr( "VISU_BAR_WIDTH" ), posHSizeGr,
4023                           LightApp_Preferences::IntSpin, "VISU", "scalar_bar_horizontal_bar_width" );
4024   int bhh = addPreference( tr( "VISU_BAR_HEIGHT" ), posHSizeGr,
4025                           LightApp_Preferences::IntSpin, "VISU", "scalar_bar_horizontal_bar_height" );
4026
4027   setPreferenceProperty( xh, "step", 0.1 );
4028   setPreferenceProperty( yh, "step", 0.1 );
4029   setPreferenceProperty( wh, "step", 0.1 );
4030   setPreferenceProperty( hh, "step", 0.1 );
4031   setPreferenceProperty( xh, "min", 0.0 );
4032   setPreferenceProperty( yh, "min", 0.0 );
4033   setPreferenceProperty( wh, "min", 0.0 );
4034   setPreferenceProperty( hh, "min", 0.0 );
4035   setPreferenceProperty( twh, "min", 0 );
4036   setPreferenceProperty( twh, "special", "auto" );
4037   setPreferenceProperty( lwh, "min", 0 );
4038   setPreferenceProperty( lwh, "special", "auto" );
4039   setPreferenceProperty( bwh, "min", 0 );
4040   setPreferenceProperty( bwh, "special", "auto" );
4041   setPreferenceProperty( bhh, "min", 0 );
4042   setPreferenceProperty( bhh, "special", "auto" );
4043   setPreferenceProperty( xh, "max", 1.0 );
4044   setPreferenceProperty( yh, "max", 1.0 );
4045   setPreferenceProperty( wh, "max", 1.0 );
4046   setPreferenceProperty( hh, "max", 1.0 );
4047   setPreferenceProperty( twh, "max", 100 );
4048   setPreferenceProperty( lwh, "max", 100 );
4049   setPreferenceProperty( bwh, "max", 100 );
4050   setPreferenceProperty( bhh, "max", 100 );
4051
4052   // TAB: "CutLines"
4053   int cutLineTab = addPreference( tr( "VISU_CUT_LINES_SEGMENT" ) );
4054
4055   // group: "CutLines preferences"
4056   int cutLineGr = addPreference( tr( "VISU_CUT_LINES_SEGMENT_PREF" ), cutLineTab );
4057   setPreferenceProperty( cutLineGr, "columns", 1 );
4058   addPreference( tr( "Show preview" ), cutLineGr, LightApp_Preferences::Bool, "VISU", "show_preview" );
4059   addPreference( tr( "Invert all curves" ), cutLineGr, LightApp_Preferences::Bool, "VISU", "invert_all_curves" );
4060   addPreference( tr( "Use absolute length" ), cutLineGr, LightApp_Preferences::Bool, "VISU", "use_absolute_length" );
4061   addPreference( tr( "Generate data table" ), cutLineGr, LightApp_Preferences::Bool, "VISU", "generate_data_table" );
4062   addPreference( tr( "Generate curves" ), cutLineGr, LightApp_Preferences::Bool, "VISU", "generate_curves" );
4063
4064   // TAB: "StreamLines"
4065   int streamLinesTab = addPreference( tr( "VISU_STREAM_LINES" ) );
4066
4067   // group: "StreamLines preferences"
4068   int streamLinesGr = addPreference( tr( "VISU_STREAM_LINES_PREF" ), streamLinesTab );
4069   setPreferenceProperty( cutLineGr, "columns", 1 );
4070   int usedPoints = addPreference( tr( "VISU_STREAM_LINES_USED_POINTS" ), streamLinesGr,
4071                                   LightApp_Preferences::DblSpin, "VISU", "stream_lines_used_points" );
4072   setPreferenceProperty( usedPoints, "min",  0 );
4073   setPreferenceProperty( usedPoints, "max",  1 );
4074   setPreferenceProperty( usedPoints, "step", 0.1 );
4075
4076   // TAB: "Sweep, Animation, 3D Cache"
4077   int animationTab = addPreference( tr( "Sweep, Animation" ) );
4078   {
4079     // group: "3D Cache System prefereces"
4080     {
4081       int cacheGroup = addPreference( tr( "VISU_3DCACHE_PREFERENCES" ), animationTab );
4082       setPreferenceProperty( cacheGroup, "columns", 2 );
4083
4084       int memory_mode = addPreference( tr( "VISU_MEMORY_MODE" ), cacheGroup,
4085                                        LightApp_Preferences::Selector, "VISU", "cache_memory_mode" );
4086
4087       modes.clear();
4088       modes.append( tr( "VISU_MINIMAL" ) );
4089       modes.append( tr( "VISU_LIMITED" ) );
4090       setPreferenceProperty( memory_mode, "strings", modes );
4091
4092       indices.clear();
4093       indices.append( 0 );
4094       indices.append( 1 );
4095       setPreferenceProperty( memory_mode, "indexes", indices );
4096
4097       int memory_limit = addPreference( tr( "VISU_MEMORY_LIMIT" ), cacheGroup,
4098                                         LightApp_Preferences::IntSpin, "VISU", "cache_memory_limit" );
4099       setPreferenceProperty( memory_limit, "min", 1 );
4100       setPreferenceProperty( memory_limit, "max", 5000 );
4101       setPreferenceProperty( memory_limit, "step", 10 );
4102     }
4103
4104     // group: "Animation preferences"
4105     {
4106       int animationGroup = addPreference( tr( "VISU_ANIMATION_PREFERENCES" ), animationTab );
4107       setPreferenceProperty( animationGroup, "columns", 1 );
4108
4109       int speed = addPreference( tr( "Speed" ), animationGroup,
4110                                  LightApp_Preferences::IntSpin, "VISU", "speed" );
4111       addPreference( tr( "Cycled animation" ), animationGroup,
4112                      LightApp_Preferences::Bool, "VISU", "cycled_animation" );
4113       addPreference( tr( "Use proportional timing" ), animationGroup,
4114                      LightApp_Preferences::Bool, "VISU", "use_proportional_timing" );
4115       addPreference( tr( "Clean memory at each frame" ), animationGroup,
4116                      LightApp_Preferences::Bool, "VISU", "clean_memory_at_each_frame" );
4117
4118       setPreferenceProperty( speed, "min", 1 );
4119       setPreferenceProperty( speed, "max", 99 );
4120
4121       int dump_mode = addPreference( tr( "VISU_DUMP_MODE" ), animationGroup,
4122                                      LightApp_Preferences::Selector, "VISU", "dump_mode" );
4123
4124       modes.clear();
4125       modes.append( tr( "VISU_NO_DUMP" ) );
4126       modes.append( tr( "VISU_DUMP_PICTURES" ) );
4127       modes.append( tr( "VISU_DUMP_VIDEO" ) );
4128       setPreferenceProperty( dump_mode, "strings", modes );
4129
4130       indices.clear();
4131       indices.append( 0 );
4132       indices.append( 1 );
4133       indices.append( 2 );
4134       setPreferenceProperty( dump_mode, "indexes", indices );
4135
4136       int time_stamp_frequency = addPreference( tr( "VISU_TIME_STAMP_FREQUENCY" ), animationGroup,
4137                                                 LightApp_Preferences::IntSpin, "VISU", "time_stamp_frequency" );
4138       setPreferenceProperty( time_stamp_frequency, "min", 1 );
4139       setPreferenceProperty( time_stamp_frequency, "max", 100 );
4140     }
4141
4142     // group: "Sweeping preferences"
4143     {
4144       int sweepGroup = addPreference( tr( "VISU_SWEEPING_PREF" ), animationTab );
4145       setPreferenceProperty( sweepGroup, "columns", 2 );
4146
4147       int modeSw = addPreference( tr( "VISU_SWEEPING_MODES" ), sweepGroup,
4148                                   LightApp_Preferences::Selector, "VISU", "sweeping_modes" );
4149       QStringList sweep_modes;
4150       sweep_modes.append( tr( "VISU_LINEAR_SWEEP" ) );
4151       sweep_modes.append( tr( "VISU_COS_SWEEP" ) );
4152       sweep_modes.append( tr( "VISU_SIN_SWEEP" ) );
4153       indices.clear();
4154       indices.append( 0 );
4155       indices.append( 1 );
4156       indices.append( 2 );
4157       setPreferenceProperty( modeSw, "strings", sweep_modes );
4158       setPreferenceProperty( modeSw, "indexes", indices );
4159
4160       int timestep   = addPreference( tr( "VISU_TIME_STEP" ), sweepGroup,
4161                                       LightApp_Preferences::DblSpin, "VISU", "sweeping_time_step" );
4162       /*    int nbcycles   = addPreference( tr( "VISU_NB_CYCLES" ), sweepGroup,
4163             LightApp_Preferences::IntSpin, "VISU", "sweeping_number_cycles" );*/
4164       int nbsteps    = addPreference( tr( "VISU_NB_STEPS" ),  sweepGroup,
4165                                       LightApp_Preferences::IntSpin, "VISU", "sweeping_number_steps" );
4166       int rangeSw = addPreference( tr( "VISU_IS2PI" ), sweepGroup, LightApp_Preferences::Selector, "VISU", "sweeping_is2PI" );
4167       QStringList ranges;
4168       ranges.append( tr( "PERIOD_PI" ) );
4169       ranges.append( tr( "PERIOD_2PI" ) );
4170       indices.clear();
4171       indices.append( 0 );
4172       indices.append( 1 );
4173       setPreferenceProperty( rangeSw, "strings", ranges );
4174       setPreferenceProperty( rangeSw, "indexes", indices );
4175
4176       setPreferenceProperty( timestep, "min",  0.1 );
4177       setPreferenceProperty( timestep, "step", 0.1 );
4178       setPreferenceProperty( timestep, "max",  1000 );
4179       //    setPreferenceProperty( nbcycles, "max",  100  );
4180       setPreferenceProperty( nbsteps,  "max",  200  );
4181     }
4182   }
4183
4184   // TAB: Representation ; group: "Representation properties"
4185   int representationTab = addPreference( tr( "Representation" ) );
4186
4187   int representGr = addPreference( tr( "VISU_REPRESENT_PROPS" ), representationTab );
4188   setPreferenceProperty( representGr, "columns", 2 );
4189
4190   QStringList mesh_modes;
4191   mesh_modes.append( "Points" );
4192   mesh_modes.append( "Wireframe" );
4193   mesh_modes.append( "Insideframe" );
4194   mesh_modes.append( "Surfaceframe" );
4195   mesh_modes.append( "Surface" );
4196   mesh_modes.append( "Feature edges" );
4197   QList<QVariant> mesh_indices;
4198   mesh_indices.append( 0 );
4199   mesh_indices.append( 1 );
4200   mesh_indices.append( 3 );
4201   mesh_indices.append( 4 );
4202   mesh_indices.append( 2 );
4203   mesh_indices.append( 5 );
4204
4205   QStringList modes0 = mesh_modes;
4206   modes0.removeAll( "Feature edges" );
4207   QList<QVariant> indices0 = mesh_indices;
4208   indices0.removeAll( 5 );
4209
4210   QStringList modes1 = modes0;
4211   modes1.removeAll( "Insideframe" );
4212   QList<QVariant> indices1 = indices0;
4213   indices1.removeAll( 3 );
4214
4215   QStringList modes2 = modes1;
4216   modes2.removeAll( "Surfaceframe" );
4217   QList<QVariant> indices2 = indices1;
4218   indices2.removeAll( 4 );
4219
4220   QStringList modes3 = modes2;
4221   modes3.removeAll( "Surface" );
4222   QList<QVariant> indices3 = indices2;
4223   indices3.removeAll( 2 );
4224
4225
4226   int mesh_represent = addPreference( tr( "VISU_MESH" ), representGr, LightApp_Preferences::Selector, "VISU", "mesh_represent" );
4227   setPreferenceProperty( mesh_represent, "strings", mesh_modes );
4228   setPreferenceProperty( mesh_represent, "indexes", mesh_indices );
4229   addPreference( tr( "VISU_SHRINK" ), representGr, LightApp_Preferences::Bool, "VISU", "mesh_shrink" );
4230
4231   int scalar_map_represent = addPreference( tr( "VISU_SCALAR_MAP" ), representGr, LightApp_Preferences::Selector, "VISU", "scalar_map_represent" );
4232   setPreferenceProperty( scalar_map_represent, "strings", modes0 );
4233   setPreferenceProperty( scalar_map_represent, "indexes", indices0 );
4234   addPreference( tr( "VISU_SHRINK" ), representGr, LightApp_Preferences::Bool, "VISU", "scalar_map_shrink" );
4235
4236   int iso_surfaces_represent = addPreference( tr( "VISU_ISO_SURFACES" ), representGr, LightApp_Preferences::Selector, "VISU", "iso_surfaces_represent" );
4237   setPreferenceProperty( iso_surfaces_represent, "strings", modes1 );
4238   setPreferenceProperty( iso_surfaces_represent, "indexes", indices1 );
4239   int sp = addPreference( "", representGr, LightApp_Preferences::Space );
4240   setPreferenceProperty( sp, "hstretch", 0 );
4241   setPreferenceProperty( sp, "vstretch", 0 );
4242
4243   int cut_planes_represent = addPreference( tr( "VISU_CUT_PLANES" ), representGr, LightApp_Preferences::Selector, "VISU", "cut_planes_represent" );
4244   setPreferenceProperty( cut_planes_represent, "strings", modes1 );
4245   setPreferenceProperty( cut_planes_represent, "indexes", indices1 );
4246   addPreference( "", representGr, LightApp_Preferences::Space );
4247
4248   int cut_lines_represent = addPreference( tr( "VISU_CUT_LINES" ), representGr, LightApp_Preferences::Selector, "VISU", "cut_lines_represent" );
4249   setPreferenceProperty( cut_lines_represent, "strings", modes3 );
4250   setPreferenceProperty( cut_lines_represent, "indexes", indices3 );
4251   sp = addPreference( "", representGr, LightApp_Preferences::Space );
4252   setPreferenceProperty( sp, "hstretch", 0 );
4253   setPreferenceProperty( sp, "vstretch", 0 );
4254
4255   int cut_segment_represent = addPreference( tr( "VISU_CUT_SEGMENT" ), representGr, LightApp_Preferences::Selector, "VISU", "cut_segment_represent" );
4256   setPreferenceProperty( cut_segment_represent, "strings", modes3 );
4257   setPreferenceProperty( cut_segment_represent, "indexes", indices3 );
4258   sp = addPreference( "", representGr, LightApp_Preferences::Space );
4259   setPreferenceProperty( sp, "hstretch", 0 );
4260   setPreferenceProperty( sp, "vstretch", 0 );
4261
4262   int deformed_shape_represent = addPreference( tr( "VISU_DEFORMED_SHAPE" ), representGr, LightApp_Preferences::Selector, "VISU", "deformed_shape_represent" );
4263   setPreferenceProperty( deformed_shape_represent, "strings", modes0 );
4264   setPreferenceProperty( deformed_shape_represent, "indexes", indices0 );
4265   addPreference( tr( "VISU_SHRINK" ), representGr, LightApp_Preferences::Bool, "VISU", "deformed_shape_shrink" );
4266
4267   int vectors_represent = addPreference( tr( "VISU_VECTORS" ), representGr, LightApp_Preferences::Selector, "VISU", "vectors_represent" );
4268   setPreferenceProperty( vectors_represent, "strings", modes3 );
4269   setPreferenceProperty( vectors_represent, "indexes", indices3 );
4270   sp = addPreference( "", representGr, LightApp_Preferences::Space );
4271   setPreferenceProperty( sp, "hstretch", 0 );
4272   setPreferenceProperty( sp, "vstretch", 0 );
4273
4274   int stream_lines_represent = addPreference( tr( "VISU_STREAM_LINES" ), representGr, LightApp_Preferences::Selector, "VISU", "stream_lines_represent" );
4275   setPreferenceProperty( stream_lines_represent, "strings", modes3 );
4276   setPreferenceProperty( stream_lines_represent, "indexes", indices3 );
4277   sp = addPreference( "", representGr, LightApp_Preferences::Space );
4278   setPreferenceProperty( sp, "hstretch", 0 );
4279   setPreferenceProperty( sp, "vstretch", 0 );
4280
4281   int plot3d_represent = addPreference( tr( "VISU_PLOT3D" ), representGr, LightApp_Preferences::Selector, "VISU", "plot3d_represent" );
4282   setPreferenceProperty( plot3d_represent, "strings", modes1 );
4283   setPreferenceProperty( plot3d_represent, "indexes", indices1 );
4284   sp = addPreference( "", representGr, LightApp_Preferences::Space );
4285   setPreferenceProperty( sp, "hstretch", 0 );
4286   setPreferenceProperty( sp, "vstretch", 0 );
4287
4288   int scalar_def_represent = addPreference( tr( "VISU_DEFORMED_SHAPE_AND_SCALAR_MAP" ), representGr, LightApp_Preferences::Selector, "VISU", "scalar_def_represent" );
4289   setPreferenceProperty( scalar_def_represent, "strings", modes1 );
4290   setPreferenceProperty( scalar_def_represent, "indexes", indices1 );
4291   addPreference( tr( "VISU_SHRINK" ), representGr, LightApp_Preferences::Bool, "VISU", "scalar_def_shrink" );
4292
4293   int quadraticmode = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), representGr, LightApp_Preferences::Selector, "VISU", "quadratic_mode" );
4294   QStringList quadraticModes;
4295   quadraticModes.append("Lines");
4296   quadraticModes.append("Arcs");
4297   indices.clear();
4298   indices.append( 0 );
4299   indices.append( 1 );
4300   setPreferenceProperty( quadraticmode, "strings", quadraticModes );
4301   setPreferenceProperty( quadraticmode, "indexes", indices );
4302
4303   int maxAngle = addPreference( tr( "MAX_ARC_ANGLE" ), representGr, LightApp_Preferences::IntSpin,
4304                               "VISU", "max_angle" );
4305   setPreferenceProperty( maxAngle, "min", 1 );
4306   setPreferenceProperty( maxAngle, "max", 90 );
4307
4308   int elem0DSize = addPreference( tr( "VISU_ELEM0D_SIZE" ), representGr, LightApp_Preferences::IntSpin, "VISU", "elem0d_size" );
4309   setPreferenceProperty( elem0DSize, "min", 1 );
4310   setPreferenceProperty( elem0DSize, "max", 10 );
4311   addPreference( "", representGr, LightApp_Preferences::Space );
4312
4313   int shrFac = addPreference( tr( "VISU_SHRINK_FACTOR" ), representGr, LightApp_Preferences::IntSpin, "VISU", "shrink_factor" );
4314   setPreferenceProperty( shrFac, "min", 20 );
4315   setPreferenceProperty( shrFac, "max", 100 );
4316   sp = addPreference( "", representGr, LightApp_Preferences::Space );
4317   setPreferenceProperty( sp, "hstretch", 0 );
4318   setPreferenceProperty( sp, "vstretch", 0 );
4319
4320   addPreference( tr( "VISU_EDGE_COLOR" ), representGr, LightApp_Preferences::Color, "VISU", "edge_color" );
4321   addPreference( "", representGr, LightApp_Preferences::Space );
4322
4323   int typeOfMarker = addPreference( tr( "VISU_TYPE_OF_MARKER" ), representGr, LightApp_Preferences::Selector, "VISU", "type_of_marker" );
4324
4325   QList<QVariant> aMarkerTypeIndicesList;
4326   QList<QVariant> aMarkerTypeIconsList;
4327   for ( int i = VTK::MT_POINT; i <= VTK::MT_O_X; i++ ) {
4328     QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
4329     QPixmap pixmap = aResourceMgr->loadPixmap( "VTKViewer", tr( qPrintable( icoFile ) ) );
4330     aMarkerTypeIndicesList << i;
4331     aMarkerTypeIconsList << pixmap;
4332   }
4333   aMarkerTypeIndicesList << VTK::MT_POINT_SPRITE;
4334   aMarkerTypeIconsList << aResourceMgr->loadPixmap( "VISU", tr( "ICON_POINT_SPRITE" ) );
4335   setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
4336   setPreferenceProperty( typeOfMarker, "icons",   aMarkerTypeIconsList );
4337
4338   int markerScale = addPreference( tr( "VISU_MARKER_SCALE" ), representGr, LightApp_Preferences::Selector, "VISU", "marker_scale" );
4339
4340   QList<QVariant> aMarkerScaleIndicesList;
4341   QStringList     aMarkerScaleValuesList;
4342   for ( int i = VISU::MS_10; i <= VISU::MS_70; i++ ) {
4343     aMarkerScaleIndicesList << i;
4344     aMarkerScaleValuesList  << QString::number( (i-(int)VISU::MS_10)*0.5 + 1.0 );
4345   }
4346   setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
4347   setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
4348
4349   addPreference( tr( "VISU_USE_SHADING" ), representGr, LightApp_Preferences::Bool, "VISU", "represent_shading" );
4350   sp = addPreference( "", representGr, LightApp_Preferences::Space );
4351   setPreferenceProperty( sp, "hstretch", 0 );
4352   setPreferenceProperty( sp, "vstretch", 0 );
4353
4354   addPreference( tr( "VISU_DISP_ONLY" ), representGr, LightApp_Preferences::Bool, "VISU", "display_only" );
4355   addPreference( "", representGr, LightApp_Preferences::Space );
4356
4357   addPreference( tr( "VISU_AUTOMATIC_FIT_ALL" ), representGr,
4358                  LightApp_Preferences::Bool, "VISU", "automatic_fit_all" );
4359
4360   // TAB: Tables ; group: "Tables editing properties"
4361   int tablesTab = addPreference( tr( "VISU_TABLES" ) );
4362
4363   int tablesGr = addPreference( tr( "VISU_TABLES_EDITING_PROPS" ), tablesTab );
4364   setPreferenceProperty( tablesGr, "columns", 1 );
4365
4366   addPreference( tr( "VISU_TABLES_ENABLE_EDITING" ), tablesGr, LightApp_Preferences::Bool, "VISU", "tables_enable_editing" );
4367
4368   int sortPolicyPref = addPreference( tr( "VISU_TABLES_SORT_POLICY" ), tablesGr, LightApp_Preferences::Selector, "VISU", "tables_sort_policy" );
4369   QStringList policies;
4370   policies.append( tr( "VISU_TABLES_EMPTY_LOWEST" ) );
4371   policies.append( tr( "VISU_TABLES_EMPTY_HIGHEST" ) );
4372   policies.append( tr( "VISU_TABLES_EMPTY_FIRST" ) );
4373   policies.append( tr( "VISU_TABLES_EMPTY_LAST" ) );
4374   policies.append( tr( "VISU_TABLES_EMPTY_IGNORE" ) );
4375   indices.clear();
4376   indices.append( 0 );
4377   indices.append( 1 );
4378   indices.append( 2 );
4379   indices.append( 3 );
4380   indices.append( 4 );
4381   setPreferenceProperty( sortPolicyPref, "strings", policies );
4382   setPreferenceProperty( sortPolicyPref, "indexes", indices );
4383
4384   // TAB: Feature edges ; group: "Feature edges properties"
4385   int featureEdgesTab = addPreference( tr( "VISU_FEATURE_EDGES" ) );
4386
4387   int featureEdgesGr = addPreference( tr( "VISU_FEATURE_EDGES_PROPS" ), featureEdgesTab );
4388   setPreferenceProperty( featureEdgesGr, "columns", 2 );
4389
4390   int featureEdgesAnglePref = addPreference( tr( "VISU_FEATURE_EDGES_ANGLE" ), featureEdgesGr,
4391                                              LightApp_Preferences::DblSpin, "VISU", "feature_edges_angle" );
4392   setPreferenceProperty( featureEdgesAnglePref, "step", 10.0 );
4393   setPreferenceProperty( featureEdgesAnglePref, "min", 0.0 );
4394   setPreferenceProperty( featureEdgesAnglePref, "max", 90.0 );
4395
4396   addPreference( tr( "VISU_SHOW_FEATURE_EDGES" ), featureEdgesGr, LightApp_Preferences::Bool, "VISU", "show_feature_edges" );
4397   addPreference( tr( "VISU_SHOW_BOUNDARY_EDGES" ), featureEdgesGr, LightApp_Preferences::Bool, "VISU", "show_boundary_edges" );
4398   addPreference( tr( "VISU_SHOW_MANIFOLD_EDGES" ), featureEdgesGr, LightApp_Preferences::Bool, "VISU", "show_manifold_edges" );
4399   addPreference( tr( "VISU_SHOW_NON_MANIFOLD_EDGES" ), featureEdgesGr, LightApp_Preferences::Bool, "VISU", "show_non_manifold_edges" );
4400   //addPreference( tr( "VISU_FEATURE_EDGES_COLORING" ), featureEdgesGr, LightApp_Preferences::Bool, "VISU", "feature_edges_coloring" );
4401
4402   // TAB: "Values labels"
4403
4404   int valLblTab = addPreference( tr( "VALUES_LABELING" ) );
4405
4406   // "Font" group
4407   int valLblFontGr = addPreference( tr( "VISU_FONT" ), valLblTab );
4408   setPreferenceProperty( valLblFontGr, "columns", 2 );
4409
4410   // font
4411   addVtkFontPref( tr( "LABELS" ), valLblFontGr, "values_labeling_font", true );
4412
4413   // color
4414   addPreference( tr( "COLOR" ), valLblFontGr,
4415     LightApp_Preferences::Color, "VISU", "values_labeling_color" );
4416
4417 }
4418
4419 void VisuGUI::preferencesChanged( const QString& a, const QString& b)
4420 {
4421   if (a != QString("VISU")) return;
4422   if (b == QString("scalar_bar_orientation")) return;
4423   SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
4424   float sbX1,sbY1,sbW,sbH;
4425   float aTol = 1.00000009999999;
4426   QString aWarning;
4427   if(b == QString("scalar_bar_vertical_x") || b == QString("scalar_bar_vertical_width")){
4428     sbX1 = aResourceMgr->doubleValue("VISU", "scalar_bar_vertical_x", 0.01);
4429     sbW = aResourceMgr->doubleValue("VISU", "scalar_bar_vertical_width", 0.05);
4430     if(sbX1+sbW > aTol){
4431       aWarning = "Origin and Size Vertical: X+Width > 1\n";
4432       sbX1=0.01;
4433       sbW=0.05;
4434       aResourceMgr->setValue("VISU", "scalar_bar_vertical_x", sbX1);
4435       aResourceMgr->setValue("VISU", "scalar_bar_vertical_width", sbW);
4436     }
4437   }
4438   else if(b == QString("scalar_bar_vertical_y") || b == QString("scalar_bar_vertical_height")){
4439     sbY1 = aResourceMgr->doubleValue("VISU", "scalar_bar_vertical_y", 0.01);
4440     sbH = aResourceMgr->doubleValue("VISU", "scalar_bar_vertical_height",0.5);
4441     if(sbY1+sbH > aTol){
4442       aWarning = "Origin and Size Vertical: Y+Height > 1\n";
4443       sbY1=0.01;
4444       sbH=0.5;
4445       aResourceMgr->setValue("VISU", "scalar_bar_vertical_y", sbY1);
4446       aResourceMgr->setValue("VISU", "scalar_bar_vertical_height",sbH);
4447     }
4448   }
4449   else if(b ==  QString("scalar_bar_horizontal_x") || b ==  QString("scalar_bar_horizontal_width")){
4450     sbX1 = aResourceMgr->doubleValue("VISU", "scalar_bar_horizontal_x", 0.2);
4451     sbW = aResourceMgr->doubleValue("VISU", "scalar_bar_horizontal_width", 0.6);
4452     if(sbX1+sbW > aTol){
4453       aWarning = "Origin and Size Horizontal: X+Width > 1\n";
4454       sbX1=0.2;
4455       sbW=0.6;
4456       aResourceMgr->setValue("VISU", "scalar_bar_horizontal_x", sbX1);
4457       aResourceMgr->setValue("VISU", "scalar_bar_horizontal_width", sbW);
4458     }
4459   }
4460   else if(b ==  QString("scalar_bar_horizontal_y") || b ==  QString("scalar_bar_horizontal_height")){
4461     sbY1 = aResourceMgr->doubleValue("VISU", "scalar_bar_horizontal_y", 0.01);
4462     sbH = aResourceMgr->doubleValue("VISU", "scalar_bar_horizontal_height",0.12);
4463     if(sbY1+sbH > aTol){
4464       aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
4465       sbY1=0.01;
4466       sbH=0.12;
4467       aResourceMgr->setValue("VISU", "scalar_bar_horizontal_y", sbY1);
4468       aResourceMgr->setValue("VISU", "scalar_bar_horizontal_height",sbH);
4469     }
4470   }
4471   else if(b == "visual_data_precision") {
4472     LightApp_Preferences* pref = preferences();
4473     QtxPreferenceItem* min = pref->findItem( tr( "VISU_MIN" ), true );
4474     QtxPreferenceItem* max = pref->findItem( tr( "VISU_MAX" ), true );
4475     if ( min )
4476       setPreferenceProperty( min->id(), "decimals", qAbs( aResourceMgr->integerValue( "VISU", "visual_data_precision", 0 ) ) );
4477     if ( max )
4478       setPreferenceProperty( max->id(), "decimals", qAbs( aResourceMgr->integerValue( "VISU", "visual_data_precision", 0 ) ) );
4479   }
4480
4481   if ( !aWarning.isEmpty() ){
4482     aWarning += "The default values are applied instead.";
4483     SUIT_MessageBox::warning(GetDesktop(this),
4484                              tr("ERR_SCALARBAR_PARAMS"),
4485                              aWarning );
4486   }
4487 }
4488
4489 SUIT_ViewManager*
4490 VisuGUI
4491 ::getViewManager(const QString& theType,
4492                  const bool theIsCreate)
4493 {
4494   return getApp()->getViewManager(theType,theIsCreate);
4495 }
4496
4497 VISU::TViewToPrs3d&
4498 VisuGUI
4499 ::getScalarBarsMap()
4500 {
4501   return myScalarBarsMap;
4502 }
4503
4504 LightApp_Displayer* VisuGUI::displayer()
4505 {
4506   if( !myDisplayer )
4507     myDisplayer = new VisuGUI_Displayer( getApp() );
4508
4509   return myDisplayer;
4510 }
4511
4512
4513 void VisuGUI::OnPlot3dFromCutPlane()
4514 {
4515  _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
4516  if (CheckLock(aCStudy, GetDesktop(this)))
4517    return;
4518
4519  LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
4520  SALOME_ListIO aListIO;
4521  aSelectionMgr->selectedObjects(aListIO);
4522
4523  if (aListIO.Extent() < 1) return;
4524
4525
4526  VISU::CutPlanes_i* aCutPrs = 0;
4527  Handle(SALOME_InteractiveObject) anIO;
4528  _PTR(SObject) aSObject;
4529  SALOME_ListIteratorOfListIO It (aListIO);
4530  for (; It.More(); It.Next()) {
4531    anIO = It.Value();
4532
4533    if (!anIO.IsNull() && anIO->hasEntry()) {
4534      aSObject = aCStudy->FindObjectID(anIO->getEntry());
4535      if ( !aSObject )
4536         continue;
4537      VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry(GetAppStudy(this), anIO->getEntry());
4538      if(VISU::Prs3d_i* aPrsObject = VISU::GetPrs3dFromBase(anObjectInfo.myBase)){
4539        if (aPrsObject->GetType() == VISU::TCUTPLANES) {
4540          aCutPrs = dynamic_cast<VISU::CutPlanes_i*>(aPrsObject);
4541          if (aCutPrs)
4542            break;
4543        }
4544      }
4545    }
4546  }
4547
4548  if (aCutPrs) {
4549    _PTR(SObject) aTimeStampSObj = aSObject->GetFather();
4550    if (SUIT_ViewManager* aViewManager = getApp()->activeViewManager()) {
4551      QString aViewType = aViewManager->getType();
4552      //bool anIsVVTK = (aViewType == VVTK_Viewer::Type());
4553
4554      Storable::TRestoringMap aRestoringMap = Storable::GetStorableMap(aTimeStampSObj);
4555      VISU::VISUType aType = VISU::Storable::RestoringMap2Type( aRestoringMap );
4556      if (aType != TTIMESTAMP )
4557         return;
4558
4559      QString aMeshName = aRestoringMap["myMeshName"];
4560      QString anEntity = aRestoringMap["myEntityId"];
4561      QString aFieldName = aRestoringMap["myFieldName"];
4562      QString aTimeStampId = aRestoringMap["myTimeStampId"];
4563
4564      int aPos;
4565      SUIT_ViewWindow* aViewWindow = 0;
4566 //      if (anIsVVTK) {
4567 //      aViewWindow = GetViewWindow<VVTK_Viewer>(this);
4568 //      aPos = GetFreePositionOfDefaultScalarBar(this, dynamic_cast<VVTK_ViewWindow*>(aViewWindow));
4569 //      } else {
4570         aViewWindow = GetViewWindow<SVTK_Viewer>(this);
4571         aPos = GetFreePositionOfDefaultScalarBar(this, dynamic_cast<SVTK_ViewWindow*>(GetViewWindow<SVTK_Viewer>(this)));
4572         //     }
4573      GetResourceMgr()->setValue("VISU", "scalar_bar_position_num", aPos);
4574
4575      VISU::Plot3D_i* aPrs3d =
4576        CreatePrs3dFromFactory<VISU::Plot3D_i>(this,
4577                                               aTimeStampSObj,
4578                                               (const char*)aMeshName.toLatin1(),
4579                                               (Entity)anEntity.toInt(),
4580                                               (const char*)aFieldName.toLatin1(),
4581                                               aTimeStampId.toInt(),
4582                                               ColoredPrs3d_i::EPublishUnderTimeStamp);
4583      if (aPrs3d) {
4584         SUIT_ResourceMgr* aResourceMgr = GetResourceMgr();
4585         int aValue = aResourceMgr->integerValue("VISU","BuildDefaultPrs3d",0);
4586         if (!aValue) {
4587           VisuGUI_Plot3DDlg* aDlg = new VisuGUI_Plot3DDlg(this);
4588           aDlg->initFromPrsObject(aPrs3d, true);
4589           int    aOrient = aCutPrs->GetOrientationType(); // Plot3d has the same orientation type
4590           double aRotX = aCutPrs->GetRotateX();
4591           double aRotY = aCutPrs->GetRotateY();
4592           double aPlanePos = aCutPrs->GetPlanePosition(0);
4593           aDlg->setPlane(aOrient, aRotX, aRotY, aPlanePos);
4594
4595           if (!(runAndWait(aDlg, 0) && (aDlg->storeToPrsObject(aPrs3d)))) {
4596             DeletePrs3d(this, aPrs3d);
4597             delete aDlg;
4598             return;
4599           }
4600           delete aDlg;
4601           UpdateObjBrowser(this, true, aTimeStampSObj);
4602         }
4603         SVTK_ViewWindow* aSVtkWindow = dynamic_cast<SVTK_ViewWindow*>(aViewWindow);
4604         if ( aSVtkWindow ) {
4605           PublishInView(this, aPrs3d, aSVtkWindow, /*highlight = */true);
4606           aSVtkWindow->onFitAll();
4607
4608           AddScalarBarPosition(this, aSVtkWindow, aPrs3d, aPos);
4609         }
4610         processPresentationCreated(aPrs3d);
4611      }
4612    }
4613    application()->putInfo(QObject::tr("INF_DONE"));
4614  }
4615 }
4616
4617 void VisuGUI::OnManageCache()
4618 {
4619   mySlider->show();
4620 }
4621
4622
4623 //---------------------------------------------------------------
4624 void VisuGUI::OnMultiprViewFullRes()
4625 {
4626   OnMultiprChangeRes(VISU::Result::FULL);
4627 }
4628
4629
4630 //---------------------------------------------------------------
4631 void VisuGUI::OnMultiprViewMediumRes()
4632 {
4633   OnMultiprChangeRes(VISU::Result::MEDIUM);
4634 }
4635
4636
4637 //---------------------------------------------------------------
4638 void VisuGUI::OnMultiprViewLowRes()
4639 {
4640   OnMultiprChangeRes(VISU::Result::LOW);
4641 }
4642
4643
4644 //---------------------------------------------------------------
4645 void VisuGUI::OnMultiprViewHide()
4646 {
4647   OnMultiprChangeRes(VISU::Result::HIDDEN);
4648 }
4649
4650
4651 //---------------------------------------------------------------
4652 void VisuGUI::OnMultiprChangeRes(VISU::Result::Resolution theResolution)
4653 {
4654   _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
4655   if (CheckLock(aCStudy,GetDesktop(this)))
4656     return;
4657
4658   VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(this);
4659   if(aSelectionInfo.empty())
4660     return;
4661
4662   QApplication::setOverrideCursor(Qt::WaitCursor);
4663
4664   typedef SALOME::GenericObjPtr<VISU::Result_i> TResultPtr;
4665   typedef std::map<TResultPtr, _PTR(SObject)> TResult2SObject;
4666   TResult2SObject aResult2SObject;
4667
4668   for (int i=0; i < aSelectionInfo.size(); i++) {
4669     VISU::TSelectionItem aSelectionItem = aSelectionInfo[i];
4670
4671     _PTR(SObject) aSObject = aSelectionItem.myObjectInfo.mySObject;
4672     if (!aSObject)
4673       continue;
4674
4675     VISU::Result_var aResult = FindResult( VISU::GetSObject( aSObject ).in() );
4676     if(CORBA::is_nil(aResult.in()))
4677       continue;
4678
4679     VISU::Result_i* aCResult = dynamic_cast<VISU::Result_i*>(VISU::GetServant(aResult).in());
4680     if(!aCResult)
4681       continue;
4682
4683     Storable::TRestoringMap aRestoringMap = Storable::GetStorableMap(aSObject);
4684     bool anIsFound = false;
4685     QString aMeshName = Storable::FindValue(aRestoringMap, "myMeshName", &anIsFound);
4686     if(!anIsFound)
4687       continue;
4688
4689     std::string aPartName = aSObject->GetName();
4690
4691     aCResult->SetResolution(aMeshName.toLatin1().data(), aPartName.c_str(), theResolution);
4692
4693     aResult2SObject[TResultPtr(aCResult)] = aSObject;
4694   }
4695
4696   // To update all result observers
4697   TResult2SObject::const_iterator anIter = aResult2SObject.begin();
4698   for(; anIter != aResult2SObject.end(); anIter++){
4699     const TResultPtr& aResultPtr = anIter->first;
4700     const _PTR(SObject)& aSObject = anIter->second;
4701     aResultPtr->UpdateObservers();
4702     VISU::UpdateObjBrowser(this, false, aSObject);
4703   }
4704
4705   QApplication::restoreOverrideCursor();
4706 }
4707
4708 //---------------------------------------------------------------
4709 void VisuGUI::OnFileInfo()
4710 {
4711   SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( getApp()->activeStudy() );
4712   SUIT_DataOwnerPtrList lst;
4713   getApp()->selectionMgr()->selected( lst );
4714   LightApp_DataOwner* owner = dynamic_cast<LightApp_DataOwner*>( lst.first().get() );
4715   VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry( aStudy, owner->entry().toLatin1().constData() );
4716   VISU::Result_i* aCResult = dynamic_cast<VISU::Result_i*>( anObjectInfo.myBase );
4717   if(!aCResult)
4718     return;
4719   VisuGUI_FileInfoDlg dlg( getApp()->desktop(), aCResult->GetMEDFileInfo() );
4720   dlg.exec();
4721 }
4722
4723 //---------------------------------------------------------------
4724 void VisuGUI::OnExportMED()
4725 {
4726   SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( getApp()->activeStudy() );
4727   SUIT_DataOwnerPtrList lst;
4728   getApp()->selectionMgr()->selected( lst );
4729   LightApp_DataOwner* owner = dynamic_cast<LightApp_DataOwner*>( lst.first().get() );
4730   VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry( aStudy, owner->entry().toLatin1().constData() );
4731   VISU::Result_i* aResult = dynamic_cast<VISU::Result_i*>( anObjectInfo.myBase );
4732   if(!aResult)
4733     return;
4734   //  VisuGUI_FileInfoDlg dlg( getApp()->desktop(), aResult->GetMEDFileInfo() );
4735   //  dlg.exec();
4736
4737   SUIT_ResourceMgr* aResourceMgr = GetResourceMgr();
4738   QString aDir = aResourceMgr->stringValue("VISU","OutputDir","");
4739
4740   // get name for the file
4741   QStringList aFilter;
4742   aFilter.append("MED Files (*.med)");
4743
4744   std::string anInitFileName = aResult->GetInitFileName();
4745   QFileInfo anInitFileInfo(anInitFileName.c_str());
4746   QString aBaseName = anInitFileInfo.fileName();
4747
4748   QString aPath = Qtx::addSlash(aDir) + aBaseName;
4749
4750   QFileInfo aFileInfo =
4751     SUIT_FileDlg::getFileName(GetDesktop(this),
4752                               aPath,
4753                               aFilter,
4754                               tr("VISU_MEN_EXPORT_MED"), // "Export To Med File"
4755                               false);
4756
4757   QString aFile = aFileInfo.filePath();
4758   if ( aFile.length() > 0 ) {
4759     aResult->ExportMED((const char*)aFile.toLatin1());
4760   }
4761 }
4762
4763 void VisuGUI::OnFilterScalars()
4764 {
4765   VisuGUI_FilterScalarsDlg* aDlg = new VisuGUI_FilterScalarsDlg( this );
4766   aDlg->show();
4767 }
4768
4769 /*!
4770   \brief SLOT called when "Labeling" popup menu item of presentation is clicked
4771    activates/deactivates labeling of results of the screen. This functionality works
4772    to numbering in SMESH module but is intended for showing results on the screen
4773    instead of elements numbers
4774    \sa OnValuesLabelingParams()
4775 */
4776 void VisuGUI::OnValuesLabeling()
4777 {
4778   // to do: rewrite for several actors if necessary
4779
4780   VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects( this );
4781   if ( aSelectionInfo.empty() )
4782     return;
4783
4784   TSelectionItem aSelectionItem = GetSelectedObjects(this).front();
4785   VISU::Prs3d_i* aPrs3d = GetPrs3dFromBase(aSelectionItem.myObjectInfo.myBase);
4786   if (!aPrs3d)
4787     return;
4788
4789   SVTK_ViewWindow* aViewWindow = GetActiveViewWindow<SVTK_ViewWindow>(this);
4790   if (!aViewWindow)
4791     return;
4792
4793   VISU_Actor* anActor = FindActor(aViewWindow, aPrs3d);
4794   if (!anActor)
4795     return;
4796
4797   if ( VISU_ScalarMapAct* aScalarMapActor = dynamic_cast<VISU_ScalarMapAct*>(anActor) )
4798   {
4799     aScalarMapActor->SetValuesLabeled( !aScalarMapActor->GetValuesLabeled() );
4800     aViewWindow->Repaint();
4801   }
4802   else if ( VISU_GaussPtsAct* aGaussPtsAct = dynamic_cast<VISU_GaussPtsAct*>(anActor) )
4803   {
4804     aGaussPtsAct->SetValuesLabeled( !aGaussPtsAct->GetValuesLabeled() );
4805     aViewWindow->Repaint();
4806   }
4807 }
4808
4809 /*!
4810   \brief SLOT called when "Labeling parameters" popup menu item of presentation
4811   is clicked launch dialog box for changing parameters of labeling
4812   \sa OnValuesLabeling()
4813 */
4814 void VisuGUI::OnValuesLabelingParams()
4815 {
4816   Handle(SALOME_InteractiveObject) anIO;
4817   if ( VISU::Prs3d_i* aPrs3d = GetPrsToModify( this, anIO ) )
4818     EditPrs3d<VISU::ColoredPrs3d_i, VisuGUI_ValuesLabelingDlg, 1>(this, anIO, aPrs3d);
4819 }
4820 /*!
4821   \brief Adds preferences for dfont of VTK viewer
4822   \param label label
4823   \param pIf group identifier
4824   \param param parameter
4825   \return identifier of preferences
4826 */
4827 int VisuGUI::addVtkFontPref(
4828   const QString& label,
4829   const int pId,
4830   const QString& param,
4831   const bool useSize )
4832 {
4833   int tfont = addPreference( label, pId, LightApp_Preferences::Font, "VISU", param );
4834
4835   setPreferenceProperty( tfont, "mode", QtxFontEdit::Custom );
4836
4837   QStringList fam;
4838   fam.append( tr( "VISU_FONT_ARIAL" ) );
4839   fam.append( tr( "VISU_FONT_COURIER" ) );
4840   fam.append( tr( "VISU_FONT_TIMES" ) );
4841
4842   setPreferenceProperty( tfont, "fonts", fam );
4843
4844   int f = QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | QtxFontEdit::Shadow;
4845   if ( useSize )
4846     f |= QtxFontEdit::UserSize | QtxFontEdit::Size;
4847
4848   setPreferenceProperty( tfont, "features", f );
4849
4850   return tfont;
4851 }
4852
4853 /*!
4854   \brief SLOT called when "2D Quadratic -> Arcs" popup menu item
4855   \      of presentation is cliked
4856  */
4857 void VisuGUI::OnArcQuadMode(){
4858   ChangeQuadratic2DRepresentation(this,VISU::ARCS);
4859 }
4860
4861 /*!
4862   \brief SLOT called when "2D Quadratic -> Lines" popup menu item
4863   \      of presentation is cliked
4864  */
4865 void VisuGUI::OnLineQuadMode(){
4866   ChangeQuadratic2DRepresentation(this,VISU::LINES);
4867 }