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