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