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