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