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