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