]> SALOME platform Git repositories - modules/visu.git/blob - src/VISUGUI/VisuGUI.cxx
Salome HOME
Preferences for VISU module.
[modules/visu.git] / src / VISUGUI / VisuGUI.cxx
1 //  VISU VISUGUI : GUI of VISU component
2 //
3 //  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
21 //
22 //
23 //
24 //  File   : VisuGUI.cxx
25 //  Author : Laurent CORNABE
26 //  Module : VISU
27 //  $Header$
28
29 #include "VisuGUI.h"
30
31 // STL Includes
32 #include <exception>
33 #include <typeinfo>
34 #include <vector>
35
36 // QT Includes
37 #include <qptrlist.h>
38 #include <qptrvector.h>
39 #include <qcolordialog.h>
40
41 // VTK Includes
42 #include <vtkRenderer.h>
43 #include <vtkRenderWindow.h>
44 #include <vtkActorCollection.h>
45
46 // SALOME Includes
47 #include "SALOME_LifeCycleCORBA.hxx"
48
49 #include "SUIT_ResourceMgr.h"
50 #include "SUIT_MessageBox.h"
51
52 #include "SUIT_ViewWindow.h"
53 #include "SUIT_ViewManager.h"
54
55 #include "CAM_Module.h"
56
57 #include "SVTK_RenderWindow.h"
58 #include "SVTK_ViewWindow.h"
59 #include "SVTK_ViewModel.h"
60 #include "SVTK_Functor.h"
61
62 #include "SPlot2d_ViewModel.h"
63 #include "SPlot2d_SetupPlot2dDlg.h"
64 #include "Plot2d_SetupCurveDlg.h"
65
66 #include "OB_Browser.h"
67
68 #include "SALOME_ListIO.hxx"
69 #include "SALOME_ListIteratorOfListIO.hxx"
70
71 #include "SalomeApp_Application.h"
72 #include "SalomeApp_DataModel.h"
73 #include "SalomeApp_Study.h"
74 #include "SalomeApp_SelectionMgr.h"
75 #include "SalomeApp_Selection.h"
76 #include "SalomeApp_Preferences.h"
77
78 #include "VISUConfig.hh"
79 #include "VISU_Gen_i.hh"
80 #include "VISU_Mesh_i.hh"
81 #include "VISU_Table_i.hh"
82 #include "VISU_Result_i.hh"
83 #include "VISU_View_i.hh"
84 #include "VISU_ViewManager_i.hh"
85 #include "VISU_Plot3D_i.hh"
86
87 #include "VISU_Actor.h"
88
89 #include "VisuGUI_Tools.h"
90 #include "VisuGUI_PopupTools.h"
91 #include "VisuGUI_NameDlg.h"
92 #include "VisuGUI_FileDlg.h"
93 #include "VisuGUI_CursorDlg.h"
94 #include "VisuGUI_Selection.h"
95 #include "VisuGUI_TimeAnimation.h"
96 #include "VisuGUI_EditContainerDlg.h"
97 #include "VisuGUI_NonIsometricDlg.h"
98 #include "VisuGUI_ClippingDlg.h"
99 #include "VisuGUI_Plot3DDlg.h"
100 #include "VisuGUI_CubeAxesDlg.h"
101 #include "VisuGUI_OffsetDlg.h"
102
103 #include "VISU_ScalarMap_i.hh"
104 #include "VisuGUI_ScalarBarDlg.h"
105
106 #include "VISU_DeformedShape_i.hh"
107 #include "VisuGUI_DeformedShapeDlg.h"
108
109 #include "VISU_IsoSurfaces_i.hh"
110 #include "VisuGUI_IsoSurfacesDlg.h"
111
112 #include "VISU_CutPlanes_i.hh"
113 #include "VisuGUI_CutPlanesDlg.h"
114
115 #include "VISU_CutLines_i.hh"
116 #include "VisuGUI_CutLinesDlg.h"
117
118 #include "VISU_StreamLines_i.hh"
119 #include "VisuGUI_StreamLinesDlg.h"
120
121 #include "VISU_Vectors_i.hh"
122 #include "VisuGUI_VectorsDlg.h"
123
124 #include "VisuGUI_TableDlg.h"
125
126 #include "SALOMEconfig.h"
127 #include CORBA_SERVER_HEADER(MED_Gen)
128
129 #include "utilities.h"
130
131 #include "VisuGUI_ActionsDef.h"
132
133 using namespace VISU;
134
135 #ifdef _DEBUG_
136 static int MYDEBUG = 1;
137 #else
138 static int MYDEBUG = 0;
139 #endif
140
141 //////////////////////////////////////////////////
142 // Class: VisuGUI
143 //////////////////////////////////////////////////
144
145 VisuGUI::VisuGUI():
146   SalomeApp_Module( "VISU" )
147 {
148 }
149
150
151 VisuGUI::~VisuGUI()
152 {
153 }
154
155
156 void
157 VisuGUI::
158 OnImportFromFile()
159 {
160   if(MYDEBUG) MESSAGE("VisuGUI::OnImportFromFile()");
161   CheckLock(GetCStudy(GetAppStudy(this)));
162   SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
163
164   QStringList aFilter;
165   aFilter.append( tr("FLT_MED_FILES") );
166   aFilter.append( tr("FLT_ALL_FILES") );
167
168   QFileInfo aFileInfo =
169     SUIT_FileDlg::getFileName(GetDesktop(this),
170                               "",
171                               aFilter,
172                               tr("MEN_IMPORT_FROM_FILE"),
173                               true);
174   if(aFileInfo.exists()){
175     application()->putInfo( "Importing From File " + aFileInfo.filePath() + "..." );
176
177     VISU::Result_var aResult;
178     bool anIsBuild = aResourceMgr->booleanValue("VISU", "full_med_loading", false);
179     if(VisuGUI_FileDlg::IsBuild){
180       aResult = GetVisuGen(this)->ImportFile(aFileInfo.filePath());
181       if(!CORBA::is_nil(aResult.in()))
182         if(Result_i* aRes = dynamic_cast<Result_i*>(GetServant(aResult).in())){
183           if(!aRes->IsPossible())
184             SUIT_MessageBox::warn1(GetDesktop(this),
185                                    tr("WRN_VISU"),
186                                    tr("ERR_CANT_BUILD_PRESENTATION"),
187                                    tr("BUT_OK") );
188           else
189             aRes->BuildAll();
190         }
191     }else{
192       aResourceMgr->setValue("VISU", "full_med_loading", false);
193       aResult = GetVisuGen(this)->ImportFile(aFileInfo.filePath());
194       aResourceMgr->setValue("VISU", "full_med_loading", anIsBuild);
195     }
196
197     if(CORBA::is_nil(aResult.in())) {
198       SUIT_MessageBox::warn1(GetDesktop(this),
199                              tr("WRN_VISU"),
200                              tr("ERR_ERROR_IN_THE_FILE"),
201                              tr("BUT_OK") );
202     }else{
203       application()->putInfo(aFileInfo.filePath()+tr("INF_DONE"));
204       updateObjBrowser();
205     }
206   }
207 }
208
209
210 void
211 VisuGUI::
212 OnExploreMEDFile()
213 {
214   if(MYDEBUG) MESSAGE("VisuGUI::OnExploreMEDFile()");
215   _PTR(Study) aStudy = GetCStudy(GetAppStudy(this));
216   CheckLock(aStudy);
217
218   SALOME_MED::MED_Gen_var aGen = GetMEDEngine();
219
220   QStringList aFilter;
221   aFilter.append( tr("FLT_MED_FILES") );
222   aFilter.append( tr("FLT_ALL_FILES") );
223
224   QFileInfo aFileInfo =
225     SUIT_FileDlg::getFileName(GetDesktop(this),
226                               "",
227                               aFilter,
228                               tr("MEN_EXPLORE_MED_FILE"),
229                               true);
230   if(aFileInfo.exists()){
231     application()->putInfo( tr("MEN_EXPLORE_MED_FILE") + " " + aFileInfo.filePath() + "..." );
232     std::string aStudyName = aStudy->Name();
233     aGen->readStructFileWithFieldType(aFileInfo.filePath(),aStudyName.c_str());
234     application()->putInfo(aFileInfo.filePath()+tr("INF_DONE"));
235     //updateObjBrowser();
236     getApp()->updateObjectBrowser(true); // as need to update MED tree
237   }
238 }
239
240
241 void
242 VisuGUI::
243 OnImportTableFromFile()
244 {
245   if(MYDEBUG) MESSAGE("VisuGUI::OnImportTableFromFile()");
246   CheckLock(GetCStudy(GetAppStudy(this)));
247
248   QStringList aFilter;
249   aFilter.append( tr("FLT_TABLE_FILES") );
250   aFilter.append( tr("FLT_ALL_FILES") );
251
252   QFileInfo aFileInfo =
253     SUIT_FileDlg::getFileName(GetDesktop(this),
254                               "",
255                               aFilter,
256                               tr("MEN_IMPORT_TABLE"),
257                               true);
258   if(aFileInfo.exists()){
259     application()->putInfo( tr("MEN_IMPORT_TABLE") + " " + aFileInfo.filePath() + " ..." );
260
261     CORBA::Object_var anObject = GetVisuGen(this)->ImportTables(aFileInfo.filePath());
262
263     if(CORBA::is_nil(anObject.in())) {
264       SUIT_MessageBox::warn1(GetDesktop(this),
265                              tr("WRN_VISU"),
266                              tr("ERR_ERROR_IN_THE_FILE"),
267                              tr("BUT_OK") );
268     }else{
269       application()->putInfo(aFileInfo.filePath()+tr("INF_DONE"));
270       updateObjBrowser();
271     }
272   }
273 }
274
275 void
276 VisuGUI::
277 OnExportTableToFile()
278 {
279   if(MYDEBUG) MESSAGE("VisuGUI::OnExportTableToFile()");
280 }
281
282 void
283 VisuGUI::
284 OnImportMedField()
285 {
286   _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
287   if (CheckLock(aCStudy))
288     return;
289   SALOMEDS::Study_var aStudy = GetDSStudy(aCStudy);
290
291   SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
292   SALOME_ListIO aListIO;
293   aSelectionMgr->selectedObjects(aListIO);
294
295   SALOME_ListIteratorOfListIO It (aListIO);
296   QApplication::setOverrideCursor(Qt::waitCursor);
297   for (; It.More(); It.Next()) {
298     Handle(SALOME_InteractiveObject) anIO = It.Value();
299     SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(anIO->getEntry());
300     if (!aSObject->_is_nil()) {
301       CORBA::Object_var anObject = VISU::SObjectToObject(aSObject);
302       if (!CORBA::is_nil(anObject)) {
303         SALOME_MED::MED_var aMED = SALOME_MED::MED::_narrow(anObject);
304         if (!CORBA::is_nil(aMED.in()))
305           GetVisuGen(this)->ImportMed(aSObject);
306         SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow(anObject);
307         if (!CORBA::is_nil(aField.in()))
308           GetVisuGen(this)->ImportMedField(aField);
309       } else {
310         SALOMEDS::SObject_var aSFather = aSObject->GetFather();
311         SALOMEDS::GenericAttribute_var anAttr;
312         aSFather->FindAttribute(anAttr, "AttributeName");
313         SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
314         CORBA::String_var aValue = aName->Value();
315         if (strcmp(aValue.in(), "MEDFIELD") == 0)
316           GetVisuGen(this)->ImportMed(aSObject);
317       }
318     }
319   }
320   updateObjBrowser(true);
321   QApplication::restoreOverrideCursor();
322 }
323
324 void
325 CreateCurves( SalomeApp_Module* theModule,
326               VISU::CutLines_i* thePrs,
327               QDialog* theDlg,
328               const bool theCreate = true )
329 {
330   if ( !thePrs )
331     return;
332   VisuGUI_CutLinesDlg* aCutDlg = dynamic_cast<VisuGUI_CutLinesDlg*>( theDlg );
333   if ( !aCutDlg )
334     return;
335
336   _PTR(Study)     aStudy = GetCStudy( GetAppStudy( theModule ) );
337   _PTR(SObject) aSObject = aStudy->FindObjectID( thePrs->GetEntry().latin1() );
338
339   if ( !theCreate && aSObject ){
340     // Remove old Table
341     _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
342     for ( _PTR(ChildIterator) aIter = aStudy->NewChildIterator( aSObject ); aIter->More(); aIter->Next() ) {
343       _PTR(SObject) aTblObj = aIter->Value();
344       if ( aTblObj ) {
345         _PTR(GenericAttribute) anAttr;
346         if (aTblObj->FindAttribute( anAttr, "AttributeName" ) ) {
347           aBuilder->RemoveObjectWithChildren( aIter->Value() ); // We should have only one child
348           break;
349         }
350       }
351     }
352   }
353
354   if ( aCutDlg->isGenerateTable() ) {
355     GetVisuGen( theModule )->CreateTable( thePrs->GetEntry() );
356     if ( aCutDlg->isGenerateCurves() ) {
357       if( aSObject ) {
358         _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
359         for ( _PTR(ChildIterator) aIter = aStudy->NewChildIterator( aSObject ); aIter->More(); aIter->Next() ) {
360           _PTR(SObject) aTblObj = aIter->Value();
361           if ( aTblObj ) {
362             _PTR(GenericAttribute) anAttr;
363             if ( aTblObj->FindAttribute( anAttr, "AttributeName" ) ) {
364               CreatePlot( theModule, aTblObj );
365             }
366           }
367         }
368       }
369     }
370   }
371 }
372
373 template<class TPrs3d_i>
374 TPrs3d_i*
375 CreatePrs3d(SalomeApp_Module* theModule,
376             _PTR(SObject) theTimeStamp,
377             const char* theMeshName,
378             VISU::Entity theEntity,
379             const char* theFieldName,
380             int theTimeId)
381 {
382   VISU::Result_var aResult;
383   if (CheckResult(theModule,theTimeStamp,aResult)){
384     QApplication::setOverrideCursor(Qt::waitCursor);
385     typedef typename TPrs3d_i::TInterface TPrs3d;
386     typename TPrs3d::_var_type aPrs3d =
387       GetVisuGen(theModule)->template Prs3dOnField<TPrs3d_i>
388       (aResult,theMeshName,theEntity,theFieldName,theTimeId);
389     QApplication::restoreOverrideCursor();
390     if (!CORBA::is_nil(aPrs3d.in()))
391       return dynamic_cast<TPrs3d_i*>(VISU::GetServant(aPrs3d.in()).in());
392   }
393   SUIT_MessageBox::warn1(GetDesktop(theModule),
394                          QObject::tr("WRN_VISU"),
395                          QObject::tr("ERR_CANT_BUILD_PRESENTATION"),
396                          QObject::tr("BUT_OK") );
397   return NULL;
398 }
399
400
401 template<class TPrs3d_i, class TDlg, int IsDlgModal>
402 bool
403 CreatePrs3d(SalomeApp_Module* theModule,
404             _PTR(SObject) theTimeStamp,
405             const Handle(SALOME_InteractiveObject)& theIO)
406 {
407   using namespace VISU;
408   Storable::TRestoringMap aMap = getMapOfValue(theTimeStamp);
409   bool isExist;
410   QString aType = Storable::FindValue(aMap,"myType",&isExist);
411   if(!isExist || aType.toInt() != TTIMESTAMP )
412     return false;
413   QString aMeshName = Storable::FindValue(aMap,"myMeshName",&isExist).latin1();
414   QString anEntity = Storable::FindValue(aMap,"myEntityId",&isExist).latin1();
415   QString aFieldName = Storable::FindValue(aMap,"myFieldName",&isExist).latin1();
416   QString aTimeStampId = Storable::FindValue(aMap,"myTimeStampId",&isExist).latin1();
417   QApplication::setOverrideCursor(Qt::waitCursor);
418   TPrs3d_i* aPrs3d =
419     CreatePrs3d<TPrs3d_i>(theModule,
420                           theTimeStamp,
421                           aMeshName.latin1(),
422                           (Entity)anEntity.toInt(),
423                           aFieldName.latin1(),
424                           aTimeStampId.toInt());
425   QApplication::restoreOverrideCursor();
426   if(aPrs3d){
427     SUIT_ResourceMgr* aResourceMgr = GetResourceMgr();
428     int aValue = aResourceMgr->integerValue("Visu:BuildDefaultPrs3d",0);
429     if(!aValue){
430       if(TDlg* aDlg = new TDlg(theModule)){ // dialog box in creation mode
431         aDlg->initFromPrsObject(aPrs3d);
432         if(IsDlgModal)
433           if(aDlg->exec() && (aDlg->storeToPrsObject(aPrs3d))) {
434             // Optionally, create table and curves for cut lines
435             QApplication::setOverrideCursor(Qt::waitCursor);
436             CreateCurves( theModule, dynamic_cast<VISU::CutLines_i*>( aPrs3d ), aDlg, true ); // in creation mode
437             QApplication::restoreOverrideCursor();
438             delete aDlg;
439           } else {
440             DeletePrs3d(theModule,aPrs3d,theIO);
441             delete aDlg;
442             return false;
443           }
444         else{
445           aDlg->show();
446           return true;
447         }
448       }
449     }
450     PublishInView(theModule,aPrs3d);
451     return true;
452   }
453   return false;
454 }
455
456
457 template<class TPrs3d_i, class TDlg, int IsDlgModal>
458 void
459 CreatePrs3d(SalomeApp_Module* theModule)
460 {
461   if (CheckLock(GetCStudy(GetAppStudy(theModule))))
462     return;
463
464   _PTR(SObject) aTimeStampSObj;
465   Handle(SALOME_InteractiveObject) anIO;
466   if (!CheckTimeStamp(theModule,aTimeStampSObj,&anIO))
467     return;
468
469   if (!CreatePrs3d<TPrs3d_i,TDlg,IsDlgModal>(theModule,aTimeStampSObj,anIO))
470     return;
471
472   theModule->application()->putInfo(QObject::tr("INF_DONE"));
473   theModule->updateObjBrowser();
474
475   if (SVTK_ViewWindow* aView = GetViewWindow(theModule))
476     aView->onFitAll();
477 }
478
479 void
480 VisuGUI::
481 OnCreateMesh()
482 {
483   _PTR(Study) aStudy = GetCStudy(GetAppStudy(this));
484   if (CheckLock(aStudy))
485     return;
486
487   // Get selected SObject
488   Handle(SALOME_InteractiveObject) anIO;
489   CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
490   if (anIO.IsNull() || !anIO->hasEntry())
491     return;
492
493   CreateMesh(this, anIO);
494 }
495
496 void
497 VisuGUI::
498 OnCreateManyMesh()
499 {
500   _PTR(Study) aStudy = GetCStudy(GetAppStudy(this));
501   if (CheckLock(aStudy))
502     return;
503
504   // Get selected SObject
505   SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
506   SALOME_ListIO aListIO;
507   aSelectionMgr->selectedObjects(aListIO);
508   SALOME_ListIteratorOfListIO anIter (aListIO);
509   for (; anIter.More(); anIter.Next()) {
510     Handle(SALOME_InteractiveObject) anIO = anIter.Value();
511     if (anIO.IsNull() || !anIO->hasEntry())
512       return;
513
514     CreateMesh(this, anIO);
515   }
516 }
517
518 void
519 VisuGUI::
520 OnCreateScalarMap()
521 {
522   CreatePrs3d<VISU::ScalarMap_i,VisuGUI_ScalarBarDlg,1>(this);
523 }
524
525
526 void
527 VisuGUI::
528 OnCreateDeformedShape()
529 {
530   CreatePrs3d<VISU::DeformedShape_i,VisuGUI_DeformedShapeDlg,1>(this);
531 }
532
533 void
534 VisuGUI::
535 OnCreateVectors()
536 {
537   CreatePrs3d<VISU::Vectors_i,VisuGUI_VectorsDlg,1>(this);
538 }
539
540 void
541 VisuGUI::
542 OnCreateIsoSurfaces()
543 {
544   CreatePrs3d<VISU::IsoSurfaces_i,VisuGUI_IsoSurfacesDlg,1>(this);
545 }
546
547 void
548 VisuGUI::
549 OnCreateCutPlanes()
550 {
551   CreatePrs3d<VISU::CutPlanes_i,VisuGUI_CutPlanesDlg,1>(this);
552 }
553
554 void
555 VisuGUI::
556 OnCreateCutLines()
557 {
558   CreatePrs3d<VISU::CutLines_i,VisuGUI_CutLinesDlg,1>(this);
559 }
560
561 void
562 VisuGUI::
563 OnCreateStreamLines()
564 {
565   CreatePrs3d<VISU::StreamLines_i,VisuGUI_StreamLinesDlg,1>(this);
566 }
567
568 void
569 VisuGUI::
570 OnCreatePlot3D()
571 {
572   CreatePrs3d<VISU::Plot3D_i,VisuGUI_Plot3DDlg,1>(this);
573 }
574
575 void
576 VisuGUI::
577 OnCreatePlot2dView()
578 {
579   CheckLock(GetCStudy(GetAppStudy(this)));
580   GetVisuGen( this )->CreateContainer();
581   updateObjBrowser();
582 }
583
584 void
585 VisuGUI::
586 OnDisplayPrs()
587 {
588   if(MYDEBUG) MESSAGE("VisuGUI::OnDisplayPrs");
589
590   QApplication::setOverrideCursor(Qt::waitCursor);
591   SALOME_ListIO aList;
592   SalomeApp_SelectionMgr* mgr = GetSelectionMgr(this);
593   mgr->selectedObjects(aList);
594
595   Handle(SALOME_InteractiveObject) anIO;
596   for ( SALOME_ListIteratorOfListIO it( aList ); it.More(); it.Next() ) {
597     anIO = it.Value();
598     CORBA::Object_var anObject = GetSelectedObj( GetAppStudy(this), anIO->getEntry() );
599     if ( !CORBA::is_nil( anObject ) ) {
600       // is it Prs3d object ?
601       VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject).in());
602       if(aPrsObject){
603         if(MYDEBUG) MESSAGE("VisuGUI::OnDisplayPrs : Prs3d object");
604         UpdateViewer( this, aPrsObject );
605         if (SVTK_ViewWindow* vw = GetViewWindow( this )) {
606           vw->highlight(anIO, 1);
607         }
608         continue;
609       }
610       // is it Curve ?
611       VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(anObject).in());
612       if(aCurve){
613         if(MYDEBUG) MESSAGE("VisuGUI::OnDisplayPrs : Curve object");
614         PlotCurve( this, aCurve, VISU::eDisplay );
615         continue;
616       }
617       // is it Container ?
618       VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(anObject).in());
619       if(aContainer){
620         if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Container object");
621         PlotContainer( this, aContainer, VISU::eDisplay );
622         continue;
623       }
624       // is it Table ?
625       VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(anObject).in());
626       if(aTable){
627         if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Table object");
628         PlotTable( this, aTable, VISU::eDisplay );
629         continue;
630       }
631     }
632   }
633   if (SVTK_ViewWindow* vw = GetViewWindow( this )) {
634     vw->getRenderer()->ResetCameraClippingRange();
635     vw->Repaint();
636   }
637   QApplication::restoreOverrideCursor();
638 }
639
640 void
641 VisuGUI::
642 OnDisplayOnlyPrs()
643 {
644   OnEraseAll();
645   OnDisplayPrs();
646 }
647
648 void
649 VisuGUI::
650 OnErasePrs()
651 {
652   if(MYDEBUG) MESSAGE("OnErasePrs");
653
654   QApplication::setOverrideCursor(Qt::waitCursor);
655
656   SVTK_ViewWindow* vw = GetViewWindow(this);
657   if (vw) vw->unHighlightAll();
658
659   SALOME_ListIO aList;
660   SalomeApp_SelectionMgr* mgr = GetSelectionMgr(this);
661   mgr->selectedObjects(aList);
662
663   Handle(SALOME_InteractiveObject) anIO;
664   for ( SALOME_ListIteratorOfListIO it( aList ); it.More(); it.Next() ) {
665     anIO = it.Value();
666     CORBA::Object_var anObject = GetSelectedObj( GetAppStudy(this), anIO->getEntry() );
667     ErasePrs(this, anObject, false);
668   }
669
670   if (vw) vw->Repaint();
671
672   QApplication::restoreOverrideCursor();
673 }
674
675 template<class TPrs3d_i, class TDlg>
676 void
677 EditPrs3d (SalomeApp_Module* theModule, VISU::Prs3d_i* thePrs3d)
678 {
679   TPrs3d_i* aPrsObject = dynamic_cast<TPrs3d_i*>(thePrs3d);
680   if (aPrsObject) {
681     //TDlg* aDlg = new TDlg (GetDesktop(theModule), false, true);
682     TDlg* aDlg = new TDlg (theModule);
683     aDlg->initFromPrsObject(aPrsObject);
684     if (aDlg->exec()) {
685       if (!(aDlg->storeToPrsObject(aPrsObject))) {
686         delete aDlg;
687         return;
688       }
689       RecreateActor(theModule, aPrsObject);
690       if (SVTK_ViewWindow* vw = GetViewWindow(theModule)) {
691         //if (vw->getRenderer()->GetActors()->GetNumberOfItems() > 0) {
692           vw->getRenderer()->ResetCameraClippingRange();
693           vw->Repaint();
694         //}
695       }
696     }
697     delete aDlg;
698   }
699 }
700
701 void
702 VisuGUI::
703 OnEditPrs()
704 {
705   if (CheckLock(GetCStudy(GetAppStudy(this))))
706     return;
707
708   Handle(SALOME_InteractiveObject) anIO;
709   CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
710   if (CORBA::is_nil(anObject)) return;
711   PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
712   if (!aServant.in()) return;
713
714   VISU::Prs3d_i* aPrs3d = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
715   if (!aPrs3d) return;
716
717   switch (aPrs3d->GetType()) {
718   case VISU::TMESH:
719     break;
720   case VISU::TSCALARMAP:
721     EditPrs3d<VISU::ScalarMap_i, VisuGUI_ScalarBarDlg>(this, aPrs3d);
722     break;
723   case VISU::TDEFORMEDSHAPE:
724     EditPrs3d<VISU::DeformedShape_i, VisuGUI_DeformedShapeDlg>(this, aPrs3d);
725     break;
726   case VISU::TCUTPLANES:
727     EditPrs3d<VISU::CutPlanes_i, VisuGUI_CutPlanesDlg>(this, aPrs3d);
728     /*{
729       VISU::CutPlanes_i* aPrsObject = dynamic_cast<VISU::CutPlanes_i*>(aPrs3d);
730       if (aPrsObject) {
731         VisuGUI_CutPlanesDlg* aDlg =
732           new VisuGUI_CutPlanesDlg (GetDesktop(this), false, false);
733         aDlg->initFromPrsObject(aPrsObject);
734         aDlg->show();
735       }
736     }*/
737     break;
738   case VISU::TCUTLINES:
739     EditPrs3d<VISU::CutLines_i, VisuGUI_CutLinesDlg>(this, aPrs3d);
740     /*{
741       VISU::CutLines_i* aPrsObject = dynamic_cast<VISU::CutLines_i*>(aPrs3d);
742       if (aPrsObject) {
743         VisuGUI_CutLinesDlg* aDlg =
744           new VisuGUI_CutLinesDlg (GetDesktop(this), false, false);
745         aDlg->initFromPrsObject(aPrsObject);
746         aDlg->show();
747       }
748     }*/
749     break;
750   case VISU::TISOSURFACE:
751     EditPrs3d<VISU::IsoSurfaces_i, VisuGUI_IsoSurfacesDlg>(this, aPrs3d);
752     break;
753   case VISU::TVECTORS:
754     EditPrs3d<VISU::Vectors_i, VisuGUI_VectorsDlg>(this, aPrs3d);
755     break;
756   case VISU::TSTREAMLINES:
757     EditPrs3d<VISU::StreamLines_i, VisuGUI_StreamLinesDlg>(this, aPrs3d);
758     break;
759   case VISU::TPLOT3D:
760     EditPrs3d<VISU::Plot3D_i, VisuGUI_Plot3DDlg>(this, aPrs3d);
761     /*{
762       VISU::Plot3D_i* aPrsObject = dynamic_cast<VISU::Plot3D_i*>(aPrs3d);
763       if (aPrsObject) {
764         VisuGUI_Plot3DDlg* aDlg = new VisuGUI_Plot3DDlg();
765         aDlg->initFromPrsObject(aPrsObject);
766         aDlg->show();
767         myActiveDialogBox = aDlg;
768       }
769     }*/
770     break;
771   default:
772     return;
773   }
774
775   if (SVTK_ViewWindow* vw = GetViewWindow())
776     vw->highlight(anIO, 1);
777 }
778
779 void
780 VisuGUI::
781 OnEraseAll()
782 {
783   if (SVTK_ViewWindow* vw = GetViewWindow()) {
784     vw->unHighlightAll();
785     if (vtkRenderer *aRen = vw->getRenderer()) {
786       vtkActor *anActor;
787       vtkActorCollection *anActColl = aRen->GetActors();
788       for (anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL; ) {
789         if (anActor->GetVisibility() > 0)
790           if (VISU_Actor* anVISUActor = VISU_Actor::SafeDownCast(anActor)) {
791             anVISUActor = anVISUActor->GetParent();
792             anVISUActor->VisibilityOff();
793           }
794       }
795       vw->Repaint();
796     }
797   } else if (SPlot2d_Viewer* aPlot2d = GetPlot2dViewer(this, false)) {
798     aPlot2d->EraseAll();
799   }
800 }
801
802 void
803 VisuGUI::
804 OnMakeSurfaceframe()
805 {
806   ChangeRepresentation(this, VISU::SURFACEFRAME);
807 }
808
809 void
810 VisuGUI::
811 OnMakeInsideframe()
812 {
813   ChangeRepresentation(this, VISU::INSIDEFRAME);
814 }
815
816 void
817 VisuGUI::
818 OnMakeWireframe()
819 {
820   ChangeRepresentation(this, VISU::WIREFRAME);
821 }
822
823 void
824 VisuGUI::
825 OnMakeSurface()
826 {
827   ChangeRepresentation(this, VISU::SHADED);
828 }
829
830 void
831 VisuGUI::
832 OnMakePoints()
833 {
834   ChangeRepresentation(this, VISU::POINT);
835 }
836
837 void
838 VisuGUI::
839 OnMakeShrink()
840 {
841   ChangeRepresentation(this, VISU::SHRINK);
842 }
843
844 void
845 VisuGUI::
846 OnChangeColor()
847 {
848   Handle(SALOME_InteractiveObject) anIO;
849   CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
850   if (CORBA::is_nil(anObject)) return;
851   PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
852   if (!aServant.in()) return;
853
854   VISU::Prs3d_i* aPrs3d = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
855   if (!aPrs3d) return;
856
857   SVTK_ViewWindow* vw = GetViewWindow();
858   if (!vw) return;
859
860   VISU_Actor* anActor = GetActor(aPrs3d, vw);
861   if (!anActor) return;
862
863   VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrs3d);
864   VISU::DeformedShape_i* aDeformedShape = dynamic_cast<VISU::DeformedShape_i*>(aPrs3d);
865   SALOMEDS::Color anOldColor, aNewColor;
866   int aRepresent = anActor->GetRepresentation();
867   if (aMesh) {
868     switch (aRepresent) {
869       case VISU::POINT :
870         anOldColor = aMesh->GetNodeColor();
871         break;
872       case VISU::WIREFRAME :
873       case VISU::INSIDEFRAME :
874         anOldColor = aMesh->GetLinkColor();
875         break;
876       case VISU::SHADED :
877       case VISU::SURFACEFRAME :
878         anOldColor = aMesh->GetCellColor();
879         break;
880     }
881   } else if (aDeformedShape) {
882     anOldColor = aDeformedShape->GetColor();
883   } else {
884     return;
885   }
886
887   QColor aColor (int(255*anOldColor.R),
888                  int(255*anOldColor.G),
889                  int(255*anOldColor.B));
890   QColor aColorNew = QColorDialog::getColor(aColor, GetDesktop(this));
891   if (aColorNew.isValid()) {
892     aNewColor.R = aColorNew.red()/255.;
893     aNewColor.G = aColorNew.green()/255.;
894     aNewColor.B = aColorNew.blue()/255.;
895     if (aMesh) {
896       switch (aRepresent) {
897         case VISU::POINT :
898           aMesh->SetNodeColor(aNewColor);
899           break;
900         case VISU::WIREFRAME :
901         case VISU::INSIDEFRAME :
902           aMesh->SetLinkColor(aNewColor);
903           break;
904         case VISU::SHADED :
905         case VISU::SURFACEFRAME :
906           aMesh->SetCellColor(aNewColor);
907           break;
908       }
909     } else {
910       aDeformedShape->SetColor(aNewColor);
911     }
912     RecreateActor(this, aPrs3d);
913   }
914 }
915
916 void
917 VisuGUI::
918 OnChangeWireframeColor()
919 {
920   Handle(SALOME_InteractiveObject) anIO;
921   CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
922   if (CORBA::is_nil(anObject)) return;
923   PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
924   if (!aServant.in()) return;
925
926   VISU::Prs3d_i* aPrs3d = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
927   if (!aPrs3d) return;
928
929   SVTK_ViewWindow* vw = GetViewWindow();
930   if (!vw) return;
931
932   VISU_Actor* anActor = GetActor(aPrs3d, vw);
933   if (!anActor) return;
934
935   if (VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrs3d)) {
936     SALOMEDS::Color anOldColor = aMesh->GetLinkColor(), aNewColor;
937     QColor aColor (int(255*anOldColor.R),
938                    int(255*anOldColor.G),
939                    int(255*anOldColor.B));
940     QColor aColorNew = QColorDialog::getColor(aColor, GetDesktop(this));
941     if (aColorNew.isValid()) {
942       aNewColor.R = aColorNew.red()/255.;
943       aNewColor.G = aColorNew.green()/255.;
944       aNewColor.B = aColorNew.blue()/255.;
945       aMesh->SetLinkColor(aNewColor);
946       RecreateActor(this, aMesh);
947     }
948   }
949 }
950
951 void
952 VisuGUI::
953 OnChangeOpacity()
954 {
955   Handle(SALOME_InteractiveObject) anIO;
956   CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
957   if (CORBA::is_nil(anObject)) return;
958   PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
959   if (!aServant.in()) return;
960
961   VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
962   if (!aPrsObject) return;
963
964   SVTK_ViewWindow* vw = GetViewWindow();
965   if (!vw) return;
966
967   VISU_Actor* anActor = GetActor(aPrsObject, vw);
968   if (!anActor) return;
969
970   VisuGUI_CursorDlg* CursorDlg =
971     new VisuGUI_CursorDlg (GetDesktop(this), tr("DLG_OPACITY_TITLE"), TRUE);
972
973   CursorDlg->Comment1->setText(tr("DLG_OPACITY_CMT1"));
974   CursorDlg->Comment2->setText(tr("DLG_OPACITY_CMT2"));
975   CursorDlg->SpinBox1->setMinValue(0);
976   CursorDlg->SpinBox1->setMaxValue(100);
977
978   float oldopac = anActor->GetOpacity();
979   int intopac = int(oldopac*100. + 0.5);
980   CursorDlg->SpinBox1->setValue(intopac);
981
982   int ret = CursorDlg->exec();
983   if (ret == 1) {
984     intopac = CursorDlg->SpinBox1->value();
985     float newopac = intopac/100.;
986     anActor->SetOpacity(newopac);
987   }
988   delete CursorDlg;
989 }
990
991 void
992 VisuGUI::
993 OnChangeLines()
994 {
995   Handle(SALOME_InteractiveObject) anIO;
996   CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
997   if (CORBA::is_nil(anObject)) return;
998   PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
999   if (!aServant.in()) return;
1000
1001   VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
1002   if (!aPrsObject) return;
1003
1004   SVTK_ViewWindow* vw = GetViewWindow();
1005   if (!vw) return;
1006
1007   VISU_Actor* anActor = GetActor(aPrsObject, vw);
1008   if (!anActor) return;
1009
1010   VisuGUI_CursorDlg* CursorDlg =
1011     new VisuGUI_CursorDlg (GetDesktop(this), tr("DLG_LINEWIDTH_TITLE"), TRUE);
1012
1013   CursorDlg->Comment1->setText(tr("DLG_LINEWIDTH_CMT1"));
1014   CursorDlg->Comment2->setText(tr("DLG_LINEWIDTH_CMT2"));
1015   CursorDlg->SpinBox1->setMinValue(1);
1016   CursorDlg->SpinBox1->setMaxValue(10);
1017
1018   float oldlwid = anActor->GetLineWidth();
1019   int intlwid = int(oldlwid);
1020   CursorDlg->SpinBox1->setValue(intlwid);
1021
1022   int ret = CursorDlg->exec();
1023   if (ret == 1) {
1024     intlwid  = CursorDlg->SpinBox1->value();
1025     float newlwid = intlwid;
1026     anActor->SetLineWidth(newlwid);
1027   }
1028   delete CursorDlg;
1029 }
1030
1031 void
1032 VisuGUI::
1033 OnShowTable()
1034 {
1035   Handle(SALOME_InteractiveObject) anIO;
1036   CORBA::Object_var anObject = GetSelectedObj( this, &anIO );
1037   _PTR(SObject) SO;
1038   if ( !CORBA::is_nil( anObject ) ) {
1039     VISU::Base_var aVisuObj = VISU::Base::_narrow( anObject );
1040     if ( !CORBA::is_nil( aVisuObj ) && aVisuObj->GetType() == VISU::TTABLE ) {
1041       CORBA::Object_ptr aTable = VISU::Table::_narrow( anObject );
1042       if( !CORBA::is_nil( aTable ) ) {
1043         VISU::Table_i* table = dynamic_cast<VISU::Table_i*>( VISU::GetServant(aTable).in() );
1044         if ( table ) {
1045           SO = GetCStudy( GetAppStudy( this ) )->FindObjectID( table->GetObjectEntry() );
1046         }
1047       }
1048     }
1049   } else {
1050     // possibly this is Table SObject
1051     SO = GetCStudy( GetAppStudy( this ) )->FindObjectID( anIO->getEntry() );
1052   }
1053
1054   if( !IsSObjectTable( SO ) )
1055     return;
1056
1057   VisuGUI_TableDlg* dlg = new VisuGUI_TableDlg( GetDesktop( this ),
1058                                                SO,
1059                                                false,
1060                                                //SAL2670 Orientation of show tables
1061                                                VisuGUI_TableDlg::ttAuto,
1062                                                Qt::Vertical );
1063   dlg->show();
1064 }
1065
1066 void
1067 VisuGUI::
1068 OnCreateTable()
1069 {
1070   Handle(SALOME_InteractiveObject) anIO;
1071   CORBA::Object_var anObject = GetSelectedObj( this, &anIO );
1072   _PTR(Study) aStudy = GetCStudy( GetAppStudy( this ) );
1073   _PTR(SObject) aSObject = aStudy->FindObjectID(anIO->getEntry());
1074   VISU::CutLines_var aCutLines = VISU::CutLines::_narrow( anObject );
1075   if(!aCutLines->_is_nil() || IsSObjectTable(aSObject)) {
1076     GetVisuGen( this )->CreateTable( aSObject->GetID().c_str() );
1077     updateObjBrowser();
1078   }
1079 }
1080
1081 void
1082 VisuGUI::
1083 OnDeleteObjects()
1084 {
1085   _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1086   if (CheckLock(aCStudy))
1087     return;
1088
1089   SALOME_ListIO aList;
1090   SalomeApp_SelectionMgr* mgr = GetSelectionMgr(this);
1091   mgr->selectedObjects(aList);
1092   int i = 0, nbSelected = aList.Extent();
1093   if (nbSelected < 1) return;
1094
1095   const char* entries [nbSelected];
1096   Handle(SALOME_InteractiveObject) anIO;
1097   for (SALOME_ListIteratorOfListIO it (aList); it.More(); it.Next()) {
1098     anIO = it.Value();
1099     if (anIO->hasEntry())
1100       entries[i++] = anIO->getEntry();
1101   }
1102   nbSelected = i;
1103   if (nbSelected < 1) return;
1104
1105   // There is a transaction
1106   _PTR(StudyBuilder) aStudyBuilder = aCStudy->NewBuilder();
1107   aStudyBuilder->NewCommand();
1108
1109   for (i = 0; i < nbSelected; i++) {
1110     _PTR(SObject) aSObject = aCStudy->FindObjectID(entries[i]);
1111     if (aSObject) {
1112       DeleteSObject(this, aCStudy, aSObject);
1113     }
1114   }
1115
1116   // Finish transaction
1117   aStudyBuilder->CommitCommand();
1118
1119   //GetActiveStudy()->unHighlightAll();
1120   updateObjBrowser(true);
1121 }
1122
1123 void
1124 VisuGUI::
1125 OnPlotData()
1126 {
1127   Handle(SALOME_InteractiveObject) anIO;
1128   CORBA::Object_var anObject = GetSelectedObj( this, &anIO );
1129   _PTR(SObject) SO;
1130   _PTR(GenericAttribute) anAttr;
1131   _PTR(AttributeName)    aName;
1132   QString SOName;
1133   _PTR(Study) aStudy = GetCStudy( GetAppStudy( this ) );
1134
1135   if ( !CORBA::is_nil( anObject ) ) {
1136     VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
1137     if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TTABLE) {
1138       // Table (VISU object) is selected
1139       CORBA::Object_ptr aTbl = VISU::Table::_narrow( anObject );
1140       if( !CORBA::is_nil( aTbl ) ) {
1141         VISU::Table_i* table = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTbl).in());
1142         if ( table ) {
1143           _PTR(SObject) SO = aStudy->FindObjectID( table->GetObjectEntry() );
1144           if ( IsSObjectTable(SO) ) {
1145             // get name of SObject
1146             if ( SO->FindAttribute( anAttr, "AttributeName" ) ) {
1147               aName = anAttr;
1148               SOName = QString( aName->Value().c_str() );
1149             }
1150             SPlot2d_SetupPlot2dDlg* dlg = new SPlot2d_SetupPlot2dDlg( SO, GetDesktop( this ) );
1151             if ( dlg->exec() == QDialog::Accepted ) {
1152               if ( !IsStudyLocked( aStudy ) ) {
1153                 // if study is not locked - create new container, create curves and insert them
1154                 // into container, then plot container if current viewer is of VIEW_PLOT2D type
1155                 int horIndex;
1156                 QValueList<int> verIndices;
1157                 dlg->getCurvesSource( horIndex, verIndices );
1158                 if ( horIndex >= 0 && verIndices.count() > 0 ) {
1159                   CORBA::Object_var aContainer = GetVisuGen(this)->CreateContainer();
1160                   if( !CORBA::is_nil( aContainer ) ) {
1161                     VISU::Container_i* pContainer =
1162                       dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
1163                     if ( pContainer ) {
1164                       for ( int i = 0; i < verIndices.count(); i++ ) {
1165                         CORBA::Object_var aNewCurve =
1166                           GetVisuGen(this)->CreateCurve( table->_this(), horIndex+1, verIndices[i]+1 );
1167                         if( !CORBA::is_nil( aNewCurve ) ) {
1168                           VISU::Curve_i* pCrv =
1169                             dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aNewCurve).in());
1170                           if ( pCrv ) {
1171                             bool isAuto;
1172                             int  marker, line, lineWidth;
1173                             QColor color;
1174                             if ( dlg->getCurveAttributes(verIndices[i], isAuto, marker,
1175                                                          line, lineWidth, color) && !isAuto ) {
1176                               SALOMEDS::Color c;
1177                               c.R = color.red()  /255.;
1178                               c.G = color.green()/255.;
1179                               c.B = color.blue() /255.;
1180                               pCrv->SetColor( c );
1181                               pCrv->SetMarker( ( VISU::Curve::MarkerType )marker );
1182                               pCrv->SetLine( ( VISU::Curve::LineType )line, lineWidth );
1183                             }
1184                             pContainer->AddCurve( pCrv->_this() );
1185                           }
1186                         }
1187                       }
1188                       updateObjBrowser();
1189                       PlotContainer( this, pContainer, VISU::eDisplay );
1190                     }
1191                   }
1192                 }
1193               }
1194               else {
1195                 // if study is locked just get curves info and plot them
1196                 // if current viewer is of VIEW_PLOT2D type
1197                 QPtrList<Plot2d_Curve> container;
1198                 dlg->getCurves( container );
1199                 if ( !container.isEmpty() ) {
1200                   GetPlot2dViewer( this )->getActiveViewFrame()->displayCurves( container, true );
1201                   GetPlot2dViewer( this )->getActiveViewFrame()->setTitle( SOName );
1202                 }
1203               }
1204             }
1205             delete dlg;
1206           }
1207         }
1208       }
1209     }
1210   }
1211   else if ( !anIO.IsNull() ) {
1212     // check if Table SObject is selected
1213     SO = aStudy->FindObjectID( anIO->getEntry() );
1214     if ( IsSObjectTable(SO) ) {
1215       // get name of SObject
1216       if ( SO->FindAttribute( anAttr, "AttributeName" ) ) {
1217         aName = anAttr;
1218         SOName = QString( aName->Value().c_str() );
1219       }
1220       SPlot2d_SetupPlot2dDlg* dlg = new SPlot2d_SetupPlot2dDlg( SO, GetDesktop( this ) );
1221       if ( dlg->exec() == QDialog::Accepted ) {
1222         if ( !IsStudyLocked( aStudy ) ) {
1223           // if study is not locked - create new table and container objects, create curves
1224           // and insert them into container, then plot container if current viewer is of VIEW_PLOT2D type
1225           int horIndex;
1226           QValueList<int> verIndices;
1227           dlg->getCurvesSource( horIndex, verIndices );
1228           if ( horIndex >= 0 && verIndices.count() > 0 ) {
1229             CORBA::Object_var aTable = GetVisuGen(this)->CreateTable( SO->GetID().c_str() );
1230             CORBA::Object_var aContainer = GetVisuGen(this)->CreateContainer();
1231             if ( !CORBA::is_nil( aTable ) && !CORBA::is_nil( aContainer ) ) {
1232               VISU::Table_i*     pTable     = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTable).in());
1233               VISU::Container_i* pContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
1234
1235               if ( pContainer && pTable ) {
1236                 for ( int i = 0; i < verIndices.count(); i++ ) {
1237                   CORBA::Object_var aNewCurve = GetVisuGen(this)->CreateCurve
1238                     ( pTable->_this(), horIndex+1, verIndices[i]+1 );
1239                   if( !CORBA::is_nil( aNewCurve ) ) {
1240                     VISU::Curve_i* pCrv = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aNewCurve).in());
1241                     if ( pCrv ) {
1242                       bool isAuto;
1243                       int  marker, line, lineWidth;
1244                       QColor color;
1245                       if ( dlg->getCurveAttributes(verIndices[i], isAuto, marker,
1246                                                    line, lineWidth, color) && !isAuto ) {
1247                         SALOMEDS::Color c;
1248                         c.R = color.red()/255.;
1249                         c.G = color.green()/255.;
1250                         c.B = color.blue()/255.;
1251                         pCrv->SetColor( c );
1252                         pCrv->SetMarker( ( VISU::Curve::MarkerType )marker );
1253                         pCrv->SetLine( ( VISU::Curve::LineType )line, lineWidth );
1254                       }
1255                       pContainer->AddCurve( pCrv->_this() );
1256                     }
1257                   }
1258                 }
1259                 updateObjBrowser();
1260                 PlotContainer( this, pContainer, VISU::eDisplay );
1261               }
1262             }
1263           }
1264         } else {
1265           // if study is locked just get curves info and plot them
1266           QPtrList<Plot2d_Curve> container;
1267           dlg->getCurves( container );
1268           if ( !container.isEmpty() ) {
1269             GetPlot2dViewer( this )->getActiveViewFrame()->displayCurves( container, true );
1270             GetPlot2dViewer( this )->getActiveViewFrame()->setTitle( SOName );
1271           }
1272         }
1273       }
1274       delete dlg;
1275     }
1276   }
1277 }
1278
1279 void
1280 VisuGUI::
1281 OnCurveProperties()
1282 {
1283   SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1284   SALOME_ListIO aListIO;
1285   aSelectionMgr->selectedObjects(aListIO);
1286   if (aListIO.Extent() != 1) return;
1287
1288   SalomeApp_Study* aAppStudy = GetAppStudy(this);
1289   const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
1290   CORBA::Object_var anObject = GetSelectedObj( aAppStudy, anIO->getEntry() );
1291   if (CORBA::is_nil( anObject )) return;
1292
1293   VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
1294   if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCURVE) {
1295     // Curve object
1296     CORBA::Object_ptr aCurve = VISU::Curve::_narrow( anObject );
1297     if( !CORBA::is_nil( aCurve ) ) {
1298       VISU::Curve_i* aDSCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
1299       if ( aDSCurve && (!IsStudyLocked( GetCStudy(aAppStudy) )) ) {
1300         Plot2d_SetupCurveDlg aDlg(GetDesktop( this ));
1301
1302         aDlg.setLine( (int)aDSCurve->GetLine(), aDSCurve->GetLineWidth() );
1303         aDlg.setMarker( (int)aDSCurve->GetMarker() );
1304         SALOMEDS::Color aColor = aDSCurve->GetColor();
1305         aDlg.setColor( QColor( (int)(aColor.R*255.), (int)(aColor.G*255.), (int)(aColor.B*255.) ) );
1306         if( aDlg.exec() == QDialog::Accepted ) {
1307           aDSCurve->SetLine( (VISU::Curve::LineType)aDlg.getLine(), aDlg.getLineWidth() );
1308           aDSCurve->SetMarker( (VISU::Curve::MarkerType)aDlg.getMarker());
1309           SALOMEDS::Color newColor;
1310           newColor.R = aDlg.getColor().red()/255.;
1311           newColor.G = aDlg.getColor().green()/255.;
1312           newColor.B = aDlg.getColor().blue()/255.;
1313           aDSCurve->SetColor( newColor );
1314           PlotCurve(this, aDSCurve, VISU::eDisplay);
1315         }
1316       }
1317     }
1318   }
1319 }
1320
1321 void
1322 VisuGUI::
1323 OnClearContainer()
1324 {
1325   _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1326   if (CheckLock(aCStudy))
1327     return;
1328   Handle(SALOME_InteractiveObject) anIO;
1329   CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
1330   if (anIO.IsNull() || CORBA::is_nil(anObject))
1331     return;
1332
1333   VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
1334   if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCONTAINER) {
1335     // Container object
1336     CORBA::Object_ptr aCnt = VISU::Container::_narrow(anObject);
1337     if (!CORBA::is_nil(aCnt)) {
1338       VISU::Container_i* container = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aCnt).in());
1339       if (container && container->GetNbCurves() > 0) {
1340         container->Clear();
1341         updateObjBrowser();
1342       }
1343     }
1344   }
1345 }
1346
1347 void
1348 VisuGUI::
1349 OnEditContainer()
1350 {
1351   Handle(SALOME_InteractiveObject) anIO;
1352   CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
1353   if (CORBA::is_nil(anObject)) return;
1354
1355   PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
1356   if (!aServant.in()) return;
1357   VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(aServant.in());
1358   if (!aContainer) return;
1359
1360   //VisuGUI_EditContainerDlg* aDlg = new VisuGUI_EditContainerDlg (GetDesktop(this));
1361   VisuGUI_EditContainerDlg* aDlg = new VisuGUI_EditContainerDlg (this);
1362   aDlg->initFromPrsObject(aContainer);
1363   if (aDlg->exec()) {
1364     aDlg->storeToPrsObject(aContainer);
1365     updateObjBrowser(true);
1366   }
1367   delete aDlg;
1368 }
1369
1370 void
1371 VisuGUI::
1372 OnSaveViewParams()
1373 {
1374   _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1375   if (CheckLock(aCStudy))
1376     return;
1377
1378   SUIT_ViewManager* aViewMgr = getApp()->activeViewManager();
1379   if (aViewMgr->getType() != SVTK_Viewer::Type())
1380     return;
1381
1382   SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1383   SALOME_ListIO aListIO;
1384   aSelectionMgr->selectedObjects(aListIO);
1385   if (aListIO.Extent() > 1)
1386     return;
1387
1388   if (aListIO.Extent() == 0) {
1389     VISU::View3D_i::SaveViewParams(aViewMgr, VISU::View3D_i::GenerateViewParamsName().latin1());
1390   } else {
1391     const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
1392     VISU::View3D_i::SaveViewParams(aViewMgr, anIO->getName());
1393   }
1394   updateObjBrowser();
1395 }
1396
1397 void
1398 VisuGUI::
1399 OnRestoreViewParams()
1400 {
1401   SUIT_ViewManager* aViewMgr = getApp()->activeViewManager();
1402   if (aViewMgr->getType() != SVTK_Viewer::Type())
1403     return;
1404
1405   SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1406   SALOME_ListIO aListIO;
1407   aSelectionMgr->selectedObjects(aListIO);
1408   if (aListIO.Extent() != 1)
1409     return;
1410
1411   const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
1412   //jfa tmp:VISU::View3D_i::RestoreViewParams(aViewMgr, anIO->getName());
1413   _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));//jfa tmp
1414   _PTR(SObject) aSObj = aCStudy->FindObjectID(anIO->getEntry());//jfa tmp
1415   VISU::View3D_i::RestoreViewParams(aViewMgr, aSObj->GetName().c_str());//jfa tmp
1416 }
1417
1418 void
1419 VisuGUI::
1420 OnRename()
1421 {
1422   _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1423   if (CheckLock(aCStudy))
1424     return;
1425
1426   Handle(SALOME_InteractiveObject) anIO;
1427   CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
1428
1429   _PTR(SObject) aSObj = aCStudy->FindObjectID(anIO->getEntry());
1430   if (!aSObj) return;
1431
1432   //TEST DU PARENT == VISU
1433   _PTR(GenericAttribute) anAttr;
1434   if (aSObj->FindAttribute(anAttr, "AttributeName")) {
1435     _PTR(AttributeName) aName (anAttr);
1436     QString Name = VisuGUI_NameDlg::getName( GetDesktop( this ), aName->Value().c_str() );
1437     if (!Name.isEmpty()) {
1438       QApplication::setOverrideCursor(Qt::waitCursor);
1439
1440       // rename specific objects
1441       if (!CORBA::is_nil(anObject)) {
1442         VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
1443         if (!CORBA::is_nil(aVisuObj)) {
1444           switch (aVisuObj->GetType()) {
1445             case VISU::TCURVE: // Curve object
1446             {
1447               CORBA::Object_ptr aCurve = VISU::Curve::_narrow(anObject);
1448               if (!CORBA::is_nil(aCurve)) {
1449                 VISU::Curve_i* curve =
1450                   dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
1451                 if (curve)
1452                   curve->SetName(Name.latin1());
1453               }
1454               break;
1455             }
1456             case VISU::TTABLE: // Table object
1457             {
1458               CORBA::Object_ptr aTable = VISU::Table::_narrow(anObject);
1459               if (!CORBA::is_nil(aTable)) {
1460                 VISU::Table_i* table =
1461                   dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTable).in());
1462                 if (table)
1463                   table->SetName(Name.latin1());
1464               }
1465               break;
1466             }
1467             case VISU::TCONTAINER: // Container object
1468             {
1469               CORBA::Object_ptr aContainer = VISU::Container::_narrow(anObject);
1470               if (!CORBA::is_nil(aContainer)) {
1471                 VISU::Container_i* container =
1472                   dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
1473                 if (container)
1474                   container->SetName(Name.latin1());
1475               }
1476               break;
1477             }
1478             default:
1479             {
1480             }
1481           }
1482         }
1483       }
1484
1485       // rename the study object
1486       //getApp()->activeStudy()->renameIObject(anIO, Name);
1487       aName->SetValue(Name.latin1()); // rename the SObject
1488       anIO->setName(Name.latin1()); // rename the InteractiveObject
1489       updateObjBrowser(false);
1490
1491       QApplication::restoreOverrideCursor();
1492     }
1493   }
1494 }
1495
1496 void
1497 VisuGUI::
1498 OnClippingPlanes()
1499 {
1500   new VisuGUI_ClippingDlg (this, "", false);
1501 }
1502
1503 void
1504 VisuGUI::
1505 OnSweep()
1506 {
1507   // GetSelectedPrs3d
1508   Handle(SALOME_InteractiveObject) anIO;
1509   CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
1510   if (CORBA::is_nil(anObject)) return;
1511   PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
1512   if (!aServant.in()) return;
1513
1514   VISU::ScalarMap_i* aPrsObject = dynamic_cast<VISU::ScalarMap_i*>(aServant.in());
1515   if (!aPrsObject) return;
1516
1517   SVTK_ViewWindow* vw = GetViewWindow();
1518   if (!vw) return;
1519
1520   VISU_Actor* aActor = GetActor(aPrsObject, vw);
1521   if (!aActor) return;
1522
1523   if (!aActor->GetVisibility()) {
1524     aActor->VisibilityOn();
1525   }
1526
1527   // Get sweep parameters
1528   SUIT_ResourceMgr* aResourceMgr = GetResourceMgr();
1529
1530   double aTempoDbl = aResourceMgr->doubleValue("VISU", "sweeping_time_step", 0.1);
1531   int aTemp = int(1.E6 * aTempoDbl);
1532
1533   int aCycles = aResourceMgr->integerValue("VISU", "sweeping_number_cycles", 1);
1534   int aSteps  = aResourceMgr->integerValue("VISU", "sweeping_time_step", 40);
1535
1536   // Sweep
1537   QApplication::setOverrideCursor(Qt::waitCursor);
1538   try {
1539     for (int j = 0; j < aCycles; j++) {
1540       for (int i = 0; i <= aSteps; i++) {
1541         float aPercents = float(i)/aSteps;
1542         aPrsObject->SetMapScale(aPercents);
1543         aPrsObject->UpdateActor(aActor);
1544         vw->getRenderWindow()->getRenderWindow()->Render();
1545         usleep(aTemp);
1546       }
1547     }
1548   } catch (std::exception& exc) {
1549     INFOS("Follow exception was occured :\n" << exc.what());
1550   } catch (...) {
1551     INFOS("Unknown exception was occured!");
1552   }
1553   QApplication::restoreOverrideCursor();
1554 }
1555
1556 void
1557 VisuGUI::
1558 OnTimeAnimation()
1559 {
1560   _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1561   VisuGUI_TimeAnimationDlg* aAnimationDlg =
1562 //    new VisuGUI_TimeAnimationDlg(GetDesktop(this), aCStudy);
1563     new VisuGUI_TimeAnimationDlg (this, aCStudy);
1564
1565   SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1566   SALOME_ListIO aListIO;
1567   aSelectionMgr->selectedObjects(aListIO);
1568
1569   bool isDefined = false;
1570   long aNbTimes = 0;
1571   SALOME_ListIteratorOfListIO It (aListIO);
1572   for (; It.More(); It.Next()) {
1573     _PTR(SObject) aSObject = aCStudy->FindObjectID(It.Value()->getEntry());
1574     if (!aSObject) continue;
1575     if (getValue(aSObject, "myComment") == QString("FIELD")) {
1576       long aNumber = getValue(aSObject, "myNbTimeStamps").toLong();
1577       if (aNumber > 1) {
1578         if (!isDefined) {
1579           aNbTimes = aNumber;
1580           aAnimationDlg->addField(aSObject);
1581           isDefined = true;
1582         } else if (aNbTimes == aNumber) {
1583           aAnimationDlg->addField(aSObject);
1584         }
1585       }
1586     }
1587   }
1588   if (isDefined) aAnimationDlg->show();
1589   else delete aAnimationDlg;
1590 }
1591
1592 //************************************************************************
1593 void
1594 VisuGUI::
1595 OnShowAnimation()
1596 {
1597   SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1598   SALOME_ListIO aListIO;
1599   aSelectionMgr->selectedObjects(aListIO);
1600
1601   if (aListIO.Extent() != 1)
1602     return;
1603
1604   const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
1605
1606   _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1607
1608   _PTR(SObject) aSObj = aCStudy->FindObjectID(anIO->getEntry());
1609   if (!aSObj) return;
1610
1611   VISU::Storable::TRestoringMap aMap;
1612   _PTR(GenericAttribute) anAttr;
1613   if (!aSObj->FindAttribute(anAttr, "AttributeComment")) return;
1614
1615   _PTR(AttributeComment) aComment (anAttr);
1616   string aComm = aComment->Value();
1617   QString strIn (aComm.c_str());
1618   VISU::Storable::StrToMap(strIn, aMap);
1619   bool isExist;
1620   VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt();
1621   if (aType != VISU::TANIMATION) return;
1622
1623   VisuGUI_TimeAnimationDlg* aAnimationDlg =
1624     new VisuGUI_TimeAnimationDlg(this, aCStudy);
1625   aAnimationDlg->restoreFromStudy(aSObj);
1626   aAnimationDlg->show();
1627 }
1628
1629 void
1630 VisuGUI::
1631 OnCopyPresentation()
1632 {
1633   _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1634   if (CheckLock(aCStudy))
1635     return;
1636
1637   Handle(SALOME_InteractiveObject) anIO;
1638   CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
1639   if (CORBA::is_nil(anObject)) return;
1640   PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
1641   if (!aServant.in()) return;
1642
1643   VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
1644   if (!aPrsObject) return;
1645
1646   switch (aPrsObject->GetType()) {
1647   case VISU::TMESH:
1648     {
1649       VISU::Mesh_i* aMeshPrs = dynamic_cast<VISU::Mesh_i*>(aPrsObject);
1650       VISU::Mesh_i* aSameMesh = new VISU::Mesh_i(aMeshPrs->GetResult());
1651       aSameMesh->SameAs(aMeshPrs);
1652       UpdateViewer(this, aSameMesh);
1653     }
1654     break;
1655   case VISU::TSCALARMAP:
1656     {
1657       VISU::ScalarMap_i* aScalarPrs = dynamic_cast<VISU::ScalarMap_i*>(aPrsObject);
1658       VISU::ScalarMap_i* aSameScalar = new VISU::ScalarMap_i(aScalarPrs->GetResult(),true);
1659       aSameScalar->SameAs(aScalarPrs);
1660       UpdateViewer(this, aSameScalar);
1661     }
1662     break;
1663   case VISU::TDEFORMEDSHAPE:
1664     {
1665       VISU::DeformedShape_i* aDefPrs = dynamic_cast<VISU::DeformedShape_i*>(aPrsObject);
1666       VISU::DeformedShape_i* aSameDeformed = new VISU::DeformedShape_i(aDefPrs->GetResult(),true);
1667       aSameDeformed->SameAs(aDefPrs);
1668       UpdateViewer(this, aSameDeformed);
1669     }
1670     break;
1671   case VISU::TCUTPLANES:
1672     {
1673       VISU::CutPlanes_i* aCutPrs = dynamic_cast<VISU::CutPlanes_i*>(aPrsObject);
1674       VISU::CutPlanes_i* aSameCut = new VISU::CutPlanes_i(aCutPrs->GetResult(),true);
1675       aSameCut->SameAs(aCutPrs);
1676       UpdateViewer(this, aSameCut);
1677     }
1678     break;
1679   case VISU::TCUTLINES:
1680     {
1681       VISU::CutLines_i* aCutPrs = dynamic_cast<VISU::CutLines_i*>(aPrsObject);
1682       VISU::CutLines_i* aSameCut = new VISU::CutLines_i(aCutPrs->GetResult(),true);
1683       aSameCut->SameAs(aCutPrs);
1684       UpdateViewer(this, aSameCut);
1685     }
1686     break;
1687   case VISU::TISOSURFACE:
1688     {
1689       VISU::IsoSurfaces_i* aIsoPrs = dynamic_cast<VISU::IsoSurfaces_i*>(aPrsObject);
1690       VISU::IsoSurfaces_i* aSameIso = new VISU::IsoSurfaces_i(aIsoPrs->GetResult(),true);
1691       aSameIso->SameAs(aIsoPrs);
1692       UpdateViewer(this, aSameIso);
1693     }
1694     break;
1695   case VISU::TSTREAMLINES:
1696     {
1697       VISU::StreamLines_i* aLinesPrs = dynamic_cast<VISU::StreamLines_i*>(aPrsObject);
1698       VISU::StreamLines_i* aSameLines = new VISU::StreamLines_i(aLinesPrs->GetResult(),true);
1699       aSameLines->SameAs(aLinesPrs);
1700       UpdateViewer(this, aSameLines);
1701     }
1702     break;
1703   case VISU::TVECTORS:
1704     {
1705       VISU::Vectors_i* aVectorsPrs = dynamic_cast<VISU::Vectors_i*>(aPrsObject);
1706       VISU::Vectors_i* aSameVectors = new VISU::Vectors_i(aVectorsPrs->GetResult(),true);
1707       aSameVectors->SameAs(aVectorsPrs);
1708       UpdateViewer(this, aSameVectors);
1709     }
1710     break;
1711   case VISU::TPLOT3D:
1712     {
1713       VISU::Plot3D_i* aPlot3DPrs = dynamic_cast<VISU::Plot3D_i*>(aPrsObject);
1714       VISU::Plot3D_i* aSamePlot3D = new VISU::Plot3D_i(aPlot3DPrs->GetResult());
1715       aSamePlot3D->SameAs(aPlot3DPrs);
1716       UpdateViewer(this, aSamePlot3D);
1717     }
1718     break;
1719   }
1720   updateObjBrowser();
1721 }
1722
1723 void
1724 VisuGUI::
1725 OnSelectionInfo()
1726 {
1727   if (GetViewWindow())
1728     (new VisuGUI_SelectionDlg(GetDesktop(this)))->show();
1729   else
1730     SUIT_MessageBox::warn1(GetDesktop(this),
1731                            tr("WRN_VISU"),
1732                            tr("ERR_ACTIVATE_VIEW3D"),
1733                            tr("BUT_OK") );
1734 }
1735
1736 void
1737 VisuGUI::
1738 OnScaling()
1739 {
1740   VisuGUI_NonIsometricDlg* m_NonIsoDlg =
1741     new VisuGUI_NonIsometricDlg (GetDesktop(this), "m_NonIsoDlg",
1742                                  false, Qt::WDestructiveClose);
1743   m_NonIsoDlg->show();
1744 }
1745
1746 void
1747 VisuGUI::
1748 OnCubeAxes()
1749 {
1750   //Show dialog that allows to select scale function and corresponding scale factor
1751   VisuGUI_CubeAxesDlg* aDlg = new VisuGUI_CubeAxesDlg (GetDesktop(this));
1752   aDlg->show();
1753 }
1754
1755 void
1756 VisuGUI::
1757 OnMergeScalarBars()
1758 {
1759   SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1760   SALOME_ListIO aListIO;
1761   aSelectionMgr->selectedObjects(aListIO);
1762
1763   SALOME_ListIteratorOfListIO It (aListIO);
1764
1765   // first find the bounds
1766   double aMin, aMax; bool first = true;
1767   for (; It.More(); It.Next()) {
1768     Handle(SALOME_InteractiveObject)& anIO = It.Value();
1769     std::vector<VISU::Prs3d_i*> aPrsList = GetPrs3dList(this, anIO);
1770     if (!aPrsList.empty()) {
1771       for (int i = 0, n = aPrsList.size(); i < n; i++) {
1772         VISU::Prs3d_i* aPrsObject = aPrsList[i];
1773         if (aPrsObject) {
1774           VISU::ScalarMap_i* aScalar = dynamic_cast<VISU::ScalarMap_i*>(aPrsObject);
1775           if (aScalar) {
1776             if (first) {
1777               first = false;
1778               aMin = aScalar->GetMin(); aMax = aScalar->GetMax();
1779             } else {
1780               if (aScalar->GetMin() < aMin) aMin = aScalar->GetMin();
1781               if (aScalar->GetMax() > aMax) aMax = aScalar->GetMax();
1782             }
1783           }
1784         }
1785       }
1786     }
1787   }
1788
1789   // set the computed range to every selected ScalarMap
1790   bool update = false;
1791   for (It.Initialize(aListIO); It.More(); It.Next() ) {
1792     Handle(SALOME_InteractiveObject)& anIO = It.Value();
1793     std::vector<VISU::Prs3d_i*> aPrsList = GetPrs3dList(this, anIO);
1794     if (!aPrsList.empty()) {
1795       for (int i = 0, n = aPrsList.size(); i < n; i++) {
1796         VISU::Prs3d_i* aPrsObject = aPrsList[i];
1797         if(aPrsObject){
1798           VISU::ScalarMap_i* aScalar = dynamic_cast<VISU::ScalarMap_i*>(aPrsObject);
1799           if (aScalar) {
1800             aScalar->SetRange(aMin, aMax);
1801             RecreateActor(this, aScalar);
1802             update = true;
1803           }
1804         }
1805       }
1806     }
1807   }
1808   if (update) {
1809     if (SVTK_ViewWindow* vw = GetViewWindow(this)) {
1810 //if (vw->getRenderer()->GetActors()->GetNumberOfItems() > 0) {
1811         vw->getRenderer()->ResetCameraClippingRange();
1812         vw->Repaint();
1813 //}
1814     }
1815   }
1816 }
1817
1818 void
1819 VisuGUI::
1820 OnFreeScalarBars()
1821 {
1822   SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1823   SALOME_ListIO aListIO;
1824   aSelectionMgr->selectedObjects(aListIO);
1825
1826   SALOME_ListIteratorOfListIO It (aListIO);
1827
1828   // restore the source range for every ScalarMap
1829   bool update = false;
1830   for (; It.More(); It.Next()) {
1831     Handle(SALOME_InteractiveObject)& anIO = It.Value();
1832     std::vector<VISU::Prs3d_i*> aPrsList = GetPrs3dList(this, anIO);
1833     if (!aPrsList.empty()) {
1834       for (int i = 0, n = aPrsList.size(); i < n; i++) {
1835         VISU::Prs3d_i* aPrsObject = aPrsList[i];
1836         if (aPrsObject) {
1837           VISU::ScalarMap_i* aScalar = dynamic_cast<VISU::ScalarMap_i*>(aPrsObject);
1838           if (aScalar) {
1839             aScalar->SetSourceRange();
1840             RecreateActor(this, aScalar);
1841             update = true;
1842           }
1843         }
1844       }
1845     }
1846   }
1847   if (update) {
1848     if (SVTK_ViewWindow* vw = GetViewWindow(this)) {
1849 //if (vw->getRenderer()->GetActors()->GetNumberOfItems() > 0) {
1850         vw->getRenderer()->ResetCameraClippingRange();
1851         vw->Repaint();
1852 //}
1853     }
1854   }
1855 }
1856
1857 void
1858 VisuGUI::
1859 OnTranslatePrs()
1860 {
1861   if(MYDEBUG) MESSAGE("VisuGUI::OnTranslatePrs");
1862   VisuGUI_OffsetDlg* aDlg = new VisuGUI_OffsetDlg (this);
1863
1864   _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1865
1866   SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1867   SALOME_ListIO aListIO;
1868   aSelectionMgr->selectedObjects(aListIO);
1869
1870   SALOME_ListIteratorOfListIO It (aListIO);
1871   for (; It.More(); It.Next()) {
1872     Handle(SALOME_InteractiveObject)& anIO = It.Value();
1873     if (anIO->hasEntry()) {
1874       _PTR(SObject) aSObject = aCStudy->FindObjectID(anIO->getEntry());
1875       if (aSObject) {
1876         CORBA::Object_var aCORBAObject = VISU::ClientSObjectToObject(aSObject);
1877         if (!CORBA::is_nil(aCORBAObject)) {
1878           PortableServer::ServantBase_var aServant = VISU::GetServant(aCORBAObject);
1879           if (VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(aServant.in())) {
1880             aDlg->addPresentation(aPrsObject);
1881           }
1882         }
1883       }
1884     }
1885   }
1886   if (aDlg->getPrsCount() > 0)
1887     aDlg->show();
1888   else
1889     delete aDlg;
1890 }
1891
1892 void
1893 VisuGUI::
1894 OnArrangeActors()
1895 {
1896   SVTK_ViewWindow* vw = GetViewWindow();
1897   if (vw) {
1898     ArrangeDlg* aDlg = new ArrangeDlg (GetDesktop(this), vw);
1899     aDlg->exec();
1900     delete aDlg;
1901   }
1902 }
1903
1904
1905 void
1906 VisuGUI::
1907 initialize( CAM_Application* theApp )
1908 {
1909   SalomeApp_Module::initialize( theApp );
1910
1911   createActions();
1912   createMenus();
1913   createToolBars();
1914   createPopupMenus();
1915 }
1916
1917 void
1918 VisuGUI::
1919 createActions()
1920 {
1921   QPixmap aPixmap;
1922   QWidget* aParent = application()->desktop();
1923   SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
1924
1925   // Create actions
1926   createAction( VISU_IMPORT_FROM_FILE, "", QIconSet(), tr("MEN_IMPORT_FROM_FILE"), "", (CTRL + Key_I), aParent, false,
1927                 this, SLOT(OnImportFromFile()));
1928   createAction( VISU_EXPLORE_MED, "", QIconSet(), tr("MEN_EXPLORE_MED_FILE"), "", (CTRL + Key_M), aParent, false,
1929                 this, SLOT(OnExploreMEDFile()));
1930   createAction( VISU_IMPORT_TABLE, "", QIconSet(), tr("MEN_IMPORT_TABLE"), "", 0, aParent, false,
1931                 this, SLOT(OnImportTableFromFile()));
1932
1933   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_SCALAR_MAP"));
1934   createAction( VISU_SCALAR_MAP, tr("MEN_SCALAR_MAP"), QIconSet(aPixmap), tr("MEN_SCALAR_MAP"), "", 0, aParent, false,
1935                 this, SLOT(OnCreateScalarMap()));
1936
1937   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_DEFORMED_SHAPE"));
1938   createAction( VISU_DEFORMED_SHAPE, tr("MEN_DEFORMED_SHAPE"), QIconSet(aPixmap), tr("MEN_DEFORMED_SHAPE"), "", 0, aParent, false,
1939                 this, SLOT(OnCreateDeformedShape()));
1940
1941   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_VECTORS"));
1942   createAction( VISU_VECTORS, tr("MEN_VECTORS"), QIconSet(aPixmap), tr("MEN_VECTORS"), "", 0, aParent, false,
1943                 this, SLOT(OnCreateVectors()));
1944
1945   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_ISO_SURFACES"));
1946   createAction( VISU_ISO_SURFACES, tr("MEN_ISO_SURFACES"), QIconSet(aPixmap), tr("MEN_ISO_SURFACES"), "", 0, aParent, false,
1947                 this, SLOT(OnCreateIsoSurfaces()));
1948
1949   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_CUT_PLANES"));
1950   createAction( VISU_CUT_PLANES, tr("MEN_CUT_PLANES"), QIconSet(aPixmap), tr("MEN_CUT_PLANES"), "", 0, aParent, false,
1951                 this, SLOT(OnCreateCutPlanes()));
1952
1953   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_STREAM_LINES"));
1954   createAction( VISU_STREAM_LINES, tr("MEN_STREAM_LINES"), QIconSet(aPixmap), tr("MEN_STREAM_LINES"), "", 0, aParent, false,
1955                 this, SLOT(OnCreateStreamLines()));
1956
1957   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_CUT_LINES"));
1958   createAction( VISU_CUT_LINES, tr("MEN_CUT_LINES"), QIconSet(aPixmap), tr("MEN_CUT_LINES"), "", 0, aParent, false,
1959                 this, SLOT(OnCreateCutLines()));
1960
1961   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_PLOT_3D"));
1962   createAction( VISU_PLOT_3D, tr("MEN_PLOT_3D"), QIconSet(aPixmap),
1963                 tr("MEN_PLOT_3D"), "", 0, aParent, false,
1964                 this, SLOT(OnCreatePlot3D()));
1965
1966   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_PLOT2D"));
1967   createAction( VISU_PLOT2D, tr("MEN_CREATE_PLOT2D"), QIconSet(aPixmap),
1968                 tr("MEN_CREATE_PLOT2D"), "", 0, aParent, false,
1969                 this, SLOT(OnCreatePlot2dView()));
1970
1971   createAction( VISU_DELETE_OBJS, tr("MEN_DELETE_OBJS"), QIconSet(),
1972                 tr("MEN_DELETE_OBJS"), "", 0, aParent, false,
1973                 this, SLOT(OnDeleteObjects()));
1974
1975   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
1976   //createAction( 4022, tr("MEN_RENAME_TABLE"), QIconSet(aPixmap), tr("MEN_RENAME_TABLE"), "", 0, aParent, false,
1977                 //this, SLOT(OnRenameTable()));
1978
1979   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
1980   createAction( VISU_SHOW_TABLE, tr("MEN_SHOW_TABLE"), QIconSet(), tr("MEN_SHOW_TABLE"), "", 0, aParent, false,
1981                 this, SLOT(OnShowTable()));
1982
1983   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
1984   createAction( VISU_CREATE_CURVES, tr("MEN_CREATE_CURVES"), QIconSet(), tr("MEN_CREATE_CURVES"), "", 0, aParent, false,
1985                 this, SLOT(OnPlotData()));
1986
1987   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
1988   createAction( VISU_EXPORT_TABLE, tr("MEN_EXPORT_TABLE"), QIconSet(), tr("MEN_EXPORT_TABLE"), "", 0, aParent, false,
1989                 this, SLOT(OnExportTableToFile()));
1990
1991   createAction( VISU_IMPORT_MED_STRUCTURE, tr("MEN_IMPORT_MED_STRUCTURE"), QIconSet(),
1992                 tr("MEN_IMPORT_MED_STRUCTURE"), "", 0, aParent, false,
1993                 this, SLOT(OnImportMedField()));
1994
1995   createAction( VISU_IMPORT_MED_TIMESTAMP, tr("MEN_IMPORT_MED_TIMESTAMP"), QIconSet(),
1996                 tr("MEN_IMPORT_MED_TIMESTAMP"), "", 0, aParent, false,
1997                 this, SLOT(OnImportMedField()));
1998
1999   createAction( VISU_IMPORT_MED_FIELD, tr("MEN_IMPORT_MED_FIELD"), QIconSet(),
2000                 tr("MEN_IMPORT_MED_FIELD"), "", 0, aParent, false,
2001                 this, SLOT(OnImportMedField()));
2002
2003   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
2004   createAction( VISU_CREATE_PRS, tr("MEN_CREATE_PRS"), QIconSet(), tr("MEN_CREATE_PRS"), "", 0, aParent, false,
2005                 this, SLOT(OnCreateMesh()));
2006
2007   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
2008   createAction( VISU_CREATE_MANY_PRS, tr("MEN_CREATE_MANY_PRS"), QIconSet(),
2009                 tr("MEN_CREATE_MANY_PRS"), "", 0, aParent, false,
2010                 this, SLOT(OnCreateManyMesh()));
2011
2012   createAction( VISU_TRANSLATE_PRS, tr("MEN_TRANSLATE_PRS"), QIconSet(),
2013                 tr("MEN_TRANSLATE_PRS"), "", 0, aParent, false,
2014                 this, SLOT(OnTranslatePrs()));
2015
2016   createAction( VISU_MERGE_SCALAR_BARS, tr("MEN_MERGE_SCALAR_BARS"), QIconSet(),
2017                 tr("MEN_MERGE_SCALAR_BARS"), "", 0, aParent, false,
2018                 this, SLOT(OnMergeScalarBars()));
2019
2020   createAction( VISU_FREE_SCALAR_BARS, tr("MEN_FREE_SCALAR_BARS"), QIconSet(),
2021                 tr("MEN_FREE_SCALAR_BARS"), "", 0, aParent, false,
2022                 this, SLOT(OnFreeScalarBars()));
2023
2024   //aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_ERASE"));
2025   createAction( VISU_ERASE, tr("MEN_ERASE"), QIconSet(), tr("MEN_ERASE"), "", 0, aParent, false,
2026                 this, SLOT(OnErasePrs()));
2027
2028   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
2029   createAction( VISU_DISPLAY, tr("MEN_DISPLAY"), QIconSet(), tr("MEN_DISPLAY"), "", 0, aParent, false,
2030                 this, SLOT(OnDisplayPrs()));
2031
2032   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
2033   createAction( VISU_DISPLAY_ONLY, tr("MEN_DISPLAY_ONLY"), QIconSet(), tr("MEN_DISPLAY_ONLY"), "", 0, aParent, false,
2034                 this, SLOT(OnDisplayOnlyPrs()));
2035
2036   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
2037   createAction( VISU_COPY_PRS, tr("MEN_COPY_PRS"), QIconSet(), tr("MEN_COPY_PRS"), "", 0, aParent, false,
2038                 this, SLOT(OnCopyPresentation()));
2039
2040   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
2041   createAction( VISU_CURVE_PROPS, tr("MEN_CURVE_PROPS"), QIconSet(), tr("MEN_CURVE_PROPS"), "", 0, aParent, false,
2042                 this, SLOT(OnCurveProperties()));
2043
2044   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
2045   createAction( VISU_RENAME, tr("MEN_RENAME"), QIconSet(), tr("MEN_RENAME"), "", 0, aParent, false,
2046                 this, SLOT(OnRename()));
2047
2048   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
2049   createAction( VISU_EDIT_CONTAINER, tr("MEN_EDIT_CONTAINER"), QIconSet(), tr("MEN_EDIT_CONTAINER"), "", 0, aParent, false,
2050                 this, SLOT(OnEditContainer()));
2051
2052   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
2053   //createAction( 4043, tr("MEN_RENAME_CONTAINER"), QIconSet(aPixmap), tr("MEN_RENAME_CONTAINER"), "", 0, aParent, false,
2054                 //this, SLOT(OnRenameContainer()));
2055
2056   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
2057   createAction( VISU_CLEAR_CONTAINER, tr("MEN_CLEAR_CONTAINER"), QIconSet(), tr("MEN_CLEAR_CONTAINER"), "", 0, aParent, false,
2058                 this, SLOT(OnClearContainer()));
2059
2060   createAction( VISU_SAVE_VIEW_PARAMS, tr("MEN_SAVE_VIEWPARAMS"), QIconSet(),
2061                 tr("MEN_SAVE_VIEWPARAMS"), "", 0, aParent, false,
2062                 this, SLOT(OnSaveViewParams()));
2063   createAction( VISU_SAVE_VIEW_PARAMS_1, tr("MEN_SAVE_VIEWPARAMS"), QIconSet(),
2064                 tr("MEN_SAVE_VIEWPARAMS"), "", 0, aParent, false,
2065                 this, SLOT(OnSaveViewParams()));
2066
2067   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
2068   createAction( VISU_RESTORE_VIEW_PARAMS, tr("MEN_RESTORE_VIEWPARAMS"), QIconSet(),
2069                 tr("MEN_RESTORE_VIEWPARAMS"), "", 0, aParent, false,
2070                 this, SLOT(OnRestoreViewParams()));
2071
2072   createAction( VISU_DELETE_VIEW_PARAMS, tr("MEN_DELETE_VIEWPARAMS"), QIconSet(),
2073                 tr("MEN_DELETE_VIEWPARAMS"), "", 0, aParent, false,
2074                 //this, SLOT(OnDeleteViewParams()));
2075                 this, SLOT(OnDeleteObjects()));
2076
2077   createAction( VISU_ARRANGE_ACTORS, tr("MEN_ARRANGE_ACTORS"), QIconSet(),
2078                 tr("MEN_ARRANGE_ACTORS"), "", 0, aParent, false,
2079                 this, SLOT(OnArrangeActors()));
2080
2081   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_POINTS"));
2082   createAction( VISU_POINTS, tr("MEN_POINTS"), QIconSet(aPixmap), tr("MEN_POINTS"), "", 0, aParent, false,
2083                 this, SLOT(OnMakePoints()));
2084
2085   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_WIREFRAME"));
2086   createAction( VISU_WIREFRAME, tr("MEN_WIREFRAME"), QIconSet(aPixmap), tr("MEN_WIREFRAME"), "", 0, aParent, false,
2087                 this, SLOT(OnMakeWireframe()));
2088
2089   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_SURFACE"));
2090   createAction( VISU_SURFACE, tr("MEN_SURFACE"), QIconSet(aPixmap), tr("MEN_SURFACE"), "", 0, aParent, false,
2091                 this, SLOT(OnMakeSurface()));
2092
2093   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
2094   createAction( VISU_INSIDEFRAME, tr("MEN_INSIDEFRAME"), QIconSet(), tr("MEN_INSIDEFRAME"), "", 0, aParent, false,
2095                 this, SLOT(OnMakeInsideframe()));
2096
2097   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
2098   createAction( VISU_SURFACEFRAME, tr("MEN_SURFACEFRAME"), QIconSet(), tr("MEN_SURFACEFRAME"), "", 0, aParent, false,
2099                 this, SLOT(OnMakeSurfaceframe()));
2100
2101   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
2102   createAction( VISU_SHRINK, tr("MEN_SHRINK"), QIconSet(), tr("MEN_SHRINK"), "", 0, aParent, false,
2103                 this, SLOT(OnMakeShrink()));
2104
2105   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
2106   createAction( VISU_UNSHRINK, tr("MEN_UNSHRINK"), QIconSet(), tr("MEN_UNSHRINK"), "", 0, aParent, false,
2107                 this, SLOT(OnMakeShrink()));
2108
2109   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
2110   createAction( VISU_CELL_COLOR, tr("MEN_CELL_COLOR"), QIconSet(), tr("MEN_CELL_COLOR"), "", 0, aParent, false,
2111                 this, SLOT(OnChangeColor()));
2112
2113   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
2114   createAction( VISU_COLOR, tr("MEN_COLOR"), QIconSet(), tr("MEN_COLOR"), "", 0, aParent, false,
2115                 this, SLOT(OnChangeColor()));
2116
2117   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
2118   createAction( VISU_EDGE_COLOR, tr("MEN_EDGE_COLOR"), QIconSet(), tr("MEN_EDGE_COLOR"), "", 0, aParent, false,
2119                 this, SLOT(OnChangeWireframeColor()));
2120
2121   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
2122   createAction( VISU_OPACITY, tr("MEN_OPACITY"), QIconSet(), tr("MEN_OPACITY"), "", 0, aParent, false,
2123                 this, SLOT(OnChangeOpacity()));
2124
2125   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
2126   createAction( VISU_LINE_WIDTH, tr("MEN_LINE_WIDTH"), QIconSet(), tr("MEN_LINE_WIDTH"), "", 0, aParent, false,
2127                 this, SLOT(OnChangeLines()));
2128
2129   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
2130   createAction( VISU_EDIT_PRS, tr("MEN_EDIT_PRS"), QIconSet(), tr("MEN_EDIT_PRS"), "", 0, aParent, false,
2131                 this, SLOT(OnEditPrs()));
2132
2133   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
2134   createAction( VISU_CREATE_TABLE, tr("MEN_CREATE_TABLE"), QIconSet(), tr("MEN_CREATE_TABLE"), "", 0, aParent, false,
2135                 this, SLOT(OnCreateTable()));
2136
2137   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_SWEEP"));
2138   createAction( VISU_SWEEP, tr("MEN_SWEEP"), QIconSet(aPixmap), tr("MEN_SWEEP"), "", 0, aParent, false,
2139                 this, SLOT(OnSweep()));
2140
2141   createAction( VISU_CLIPPING, tr("MEN_CLIPPING"), QIconSet(),
2142                 tr("MEN_CLIPPING"), "", 0, aParent, false,
2143                 this, SLOT(OnClippingPlanes()));
2144
2145   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
2146   createAction( VISU_SELECTION_INFO, tr("MEN_SELECTION_INFO"), QIconSet(),
2147                 tr("MEN_SELECTION_INFO"), "", 0, aParent, false,
2148                 this, SLOT(OnSelectionInfo()));
2149
2150   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_TIMEANIMATION"));
2151   createAction( VISU_ANIMATION, tr("MEN_ANIMATION"), QIconSet(aPixmap), tr("MEN_ANIMATION"), "", 0, aParent, false,
2152                 this, SLOT(OnTimeAnimation()));
2153
2154   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_ERASE_ALL"));
2155   createAction( VISU_ERASE_ALL, tr("MEN_ERASE_ALL"), QIconSet(aPixmap),
2156                 tr("MEN_ERASE_ALL"), "", 0, aParent, false,
2157                 this, SLOT(OnEraseAll()));
2158
2159   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_GLOBAL_SELECTION"));
2160   createAction( VISU_GLOBAL_SELECTION, tr("MEN_GLOBAL_SELECTION"), QIconSet(aPixmap),
2161                 tr("MEN_GLOBAL_SELECTION"), "", 0, aParent, false,
2162                 //this, SLOT(OnEraseAll()));
2163                 this);
2164
2165   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_PARTIAL_SELECTION"));
2166   createAction( VISU_PARTIAL_SELECTION, tr("MEN_PARTIAL_SELECTION"), QIconSet(aPixmap),
2167                 tr("MEN_PARTIAL_SELECTION"), "", 0, aParent, false,
2168                 //this, SLOT(OnEraseAll()));
2169                 this);
2170
2171   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_SCALING"));
2172   createAction( VISU_SCALING, tr("MEN_SCALING"), QIconSet(aPixmap),
2173                 tr("MEN_SCALING"), "", 0, aParent, false,
2174                 this, SLOT(OnScaling()));
2175
2176   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_CUBE_AXES"));
2177   createAction( VISU_CUBE_AXES, tr("MEN_CUBE_AXES"), QIconSet(aPixmap),
2178                 tr("MEN_CUBE_AXES"), "", 0, aParent, false,
2179                 this, SLOT(OnCubeAxes()));
2180
2181   createAction( VISU_SHOW_ANIMATION, tr("MEN_SHOW_ANIMATION"), QIconSet(),
2182                 tr("MEN_SHOW_ANIMATION"), "", 0, aParent, false,
2183                 this, SLOT(OnShowAnimation()));
2184 }
2185
2186 void
2187 VisuGUI::
2188 createMenus()
2189 {
2190   // Add actions to menus
2191   int aMenuId;
2192   aMenuId = createMenu( tr( "MEN_DESK_FILE" ), -1 );
2193   createMenu( separator(), aMenuId, -1, 10 );
2194   createMenu( VISU_IMPORT_FROM_FILE, aMenuId, 10 ); // import from file
2195   createMenu( VISU_EXPLORE_MED, aMenuId, 10 ); // explore MED file
2196   createMenu( VISU_IMPORT_TABLE, aMenuId, 10 ); // import table
2197
2198   aMenuId = createMenu( tr( "MEN_VISUALIZATION" ), -1, -1, 30 );
2199   createMenu( VISU_SCALAR_MAP, aMenuId, 10 ); // scalar map
2200   createMenu( VISU_DEFORMED_SHAPE, aMenuId, 10 ); // deformed shape
2201   createMenu( VISU_VECTORS, aMenuId, 10 ); // vectors
2202   createMenu( VISU_ISO_SURFACES, aMenuId, 10 ); // iso surfaces
2203   createMenu( VISU_CUT_PLANES, aMenuId, 10 ); // cut planes
2204   createMenu( VISU_CUT_LINES, aMenuId, 10 ); // cut lines
2205   createMenu( VISU_STREAM_LINES, aMenuId, 10 ); // stream lines
2206   createMenu( VISU_PLOT_3D, aMenuId, 10 ); // Plot3d
2207
2208   aMenuId = createMenu( tr( "MEN_SELECTION" ), -1, -1, 30 );
2209   createMenu( VISU_SELECTION_INFO, aMenuId, 10 ); // selection info
2210
2211   aMenuId = createMenu( tr( "MEN_REPRESENTATION" ), -1, -1, 30 );
2212   int parentId =
2213     createMenu( tr( "MEN_DISPLAY_SELECTION" ), aMenuId, 10 ); // display selection
2214   createMenu( VISU_POINTS, parentId, 10 ); //   points
2215   createMenu( VISU_WIREFRAME, parentId, 10 ); //   wireframe
2216   createMenu( VISU_SURFACE, parentId, 10 ); //   surface
2217   createMenu( VISU_ERASE_ALL, aMenuId, 10 ); // erase all
2218   createMenu( VISU_GLOBAL_SELECTION, aMenuId, 10 ); // global selection
2219   createMenu( VISU_PARTIAL_SELECTION, aMenuId, 10 ); // partial selection
2220   createMenu( VISU_SCALING, aMenuId, 10 ); // scaling
2221   createMenu( VISU_CUBE_AXES, aMenuId, 10 ); // scaling
2222 }
2223
2224 void
2225 VisuGUI::
2226 createToolBars()
2227 {
2228   int aToolId = createTool(tr("TOOL_VISUALISATION"));
2229   createTool( VISU_SCALAR_MAP, aToolId );
2230   createTool( VISU_DEFORMED_SHAPE, aToolId );
2231   createTool( VISU_VECTORS, aToolId );
2232   createTool( VISU_ISO_SURFACES, aToolId );
2233   createTool( VISU_CUT_PLANES, aToolId );
2234   createTool( VISU_CUT_LINES, aToolId );
2235   createTool( VISU_STREAM_LINES, aToolId );
2236   createTool( VISU_PLOT_3D, aToolId );
2237
2238   aToolId = createTool(tr("TOOL_REPRESENTATION"));
2239   createTool( VISU_POINTS, aToolId );
2240   createTool( VISU_WIREFRAME, aToolId );
2241   createTool( VISU_SURFACE, aToolId );
2242   createTool( VISU_ERASE_ALL, aToolId );
2243   createTool( VISU_GLOBAL_SELECTION, aToolId );
2244   createTool( VISU_PARTIAL_SELECTION, aToolId );
2245   createTool( VISU_SCALING, aToolId );
2246   createTool( VISU_CUBE_AXES, aToolId );
2247 }
2248
2249 void
2250 VisuGUI::
2251 createPopupMenus()
2252 {
2253   // Prepare popup menus
2254   QtxPopupMgr* mgr = popupMgr();
2255
2256   // VISU root commands
2257   mgr->insert( action( VISU_IMPORT_FROM_FILE ), -1, -1, -1 ); // import MED file
2258   mgr->insert( action( VISU_IMPORT_TABLE ), -1, -1, -1 ); // import tables from file
2259   mgr->insert( action( VISU_PLOT2D ), -1, -1, -1 ); // create Plot2d View
2260
2261   //mgr->insert( action( VISU_IMPORT_MED ), -1, -1, -1 ); // import MED structure from MED module
2262
2263   // create
2264   mgr->insert( action( VISU_SCALAR_MAP ), -1, -1, -1 ); // scalar bar
2265   mgr->insert( action( VISU_ISO_SURFACES ), -1, -1, -1 ); // iso surface
2266   mgr->insert( action( VISU_CUT_PLANES ), -1, -1, -1 ); // cut planes
2267   mgr->insert( action( VISU_CUT_LINES ), -1, -1, -1 ); // cut lines
2268   mgr->insert( action( VISU_DEFORMED_SHAPE ), -1, -1, -1 ); // deformed shape
2269   mgr->insert( action( VISU_VECTORS ), -1, -1, -1 ); // vectors
2270   mgr->insert( action( VISU_STREAM_LINES ), -1, -1, -1 ); // stream lines
2271   mgr->insert( action( VISU_PLOT_3D ), -1, -1, -1 ); // Plot3d
2272
2273   mgr->insert( action( VISU_CREATE_PRS ), -1, -1, -1 ); // create presentation
2274   mgr->insert( action( VISU_CREATE_MANY_PRS ), -1, -1, -1 ); // create presentations
2275
2276   mgr->insert( action( VISU_CREATE_TABLE ), -1, -1, -1 ); // create table
2277
2278   // edit
2279   mgr->insert( action( VISU_EDIT_PRS ), -1, -1, -1 );
2280   mgr->insert( action( VISU_EDIT_CONTAINER ), -1, -1, -1 );
2281
2282   // rename
2283   mgr->insert( action( VISU_RENAME ), -1, -1, -1 );
2284
2285   // copy
2286   mgr->insert( action( VISU_COPY_PRS ), -1, -1, -1 );
2287
2288   // delete
2289   mgr->insert( action( VISU_CLEAR_CONTAINER ), -1, -1, -1 );
2290
2291   // table commands
2292   //mgr->insert( action( VISU_SHOW_TABLE ), -1, -1, -1 ); // show table
2293   //mgr->insert( action( VISU_CREATE_CURVES ), -1, -1, -1 ); // create curves
2294   //mgr->insert( action( VISU_EXPORT_TABLE ), -1, -1, -1 ); // export table
2295
2296   mgr->insert( separator(), -1, -1, -1 );
2297
2298   mgr->insert( action( VISU_ERASE ), -1, -1, -1 ); // erase
2299   mgr->insert( action( VISU_DISPLAY ), -1, -1, -1 ); // display
2300   mgr->insert( action( VISU_DISPLAY_ONLY ), -1, -1, -1 ); // display only
2301
2302   // "Representation" submenu
2303   int parentId = mgr->insert( tr( "MEN_REPRESENTATION" ), -1, -1 );
2304   mgr->insert( action( VISU_POINTS )      , parentId, -1, -1 ); // points
2305   mgr->insert( action( VISU_WIREFRAME )   , parentId, -1, -1 ); // wireframe
2306   mgr->insert( action( VISU_SURFACE )     , parentId, -1, -1 ); // surface
2307   mgr->insert( action( VISU_INSIDEFRAME ) , parentId, -1, -1 ); // insideframe
2308   mgr->insert( action( VISU_SURFACEFRAME ), parentId, -1, -1 ); // surfaceframe
2309   mgr->insert( action( VISU_SHRINK )      , parentId, -1, -1 ); // shrink
2310   mgr->insert( action( VISU_UNSHRINK )    , parentId, -1, -1 ); // unshrink
2311
2312   // "Properties" submenu
2313   parentId = mgr->insert( tr( "MEN_PROPERTIES" ), -1, -1 );
2314   mgr->insert( action( VISU_CELL_COLOR ), parentId, -1, -1 ); // cell color
2315   mgr->insert( action( VISU_EDGE_COLOR ), parentId, -1, -1 ); // edge color
2316   mgr->insert( action( VISU_COLOR )     , parentId, -1, -1 ); // color
2317   mgr->insert( action( VISU_OPACITY )   , parentId, -1, -1 ); // opacity
2318   mgr->insert( action( VISU_LINE_WIDTH ), parentId, -1, -1 ); // line width
2319
2320   mgr->insert( separator(), -1, -1, -1 );
2321
2322   // Other presentations management
2323   mgr->insert( action( VISU_TRANSLATE_PRS ), -1, -1, -1 );
2324   mgr->insert( action( VISU_CLIPPING ), -1, -1, -1 );
2325
2326   mgr->insert( action( VISU_MERGE_SCALAR_BARS ), -1, -1, -1 );
2327   mgr->insert( action( VISU_FREE_SCALAR_BARS ), -1, -1, -1 );
2328
2329   mgr->insert( action( VISU_SWEEP ), -1, -1, -1 );
2330   mgr->insert( action( VISU_ANIMATION ), -1, -1, -1 );
2331
2332   mgr->insert( separator(), -1, -1, -1 );
2333
2334   // view parameters commands
2335   mgr->insert( action( VISU_SAVE_VIEW_PARAMS ), -1, -1, -1 ); // save view params
2336   mgr->insert( action( VISU_SAVE_VIEW_PARAMS_1 ), -1, -1, -1 ); // save view params
2337   mgr->insert( action( VISU_RESTORE_VIEW_PARAMS ), -1, -1, -1 ); // restore view params
2338   mgr->insert( action( VISU_DELETE_VIEW_PARAMS ), -1, -1, -1 ); // delete view params
2339
2340   mgr->insert( action( VISU_ARRANGE_ACTORS ), -1, -1, -1 ); // arrange actors
2341
2342   mgr->insert( action( VISU_CURVE_PROPS ), -1, -1, -1 ); // curve properties
2343
2344   mgr->insert( action( VISU_SELECTION_INFO ), -1, -1, -1 ); // Selection info
2345
2346   // Rules
2347
2348   QString aSel_One_ObjBr  ("client='ObjectBrowser' and selcount=1");
2349   QString aSel_Some_ObjBr ("client='ObjectBrowser' and selcount>0");
2350   QString aSel_Many_ObjBr ("client='ObjectBrowser' and selcount>1");
2351
2352   QString aPrsAll ("'VISU::TSCALARMAP' 'VISU::TISOSURFACE' 'VISU::TDEFORMEDSHAPE' 'VISU::TCUTPLANES' "
2353                    "'VISU::TCUTLINES' 'VISU::TVECTORS' 'VISU::TSTREAMLINES' 'VISU::TPLOT3D'");
2354
2355   QString aCurveAll = "'VISU::TTABLE' 'VISU::TCURVE' 'VISU::TCONTAINER'";
2356
2357   // VISU root commands
2358   QString aRule = aSel_One_ObjBr + " and type='VISU::TVISUGEN'";
2359   mgr->setRule( action( VISU_IMPORT_FROM_FILE ), aRule, true );
2360   mgr->setRule( action( VISU_IMPORT_TABLE ), aRule, true );
2361   mgr->setRule( action( VISU_PLOT2D ), aRule, true );
2362
2363   // timestamp commands
2364   aRule = aSel_One_ObjBr + " and type='VISU::TTIMESTAMP'";
2365   mgr->setRule( action( VISU_SCALAR_MAP ), aRule, true );
2366   mgr->setRule( action( VISU_ISO_SURFACES ), aRule, true );
2367   mgr->setRule( action( VISU_CUT_PLANES ), aRule, true );
2368   mgr->setRule( action( VISU_CUT_LINES ), aRule, true );
2369   mgr->setRule( action( VISU_PLOT_3D ), aRule, true );
2370   aRule += " and nbComponents>1";
2371   mgr->setRule( action( VISU_DEFORMED_SHAPE ), aRule, true );
2372   mgr->setRule( action( VISU_VECTORS ), aRule, true );
2373   mgr->setRule( action( VISU_STREAM_LINES ), aRule, true );
2374
2375   // table commands
2376   //aRule = aSel_One_ObjBr + " and type='VISU::TTABLE'";
2377   //mgr->setRule( action( VISU_SHOW_TABLE ), aRule, true );
2378   //mgr->setRule( action( VISU_CREATE_CURVES ), aRule, true );
2379   //mgr->setRule( action( VISU_EXPORT_TABLE ), aRule, true );
2380
2381   aRule = "(" + aSel_Some_ObjBr + " and ((type='VISU::TTABLE' and nbChildren>0) or"
2382           " ($type in {'VISU::TCURVE' 'VISU::TCONTAINER'}))"
2383           ") or (selcount>0 and $type in {'VISU::TMESH' " + aPrsAll + "})";
2384
2385   mgr->setRule( action( VISU_ERASE ), aRule + "and (isVisible=true)", true );// TODO: aRule.arg(" and isVisible=1"), true );
2386   mgr->setRule( action( VISU_DISPLAY ), aRule + "and (isVisible=false)", true );// TODO: aRule.arg(" and isVisible=0"), true );
2387   mgr->setRule( action( VISU_DISPLAY_ONLY ), aRule, true );
2388
2389   aRule = "selcount>0 and $type in {'VISU::TMESH' " + aPrsAll + "}";
2390   mgr->setRule( action( VISU_TRANSLATE_PRS ), aRule, true );
2391
2392   aRule = "selcount>1 and $type in {'VISU::TMESH' " + aPrsAll + "}";
2393   mgr->setRule( action( VISU_MERGE_SCALAR_BARS ), aRule, true );
2394   mgr->setRule( action( VISU_FREE_SCALAR_BARS ), aRule, true );
2395
2396   // View parameters
2397   aRule = "selcount=1 and type='VISU::TVIEW3D'";
2398   mgr->setRule( action( VISU_SAVE_VIEW_PARAMS_1 ), aRule, true );
2399   mgr->setRule( action( VISU_SAVE_VIEW_PARAMS ), "client='VTKViewer' and selcount=0", true );
2400   mgr->setRule( action( VISU_RESTORE_VIEW_PARAMS ), "selcount=1 and type='VISU::TVIEW3D'", true );
2401   mgr->setRule( action( VISU_DELETE_VIEW_PARAMS ), "selcount=1 and type='VISU::TVIEW3D'", true );
2402
2403   mgr->setRule( action( VISU_ARRANGE_ACTORS ), "client='VTKViewer' and selcount=0", true );
2404
2405   // 3D presentations commands
2406   QString aPrsType    = " and $type in {'VISU::TMESH' " + aPrsAll + "}";
2407   QString aInsideType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TDEFORMEDSHAPE'}";
2408   QString aSurfType   = " and $type in {'VISU::TMESH'}";
2409   QString aShrinkType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TISOSURFACE' "
2410                         "'VISU::TDEFORMEDSHAPE' 'VISU::TCUTPLANES' 'VISU::TCUTLINES' 'VISU::TPLOT3D'}";
2411   QString aLineType   = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TISOSURFACE' 'VISU::TDEFORMEDSHAPE' "
2412                         "'VISU::TCUTPLANES' 'VISU::TCUTLINES' 'VISU::TSTREAMLINES' 'VISU::TPLOT3D'}";
2413
2414   aRule = "selcount=1";
2415   mgr->setRule( action( VISU_CLIPPING ), aRule + aPrsType, true );
2416
2417   // "Representation" submenu
2418   QString aNotPoints = " and $representation in {'VISU::WIREFRAME' 'VISU::SHADED' 'VISU::INSIDEFRAME' 'VISU::SURFACEFRAME'}";
2419   QString aNotWirefr = " and $representation in {'VISU::POINT' 'VISU::SHADED' 'VISU::INSIDEFRAME' 'VISU::SURFACEFRAME'}";
2420   QString aNotSurfac = " and $representation in {'VISU::POINT' 'VISU::WIREFRAME' 'VISU::INSIDEFRAME' 'VISU::SURFACEFRAME'}";
2421   QString aNotInside = " and $representation in {'VISU::POINT' 'VISU::WIREFRAME' 'VISU::SHADED' 'VISU::SURFACEFRAME'}";
2422   QString aNotSurffr = " and $representation in {'VISU::POINT' 'VISU::WIREFRAME' 'VISU::SHADED' 'VISU::INSIDEFRAME'}";
2423
2424   mgr->setRule( action( VISU_POINTS )      , aRule + aPrsType + aNotPoints, true );
2425   mgr->setRule( action( VISU_WIREFRAME )   , aRule + aPrsType + aNotWirefr, true );
2426   mgr->setRule( action( VISU_SURFACE )     , aRule + aPrsType + aNotSurfac, true );
2427   mgr->setRule( action( VISU_INSIDEFRAME ) , aRule + aInsideType + aNotInside, true );
2428   mgr->setRule( action( VISU_SURFACEFRAME ), aRule + aSurfType + aNotSurffr, true );
2429
2430   mgr->setRule( action( VISU_SHRINK )  , aRule + aShrinkType + " and isShrunk=0", true );
2431   mgr->setRule( action( VISU_UNSHRINK ), aRule + aShrinkType + " and isShrunk=1", true );
2432
2433   // "Properties" submenu
2434   mgr->setRule( action( VISU_CELL_COLOR ), aRule + " and type='VISU::TMESH' and representation='VISU::SURFACEFRAME'", true );
2435   mgr->setRule( action( VISU_EDGE_COLOR ), aRule + " and type='VISU::TMESH' and representation='VISU::SURFACEFRAME'", true );
2436   mgr->setRule( action( VISU_COLOR ), aRule + " and ((type='VISU::TMESH'"
2437                " and $representation in {'VISU::POINT' 'VISU::WIREFRAME' 'VISU::SHADED' 'VISU::INSIDEFRAME'}) "
2438                "or (type='VISU::TDEFORMEDSHAPE' and hasActor=1))", true );
2439   mgr->setRule( action( VISU_OPACITY ), aRule + aShrinkType + " and hasActor=1", true );
2440   mgr->setRule( action( VISU_LINE_WIDTH ), aRule + aLineType + " and hasActor=1", true );
2441
2442   // rename command
2443   aRule = "selcount=1 and ($type in {'VISU::TVIEW3D' " + aCurveAll + " " + aPrsAll + "})";
2444   mgr->setRule( action( VISU_RENAME ), aRule, true );
2445
2446   // copy presentation command
2447   aRule = "selcount=1 and ($type in {" + aPrsAll + "})";
2448   mgr->setRule( action( VISU_COPY_PRS ), aRule, true );
2449
2450   // curve commands
2451   aRule = "selcount=1 and type='VISU::TCURVE'";
2452   mgr->setRule( action( VISU_CURVE_PROPS ), aRule, true );
2453
2454   // curve container commands
2455   aRule = aSel_One_ObjBr + " and type='VISU::TCONTAINER'";
2456   mgr->setRule( action( VISU_EDIT_CONTAINER ), aRule, true );
2457   mgr->setRule( action( VISU_CLEAR_CONTAINER ), aRule, true );
2458
2459   aRule = "selcount=1 and $type in {" + aPrsAll + "}";
2460   mgr->setRule( action( VISU_EDIT_PRS ), aRule, true );
2461
2462   aRule = "selcount=1 and type='VISU::TCUTLINES' and nbNamedChildren=0";
2463   mgr->setRule( action( VISU_CREATE_TABLE ), aRule, true );
2464
2465   aRule = "selcount=1 and ($type in {" + aPrsAll + "})";
2466   mgr->setRule( action( VISU_SWEEP ), aRule, true );
2467
2468   // Selection info popup item
2469   aRule = "client='VTKViewer' and selcount=1" + aInsideType;
2470   mgr->setRule( action( VISU_SELECTION_INFO ), aRule, true );
2471
2472   aRule = "client='ObjectBrowser' and selcount>0 and $type in {'VISU::TFIELD'} and nbTimeStamps>1";
2473   mgr->setRule( action( VISU_ANIMATION ), aRule, true );
2474
2475   aRule = "client='ObjectBrowser' and $type in {'VISU::TENTITY' 'VISU::TFAMILY' 'VISU::TGROUP'}";
2476   mgr->setRule( action( VISU_CREATE_PRS ), aRule + " and selcount=1", true );
2477   mgr->setRule( action( VISU_CREATE_MANY_PRS ), aRule + " and selcount>1", true );
2478
2479   //aRule = "client='ObjectBrowser' and type='MEDFIELD'";
2480   //mgr->setRule( action( VISU_IMPORT_MED ), aRule, true );
2481 }
2482
2483 //***************************************************************************
2484 void VisuGUI::contextMenuPopup( const QString& theClient, QPopupMenu* theMenu, QString& theTitle )
2485 {
2486   SalomeApp_Module::contextMenuPopup(theClient, theMenu, theTitle);
2487
2488   SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
2489   SALOME_ListIO aListIO;
2490   aSelectionMgr->selectedObjects(aListIO);
2491
2492   if (aListIO.Extent() < 1) return;
2493
2494   _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
2495
2496   // Check if "Merge Scalar Range" can be applied
2497   int nbPrs = 0;
2498   SALOME_ListIteratorOfListIO It (aListIO);
2499   for (; It.More(); It.Next()) {
2500     Handle(SALOME_InteractiveObject)& anIO = It.Value();
2501     /*std::vector<VISU::Prs3d_i*> aPrsList = GetPrs3dList(this, anIO);
2502     nbPrs += aPrsList.size();*/
2503
2504     if (!anIO.IsNull() && anIO->hasEntry()) {
2505       _PTR(SObject) aSObject = aCStudy->FindObjectID(anIO->getEntry());
2506       CORBA::Object_var aCORBAObject = VISU::ClientSObjectToObject(aSObject);
2507       if (CORBA::is_nil(aCORBAObject)) {
2508         _PTR(GenericAttribute) anAttr;
2509         if (aSObject->FindAttribute(anAttr, "AttributeComment")) {
2510           _PTR(AttributeComment) aComment (anAttr);
2511           string aComm = aComment->Value();
2512           QString strIn (aComm.c_str());
2513           VISU::Storable::TRestoringMap pMap;
2514           VISU::Storable::StrToMap(strIn, pMap);
2515           bool isExist;
2516           VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(pMap,"myType",&isExist).toInt();
2517           if (isExist && aType == VISU::TTIMESTAMP) {
2518             _PTR(ChildIterator) anIter = aCStudy->NewChildIterator(aSObject);
2519             _PTR(SObject) aPrs;
2520             for (; anIter->More(); anIter->Next()) {
2521               aPrs = anIter->Value();
2522               if (!aPrs) continue;
2523               std::vector<VISU::Prs3d_i*> aSubList = GetPrs3dList(this, aPrs);
2524               nbPrs += aSubList.size();
2525             }
2526           }
2527         }
2528       }
2529     }
2530   }
2531
2532   if (nbPrs > 1) {
2533     theMenu->insertSeparator();
2534     action( VISU_MERGE_SCALAR_BARS )->addTo(theMenu);
2535     action( VISU_FREE_SCALAR_BARS  )->addTo(theMenu);
2536   }
2537
2538   theMenu->insertSeparator();
2539
2540   // Check if some (nb > 0) removable objects selected
2541   if (IsRemovableSelected(this)) {
2542     action( VISU_DELETE_OBJS )->addTo(theMenu);
2543   }
2544
2545   // Check single selection
2546   if (aListIO.Extent() != 1) return;
2547
2548   Handle(SALOME_InteractiveObject) anIO;
2549   VISU::Storable::TRestoringMap aMap;
2550   CORBA::Object_var anObject = GetSelectedObj( this, &anIO, &aMap);
2551
2552   _PTR(SObject) SO = aCStudy->FindObjectID(anIO->getEntry());
2553   bool isExist;
2554   VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt();
2555
2556   if (aType == VISU::TANIMATION) {
2557     action( VISU_SHOW_ANIMATION )->addTo(theMenu);
2558
2559   } else if (IsSObjectTable(SO)) {
2560     action( VISU_SHOW_TABLE )->addTo(theMenu);
2561     action( VISU_CREATE_CURVES )->addTo(theMenu);
2562     action( VISU_EXPORT_TABLE )->addTo(theMenu);
2563     theMenu->insertSeparator();
2564
2565   } else {
2566     if (!CORBA::is_nil(anObject)) {
2567       SALOME_MED::MED_var aMED = SALOME_MED::MED::_narrow(anObject);
2568       if (!CORBA::is_nil(aMED.in())) {
2569         action( VISU_IMPORT_MED_STRUCTURE )->addTo(theMenu);
2570       }
2571
2572       SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow(anObject); // "Import Structure"
2573       if (!CORBA::is_nil(aField)) {
2574         action( VISU_IMPORT_MED_TIMESTAMP )->addTo(theMenu); // "Import TimeStamp"
2575       }
2576     } else {
2577       _PTR(SObject) aSFather = SO->GetFather();
2578       if (aSFather) {
2579         _PTR(GenericAttribute) anAttr;
2580         aSFather->FindAttribute(anAttr, "AttributeName");
2581         if (anAttr) {
2582           _PTR(AttributeName) aName (anAttr);
2583           std::string aValue = aName->Value();
2584           if (strcmp(aValue.c_str(), "MEDFIELD") == 0) {
2585             action( VISU_IMPORT_MED_FIELD )->addTo(theMenu); // "Import Field"
2586           }
2587         }
2588       }
2589     }
2590   }
2591 }
2592
2593
2594 //***************************************************************************
2595 void
2596 VisuGUI::
2597 windows( QMap<int, int>& theMap ) const
2598 {
2599   theMap.clear();
2600   theMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
2601   theMap.insert( SalomeApp_Application::WT_PyConsole, Qt::DockBottom );
2602 }
2603
2604
2605 void
2606 VisuGUI::
2607 viewManagers( QStringList& theList ) const
2608 {
2609   theList.clear();
2610   theList.append( SVTK_Viewer::Type() );
2611 }
2612
2613
2614 QString
2615 VisuGUI::
2616 engineIOR() const
2617 {
2618   CORBA::String_var anIOR = GetVisuGen(this)->GetID();
2619   return QString(anIOR.in());
2620 }
2621
2622
2623 bool
2624 VisuGUI::
2625 activateModule( SUIT_Study* theStudy )
2626 {
2627   SalomeApp_Module::activateModule( theStudy );
2628   studyActivated();
2629   setMenuShown( true );
2630   setToolShown( true );
2631   return true;
2632 }
2633
2634
2635 bool
2636 VisuGUI::
2637 deactivateModule( SUIT_Study* theStudy )
2638 {
2639   setMenuShown( false );
2640   setToolShown( false );
2641
2642   SalomeApp_Module::deactivateModule( theStudy );
2643   return true;
2644 }
2645
2646 SalomeApp_Selection*
2647 VisuGUI::
2648 createSelection() const
2649 {
2650   return new VisuGUI_Selection( (SalomeApp_Module*)this );
2651 }
2652
2653 //******************************************************************
2654 void VisuGUI::studyActivated()
2655 {
2656   GetVisuGen(this)->SetCurrentStudy(GetDSStudy(GetCStudy(GetAppStudy(this))));
2657 }
2658
2659
2660 extern "C" {
2661   CAM_Module*
2662   createModule()
2663   {
2664     return new VisuGUI();
2665   }
2666 }
2667
2668 void VisuGUI::createPreferences()
2669 {
2670   int sbarTab = addPreference( tr( "VISU_SCALAR_BAR" ) );
2671
2672   int fontGr = addPreference( tr( "VISU_FONT" ), sbarTab );
2673   int tfont = addPreference( tr( "VISU_TITLE" ), fontGr, SalomeApp_Preferences::Font, "VISU", "scalar_bar_title_font" );
2674   addPreference( tr( "VISU_TITLE" ), fontGr, SalomeApp_Preferences::Color, "VISU", "scalar_bar_title_color" );
2675   int lfont = addPreference( tr( "VISU_LABELS" ), fontGr, SalomeApp_Preferences::Font, "VISU", "scalar_bar_label_font" );
2676   addPreference( tr( "VISU_LABELS" ), fontGr, SalomeApp_Preferences::Color, "VISU", "scalar_bar_label_color" );
2677
2678   QStringList fam;
2679   fam.append( tr( "VISU_FONT_ARIAL" ) );
2680   fam.append( tr( "VISU_FONT_COURIER" ) );
2681   fam.append( tr( "VISU_FONT_TIMES" ) );
2682   int wflag = ( QtxListResourceEdit::FontItem::All & ( ~( QtxListResourceEdit::FontItem::Size | QtxListResourceEdit::FontItem::UserSize ) ) );
2683
2684   setPreferenceProperty( tfont, "families", fam );
2685   setPreferenceProperty( tfont, "system", false );
2686   setPreferenceProperty( tfont, "widget_flags", wflag );  
2687   setPreferenceProperty( lfont, "families", fam );
2688   setPreferenceProperty( lfont, "system", false );
2689   setPreferenceProperty( lfont, "widget_flags", wflag );
2690   
2691   int colorsLabelsGr = addPreference( tr( "VISU_COLORS_AND_LABELS" ), sbarTab );
2692
2693   int numcol = addPreference( tr( "VISU_NB_COLORS" ), colorsLabelsGr, SalomeApp_Preferences::IntSpin, "VISU", "scalar_bar_num_colors" );
2694   setPreferenceProperty( numcol, "min", 2 );
2695   setPreferenceProperty( numcol, "max", 64 );  
2696   
2697   int numlab = addPreference( tr( "VISU_NB_LABELS" ), colorsLabelsGr, SalomeApp_Preferences::IntSpin, "VISU", "scalar_bar_num_labels" );
2698   setPreferenceProperty( numlab, "min", 2 );
2699   setPreferenceProperty( numlab, "max", 65 );
2700
2701   int orientGr = addPreference( tr( "VISU_ORIENTATION" ), sbarTab );
2702   int orient = addPreference( tr( "VISU_ORIENTATION" ), orientGr, SalomeApp_Preferences::Selector, "VISU", "scalar_bar_orientation" );
2703   QStringList orients;
2704   orients.append( tr( "VISU_VERTICAL" ) );
2705   orients.append( tr( "VISU_HORIZONTAL" ) );
2706   QValueList<QVariant> indices; 
2707   indices.append( 0 ); 
2708   indices.append( 1 );
2709   setPreferenceProperty( orient, "strings", orients );
2710   setPreferenceProperty( orient, "indexes", indices );
2711   
2712   int posVSizeGr = addPreference( tr( "VISU_ORIGIN_AND_SIZE" ) + " " + tr( "VISU_VERTICAL" ), sbarTab );
2713   int xv = addPreference( tr( "VISU_X" ), posVSizeGr, SalomeApp_Preferences::DblSpin, "VISU", "scalar_bar_vertical_x" );
2714   int yv = addPreference( tr( "VISU_Y" ), posVSizeGr, SalomeApp_Preferences::DblSpin, "VISU", "scalar_bar_vertical_y" );  
2715   int wv = addPreference( tr( "VISU_WIDTH" ), posVSizeGr, SalomeApp_Preferences::DblSpin, "VISU", "scalar_bar_vertical_width" );
2716   int hv = addPreference( tr( "VISU_HEIGHT" ), posVSizeGr, SalomeApp_Preferences::DblSpin, "VISU", "scalar_bar_vertical_height" );
2717   setPreferenceProperty( xv, "step", 0.1 );
2718   setPreferenceProperty( yv, "step", 0.1 );
2719   setPreferenceProperty( wv, "step", 0.1 );
2720   setPreferenceProperty( hv, "step", 0.1 );
2721   setPreferenceProperty( xv, "min", 0.0 );
2722   setPreferenceProperty( yv, "min", 0.0 );
2723   setPreferenceProperty( wv, "min", 0.0 );
2724   setPreferenceProperty( hv, "min", 0.0 );
2725   setPreferenceProperty( xv, "max", 1.0 );
2726   setPreferenceProperty( yv, "max", 1.0 );
2727   setPreferenceProperty( wv, "max", 1.0 );
2728   setPreferenceProperty( hv, "max", 1.0 );
2729
2730   int posHSizeGr = addPreference( tr( "VISU_ORIGIN_AND_SIZE" ) + " " + tr( "VISU_HORIZONTAL" ), sbarTab );
2731   int xh = addPreference( tr( "VISU_X" ), posHSizeGr, SalomeApp_Preferences::DblSpin, "VISU", "scalar_bar_horizontal_x" );
2732   int yh = addPreference( tr( "VISU_Y" ), posHSizeGr, SalomeApp_Preferences::DblSpin, "VISU", "scalar_bar_horizontal_y" );
2733   int wh = addPreference( tr( "VISU_WIDTH" ), posHSizeGr, SalomeApp_Preferences::DblSpin, "VISU", "scalar_bar_horizontal_width" );
2734   int hh = addPreference( tr( "VISU_HEIGHT" ), posHSizeGr, SalomeApp_Preferences::DblSpin, "VISU", "scalar_bar_horizontal_height" );
2735   setPreferenceProperty( xh, "step", 0.1 );
2736   setPreferenceProperty( yh, "step", 0.1 );
2737   setPreferenceProperty( wh, "step", 0.1 );
2738   setPreferenceProperty( hh, "step", 0.1 );
2739   setPreferenceProperty( xh, "min", 0.0 );
2740   setPreferenceProperty( yh, "min", 0.0 );
2741   setPreferenceProperty( wh, "min", 0.0 );
2742   setPreferenceProperty( hh, "min", 0.0 );
2743   setPreferenceProperty( xh, "max", 1.0 );
2744   setPreferenceProperty( yh, "max", 1.0 );
2745   setPreferenceProperty( wh, "max", 1.0 );
2746   setPreferenceProperty( hh, "max", 1.0 );
2747
2748   int srangeTab = addPreference( tr( "Scalar range, Sweep, MED import" ) );
2749   
2750   int rangeGr = addPreference( tr( "VISU_SCALAR_RANGE" ), srangeTab );
2751   setPreferenceProperty( rangeGr, "columns", 1 );
2752
2753   int mode = addPreference( tr( "VISU_SCALAR_MODE" ), rangeGr, SalomeApp_Preferences::Selector, "VISU", "scalar_bar_mode" );
2754   QStringList modes;
2755   modes.append( tr( "VISU_MODULUS" ) );
2756   modes.append( tr( "VISU_COMPONENT" ) + tr("1") );
2757   modes.append( tr( "VISU_COMPONENT" ) + tr("2") );
2758   modes.append( tr( "VISU_COMPONENT" ) + tr("3") );
2759   indices.clear(); 
2760   indices.append( 0 ); 
2761   indices.append( 1 );
2762   indices.append( 2 );
2763   indices.append( 3 );
2764   setPreferenceProperty( mode, "strings", modes );
2765   setPreferenceProperty( mode, "indexes", indices );
2766   
2767   addPreference( tr( "VISU_LOGARITHMIC_SCALING" ), rangeGr, SalomeApp_Preferences::Bool, "VISU", "scalar_bar_logarithmic" );
2768
2769   int rangetype = addPreference( tr( "VISU_RANGE_TO_USE" ), rangeGr, SalomeApp_Preferences::Selector, "VISU", "scalar_range_type" );
2770   QStringList types;
2771   types.append( tr( "VISU_FIELD_RANGE" ) );
2772   types.append( tr( "VISU_IMPOSED_RANGE" ) );
2773   indices.clear(); 
2774   indices.append( 0 ); 
2775   indices.append( 1 );
2776   setPreferenceProperty( rangetype, "strings", types );
2777   setPreferenceProperty( rangetype, "indexes", indices );
2778     
2779   int imposedGr = addPreference( tr( "VISU_MINMAX_IMPOSED_RANGE" ), srangeTab );
2780   
2781   int min = addPreference( tr( "VISU_MIN" ), imposedGr, SalomeApp_Preferences::DblSpin, "VISU", "scalar_range_min" );
2782   int max = addPreference( tr( "VISU_MAX" ), imposedGr, SalomeApp_Preferences::DblSpin, "VISU", "scalar_range_max" );
2783   setPreferenceProperty( min, "step", 0.1 );
2784   setPreferenceProperty( max, "step", 0.1 );
2785
2786   int sweepGr = addPreference( tr( "VISU_SWEEPING_PREF" ), srangeTab );
2787   setPreferenceProperty( sweepGr, "columns", 1 );
2788   
2789   int timestep   = addPreference( tr( "VISU_TIME_STEP" ), sweepGr, SalomeApp_Preferences::DblSpin, "VISU", "sweeping_time_step" );
2790   int nbcycles   = addPreference( tr( "VISU_NB_CYCLES" ), sweepGr, SalomeApp_Preferences::IntSpin, "VISU", "sweeping_number_cycles" );
2791   int nbsteps    = addPreference( tr( "VISU_NB_STEPS" ),  sweepGr, SalomeApp_Preferences::IntSpin, "VISU", "sweeping_number_steps" );
2792   setPreferenceProperty( timestep, "min",  0.1 );
2793   setPreferenceProperty( timestep, "step", 0.1 );
2794   setPreferenceProperty( timestep, "max",  1000 );
2795   setPreferenceProperty( nbcycles, "max",  100  );
2796   setPreferenceProperty( nbsteps,  "max",  200  );
2797
2798   int importGr = addPreference( tr( "MED files import" ), srangeTab );
2799   addPreference( tr( "Full MED loading" ), importGr, SalomeApp_Preferences::Bool, "VISU", "full_med_loading" );
2800 }
2801
2802 void VisuGUI::preferencesChanged( const QString&, const QString& )
2803 {
2804 }