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