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