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