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