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