]> SALOME platform Git repositories - modules/visu.git/blob - src/VISUGUI/VisuGUI.cxx
Salome HOME
39ae63851a971090ed6eb29e361a0957261c6a96
[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(GetDesktop(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 (GetDesktop(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 OnDeletePrs()
781 {
782   _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
783   if (CheckLock(aCStudy))
784     return;
785   SALOMEDS::Study_var aStudy = GetDSStudy(aCStudy);
786
787   Handle(SALOME_InteractiveObject) anIO;
788   CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
789   if (anIO.IsNull())
790     return;
791
792   // There is a transaction
793   SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
794   aStudyBuilder->NewCommand();
795
796   // is it Prs3d object ?
797   VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject).in());
798   if (aPrsObject) {
799     DeletePrs3d(this, aPrsObject, anIO);
800   }
801
802   // is it Curve object ?
803   VISU::Curve_i* aCurveObject = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(anObject).in());
804   if (aCurveObject) {
805     //jfa tmp:DeleteCurve(this, aCurveObject, anIO);
806   }
807
808   aStudyBuilder->CommitCommand();
809 }
810
811
812 void
813 VisuGUI::
814 OnEraseAll()
815 {
816   if (SVTK_ViewWindow* vw = GetViewWindow()) {
817     vw->unHighlightAll();
818     if (vtkRenderer *aRen = vw->getRenderer()) {
819       vtkActor *anActor;
820       vtkActorCollection *anActColl = aRen->GetActors();
821       for (anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL; ) {
822         if (anActor->GetVisibility() > 0)
823           if (VISU_Actor* anVISUActor = VISU_Actor::SafeDownCast(anActor)) {
824             anVISUActor = anVISUActor->GetParent();
825             anVISUActor->VisibilityOff();
826           }
827       }
828       vw->Repaint();
829     }
830   } else if (SPlot2d_Viewer* aPlot2d = GetPlot2dViewer(this, false)) {
831     aPlot2d->EraseAll();
832   }
833 }
834
835 void
836 VisuGUI::
837 OnMakeSurfaceframe()
838 {
839   ChangeRepresentation(this, VISU::SURFACEFRAME);
840 }
841
842 void
843 VisuGUI::
844 OnMakeInsideframe()
845 {
846   ChangeRepresentation(this, VISU::INSIDEFRAME);
847 }
848
849 void
850 VisuGUI::
851 OnMakeWireframe()
852 {
853   ChangeRepresentation(this, VISU::WIREFRAME);
854 }
855
856 void
857 VisuGUI::
858 OnMakeSurface()
859 {
860   ChangeRepresentation(this, VISU::SHADED);
861 }
862
863 void
864 VisuGUI::
865 OnMakePoints()
866 {
867   ChangeRepresentation(this, VISU::POINT);
868 }
869
870 void
871 VisuGUI::
872 OnMakeShrink()
873 {
874   ChangeRepresentation(this, VISU::SHRINK);
875 }
876
877 void
878 VisuGUI::
879 OnChangeColor()
880 {
881   Handle(SALOME_InteractiveObject) anIO;
882   CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
883   if (CORBA::is_nil(anObject)) return;
884   PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
885   if (!aServant.in()) return;
886
887   VISU::Prs3d_i* aPrs3d = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
888   if (!aPrs3d) return;
889
890   SVTK_ViewWindow* vw = GetViewWindow();
891   if (!vw) return;
892
893   VISU_Actor* anActor = GetActor(aPrs3d, vw);
894   if (!anActor) return;
895
896   VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrs3d);
897   VISU::DeformedShape_i* aDeformedShape = dynamic_cast<VISU::DeformedShape_i*>(aPrs3d);
898   SALOMEDS::Color anOldColor, aNewColor;
899   int aRepresent = anActor->GetRepresentation();
900   if (aMesh) {
901     switch (aRepresent) {
902       case VISU::POINT :
903         anOldColor = aMesh->GetNodeColor();
904         break;
905       case VISU::WIREFRAME :
906       case VISU::INSIDEFRAME :
907         anOldColor = aMesh->GetLinkColor();
908         break;
909       case VISU::SHADED :
910       case VISU::SURFACEFRAME :
911         anOldColor = aMesh->GetCellColor();
912         break;
913     }
914   } else if (aDeformedShape) {
915     anOldColor = aDeformedShape->GetColor();
916   } else {
917     return;
918   }
919
920   QColor aColor (int(255*anOldColor.R),
921                  int(255*anOldColor.G),
922                  int(255*anOldColor.B));
923   QColor aColorNew = QColorDialog::getColor(aColor, GetDesktop(this));
924   if (aColorNew.isValid()) {
925     aNewColor.R = aColorNew.red()/255.;
926     aNewColor.G = aColorNew.green()/255.;
927     aNewColor.B = aColorNew.blue()/255.;
928     if (aMesh) {
929       switch (aRepresent) {
930         case VISU::POINT :
931           aMesh->SetNodeColor(aNewColor);
932           break;
933         case VISU::WIREFRAME :
934         case VISU::INSIDEFRAME :
935           aMesh->SetLinkColor(aNewColor);
936           break;
937         case VISU::SHADED :
938         case VISU::SURFACEFRAME :
939           aMesh->SetCellColor(aNewColor);
940           break;
941       }
942     } else {
943       aDeformedShape->SetColor(aNewColor);
944     }
945     RecreateActor(this, aPrs3d);
946   }
947 }
948
949 void
950 VisuGUI::
951 OnChangeWireframeColor()
952 {
953   Handle(SALOME_InteractiveObject) anIO;
954   CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
955   if (CORBA::is_nil(anObject)) return;
956   PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
957   if (!aServant.in()) return;
958
959   VISU::Prs3d_i* aPrs3d = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
960   if (!aPrs3d) return;
961
962   SVTK_ViewWindow* vw = GetViewWindow();
963   if (!vw) return;
964
965   VISU_Actor* anActor = GetActor(aPrs3d, vw);
966   if (!anActor) return;
967
968   if (VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrs3d)) {
969     SALOMEDS::Color anOldColor = aMesh->GetLinkColor(), aNewColor;
970     QColor aColor (int(255*anOldColor.R),
971                    int(255*anOldColor.G),
972                    int(255*anOldColor.B));
973     QColor aColorNew = QColorDialog::getColor(aColor, GetDesktop(this));
974     if (aColorNew.isValid()) {
975       aNewColor.R = aColorNew.red()/255.;
976       aNewColor.G = aColorNew.green()/255.;
977       aNewColor.B = aColorNew.blue()/255.;
978       aMesh->SetLinkColor(aNewColor);
979       RecreateActor(this, aMesh);
980     }
981   }
982 }
983
984 void
985 VisuGUI::
986 OnChangeOpacity()
987 {
988   Handle(SALOME_InteractiveObject) anIO;
989   CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
990   if (CORBA::is_nil(anObject)) return;
991   PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
992   if (!aServant.in()) return;
993
994   VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
995   if (!aPrsObject) return;
996
997   SVTK_ViewWindow* vw = GetViewWindow();
998   if (!vw) return;
999
1000   VISU_Actor* anActor = GetActor(aPrsObject, vw);
1001   if (!anActor) return;
1002
1003   VisuGUI_CursorDlg* CursorDlg =
1004     new VisuGUI_CursorDlg (GetDesktop(this), tr("DLG_OPACITY_TITLE"), TRUE);
1005
1006   CursorDlg->Comment1->setText(tr("DLG_OPACITY_CMT1"));
1007   CursorDlg->Comment2->setText(tr("DLG_OPACITY_CMT2"));
1008   CursorDlg->SpinBox1->setMinValue(0);
1009   CursorDlg->SpinBox1->setMaxValue(100);
1010
1011   float oldopac = anActor->GetOpacity();
1012   int intopac = int(oldopac*100. + 0.5);
1013   CursorDlg->SpinBox1->setValue(intopac);
1014
1015   int ret = CursorDlg->exec();
1016   if (ret == 1) {
1017     intopac = CursorDlg->SpinBox1->value();
1018     float newopac = intopac/100.;
1019     anActor->SetOpacity(newopac);
1020   }
1021   delete CursorDlg;
1022 }
1023
1024 void
1025 VisuGUI::
1026 OnChangeLines()
1027 {
1028   Handle(SALOME_InteractiveObject) anIO;
1029   CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
1030   if (CORBA::is_nil(anObject)) return;
1031   PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
1032   if (!aServant.in()) return;
1033
1034   VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
1035   if (!aPrsObject) return;
1036
1037   SVTK_ViewWindow* vw = GetViewWindow();
1038   if (!vw) return;
1039
1040   VISU_Actor* anActor = GetActor(aPrsObject, vw);
1041   if (!anActor) return;
1042
1043   VisuGUI_CursorDlg* CursorDlg =
1044     new VisuGUI_CursorDlg (GetDesktop(this), tr("DLG_LINEWIDTH_TITLE"), TRUE);
1045
1046   CursorDlg->Comment1->setText(tr("DLG_LINEWIDTH_CMT1"));
1047   CursorDlg->Comment2->setText(tr("DLG_LINEWIDTH_CMT2"));
1048   CursorDlg->SpinBox1->setMinValue(1);
1049   CursorDlg->SpinBox1->setMaxValue(10);
1050
1051   float oldlwid = anActor->GetLineWidth();
1052   int intlwid = int(oldlwid);
1053   CursorDlg->SpinBox1->setValue(intlwid);
1054
1055   int ret = CursorDlg->exec();
1056   if (ret == 1) {
1057     intlwid  = CursorDlg->SpinBox1->value();
1058     float newlwid = intlwid;
1059     anActor->SetLineWidth(newlwid);
1060   }
1061   delete CursorDlg;
1062 }
1063
1064 void
1065 VisuGUI::
1066 OnShowTable()
1067 {
1068   Handle(SALOME_InteractiveObject) anIO;
1069   CORBA::Object_var anObject = GetSelectedObj( this, &anIO );
1070   _PTR(SObject) SO;
1071   if ( !CORBA::is_nil( anObject ) ) {
1072     VISU::Base_var aVisuObj = VISU::Base::_narrow( anObject );
1073     if ( !CORBA::is_nil( aVisuObj ) && aVisuObj->GetType() == VISU::TTABLE ) {
1074       CORBA::Object_ptr aTable = VISU::Table::_narrow( anObject );
1075       if( !CORBA::is_nil( aTable ) ) {
1076         VISU::Table_i* table = dynamic_cast<VISU::Table_i*>( VISU::GetServant(aTable).in() );
1077         if ( table ) {
1078           SO = GetCStudy( GetAppStudy( this ) )->FindObjectID( table->GetObjectEntry() );
1079         }
1080       }
1081     }
1082   } else {
1083     // possibly this is Table SObject
1084     SO = GetCStudy( GetAppStudy( this ) )->FindObjectID( anIO->getEntry() );
1085   }
1086
1087   if( !IsSObjectTable( SO ) )
1088     return;
1089
1090   VisuGUI_TableDlg* dlg = new VisuGUI_TableDlg( GetDesktop( this ),
1091                                                SO,
1092                                                false,
1093                                                //SAL2670 Orientation of show tables
1094                                                VisuGUI_TableDlg::ttAuto,
1095                                                Qt::Vertical );
1096   dlg->show();
1097 }
1098
1099 void
1100 VisuGUI::
1101 OnCreateTable()
1102 {
1103   Handle(SALOME_InteractiveObject) anIO;
1104   CORBA::Object_var anObject = GetSelectedObj( this, &anIO );
1105   _PTR(Study) aStudy = GetCStudy( GetAppStudy( this ) );
1106   _PTR(SObject) aSObject = aStudy->FindObjectID(anIO->getEntry());
1107   VISU::CutLines_var aCutLines = VISU::CutLines::_narrow( anObject );
1108   if(!aCutLines->_is_nil() || IsSObjectTable(aSObject)) {
1109     GetVisuGen( this )->CreateTable( aSObject->GetID().c_str() );
1110     updateObjBrowser();
1111   }
1112 }
1113
1114 void
1115 VisuGUI::
1116 OnDeleteObject()
1117 {
1118   _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1119   if (CheckLock(aCStudy))
1120     return;
1121   SALOMEDS::Study_var aStudy = GetDSStudy(aCStudy);
1122
1123   Handle(SALOME_InteractiveObject) anIO;
1124   CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
1125   if (anIO.IsNull() || !anIO->hasEntry())
1126     return;
1127
1128   SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(anIO->getEntry());
1129   if (!aSObject->_is_nil()) {
1130     SALOMEDS::ChildIterator_var aChildIter = aStudy->NewChildIterator(aSObject);
1131     for (aChildIter->InitEx(true); aChildIter->More(); aChildIter->Next()) {
1132       SALOMEDS::SObject_var aChildSObject = aChildIter->Value();
1133       CORBA::Object_var aChildObj = VISU::SObjectToObject(aChildSObject);
1134       ErasePrs(this, aChildObj);
1135     }
1136     SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
1137     // There is a transaction
1138     aStudyBuilder->NewCommand();
1139     CORBA::Object_var anObj = VISU::SObjectToObject(aSObject);
1140     if (!CORBA::is_nil(anObj)) {
1141       VISU::Base_var aBase = VISU::Base::_narrow(anObj);
1142       if (!CORBA::is_nil(aBase)) {
1143         VISU::VISUType aType = aBase->GetType();
1144         switch (aType) {
1145         case VISU::TRESULT:
1146           {
1147             SALOMEDS::ChildIterator_var aChildIter = aStudy->NewChildIterator(aSObject);
1148             for (aChildIter->InitEx(true); aChildIter->More(); aChildIter->Next()) {
1149               SALOMEDS::SObject_var aChildSObject = aChildIter->Value();
1150               CORBA::Object_var aChildObj = VISU::SObjectToObject(aChildSObject);
1151               if (CORBA::is_nil(aChildObj)) continue;
1152               VISU::Prs3d_var aPrs3d = VISU::Prs3d::_narrow(aChildObj);
1153               if (CORBA::is_nil(aPrs3d)) continue;
1154               VISU::Prs3d_i* pPrs3d = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(aPrs3d).in());
1155               DeletePrs3d(this, pPrs3d, NULL);
1156             }
1157             break;
1158           }
1159         case VISU::TTABLE:
1160           {
1161             SALOMEDS::ChildIterator_var aChildIter = aStudy->NewChildIterator(aSObject);
1162             for (aChildIter->InitEx(true); aChildIter->More(); aChildIter->Next()) {
1163               SALOMEDS::SObject_var aChildSObject = aChildIter->Value();
1164               CORBA::Object_var aChildObj = VISU::SObjectToObject(aChildSObject);
1165               if (CORBA::is_nil(aChildObj)) continue;
1166               CORBA::Object_ptr aCurve = VISU::Curve::_narrow(aChildObj);
1167               if (CORBA::is_nil(aCurve)) continue;
1168               //VISU::Curve_i* pCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
1169               //jfa tmp:DeleteCurve(this, pCurve, NULL);
1170             }
1171             break;
1172           }
1173         }
1174       }
1175     }
1176     aStudyBuilder->RemoveObjectWithChildren(aSObject);
1177     aStudyBuilder->CommitCommand();
1178     //jfa tmp:GetActiveStudy()->unHighlightAll();
1179     updateObjBrowser(true);
1180   }
1181 }
1182
1183 void
1184 VisuGUI::
1185 OnDeleteObjects()
1186 {
1187   _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1188   if (CheckLock(aCStudy))
1189     return;
1190   SALOMEDS::Study_var aStudy = GetDSStudy(aCStudy);
1191
1192   SALOME_ListIO aList;
1193   SalomeApp_SelectionMgr* mgr = GetSelectionMgr(this);
1194   mgr->selectedObjects(aList);
1195   int i = 0, nbSelected = aList.Extent();
1196   if (nbSelected < 1) return;
1197
1198   const char* entries [nbSelected];
1199   Handle(SALOME_InteractiveObject) anIO;
1200   for (SALOME_ListIteratorOfListIO it (aList); it.More(); it.Next()) {
1201     anIO = it.Value();
1202     if (anIO->hasEntry())
1203       entries[i++] = anIO->getEntry();
1204   }
1205   nbSelected = i;
1206   if (nbSelected < 1) return;
1207
1208   // There is a transaction
1209   SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
1210   aStudyBuilder->NewCommand();
1211
1212   for (i = 0; i < nbSelected; i++) {
1213     SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(entries[i]);
1214     if (!aSObject->_is_nil()) {
1215       DeleteSObject(this, aStudy, aSObject);
1216     }
1217   }
1218
1219   // Finish transaction
1220   aStudyBuilder->CommitCommand();
1221
1222   //GetActiveStudy()->unHighlightAll();
1223   updateObjBrowser(true);
1224 }
1225
1226 void
1227 VisuGUI::
1228 OnPlotData()
1229 {
1230   Handle(SALOME_InteractiveObject) anIO;
1231   CORBA::Object_var anObject = GetSelectedObj( this, &anIO );
1232   _PTR(SObject) SO;
1233   _PTR(GenericAttribute) anAttr;
1234   _PTR(AttributeName)    aName;
1235   QString SOName;
1236   _PTR(Study) aStudy = GetCStudy( GetAppStudy( this ) );
1237
1238   if ( !CORBA::is_nil( anObject ) ) {
1239     VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
1240     if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TTABLE) {
1241       // Table (VISU object) is selected
1242       CORBA::Object_ptr aTbl = VISU::Table::_narrow( anObject );
1243       if( !CORBA::is_nil( aTbl ) ) {
1244         VISU::Table_i* table = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTbl).in());
1245         if ( table ) {
1246           _PTR(SObject) SO = aStudy->FindObjectID( table->GetObjectEntry() );
1247           if ( IsSObjectTable(SO) ) {
1248             // get name of SObject
1249             if ( SO->FindAttribute( anAttr, "AttributeName" ) ) {
1250               aName = anAttr;
1251               SOName = QString( aName->Value().c_str() );
1252             }
1253             SPlot2d_SetupPlot2dDlg* dlg = new SPlot2d_SetupPlot2dDlg( SO, GetDesktop( this ) );
1254             if ( dlg->exec() == QDialog::Accepted ) {
1255               if ( !IsStudyLocked( aStudy ) ) {
1256                 // if study is not locked - create new container, create curves and insert them
1257                 // into container, then plot container if current viewer is of VIEW_PLOT2D type
1258                 int horIndex;
1259                 QValueList<int> verIndices;
1260                 dlg->getCurvesSource( horIndex, verIndices );
1261                 if ( horIndex >= 0 && verIndices.count() > 0 ) {
1262                   CORBA::Object_var aContainer = GetVisuGen(this)->CreateContainer();
1263                   if( !CORBA::is_nil( aContainer ) ) {
1264                     VISU::Container_i* pContainer =
1265                       dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
1266                     if ( pContainer ) {
1267                       for ( int i = 0; i < verIndices.count(); i++ ) {
1268                         CORBA::Object_var aNewCurve =
1269                           GetVisuGen(this)->CreateCurve( table->_this(), horIndex+1, verIndices[i]+1 );
1270                         if( !CORBA::is_nil( aNewCurve ) ) {
1271                           VISU::Curve_i* pCrv =
1272                             dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aNewCurve).in());
1273                           if ( pCrv ) {
1274                             bool isAuto;
1275                             int  marker, line, lineWidth;
1276                             QColor color;
1277                             if ( dlg->getCurveAttributes(verIndices[i], isAuto, marker,
1278                                                          line, lineWidth, color) && !isAuto ) {
1279                               SALOMEDS::Color c;
1280                               c.R = color.red()  /255.;
1281                               c.G = color.green()/255.;
1282                               c.B = color.blue() /255.;
1283                               pCrv->SetColor( c );
1284                               pCrv->SetMarker( ( VISU::Curve::MarkerType )marker );
1285                               pCrv->SetLine( ( VISU::Curve::LineType )line, lineWidth );
1286                             }
1287                             pContainer->AddCurve( pCrv->_this() );
1288                           }
1289                         }
1290                       }
1291                       updateObjBrowser();
1292                       PlotContainer( this, pContainer, VISU::eDisplay );
1293                     }
1294                   }
1295                 }
1296               }
1297               else {
1298                 // if study is locked just get curves info and plot them
1299                 // if current viewer is of VIEW_PLOT2D type
1300                 QPtrList<Plot2d_Curve> container;
1301                 dlg->getCurves( container );
1302                 if ( !container.isEmpty() ) {
1303                   GetPlot2dViewer( this )->getActiveViewFrame()->displayCurves( container, true );
1304                   GetPlot2dViewer( this )->getActiveViewFrame()->setTitle( SOName );
1305                 }
1306               }
1307             }
1308             delete dlg;
1309           }
1310         }
1311       }
1312     }
1313   }
1314   else if ( !anIO.IsNull() ) {
1315     // check if Table SObject is selected
1316     SO = aStudy->FindObjectID( anIO->getEntry() );
1317     if ( IsSObjectTable(SO) ) {
1318       // get name of SObject
1319       if ( SO->FindAttribute( anAttr, "AttributeName" ) ) {
1320         aName = anAttr;
1321         SOName = QString( aName->Value().c_str() );
1322       }
1323       SPlot2d_SetupPlot2dDlg* dlg = new SPlot2d_SetupPlot2dDlg( SO, GetDesktop( this ) );
1324       if ( dlg->exec() == QDialog::Accepted ) {
1325         if ( !IsStudyLocked( aStudy ) ) {
1326           // if study is not locked - create new table and container objects, create curves
1327           // and insert them into container, then plot container if current viewer is of VIEW_PLOT2D type
1328           int horIndex;
1329           QValueList<int> verIndices;
1330           dlg->getCurvesSource( horIndex, verIndices );
1331           if ( horIndex >= 0 && verIndices.count() > 0 ) {
1332             CORBA::Object_var aTable = GetVisuGen(this)->CreateTable( SO->GetID().c_str() );
1333             CORBA::Object_var aContainer = GetVisuGen(this)->CreateContainer();
1334             if ( !CORBA::is_nil( aTable ) && !CORBA::is_nil( aContainer ) ) {
1335               VISU::Table_i*     pTable     = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTable).in());
1336               VISU::Container_i* pContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
1337
1338               if ( pContainer && pTable ) {
1339                 for ( int i = 0; i < verIndices.count(); i++ ) {
1340                   CORBA::Object_var aNewCurve = GetVisuGen(this)->CreateCurve
1341                     ( pTable->_this(), horIndex+1, verIndices[i]+1 );
1342                   if( !CORBA::is_nil( aNewCurve ) ) {
1343                     VISU::Curve_i* pCrv = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aNewCurve).in());
1344                     if ( pCrv ) {
1345                       bool isAuto;
1346                       int  marker, line, lineWidth;
1347                       QColor color;
1348                       if ( dlg->getCurveAttributes(verIndices[i], isAuto, marker,
1349                                                    line, lineWidth, color) && !isAuto ) {
1350                         SALOMEDS::Color c;
1351                         c.R = color.red()/255.;
1352                         c.G = color.green()/255.;
1353                         c.B = color.blue()/255.;
1354                         pCrv->SetColor( c );
1355                         pCrv->SetMarker( ( VISU::Curve::MarkerType )marker );
1356                         pCrv->SetLine( ( VISU::Curve::LineType )line, lineWidth );
1357                       }
1358                       pContainer->AddCurve( pCrv->_this() );
1359                     }
1360                   }
1361                 }
1362                 updateObjBrowser();
1363                 PlotContainer( this, pContainer, VISU::eDisplay );
1364               }
1365             }
1366           }
1367         } else {
1368           // if study is locked just get curves info and plot them
1369           QPtrList<Plot2d_Curve> container;
1370           dlg->getCurves( container );
1371           if ( !container.isEmpty() ) {
1372             GetPlot2dViewer( this )->getActiveViewFrame()->displayCurves( container, true );
1373             GetPlot2dViewer( this )->getActiveViewFrame()->setTitle( SOName );
1374           }
1375         }
1376       }
1377       delete dlg;
1378     }
1379   }
1380 }
1381
1382 void
1383 VisuGUI::
1384 OnCurveProperties()
1385 {
1386   SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1387   SALOME_ListIO aListIO;
1388   aSelectionMgr->selectedObjects(aListIO);
1389   if (aListIO.Extent() != 1) return;
1390
1391   SalomeApp_Study* aAppStudy = GetAppStudy(this);
1392   const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
1393   CORBA::Object_var anObject = GetSelectedObj( aAppStudy, anIO->getEntry() );
1394   if (CORBA::is_nil( anObject )) return;
1395
1396   VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
1397   if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCURVE) {
1398     // Curve object
1399     CORBA::Object_ptr aCurve = VISU::Curve::_narrow( anObject );
1400     if( !CORBA::is_nil( aCurve ) ) {
1401       VISU::Curve_i* aDSCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
1402       if ( aDSCurve && (!IsStudyLocked( GetCStudy(aAppStudy) )) ) {
1403         Plot2d_SetupCurveDlg aDlg(GetDesktop( this ));
1404
1405         aDlg.setLine( (int)aDSCurve->GetLine(), aDSCurve->GetLineWidth() );
1406         aDlg.setMarker( (int)aDSCurve->GetMarker() );
1407         SALOMEDS::Color aColor = aDSCurve->GetColor();
1408         aDlg.setColor( QColor( (int)(aColor.R*255.), (int)(aColor.G*255.), (int)(aColor.B*255.) ) );
1409         if( aDlg.exec() == QDialog::Accepted ) {
1410           aDSCurve->SetLine( (VISU::Curve::LineType)aDlg.getLine(), aDlg.getLineWidth() );
1411           aDSCurve->SetMarker( (VISU::Curve::MarkerType)aDlg.getMarker());
1412           SALOMEDS::Color newColor;
1413           newColor.R = aDlg.getColor().red()/255.;
1414           newColor.G = aDlg.getColor().green()/255.;
1415           newColor.B = aDlg.getColor().blue()/255.;
1416           aDSCurve->SetColor( newColor );
1417           PlotCurve(this, aDSCurve, VISU::eDisplay);
1418         }
1419       }
1420     }
1421   }
1422 }
1423
1424 void
1425 VisuGUI::
1426 OnClearContainer()
1427 {
1428   _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1429   if (CheckLock(aCStudy))
1430     return;
1431   SALOMEDS::Study_var aStudy = GetDSStudy(aCStudy);
1432   Handle(SALOME_InteractiveObject) anIO;
1433   CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
1434   if (anIO.IsNull() || CORBA::is_nil(anObject))
1435     return;
1436
1437   VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
1438   if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCONTAINER) {
1439     // Container object
1440     CORBA::Object_ptr aCnt = VISU::Container::_narrow(anObject);
1441     if (!CORBA::is_nil(aCnt)) {
1442       VISU::Container_i* container = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aCnt).in());
1443       if (container && container->GetNbCurves() > 0) {
1444         container->Clear();
1445         updateObjBrowser();
1446       }
1447     }
1448   }
1449 }
1450
1451 void
1452 VisuGUI::
1453 OnEditContainer()
1454 {
1455   Handle(SALOME_InteractiveObject) anIO;
1456   CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
1457   if (CORBA::is_nil(anObject)) return;
1458
1459   PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
1460   if (!aServant.in()) return;
1461   VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(aServant.in());
1462   if (!aContainer) return;
1463
1464   VisuGUI_EditContainerDlg* aDlg = new VisuGUI_EditContainerDlg (GetDesktop(this));
1465   aDlg->initFromPrsObject(aContainer);
1466   if (aDlg->exec()) {
1467     aDlg->storeToPrsObject(aContainer);
1468     updateObjBrowser(true);
1469   }
1470   delete aDlg;
1471 }
1472
1473 void
1474 VisuGUI::
1475 OnSaveViewParams()
1476 {
1477   _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1478   if (CheckLock(aCStudy))
1479     return;
1480   SALOMEDS::Study_var aStudy = GetDSStudy(aCStudy);
1481
1482   SUIT_ViewManager* aViewMgr = getApp()->activeViewManager();
1483   if (aViewMgr->getType() != SVTK_Viewer::Type())
1484     return;
1485
1486   SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1487   SALOME_ListIO aListIO;
1488   aSelectionMgr->selectedObjects(aListIO);
1489   if (aListIO.Extent() > 1)
1490     return;
1491
1492   if (aListIO.Extent() == 0) {
1493     VISU::View3D_i::SaveViewParams(aViewMgr, VISU::View3D_i::GenerateViewParamsName().latin1());
1494   } else {
1495     const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
1496     VISU::View3D_i::SaveViewParams(aViewMgr, anIO->getName());
1497   }
1498   updateObjBrowser();
1499 }
1500
1501 void
1502 VisuGUI::
1503 OnRestoreViewParams()
1504 {
1505   SUIT_ViewManager* aViewMgr = getApp()->activeViewManager();
1506   if (aViewMgr->getType() != SVTK_Viewer::Type())
1507     return;
1508
1509   SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1510   SALOME_ListIO aListIO;
1511   aSelectionMgr->selectedObjects(aListIO);
1512   if (aListIO.Extent() != 1)
1513     return;
1514
1515   const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
1516   //jfa tmp:VISU::View3D_i::RestoreViewParams(aViewMgr, anIO->getName());
1517   _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));//jfa tmp
1518   _PTR(SObject) aSObj = aCStudy->FindObjectID(anIO->getEntry());//jfa tmp
1519   VISU::View3D_i::RestoreViewParams(aViewMgr, aSObj->GetName().c_str());//jfa tmp
1520 }
1521
1522 void
1523 VisuGUI::
1524 OnDeleteViewParams()
1525 {
1526   _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1527   if (CheckLock(aCStudy))
1528     return;
1529   SALOMEDS::Study_var aStudy = GetDSStudy(aCStudy);
1530
1531   Handle(SALOME_InteractiveObject) anIO;
1532   CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
1533   _PTR(SObject) aSObject = aCStudy->FindObjectID(anIO->getEntry());
1534   if (!aSObject) return;
1535
1536   VISU::VISUType aType = (VISU::VISUType)getValue(aSObject, "myType").toInt();
1537   if (aType == VISU::TVIEW3D) {
1538     SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1539     SALOME_ListIO aListIO, aNewListIO;
1540     aSelectionMgr->selectedObjects(aListIO);
1541     for (SALOME_ListIteratorOfListIO it (aListIO); it.More(); it.Next()) {
1542       if (it.Value()->getEntry() != anIO->getEntry()) {
1543         aNewListIO.Append(it.Value());
1544       }
1545     }
1546     aSelectionMgr->setSelectedObjects(aNewListIO);
1547
1548     aCStudy->NewBuilder()->RemoveObject(aSObject);
1549
1550     updateObjBrowser();
1551   }
1552 }
1553
1554 void
1555 VisuGUI::
1556 OnRename()
1557 {
1558   _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1559   if (CheckLock(aCStudy))
1560     return;
1561
1562   Handle(SALOME_InteractiveObject) anIO;
1563   CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
1564
1565   _PTR(SObject) aSObj = aCStudy->FindObjectID(anIO->getEntry());
1566   if (!aSObj) return;
1567
1568   //TEST DU PARENT == VISU
1569   _PTR(GenericAttribute) anAttr;
1570   if (aSObj->FindAttribute(anAttr, "AttributeName")) {
1571     _PTR(AttributeName) aName (anAttr);
1572     QString Name = VisuGUI_NameDlg::getName( GetDesktop( this ), aName->Value().c_str() );
1573     if (!Name.isEmpty()) {
1574       QApplication::setOverrideCursor(Qt::waitCursor);
1575
1576       // rename specific objects
1577       if (!CORBA::is_nil(anObject)) {
1578         VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
1579         if (!CORBA::is_nil(aVisuObj)) {
1580           switch (aVisuObj->GetType()) {
1581             case VISU::TCURVE: // Curve object
1582             {
1583               CORBA::Object_ptr aCurve = VISU::Curve::_narrow(anObject);
1584               if (!CORBA::is_nil(aCurve)) {
1585                 VISU::Curve_i* curve =
1586                   dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
1587                 if (curve)
1588                   curve->SetName(Name.latin1());
1589               }
1590               break;
1591             }
1592             case VISU::TTABLE: // Table object
1593             {
1594               CORBA::Object_ptr aTable = VISU::Table::_narrow(anObject);
1595               if (!CORBA::is_nil(aTable)) {
1596                 VISU::Table_i* table =
1597                   dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTable).in());
1598                 if (table)
1599                   table->SetName(Name.latin1());
1600               }
1601               break;
1602             }
1603             case VISU::TCONTAINER: // Container object
1604             {
1605               CORBA::Object_ptr aContainer = VISU::Container::_narrow(anObject);
1606               if (!CORBA::is_nil(aContainer)) {
1607                 VISU::Container_i* container =
1608                   dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
1609                 if (container)
1610                   container->SetName(Name.latin1());
1611               }
1612               break;
1613             }
1614             default:
1615             {
1616             }
1617           }
1618         }
1619       }
1620
1621       // rename the study object
1622       //getApp()->activeStudy()->renameIObject(anIO, Name);
1623       aName->SetValue(Name.latin1()); // rename the SObject
1624       anIO->setName(Name.latin1()); // rename the InteractiveObject
1625       updateObjBrowser(false);
1626
1627       QApplication::restoreOverrideCursor();
1628     }
1629   }
1630 }
1631
1632 void
1633 VisuGUI::
1634 OnClippingPlanes()
1635 {
1636   new VisuGUI_ClippingDlg (this, "", false);
1637 }
1638
1639 void
1640 VisuGUI::
1641 OnSweep()
1642 {
1643   // GetSelectedPrs3d
1644   Handle(SALOME_InteractiveObject) anIO;
1645   CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
1646   if (CORBA::is_nil(anObject)) return;
1647   PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
1648   if (!aServant.in()) return;
1649
1650   VISU::ScalarMap_i* aPrsObject = dynamic_cast<VISU::ScalarMap_i*>(aServant.in());
1651   if (!aPrsObject) return;
1652
1653   SVTK_ViewWindow* vw = GetViewWindow();
1654   if (!vw) return;
1655
1656   VISU_Actor* aActor = GetActor(aPrsObject, vw);
1657   if (!aActor) return;
1658
1659   if (!aActor->GetVisibility()) {
1660     aActor->VisibilityOn();
1661   }
1662
1663   // Get sweep parameters
1664   SUIT_ResourceMgr* aResourceMgr = GetResourceMgr();
1665
1666   double aTempoDbl = aResourceMgr->doubleValue("Visu:SweepTempo", 0.1);
1667   int aTemp = int(1.E6 * aTempoDbl);
1668
1669   int aCycles = aResourceMgr->integerValue("Visu:SweepCycles", 1);
1670   int aSteps  = aResourceMgr->integerValue("Visu:SweepSteps", 40);
1671
1672   // Sweep
1673   QApplication::setOverrideCursor(Qt::waitCursor);
1674   try {
1675     for (int j = 0; j < aCycles; j++) {
1676       for (int i = 0; i <= aSteps; i++) {
1677         float aPercents = float(i)/aSteps;
1678         aPrsObject->SetMapScale(aPercents);
1679         aPrsObject->UpdateActor(aActor);
1680         vw->getRenderWindow()->getRenderWindow()->Render();
1681         usleep(aTemp);
1682       }
1683     }
1684   } catch (std::exception& exc) {
1685     INFOS("Follow exception was occured :\n" << exc.what());
1686   } catch (...) {
1687     INFOS("Unknown exception was occured!");
1688   }
1689   QApplication::restoreOverrideCursor();
1690 }
1691
1692 void
1693 VisuGUI::
1694 OnTimeAnimation()
1695 {
1696   _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1697   VisuGUI_TimeAnimationDlg* aAnimationDlg =
1698 //    new VisuGUI_TimeAnimationDlg(GetDesktop(this), aCStudy);
1699     new VisuGUI_TimeAnimationDlg (this, aCStudy);
1700
1701   SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1702   SALOME_ListIO aListIO;
1703   aSelectionMgr->selectedObjects(aListIO);
1704
1705   bool isDefined = false;
1706   long aNbTimes = 0;
1707   SALOME_ListIteratorOfListIO It (aListIO);
1708   for (; It.More(); It.Next()) {
1709     _PTR(SObject) aSObject = aCStudy->FindObjectID(It.Value()->getEntry());
1710     if (!aSObject) continue;
1711     if (getValue(aSObject, "myComment") == QString("FIELD")) {
1712       long aNumber = getValue(aSObject, "myNbTimeStamps").toLong();
1713       if (aNumber > 1) {
1714         if (!isDefined) {
1715           aNbTimes = aNumber;
1716           aAnimationDlg->addField(aSObject);
1717           isDefined = true;
1718         } else if (aNbTimes == aNumber) {
1719           aAnimationDlg->addField(aSObject);
1720         }
1721       }
1722     }
1723   }
1724   if (isDefined) aAnimationDlg->show();
1725   else delete aAnimationDlg;
1726 }
1727
1728 //************************************************************************
1729 void
1730 VisuGUI::
1731 OnShowAnimation()
1732 {
1733   SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1734   SALOME_ListIO aListIO;
1735   aSelectionMgr->selectedObjects(aListIO);
1736
1737   if (aListIO.Extent() != 1)
1738     return;
1739
1740   const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
1741
1742   _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1743
1744   _PTR(SObject) aSObj = aCStudy->FindObjectID(anIO->getEntry());
1745   if (!aSObj) return;
1746
1747   VISU::Storable::TRestoringMap aMap;
1748   _PTR(GenericAttribute) anAttr;
1749   if (!aSObj->FindAttribute(anAttr, "AttributeComment")) return;
1750
1751   _PTR(AttributeComment) aComment (anAttr);
1752   string aComm = aComment->Value();
1753   QString strIn (aComm.c_str());
1754   VISU::Storable::StrToMap(strIn, aMap);
1755   bool isExist;
1756   VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt();
1757   if (aType != VISU::TANIMATION) return;
1758
1759   VisuGUI_TimeAnimationDlg* aAnimationDlg =
1760     new VisuGUI_TimeAnimationDlg(this, aCStudy);
1761   aAnimationDlg->restoreFromStudy(aSObj);
1762   aAnimationDlg->show();
1763 }
1764
1765 void
1766 VisuGUI::
1767 OnCopyPresentation()
1768 {
1769   _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1770   if (CheckLock(aCStudy))
1771     return;
1772
1773   Handle(SALOME_InteractiveObject) anIO;
1774   CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
1775   if (CORBA::is_nil(anObject)) return;
1776   PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
1777   if (!aServant.in()) return;
1778
1779   VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
1780   if (!aPrsObject) return;
1781
1782   switch (aPrsObject->GetType()) {
1783   case VISU::TMESH:
1784     {
1785       VISU::Mesh_i* aMeshPrs = dynamic_cast<VISU::Mesh_i*>(aPrsObject);
1786       VISU::Mesh_i* aSameMesh = new VISU::Mesh_i(aMeshPrs->GetResult());
1787       aSameMesh->SameAs(aMeshPrs);
1788       UpdateViewer(this, aSameMesh);
1789     }
1790     break;
1791   case VISU::TSCALARMAP:
1792     {
1793       VISU::ScalarMap_i* aScalarPrs = dynamic_cast<VISU::ScalarMap_i*>(aPrsObject);
1794       VISU::ScalarMap_i* aSameScalar = new VISU::ScalarMap_i(aScalarPrs->GetResult(),true);
1795       aSameScalar->SameAs(aScalarPrs);
1796       UpdateViewer(this, aSameScalar);
1797     }
1798     break;
1799   case VISU::TDEFORMEDSHAPE:
1800     {
1801       VISU::DeformedShape_i* aDefPrs = dynamic_cast<VISU::DeformedShape_i*>(aPrsObject);
1802       VISU::DeformedShape_i* aSameDeformed = new VISU::DeformedShape_i(aDefPrs->GetResult(),true);
1803       aSameDeformed->SameAs(aDefPrs);
1804       UpdateViewer(this, aSameDeformed);
1805     }
1806     break;
1807   case VISU::TCUTPLANES:
1808     {
1809       VISU::CutPlanes_i* aCutPrs = dynamic_cast<VISU::CutPlanes_i*>(aPrsObject);
1810       VISU::CutPlanes_i* aSameCut = new VISU::CutPlanes_i(aCutPrs->GetResult(),true);
1811       aSameCut->SameAs(aCutPrs);
1812       UpdateViewer(this, aSameCut);
1813     }
1814     break;
1815   case VISU::TCUTLINES:
1816     {
1817       VISU::CutLines_i* aCutPrs = dynamic_cast<VISU::CutLines_i*>(aPrsObject);
1818       VISU::CutLines_i* aSameCut = new VISU::CutLines_i(aCutPrs->GetResult(),true);
1819       aSameCut->SameAs(aCutPrs);
1820       UpdateViewer(this, aSameCut);
1821     }
1822     break;
1823   case VISU::TISOSURFACE:
1824     {
1825       VISU::IsoSurfaces_i* aIsoPrs = dynamic_cast<VISU::IsoSurfaces_i*>(aPrsObject);
1826       VISU::IsoSurfaces_i* aSameIso = new VISU::IsoSurfaces_i(aIsoPrs->GetResult(),true);
1827       aSameIso->SameAs(aIsoPrs);
1828       UpdateViewer(this, aSameIso);
1829     }
1830     break;
1831   case VISU::TSTREAMLINES:
1832     {
1833       VISU::StreamLines_i* aLinesPrs = dynamic_cast<VISU::StreamLines_i*>(aPrsObject);
1834       VISU::StreamLines_i* aSameLines = new VISU::StreamLines_i(aLinesPrs->GetResult(),true);
1835       aSameLines->SameAs(aLinesPrs);
1836       UpdateViewer(this, aSameLines);
1837     }
1838     break;
1839   case VISU::TVECTORS:
1840     {
1841       VISU::Vectors_i* aVectorsPrs = dynamic_cast<VISU::Vectors_i*>(aPrsObject);
1842       VISU::Vectors_i* aSameVectors = new VISU::Vectors_i(aVectorsPrs->GetResult(),true);
1843       aSameVectors->SameAs(aVectorsPrs);
1844       UpdateViewer(this, aSameVectors);
1845     }
1846     break;
1847   case VISU::TPLOT3D:
1848     {
1849       VISU::Plot3D_i* aPlot3DPrs = dynamic_cast<VISU::Plot3D_i*>(aPrsObject);
1850       VISU::Plot3D_i* aSamePlot3D = new VISU::Plot3D_i(aPlot3DPrs->GetResult());
1851       aSamePlot3D->SameAs(aPlot3DPrs);
1852       UpdateViewer(this, aSamePlot3D);
1853     }
1854     break;
1855   }
1856   updateObjBrowser();
1857 }
1858
1859 void
1860 VisuGUI::
1861 OnSelectionInfo()
1862 {
1863   (new VisuGUI_SelectionDlg(GetDesktop(this)))->show();
1864 }
1865
1866 void
1867 VisuGUI::
1868 OnScaling()
1869 {
1870   VisuGUI_NonIsometricDlg* m_NonIsoDlg =
1871     new VisuGUI_NonIsometricDlg (GetDesktop(this), "m_NonIsoDlg",
1872                                  false, Qt::WDestructiveClose);
1873   m_NonIsoDlg->show();
1874 }
1875
1876 void
1877 VisuGUI::
1878 OnCubeAxes()
1879 {
1880   //Show dialog that allows to select scale function and corresponding scale factor
1881   VisuGUI_CubeAxesDlg* aDlg = new VisuGUI_CubeAxesDlg (GetDesktop(this));
1882   aDlg->show();
1883 }
1884
1885 void
1886 VisuGUI::
1887 OnMergeScalarBars()
1888 {
1889   SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1890   SALOME_ListIO aListIO;
1891   aSelectionMgr->selectedObjects(aListIO);
1892
1893   SALOME_ListIteratorOfListIO It (aListIO);
1894
1895   // first find the bounds
1896   double aMin, aMax; bool first = true;
1897   for (; It.More(); It.Next()) {
1898     Handle(SALOME_InteractiveObject)& anIO = It.Value();
1899     std::vector<VISU::Prs3d_i*> aPrsList = GetPrs3dList(this, anIO);
1900     if (!aPrsList.empty()) {
1901       for (int i = 0, n = aPrsList.size(); i < n; i++) {
1902         VISU::Prs3d_i* aPrsObject = aPrsList[i];
1903         if (aPrsObject) {
1904           VISU::ScalarMap_i* aScalar = dynamic_cast<VISU::ScalarMap_i*>(aPrsObject);
1905           if (aScalar) {
1906             if (first) {
1907               first = false;
1908               aMin = aScalar->GetMin(); aMax = aScalar->GetMax();
1909             } else {
1910               if (aScalar->GetMin() < aMin) aMin = aScalar->GetMin();
1911               if (aScalar->GetMax() > aMax) aMax = aScalar->GetMax();
1912             }
1913           }
1914         }
1915       }
1916     }
1917   }
1918
1919   // set the computed range to every selected ScalarMap
1920   bool update = false;
1921   for (It.Initialize(aListIO); It.More(); It.Next() ) {
1922     Handle(SALOME_InteractiveObject)& anIO = It.Value();
1923     std::vector<VISU::Prs3d_i*> aPrsList = GetPrs3dList(this, anIO);
1924     if (!aPrsList.empty()) {
1925       for (int i = 0, n = aPrsList.size(); i < n; i++) {
1926         VISU::Prs3d_i* aPrsObject = aPrsList[i];
1927         if(aPrsObject){
1928           VISU::ScalarMap_i* aScalar = dynamic_cast<VISU::ScalarMap_i*>(aPrsObject);
1929           if (aScalar) {
1930             aScalar->SetRange(aMin, aMax);
1931             RecreateActor(this, aScalar);
1932             update = true;
1933           }
1934         }
1935       }
1936     }
1937   }
1938   if (update) {
1939     if (SVTK_ViewWindow* vw = GetViewWindow(this)) {
1940 //if (vw->getRenderer()->GetActors()->GetNumberOfItems() > 0) {
1941         vw->getRenderer()->ResetCameraClippingRange();
1942         vw->Repaint();
1943 //}
1944     }
1945   }
1946 }
1947
1948 void
1949 VisuGUI::
1950 OnFreeScalarBars()
1951 {
1952   SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1953   SALOME_ListIO aListIO;
1954   aSelectionMgr->selectedObjects(aListIO);
1955
1956   SALOME_ListIteratorOfListIO It (aListIO);
1957
1958   // restore the source range for every ScalarMap
1959   bool update = false;
1960   for (; It.More(); It.Next()) {
1961     Handle(SALOME_InteractiveObject)& anIO = It.Value();
1962     std::vector<VISU::Prs3d_i*> aPrsList = GetPrs3dList(this, anIO);
1963     if (!aPrsList.empty()) {
1964       for (int i = 0, n = aPrsList.size(); i < n; i++) {
1965         VISU::Prs3d_i* aPrsObject = aPrsList[i];
1966         if (aPrsObject) {
1967           VISU::ScalarMap_i* aScalar = dynamic_cast<VISU::ScalarMap_i*>(aPrsObject);
1968           if (aScalar) {
1969             aScalar->SetSourceRange();
1970             RecreateActor(this, aScalar);
1971             update = true;
1972           }
1973         }
1974       }
1975     }
1976   }
1977   if (update) {
1978     if (SVTK_ViewWindow* vw = GetViewWindow(this)) {
1979 //if (vw->getRenderer()->GetActors()->GetNumberOfItems() > 0) {
1980         vw->getRenderer()->ResetCameraClippingRange();
1981         vw->Repaint();
1982 //}
1983     }
1984   }
1985 }
1986
1987 void
1988 VisuGUI::
1989 OnTranslatePrs()
1990 {
1991   if(MYDEBUG) MESSAGE("VisuGUI::OnTranslatePrs");
1992   VisuGUI_OffsetDlg* aDlg = new VisuGUI_OffsetDlg (this);
1993
1994   _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1995   SALOMEDS::Study_var aStudy = GetDSStudy(aCStudy);
1996
1997   SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1998   SALOME_ListIO aListIO;
1999   aSelectionMgr->selectedObjects(aListIO);
2000
2001   SALOME_ListIteratorOfListIO It (aListIO);
2002   for (; It.More(); It.Next()) {
2003     Handle(SALOME_InteractiveObject)& anIO = It.Value();
2004     if (anIO->hasEntry()) {
2005       SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(anIO->getEntry());
2006       if (!aSObject->_is_nil()) {
2007         CORBA::Object_var aCORBAObject = VISU::SObjectToObject(aSObject);
2008         if (!CORBA::is_nil(aCORBAObject)) {
2009           PortableServer::ServantBase_var aServant = VISU::GetServant(aCORBAObject);
2010           if (VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(aServant.in())) {
2011             aDlg->addPresentation(aPrsObject);
2012           }
2013         }
2014       }
2015     }
2016   }
2017   if (aDlg->getPrsCount() > 0)
2018     aDlg->show();
2019   else
2020     delete aDlg;
2021 }
2022
2023 void
2024 VisuGUI::
2025 OnArrangeActors()
2026 {
2027   SVTK_ViewWindow* vw = GetViewWindow();
2028   if (vw) {
2029     ArrangeDlg* aDlg = new ArrangeDlg (GetDesktop(this), vw);
2030     aDlg->exec();
2031     delete aDlg;
2032   }
2033 }
2034
2035
2036 void
2037 VisuGUI::
2038 initialize( CAM_Application* theApp )
2039 {
2040   SalomeApp_Module::initialize( theApp );
2041
2042   createActions();
2043   createMenus();
2044   createToolBars();
2045   createPopupMenus();
2046 }
2047
2048 void
2049 VisuGUI::
2050 createActions()
2051 {
2052   QPixmap aPixmap;
2053   QWidget* aParent = application()->desktop();
2054   SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
2055
2056   // Create actions
2057   createAction( VISU_IMPORT_FROM_FILE, "", QIconSet(), tr("MEN_IMPORT_FROM_FILE"), "", (CTRL + Key_I), aParent, false,
2058                 this, SLOT(OnImportFromFile()));
2059   createAction( VISU_EXPLORE_MED, "", QIconSet(), tr("MEN_EXPLORE_MED_FILE"), "", (CTRL + Key_M), aParent, false,
2060                 this, SLOT(OnExploreMEDFile()));
2061   createAction( VISU_IMPORT_TABLE, "", QIconSet(), tr("MEN_IMPORT_TABLE"), "", 0, aParent, false,
2062                 this, SLOT(OnImportTableFromFile()));
2063
2064   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_SCALAR_MAP"));
2065   createAction( VISU_SCALAR_MAP, tr("MEN_SCALAR_MAP"), QIconSet(aPixmap), tr("MEN_SCALAR_MAP"), "", 0, aParent, false,
2066                 this, SLOT(OnCreateScalarMap()));
2067
2068   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_DEFORMED_SHAPE"));
2069   createAction( VISU_DEFORMED_SHAPE, tr("MEN_DEFORMED_SHAPE"), QIconSet(aPixmap), tr("MEN_DEFORMED_SHAPE"), "", 0, aParent, false,
2070                 this, SLOT(OnCreateDeformedShape()));
2071
2072   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_VECTORS"));
2073   createAction( VISU_VECTORS, tr("MEN_VECTORS"), QIconSet(aPixmap), tr("MEN_VECTORS"), "", 0, aParent, false,
2074                 this, SLOT(OnCreateVectors()));
2075
2076   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_ISO_SURFACES"));
2077   createAction( VISU_ISO_SURFACES, tr("MEN_ISO_SURFACES"), QIconSet(aPixmap), tr("MEN_ISO_SURFACES"), "", 0, aParent, false,
2078                 this, SLOT(OnCreateIsoSurfaces()));
2079
2080   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_CUT_PLANES"));
2081   createAction( VISU_CUT_PLANES, tr("MEN_CUT_PLANES"), QIconSet(aPixmap), tr("MEN_CUT_PLANES"), "", 0, aParent, false,
2082                 this, SLOT(OnCreateCutPlanes()));
2083
2084   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_STREAM_LINES"));
2085   createAction( VISU_STREAM_LINES, tr("MEN_STREAM_LINES"), QIconSet(aPixmap), tr("MEN_STREAM_LINES"), "", 0, aParent, false,
2086                 this, SLOT(OnCreateStreamLines()));
2087
2088   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_CUT_LINES"));
2089   createAction( VISU_CUT_LINES, tr("MEN_CUT_LINES"), QIconSet(aPixmap), tr("MEN_CUT_LINES"), "", 0, aParent, false,
2090                 this, SLOT(OnCreateCutLines()));
2091
2092   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_PLOT_3D"));
2093   createAction( VISU_PLOT_3D, tr("MEN_PLOT_3D"), QIconSet(aPixmap),
2094                 tr("MEN_PLOT_3D"), "", 0, aParent, false,
2095                 this, SLOT(OnCreatePlot3D()));
2096
2097   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_PLOT2D"));
2098   createAction( VISU_PLOT2D, tr("MEN_CREATE_PLOT2D"), QIconSet(aPixmap),
2099                 tr("MEN_CREATE_PLOT2D"), "", 0, aParent, false,
2100                 this, SLOT(OnCreatePlot2dView()));
2101
2102   createAction( VISU_DELETE_OBJS, tr("MEN_DELETE_OBJS"), QIconSet(),
2103                 tr("MEN_DELETE_OBJS"), "", 0, aParent, false,
2104                 this, SLOT(OnDeleteObjects()));
2105
2106   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
2107   //createAction( 4022, tr("MEN_RENAME_TABLE"), QIconSet(aPixmap), tr("MEN_RENAME_TABLE"), "", 0, aParent, false,
2108                 //this, SLOT(OnRenameTable()));
2109
2110   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
2111   createAction( VISU_SHOW_TABLE, tr("MEN_SHOW_TABLE"), QIconSet(), tr("MEN_SHOW_TABLE"), "", 0, aParent, false,
2112                 this, SLOT(OnShowTable()));
2113
2114   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
2115   createAction( VISU_CREATE_CURVES, tr("MEN_CREATE_CURVES"), QIconSet(), tr("MEN_CREATE_CURVES"), "", 0, aParent, false,
2116                 this, SLOT(OnPlotData()));
2117
2118   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
2119   createAction( VISU_EXPORT_TABLE, tr("MEN_EXPORT_TABLE"), QIconSet(), tr("MEN_EXPORT_TABLE"), "", 0, aParent, false,
2120                 this, SLOT(OnExportTableToFile()));
2121
2122   createAction( VISU_IMPORT_MED_STRUCTURE, tr("MEN_IMPORT_MED_STRUCTURE"), QIconSet(),
2123                 tr("MEN_IMPORT_MED_STRUCTURE"), "", 0, aParent, false,
2124                 this, SLOT(OnImportMedField()));
2125
2126   createAction( VISU_IMPORT_MED_TIMESTAMP, tr("MEN_IMPORT_MED_TIMESTAMP"), QIconSet(),
2127                 tr("MEN_IMPORT_MED_TIMESTAMP"), "", 0, aParent, false,
2128                 this, SLOT(OnImportMedField()));
2129
2130   createAction( VISU_IMPORT_MED_FIELD, tr("MEN_IMPORT_MED_FIELD"), QIconSet(),
2131                 tr("MEN_IMPORT_MED_FIELD"), "", 0, aParent, false,
2132                 this, SLOT(OnImportMedField()));
2133
2134   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
2135   createAction( VISU_CREATE_PRS, tr("MEN_CREATE_PRS"), QIconSet(), tr("MEN_CREATE_PRS"), "", 0, aParent, false,
2136                 this, SLOT(OnCreateMesh()));
2137
2138   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
2139   createAction( VISU_CREATE_MANY_PRS, tr("MEN_CREATE_MANY_PRS"), QIconSet(),
2140                 tr("MEN_CREATE_MANY_PRS"), "", 0, aParent, false,
2141                 this, SLOT(OnCreateManyMesh()));
2142
2143   createAction( VISU_TRANSLATE_PRS, tr("MEN_TRANSLATE_PRS"), QIconSet(),
2144                 tr("MEN_TRANSLATE_PRS"), "", 0, aParent, false,
2145                 this, SLOT(OnTranslatePrs()));
2146
2147   createAction( VISU_MERGE_SCALAR_BARS, tr("MEN_MERGE_SCALAR_BARS"), QIconSet(),
2148                 tr("MEN_MERGE_SCALAR_BARS"), "", 0, aParent, false,
2149                 this, SLOT(OnMergeScalarBars()));
2150
2151   createAction( VISU_FREE_SCALAR_BARS, tr("MEN_FREE_SCALAR_BARS"), QIconSet(),
2152                 tr("MEN_FREE_SCALAR_BARS"), "", 0, aParent, false,
2153                 this, SLOT(OnFreeScalarBars()));
2154
2155   //aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_ERASE"));
2156   createAction( VISU_ERASE, tr("MEN_ERASE"), QIconSet(), tr("MEN_ERASE"), "", 0, aParent, false,
2157                 this, SLOT(OnErasePrs()));
2158
2159   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
2160   createAction( VISU_DISPLAY, tr("MEN_DISPLAY"), QIconSet(), tr("MEN_DISPLAY"), "", 0, aParent, false,
2161                 this, SLOT(OnDisplayPrs()));
2162
2163   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
2164   createAction( VISU_DISPLAY_ONLY, tr("MEN_DISPLAY_ONLY"), QIconSet(), tr("MEN_DISPLAY_ONLY"), "", 0, aParent, false,
2165                 this, SLOT(OnDisplayOnlyPrs()));
2166
2167   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
2168   createAction( VISU_COPY_PRS, tr("MEN_COPY_PRS"), QIconSet(), tr("MEN_COPY_PRS"), "", 0, aParent, false,
2169                 this, SLOT(OnCopyPresentation()));
2170
2171   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
2172   createAction( VISU_CURVE_PROPS, tr("MEN_CURVE_PROPS"), QIconSet(), tr("MEN_CURVE_PROPS"), "", 0, aParent, false,
2173                 this, SLOT(OnCurveProperties()));
2174
2175   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
2176   createAction( VISU_RENAME, tr("MEN_RENAME"), QIconSet(), tr("MEN_RENAME"), "", 0, aParent, false,
2177                 this, SLOT(OnRename()));
2178
2179   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
2180   createAction( VISU_EDIT_CONTAINER, tr("MEN_EDIT_CONTAINER"), QIconSet(), tr("MEN_EDIT_CONTAINER"), "", 0, aParent, false,
2181                 this, SLOT(OnEditContainer()));
2182
2183   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
2184   //createAction( 4043, tr("MEN_RENAME_CONTAINER"), QIconSet(aPixmap), tr("MEN_RENAME_CONTAINER"), "", 0, aParent, false,
2185                 //this, SLOT(OnRenameContainer()));
2186
2187   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
2188   createAction( VISU_CLEAR_CONTAINER, tr("MEN_CLEAR_CONTAINER"), QIconSet(), tr("MEN_CLEAR_CONTAINER"), "", 0, aParent, false,
2189                 this, SLOT(OnClearContainer()));
2190
2191   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
2192   createAction( VISU_SAVE_VIEW_PARAMS, tr("MEN_SAVE_VIEWPARAMS"), QIconSet(),
2193                 tr("MEN_SAVE_VIEWPARAMS"), "", 0, aParent, false,
2194                 this, SLOT(OnSaveViewParams()));
2195
2196   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
2197   createAction( VISU_RESTORE_VIEW_PARAMS, tr("MEN_RESTORE_VIEWPARAMS"), QIconSet(),
2198                 tr("MEN_RESTORE_VIEWPARAMS"), "", 0, aParent, false,
2199                 this, SLOT(OnRestoreViewParams()));
2200
2201   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
2202   createAction( VISU_DELETE_VIEW_PARAMS, tr("MEN_DELETE_VIEWPARAMS"), QIconSet(),
2203                 tr("MEN_DELETE_VIEWPARAMS"), "", 0, aParent, false,
2204                 this, SLOT(OnDeleteViewParams()));
2205
2206   createAction( VISU_ARRANGE_ACTORS, tr("MEN_ARRANGE_ACTORS"), QIconSet(),
2207                 tr("MEN_ARRANGE_ACTORS"), "", 0, aParent, false,
2208                 this, SLOT(OnArrangeActors()));
2209
2210   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_POINTS"));
2211   createAction( VISU_POINTS, tr("MEN_POINTS"), QIconSet(aPixmap), tr("MEN_POINTS"), "", 0, aParent, false,
2212                 this, SLOT(OnMakePoints()));
2213
2214   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_WIREFRAME"));
2215   createAction( VISU_WIREFRAME, tr("MEN_WIREFRAME"), QIconSet(aPixmap), tr("MEN_WIREFRAME"), "", 0, aParent, false,
2216                 this, SLOT(OnMakeWireframe()));
2217
2218   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_SURFACE"));
2219   createAction( VISU_SURFACE, tr("MEN_SURFACE"), QIconSet(aPixmap), tr("MEN_SURFACE"), "", 0, aParent, false,
2220                 this, SLOT(OnMakeSurface()));
2221
2222   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
2223   createAction( VISU_INSIDEFRAME, tr("MEN_INSIDEFRAME"), QIconSet(), tr("MEN_INSIDEFRAME"), "", 0, aParent, false,
2224                 this, SLOT(OnMakeInsideframe()));
2225
2226   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
2227   createAction( VISU_SURFACEFRAME, tr("MEN_SURFACEFRAME"), QIconSet(), tr("MEN_SURFACEFRAME"), "", 0, aParent, false,
2228                 this, SLOT(OnMakeSurfaceframe()));
2229
2230   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
2231   createAction( VISU_SHRINK, tr("MEN_SHRINK"), QIconSet(), tr("MEN_SHRINK"), "", 0, aParent, false,
2232                 this, SLOT(OnMakeShrink()));
2233
2234   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
2235   createAction( VISU_UNSHRINK, tr("MEN_UNSHRINK"), QIconSet(), tr("MEN_UNSHRINK"), "", 0, aParent, false,
2236                 this, SLOT(OnMakeShrink()));
2237
2238   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
2239   createAction( VISU_CELL_COLOR, tr("MEN_CELL_COLOR"), QIconSet(), tr("MEN_CELL_COLOR"), "", 0, aParent, false,
2240                 this, SLOT(OnChangeColor()));
2241
2242   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
2243   createAction( VISU_COLOR, tr("MEN_COLOR"), QIconSet(), tr("MEN_COLOR"), "", 0, aParent, false,
2244                 this, SLOT(OnChangeColor()));
2245
2246   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
2247   createAction( VISU_EDGE_COLOR, tr("MEN_EDGE_COLOR"), QIconSet(), tr("MEN_EDGE_COLOR"), "", 0, aParent, false,
2248                 this, SLOT(OnChangeWireframeColor()));
2249
2250   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
2251   createAction( VISU_OPACITY, tr("MEN_OPACITY"), QIconSet(), tr("MEN_OPACITY"), "", 0, aParent, false,
2252                 this, SLOT(OnChangeOpacity()));
2253
2254   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
2255   createAction( VISU_LINE_WIDTH, tr("MEN_LINE_WIDTH"), QIconSet(), tr("MEN_LINE_WIDTH"), "", 0, aParent, false,
2256                 this, SLOT(OnChangeLines()));
2257
2258   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
2259   createAction( VISU_EDIT_PRS, tr("MEN_EDIT_PRS"), QIconSet(), tr("MEN_EDIT_PRS"), "", 0, aParent, false,
2260                 this, SLOT(OnEditPrs()));
2261
2262   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
2263   createAction( VISU_CREATE_TABLE, tr("MEN_CREATE_TABLE"), QIconSet(), tr("MEN_CREATE_TABLE"), "", 0, aParent, false,
2264                 this, SLOT(OnCreateTable()));
2265
2266   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_SWEEP"));
2267   createAction( VISU_SWEEP, tr("MEN_SWEEP"), QIconSet(aPixmap), tr("MEN_SWEEP"), "", 0, aParent, false,
2268                 this, SLOT(OnSweep()));
2269
2270   createAction( VISU_CLIPPING, tr("MEN_CLIPPING"), QIconSet(),
2271                 tr("MEN_CLIPPING"), "", 0, aParent, false,
2272                 this, SLOT(OnClippingPlanes()));
2273
2274   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
2275   createAction( VISU_SELECTION_INFO, tr("MEN_SELECTION_INFO"), QIconSet(),
2276                 tr("MEN_SELECTION_INFO"), "", 0, aParent, false,
2277                 this, SLOT(OnSelectionInfo()));
2278
2279   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_TIMEANIMATION"));
2280   createAction( VISU_ANIMATION, tr("MEN_ANIMATION"), QIconSet(aPixmap), tr("MEN_ANIMATION"), "", 0, aParent, false,
2281                 this, SLOT(OnTimeAnimation()));
2282
2283   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_ERASE_ALL"));
2284   createAction( VISU_ERASE_ALL, tr("MEN_ERASE_ALL"), QIconSet(aPixmap),
2285                 tr("MEN_ERASE_ALL"), "", 0, aParent, false,
2286                 this, SLOT(OnEraseAll()));
2287
2288   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_GLOBAL_SELECTION"));
2289   createAction( VISU_GLOBAL_SELECTION, tr("MEN_GLOBAL_SELECTION"), QIconSet(aPixmap),
2290                 tr("MEN_GLOBAL_SELECTION"), "", 0, aParent, false,
2291                 //this, SLOT(OnEraseAll()));
2292                 this);
2293
2294   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_PARTIAL_SELECTION"));
2295   createAction( VISU_PARTIAL_SELECTION, tr("MEN_PARTIAL_SELECTION"), QIconSet(aPixmap),
2296                 tr("MEN_PARTIAL_SELECTION"), "", 0, aParent, false,
2297                 //this, SLOT(OnEraseAll()));
2298                 this);
2299
2300   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_SCALING"));
2301   createAction( VISU_SCALING, tr("MEN_SCALING"), QIconSet(aPixmap),
2302                 tr("MEN_SCALING"), "", 0, aParent, false,
2303                 this, SLOT(OnScaling()));
2304
2305   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_CUBE_AXES"));
2306   createAction( VISU_CUBE_AXES, tr("MEN_CUBE_AXES"), QIconSet(aPixmap),
2307                 tr("MEN_CUBE_AXES"), "", 0, aParent, false,
2308                 this, SLOT(OnCubeAxes()));
2309
2310   createAction( VISU_SHOW_ANIMATION, tr("MEN_SHOW_ANIMATION"), QIconSet(),
2311                 tr("MEN_SHOW_ANIMATION"), "", 0, aParent, false,
2312                 this, SLOT(OnShowAnimation()));
2313 }
2314
2315 void
2316 VisuGUI::
2317 createMenus()
2318 {
2319   // Add actions to menus
2320   int aMenuId;
2321   aMenuId = createMenu( tr( "MEN_DESK_FILE" ), -1 );
2322   createMenu( separator(), aMenuId, -1, 10 );
2323   createMenu( VISU_IMPORT_FROM_FILE, aMenuId, 10 ); // import from file
2324   createMenu( VISU_EXPLORE_MED, aMenuId, 10 ); // explore MED file
2325   createMenu( VISU_IMPORT_TABLE, aMenuId, 10 ); // import table
2326
2327   aMenuId = createMenu( tr( "MEN_VISUALIZATION" ), -1, -1, 30 );
2328   createMenu( VISU_SCALAR_MAP, aMenuId, 10 ); // scalar map
2329   createMenu( VISU_DEFORMED_SHAPE, aMenuId, 10 ); // deformed shape
2330   createMenu( VISU_VECTORS, aMenuId, 10 ); // vectors
2331   createMenu( VISU_ISO_SURFACES, aMenuId, 10 ); // iso surfaces
2332   createMenu( VISU_CUT_PLANES, aMenuId, 10 ); // cut planes
2333   createMenu( VISU_CUT_LINES, aMenuId, 10 ); // cut lines
2334   createMenu( VISU_STREAM_LINES, aMenuId, 10 ); // stream lines
2335   createMenu( VISU_PLOT_3D, aMenuId, 10 ); // Plot3d
2336
2337   aMenuId = createMenu( tr( "MEN_SELECTION" ), -1, -1, 30 );
2338   createMenu( VISU_SELECTION_INFO, aMenuId, 10 ); // selection info
2339
2340   aMenuId = createMenu( tr( "MEN_REPRESENTATION" ), -1, -1, 30 );
2341   int parentId =
2342     createMenu( tr( "MEN_DISPLAY_SELECTION" ), aMenuId, 10 ); // display selection
2343   createMenu( VISU_POINTS, parentId, 10 ); //   points
2344   createMenu( VISU_WIREFRAME, parentId, 10 ); //   wireframe
2345   createMenu( VISU_SURFACE, parentId, 10 ); //   surface
2346   createMenu( VISU_ERASE_ALL, aMenuId, 10 ); // erase all
2347   createMenu( VISU_GLOBAL_SELECTION, aMenuId, 10 ); // global selection
2348   createMenu( VISU_PARTIAL_SELECTION, aMenuId, 10 ); // partial selection
2349   createMenu( VISU_SCALING, aMenuId, 10 ); // scaling
2350   createMenu( VISU_CUBE_AXES, aMenuId, 10 ); // scaling
2351 }
2352
2353 void
2354 VisuGUI::
2355 createToolBars()
2356 {
2357   int aToolId = createTool(tr("TOOL_VISUALISATION"));
2358   createTool( VISU_SCALAR_MAP, aToolId );
2359   createTool( VISU_DEFORMED_SHAPE, aToolId );
2360   createTool( VISU_VECTORS, aToolId );
2361   createTool( VISU_ISO_SURFACES, aToolId );
2362   createTool( VISU_CUT_PLANES, aToolId );
2363   createTool( VISU_CUT_LINES, aToolId );
2364   createTool( VISU_STREAM_LINES, aToolId );
2365   createTool( VISU_PLOT_3D, aToolId );
2366
2367   aToolId = createTool(tr("TOOL_REPRESENTATION"));
2368   createTool( VISU_POINTS, aToolId );
2369   createTool( VISU_WIREFRAME, aToolId );
2370   createTool( VISU_SURFACE, aToolId );
2371   createTool( VISU_ERASE_ALL, aToolId );
2372   createTool( VISU_GLOBAL_SELECTION, aToolId );
2373   createTool( VISU_PARTIAL_SELECTION, aToolId );
2374   createTool( VISU_SCALING, aToolId );
2375   createTool( VISU_CUBE_AXES, aToolId );
2376 }
2377
2378 void
2379 VisuGUI::
2380 createPopupMenus()
2381 {
2382   // Prepare popup menus
2383   QtxPopupMgr* mgr = popupMgr();
2384
2385   // VISU root commands
2386   mgr->insert( action( VISU_IMPORT_FROM_FILE ), -1, -1, -1 ); // import MED file
2387   mgr->insert( action( VISU_IMPORT_TABLE ), -1, -1, -1 ); // import tables from file
2388   mgr->insert( action( VISU_PLOT2D ), -1, -1, -1 ); // create Plot2d View
2389
2390   //mgr->insert( action( VISU_IMPORT_MED ), -1, -1, -1 ); // import MED structure from MED module
2391
2392   // create
2393   mgr->insert( action( VISU_SCALAR_MAP ), -1, -1, -1 ); // scalar bar
2394   mgr->insert( action( VISU_ISO_SURFACES ), -1, -1, -1 ); // iso surface
2395   mgr->insert( action( VISU_CUT_PLANES ), -1, -1, -1 ); // cut planes
2396   mgr->insert( action( VISU_CUT_LINES ), -1, -1, -1 ); // cut lines
2397   mgr->insert( action( VISU_DEFORMED_SHAPE ), -1, -1, -1 ); // deformed shape
2398   mgr->insert( action( VISU_VECTORS ), -1, -1, -1 ); // vectors
2399   mgr->insert( action( VISU_STREAM_LINES ), -1, -1, -1 ); // stream lines
2400   mgr->insert( action( VISU_PLOT_3D ), -1, -1, -1 ); // Plot3d
2401
2402   mgr->insert( action( VISU_CREATE_PRS ), -1, -1, -1 ); // create presentation
2403   mgr->insert( action( VISU_CREATE_MANY_PRS ), -1, -1, -1 ); // create presentations
2404
2405   mgr->insert( action( VISU_CREATE_TABLE ), -1, -1, -1 ); // create table
2406
2407   // edit
2408   mgr->insert( action( VISU_EDIT_PRS ), -1, -1, -1 );
2409   mgr->insert( action( VISU_EDIT_CONTAINER ), -1, -1, -1 );
2410
2411   // rename
2412   mgr->insert( action( VISU_RENAME ), -1, -1, -1 );
2413
2414   // copy
2415   mgr->insert( action( VISU_COPY_PRS ), -1, -1, -1 );
2416
2417   // delete
2418   mgr->insert( action( VISU_CLEAR_CONTAINER ), -1, -1, -1 );
2419
2420   // table commands
2421   mgr->insert( action( VISU_SHOW_TABLE ), -1, -1, -1 ); // show table
2422   mgr->insert( action( VISU_CREATE_CURVES ), -1, -1, -1 ); // create curves
2423   mgr->insert( action( VISU_EXPORT_TABLE ), -1, -1, -1 ); // export table
2424
2425   mgr->insert( separator(), -1, -1, -1 );
2426
2427   mgr->insert( action( VISU_ERASE ), -1, -1, -1 ); // erase
2428   mgr->insert( action( VISU_DISPLAY ), -1, -1, -1 ); // display
2429   mgr->insert( action( VISU_DISPLAY_ONLY ), -1, -1, -1 ); // display only
2430
2431   // "Representation" submenu
2432   int parentId = mgr->insert( tr( "MEN_REPRESENTATION" ), -1, -1 );
2433   mgr->insert( action( VISU_POINTS )      , parentId, -1, -1 ); // points
2434   mgr->insert( action( VISU_WIREFRAME )   , parentId, -1, -1 ); // wireframe
2435   mgr->insert( action( VISU_SURFACE )     , parentId, -1, -1 ); // surface
2436   mgr->insert( action( VISU_INSIDEFRAME ) , parentId, -1, -1 ); // insideframe
2437   mgr->insert( action( VISU_SURFACEFRAME ), parentId, -1, -1 ); // surfaceframe
2438   mgr->insert( action( VISU_SHRINK )      , parentId, -1, -1 ); // shrink
2439   mgr->insert( action( VISU_UNSHRINK )    , parentId, -1, -1 ); // unshrink
2440
2441   // "Properties" submenu
2442   parentId = mgr->insert( tr( "MEN_PROPERTIES" ), -1, -1 );
2443   mgr->insert( action( VISU_CELL_COLOR ), parentId, -1, -1 ); // cell color
2444   mgr->insert( action( VISU_EDGE_COLOR ), parentId, -1, -1 ); // edge color
2445   mgr->insert( action( VISU_COLOR )     , parentId, -1, -1 ); // color
2446   mgr->insert( action( VISU_OPACITY )   , parentId, -1, -1 ); // opacity
2447   mgr->insert( action( VISU_LINE_WIDTH ), parentId, -1, -1 ); // line width
2448
2449   mgr->insert( separator(), -1, -1, -1 );
2450
2451   // Other presentations management
2452   mgr->insert( action( VISU_TRANSLATE_PRS ), -1, -1, -1 );
2453   mgr->insert( action( VISU_CLIPPING ), -1, -1, -1 );
2454
2455   mgr->insert( action( VISU_MERGE_SCALAR_BARS ), -1, -1, -1 );
2456   mgr->insert( action( VISU_FREE_SCALAR_BARS ), -1, -1, -1 );
2457
2458   mgr->insert( action( VISU_SWEEP ), -1, -1, -1 );
2459   mgr->insert( action( VISU_ANIMATION ), -1, -1, -1 );
2460
2461   mgr->insert( separator(), -1, -1, -1 );
2462
2463   // view parameters commands
2464   mgr->insert( action( VISU_SAVE_VIEW_PARAMS ), -1, -1, -1 ); // save view params
2465   mgr->insert( action( VISU_RESTORE_VIEW_PARAMS ), -1, -1, -1 ); // restore view params
2466   mgr->insert( action( VISU_DELETE_VIEW_PARAMS ), -1, -1, -1 ); // delete view params
2467
2468   mgr->insert( action( VISU_ARRANGE_ACTORS ), -1, -1, -1 ); // arrange actors
2469
2470   mgr->insert( action( VISU_CURVE_PROPS ), -1, -1, -1 ); // curve properties
2471
2472   mgr->insert( action( VISU_SELECTION_INFO ), -1, -1, -1 ); // Selection info
2473
2474   // Rules
2475
2476   QString aSel_One_ObjBr  ("client='ObjectBrowser' and selcount=1");
2477   QString aSel_Some_ObjBr ("client='ObjectBrowser' and selcount>0");
2478   QString aSel_Many_ObjBr ("client='ObjectBrowser' and selcount>1");
2479
2480   QString aPrsAll ("'VISU::TSCALARMAP' 'VISU::TISOSURFACE' 'VISU::TDEFORMEDSHAPE' 'VISU::TCUTPLANES' "
2481                    "'VISU::TCUTLINES' 'VISU::TVECTORS' 'VISU::TSTREAMLINES' 'VISU::TPLOT3D'");
2482
2483   QString aCurveAll = "'VISU::TTABLE' 'VISU::TCURVE' 'VISU::TCONTAINER'";
2484
2485   // VISU root commands
2486   QString aRule = aSel_One_ObjBr + " and type='VISU::TVISUGEN'";
2487   mgr->setRule( action( VISU_IMPORT_FROM_FILE ), aRule, true );
2488   mgr->setRule( action( VISU_IMPORT_TABLE ), aRule, true );
2489   mgr->setRule( action( VISU_PLOT2D ), aRule, true );
2490
2491   // timestamp commands
2492   aRule = aSel_One_ObjBr + " and type='VISU::TTIMESTAMP'";
2493   mgr->setRule( action( VISU_SCALAR_MAP ), aRule, true );
2494   mgr->setRule( action( VISU_ISO_SURFACES ), aRule, true );
2495   mgr->setRule( action( VISU_CUT_PLANES ), aRule, true );
2496   mgr->setRule( action( VISU_CUT_LINES ), aRule, true );
2497   mgr->setRule( action( VISU_PLOT_3D ), aRule, true );
2498   aRule += " and nbComponents>1";
2499   mgr->setRule( action( VISU_DEFORMED_SHAPE ), aRule, true );
2500   mgr->setRule( action( VISU_VECTORS ), aRule, true );
2501   mgr->setRule( action( VISU_STREAM_LINES ), aRule, true );
2502
2503   // table commands
2504   aRule = aSel_One_ObjBr + " and type='VISU::TTABLE'";
2505   mgr->setRule( action( VISU_SHOW_TABLE ), aRule, true );
2506   mgr->setRule( action( VISU_CREATE_CURVES ), aRule, true );
2507   mgr->setRule( action( VISU_EXPORT_TABLE ), aRule, true );
2508
2509   aRule = "(" + aSel_Some_ObjBr + " and ((type='VISU::TTABLE' and nbChildren>0) or"
2510           " ($type in {'VISU::TCURVE' 'VISU::TCONTAINER'}))"
2511           ") or (selcount>0 and $type in {'VISU::TMESH' " + aPrsAll + "})";
2512
2513   mgr->setRule( action( VISU_ERASE ), aRule + "and (isVisible=true)", true );// TODO: aRule.arg(" and isVisible=1"), true );
2514   mgr->setRule( action( VISU_DISPLAY ), aRule + "and (isVisible=false)", true );// TODO: aRule.arg(" and isVisible=0"), true );
2515   mgr->setRule( action( VISU_DISPLAY_ONLY ), aRule, true );
2516
2517   aRule = "selcount>0 and $type in {'VISU::TMESH' " + aPrsAll + "}";
2518   mgr->setRule( action( VISU_TRANSLATE_PRS ), aRule, true );
2519
2520   aRule = "selcount>1 and $type in {'VISU::TMESH' " + aPrsAll + "}";
2521   mgr->setRule( action( VISU_MERGE_SCALAR_BARS ), aRule, true );
2522   mgr->setRule( action( VISU_FREE_SCALAR_BARS ), aRule, true );
2523
2524   // View parameters
2525   //jfa tmp:aRule = "(client='VTKViewer' and selcount=0) or (selcount=1 and type='VISU::TVIEW3D')";
2526   //jfa tmp:mgr->setRule( action( VISU_SAVE_VIEW_PARAMS ), aRule, true );
2527   mgr->setRule( action( VISU_SAVE_VIEW_PARAMS ), "client='VTKViewer' and selcount=0", true ); //jfa tmp
2528   mgr->setRule( action( VISU_RESTORE_VIEW_PARAMS ), "selcount=1 and type='VISU::TVIEW3D'", true );
2529   mgr->setRule( action( VISU_DELETE_VIEW_PARAMS ), "selcount=1 and type='VISU::TVIEW3D'", true );
2530
2531   mgr->setRule( action( VISU_ARRANGE_ACTORS ), "client='VTKViewer' and selcount=0", true );
2532
2533   // 3D presentations commands
2534   QString aPrsType    = " and $type in {'VISU::TMESH' " + aPrsAll + "}";
2535   QString aInsideType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TDEFORMEDSHAPE'}";
2536   QString aSurfType   = " and $type in {'VISU::TMESH'}";
2537   QString aShrinkType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TISOSURFACE' "
2538                         "'VISU::TDEFORMEDSHAPE' 'VISU::TCUTPLANES' 'VISU::TCUTLINES' 'VISU::TPLOT3D'}";
2539   QString aLineType   = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TISOSURFACE' 'VISU::TDEFORMEDSHAPE' "
2540                         "'VISU::TCUTPLANES' 'VISU::TCUTLINES' 'VISU::TSTREAMLINES' 'VISU::TPLOT3D'}";
2541
2542   aRule = "selcount=1";
2543   mgr->setRule( action( VISU_CLIPPING ), aRule + aPrsType, true );
2544
2545   // "Representation" submenu
2546   QString aNotPoints = " and $representation in {'VISU::WIREFRAME' 'VISU::SHADED' 'VISU::INSIDEFRAME' 'VISU::SURFACEFRAME'}";
2547   QString aNotWirefr = " and $representation in {'VISU::POINT' 'VISU::SHADED' 'VISU::INSIDEFRAME' 'VISU::SURFACEFRAME'}";
2548   QString aNotSurfac = " and $representation in {'VISU::POINT' 'VISU::WIREFRAME' 'VISU::INSIDEFRAME' 'VISU::SURFACEFRAME'}";
2549   QString aNotInside = " and $representation in {'VISU::POINT' 'VISU::WIREFRAME' 'VISU::SHADED' 'VISU::SURFACEFRAME'}";
2550   QString aNotSurffr = " and $representation in {'VISU::POINT' 'VISU::WIREFRAME' 'VISU::SHADED' 'VISU::INSIDEFRAME'}";
2551
2552   mgr->setRule( action( VISU_POINTS )      , aRule + aPrsType + aNotPoints, true );
2553   mgr->setRule( action( VISU_WIREFRAME )   , aRule + aPrsType + aNotWirefr, true );
2554   mgr->setRule( action( VISU_SURFACE )     , aRule + aPrsType + aNotSurfac, true );
2555   mgr->setRule( action( VISU_INSIDEFRAME ) , aRule + aInsideType + aNotInside, true );
2556   mgr->setRule( action( VISU_SURFACEFRAME ), aRule + aSurfType + aNotSurffr, true );
2557
2558   mgr->setRule( action( VISU_SHRINK )  , aRule + aShrinkType + " and isShrunk=0", true );
2559   mgr->setRule( action( VISU_UNSHRINK ), aRule + aShrinkType + " and isShrunk=1", true );
2560
2561   // "Properties" submenu
2562   mgr->setRule( action( VISU_CELL_COLOR ), aRule + " and type='VISU::TMESH' and representation='VISU::SURFACEFRAME'", true );
2563   mgr->setRule( action( VISU_EDGE_COLOR ), aRule + " and type='VISU::TMESH' and representation='VISU::SURFACEFRAME'", true );
2564   mgr->setRule( action( VISU_COLOR ), aRule + " and ((type='VISU::TMESH'"
2565                " and $representation in {'VISU::POINT' 'VISU::WIREFRAME' 'VISU::SHADED' 'VISU::INSIDEFRAME'}) "
2566                "or (type='VISU::TDEFORMEDSHAPE' and hasActor=1))", true );
2567   mgr->setRule( action( VISU_OPACITY ), aRule + aShrinkType + " and hasActor=1", true );
2568   mgr->setRule( action( VISU_LINE_WIDTH ), aRule + aLineType + " and hasActor=1", true );
2569
2570   // rename command
2571   aRule = "selcount=1 and ($type in {'VISU::TVIEW3D' " + aCurveAll + " " + aPrsAll + "})";
2572   mgr->setRule( action( VISU_RENAME ), aRule, true );
2573
2574   // copy presentation command
2575   aRule = "selcount=1 and ($type in {" + aPrsAll + "})";
2576   mgr->setRule( action( VISU_COPY_PRS ), aRule, true );
2577
2578   // curve commands
2579   aRule = "selcount=1 and type='VISU::TCURVE'";
2580   mgr->setRule( action( VISU_CURVE_PROPS ), aRule, true );
2581
2582   // curve container commands
2583   aRule = aSel_One_ObjBr + " and type='VISU::TCONTAINER'";
2584   mgr->setRule( action( VISU_EDIT_CONTAINER ), aRule, true );
2585   mgr->setRule( action( VISU_CLEAR_CONTAINER ), aRule, true );
2586
2587   aRule = "selcount=1 and $type in {" + aPrsAll + "}";
2588   mgr->setRule( action( VISU_EDIT_PRS ), aRule, true );
2589
2590   aRule = "selcount=1 and type='VISU::TCUTLINES' and nbNamedChildren=0";
2591   mgr->setRule( action( VISU_CREATE_TABLE ), aRule, true );
2592
2593   aRule = "selcount=1 and type='VISU::TSCALARMAP'";
2594   mgr->setRule( action( VISU_SWEEP ), aRule, true );
2595
2596   // Selection info popup item
2597   aRule = "client='ObjectBrowser' and selcount=1" + aInsideType;
2598   mgr->setRule( action( VISU_SELECTION_INFO ), aRule, true );
2599
2600   aRule = "client='ObjectBrowser' and selcount>0 and $type in {'VISU::TFIELD'} and nbTimeStamps>1";
2601   mgr->setRule( action( VISU_ANIMATION ), aRule, true );
2602
2603   aRule = "client='ObjectBrowser' and $type in {'VISU::TENTITY' 'VISU::TFAMILY' 'VISU::TGROUP'}";
2604   mgr->setRule( action( VISU_CREATE_PRS ), aRule + " and selcount=1", true );
2605   mgr->setRule( action( VISU_CREATE_MANY_PRS ), aRule + " and selcount>1", true );
2606
2607   //aRule = "client='ObjectBrowser' and type='MEDFIELD'";
2608   //mgr->setRule( action( VISU_IMPORT_MED ), aRule, true );
2609 }
2610
2611 //***************************************************************************
2612 void VisuGUI::contextMenuPopup( const QString& theClient, QPopupMenu* theMenu, QString& theTitle )
2613 {
2614   SalomeApp_Module::contextMenuPopup(theClient, theMenu, theTitle);
2615
2616   // Check if some (nb > 0) removable objects selected
2617   if (IsRemovableSelected(this)) {
2618     action( VISU_DELETE_OBJS )->addTo(theMenu);
2619   }
2620
2621   // Check single selection
2622   SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
2623   SALOME_ListIO aListIO;
2624   aSelectionMgr->selectedObjects(aListIO);
2625   if (aListIO.Extent() != 1) return;
2626
2627   Handle(SALOME_InteractiveObject) anIO;
2628   VISU::Storable::TRestoringMap aMap;
2629   CORBA::Object_var anObject = GetSelectedObj( this, &anIO, &aMap);
2630
2631   _PTR(SObject) SO = GetCStudy(GetAppStudy(this))->FindObjectID(anIO->getEntry());
2632   bool isExist;
2633   VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt();
2634
2635   if (aType == VISU::TANIMATION) {
2636     action( VISU_SHOW_ANIMATION )->addTo(theMenu);
2637
2638   } else if (IsSObjectTable(SO)) {
2639     action( VISU_SHOW_TABLE )->addTo(theMenu);
2640     action( VISU_CREATE_CURVES )->addTo(theMenu);
2641     action( VISU_EXPORT_TABLE )->addTo(theMenu);
2642     theMenu->insertSeparator();
2643
2644   } else {
2645     if (!CORBA::is_nil(anObject)) {
2646       SALOME_MED::MED_var aMED = SALOME_MED::MED::_narrow(anObject);
2647       if (!CORBA::is_nil(aMED.in())) {
2648         action( VISU_IMPORT_MED_STRUCTURE )->addTo(theMenu);
2649       }
2650
2651       SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow(anObject); // "Import Structure"
2652       if (!CORBA::is_nil(aField)) {
2653         action( VISU_IMPORT_MED_TIMESTAMP )->addTo(theMenu); // "Import TimeStamp"
2654       }
2655     } else {
2656       _PTR(SObject) aSFather = SO->GetFather();
2657       if (aSFather) {
2658         _PTR(GenericAttribute) anAttr;
2659         aSFather->FindAttribute(anAttr, "AttributeName");
2660         if (anAttr) {
2661           _PTR(AttributeName) aName (anAttr);
2662           std::string aValue = aName->Value();
2663           if (strcmp(aValue.c_str(), "MEDFIELD") == 0) {
2664             action( VISU_IMPORT_MED_FIELD )->addTo(theMenu); // "Import Field"
2665           }
2666         }
2667       }
2668     }
2669   }
2670 }
2671
2672
2673 //***************************************************************************
2674 void
2675 VisuGUI::
2676 windows( QMap<int, int>& theMap ) const
2677 {
2678   theMap.clear();
2679   theMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
2680   theMap.insert( SalomeApp_Application::WT_PyConsole, Qt::DockBottom );
2681 }
2682
2683
2684 void
2685 VisuGUI::
2686 viewManagers( QStringList& theList ) const
2687 {
2688   theList.clear();
2689   theList.append( SVTK_Viewer::Type() );
2690 }
2691
2692
2693 QString
2694 VisuGUI::
2695 engineIOR() const
2696 {
2697   CORBA::String_var anIOR = GetVisuGen(this)->GetID();
2698   return QString(anIOR.in());
2699 }
2700
2701
2702 bool
2703 VisuGUI::
2704 activateModule( SUIT_Study* theStudy )
2705 {
2706   SalomeApp_Module::activateModule( theStudy );
2707   studyActivated();
2708   setMenuShown( true );
2709   setToolShown( true );
2710   return true;
2711 }
2712
2713
2714 bool
2715 VisuGUI::
2716 deactivateModule( SUIT_Study* theStudy )
2717 {
2718   setMenuShown( false );
2719   setToolShown( false );
2720
2721   SalomeApp_Module::deactivateModule( theStudy );
2722   return true;
2723 }
2724
2725 SalomeApp_Selection*
2726 VisuGUI::
2727 createSelection() const
2728 {
2729   return new VisuGUI_Selection( (SalomeApp_Module*)this );
2730 }
2731
2732 //******************************************************************
2733 void VisuGUI::studyActivated()
2734 {
2735   GetVisuGen(this)->SetCurrentStudy(GetDSStudy(GetCStudy(GetAppStudy(this))));
2736 }
2737
2738
2739 extern "C" {
2740   CAM_Module*
2741   createModule()
2742   {
2743     return new VisuGUI();
2744   }
2745 }