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