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