Salome HOME
Bug 9326: Popup on table objects
[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("WRN_VISU"),
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("WRN_VISU"),
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   SUIT_ViewWindow* aView = GetActiveView(this, VTKViewer_Viewer::Type());
882   if (!aView) return;
883   SVTK_ViewWindow* vw  = (SVTK_ViewWindow*) aView;
884
885   Handle(SALOME_InteractiveObject) anIO;
886   CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
887   if (CORBA::is_nil(anObject)) return;
888   PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
889   if (!aServant.in()) return;
890
891   VISU::Prs3d_i* aPrs3d = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
892   if (aPrs3d) {
893     if (VISU_Actor* anActor = GetActor(aPrs3d, vw)) {
894       switch (theType) {
895       case VISU::SHRINK:
896         if (anActor->IsShrunk())
897           anActor->UnShrink();
898         else
899           anActor->SetShrink();
900         break;
901       default:
902         if (VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrs3d)) {
903           aMesh->SetPresentationType(theType);
904           RecreateActor(this, aMesh);
905         } else {
906           anActor->SetRepresentation(theType);
907         }
908       }
909       vw->Repaint();
910     }
911   }
912 }
913
914 void
915 VisuGUI::
916 OnMakeSurfaceframe()
917 {
918   ChangeRepresentation(VISU::SURFACEFRAME);
919 }
920
921 void
922 VisuGUI::
923 OnMakeInsideframe()
924 {
925   ChangeRepresentation(VISU::INSIDEFRAME);
926 }
927
928 void
929 VisuGUI::
930 OnMakeWireframe()
931 {
932   ChangeRepresentation(VISU::WIREFRAME);
933 }
934
935 void
936 VisuGUI::
937 OnMakeSurface()
938 {
939   ChangeRepresentation(VISU::SHADED);
940 }
941
942 void
943 VisuGUI::
944 OnMakePoints()
945 {
946   ChangeRepresentation(VISU::POINT);
947 }
948
949 void
950 VisuGUI::
951 OnMakeShrink()
952 {
953   ChangeRepresentation(VISU::SHRINK);
954 }
955
956 void
957 VisuGUI::
958 OnChangeColor()
959 {
960   Handle(SALOME_InteractiveObject) anIO;
961   CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
962   if (CORBA::is_nil(anObject)) return;
963   PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
964   if (!aServant.in()) return;
965
966   VISU::Prs3d_i* aPrs3d = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
967   if (!aPrs3d) return;
968
969   SVTK_ViewWindow* vw = GetViewWindow();
970   if (!vw) return;
971
972   VISU_Actor* anActor = GetActor(aPrs3d, vw);
973   if (!anActor) return;
974
975   VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrs3d);
976   VISU::DeformedShape_i* aDeformedShape = dynamic_cast<VISU::DeformedShape_i*>(aPrs3d);
977   SALOMEDS::Color anOldColor, aNewColor;
978   int aRepresent = anActor->GetRepresentation();
979   if (aMesh) {
980     switch (aRepresent) {
981       case VISU::POINT :
982         anOldColor = aMesh->GetNodeColor();
983         break;
984       case VISU::WIREFRAME :
985       case VISU::INSIDEFRAME :
986         anOldColor = aMesh->GetLinkColor();
987         break;
988       case VISU::SHADED :
989       case VISU::SURFACEFRAME :
990         anOldColor = aMesh->GetCellColor();
991         break;
992     }
993   } else if (aDeformedShape) {
994     anOldColor = aDeformedShape->GetColor();
995   } else {
996     return;
997   }
998
999   QColor aColor (int(255*anOldColor.R),
1000                  int(255*anOldColor.G),
1001                  int(255*anOldColor.B));
1002   QColor aColorNew = QColorDialog::getColor(aColor, GetDesktop(this));
1003   if (aColorNew.isValid()) {
1004     aNewColor.R = aColorNew.red()/255.;
1005     aNewColor.G = aColorNew.green()/255.;
1006     aNewColor.B = aColorNew.blue()/255.;
1007     if (aMesh) {
1008       switch (aRepresent) {
1009         case VISU::POINT :
1010           aMesh->SetNodeColor(aNewColor);
1011           break;
1012         case VISU::WIREFRAME :
1013         case VISU::INSIDEFRAME :
1014           aMesh->SetLinkColor(aNewColor);
1015           break;
1016         case VISU::SHADED :
1017         case VISU::SURFACEFRAME :
1018           aMesh->SetCellColor(aNewColor);
1019           break;
1020       }
1021     } else {
1022       aDeformedShape->SetColor(aNewColor);
1023     }
1024     RecreateActor(this, aPrs3d);
1025   }
1026 }
1027
1028 void
1029 VisuGUI::
1030 OnChangeWireframeColor()
1031 {
1032   Handle(SALOME_InteractiveObject) anIO;
1033   CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
1034   if (CORBA::is_nil(anObject)) return;
1035   PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
1036   if (!aServant.in()) return;
1037
1038   VISU::Prs3d_i* aPrs3d = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
1039   if (!aPrs3d) return;
1040
1041   SVTK_ViewWindow* vw = GetViewWindow();
1042   if (!vw) return;
1043
1044   VISU_Actor* anActor = GetActor(aPrs3d, vw);
1045   if (!anActor) return;
1046
1047   if (VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrs3d)) {
1048     SALOMEDS::Color anOldColor = aMesh->GetLinkColor(), aNewColor;
1049     QColor aColor (int(255*anOldColor.R),
1050                    int(255*anOldColor.G),
1051                    int(255*anOldColor.B));
1052     QColor aColorNew = QColorDialog::getColor(aColor, GetDesktop(this));
1053     if (aColorNew.isValid()) {
1054       aNewColor.R = aColorNew.red()/255.;
1055       aNewColor.G = aColorNew.green()/255.;
1056       aNewColor.B = aColorNew.blue()/255.;
1057       aMesh->SetLinkColor(aNewColor);
1058       RecreateActor(this, aMesh);
1059     }
1060   }
1061 }
1062
1063 void
1064 VisuGUI::
1065 OnChangeOpacity()
1066 {
1067   Handle(SALOME_InteractiveObject) anIO;
1068   CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
1069   if (CORBA::is_nil(anObject)) return;
1070   PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
1071   if (!aServant.in()) return;
1072
1073   VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
1074   if (!aPrsObject) return;
1075
1076   SVTK_ViewWindow* vw = GetViewWindow();
1077   if (!vw) return;
1078
1079   VISU_Actor* anActor = GetActor(aPrsObject, vw);
1080   if (!anActor) return;
1081
1082   VisuGUI_CursorDlg* CursorDlg =
1083     new VisuGUI_CursorDlg (GetDesktop(this), tr("DLG_OPACITY_TITLE"), TRUE);
1084
1085   CursorDlg->Comment1->setText(tr("DLG_OPACITY_CMT1"));
1086   CursorDlg->Comment2->setText(tr("DLG_OPACITY_CMT2"));
1087   CursorDlg->SpinBox1->setMinValue(0);
1088   CursorDlg->SpinBox1->setMaxValue(100);
1089
1090   float oldopac = anActor->GetOpacity();
1091   int intopac = int(oldopac*100. + 0.5);
1092   CursorDlg->SpinBox1->setValue(intopac);
1093
1094   int ret = CursorDlg->exec();
1095   if (ret == 1) {
1096     intopac = CursorDlg->SpinBox1->value();
1097     float newopac = intopac/100.;
1098     anActor->SetOpacity(newopac);
1099   }
1100   delete CursorDlg;
1101 }
1102
1103 void
1104 VisuGUI::
1105 OnChangeLines()
1106 {
1107   Handle(SALOME_InteractiveObject) anIO;
1108   CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
1109   if (CORBA::is_nil(anObject)) return;
1110   PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
1111   if (!aServant.in()) return;
1112
1113   VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
1114   if (!aPrsObject) return;
1115
1116   SVTK_ViewWindow* vw = GetViewWindow();
1117   if (!vw) return;
1118
1119   VISU_Actor* anActor = GetActor(aPrsObject, vw);
1120   if (!anActor) return;
1121
1122   VisuGUI_CursorDlg* CursorDlg =
1123     new VisuGUI_CursorDlg (GetDesktop(this), tr("DLG_LINEWIDTH_TITLE"), TRUE);
1124
1125   CursorDlg->Comment1->setText(tr("DLG_LINEWIDTH_CMT1"));
1126   CursorDlg->Comment2->setText(tr("DLG_LINEWIDTH_CMT2"));
1127   CursorDlg->SpinBox1->setMinValue(1);
1128   CursorDlg->SpinBox1->setMaxValue(10);
1129
1130   float oldlwid = anActor->GetLineWidth();
1131   int intlwid = int(oldlwid);
1132   CursorDlg->SpinBox1->setValue(intlwid);
1133
1134   int ret = CursorDlg->exec();
1135   if (ret == 1) {
1136     intlwid  = CursorDlg->SpinBox1->value();
1137     float newlwid = intlwid;
1138     anActor->SetLineWidth(newlwid);
1139   }
1140   delete CursorDlg;
1141 }
1142
1143 void
1144 VisuGUI::
1145 OnShowTable()
1146 {
1147   Handle(SALOME_InteractiveObject) anIO;
1148   CORBA::Object_var anObject = GetSelectedObj( this, &anIO );
1149   _PTR(SObject) SO;
1150   if ( !CORBA::is_nil( anObject ) ) {
1151     VISU::Base_var aVisuObj = VISU::Base::_narrow( anObject );
1152     if ( !CORBA::is_nil( aVisuObj ) && aVisuObj->GetType() == VISU::TTABLE ) {
1153       CORBA::Object_ptr aTable = VISU::Table::_narrow( anObject );
1154       if( !CORBA::is_nil( aTable ) ) {
1155         VISU::Table_i* table = dynamic_cast<VISU::Table_i*>( VISU::GetServant(aTable).in() );
1156         if ( table ) {
1157           SO = GetCStudy( GetAppStudy( this ) )->FindObjectID( table->GetObjectEntry() );
1158         }
1159       }
1160     } 
1161   } else {
1162     // possibly this is Table SObject
1163     SO = GetCStudy( GetAppStudy( this ) )->FindObjectID( anIO->getEntry() );
1164   }
1165
1166   if( !IsSObjectTable( SO ) )
1167     return;
1168
1169   VisuGUI_TableDlg* dlg = new VisuGUI_TableDlg( GetDesktop( this ),
1170                                                SO, 
1171                                                false, 
1172                                                //SAL2670 Orientation of show tables
1173                                                VisuGUI_TableDlg::ttAuto, 
1174                                                Qt::Vertical );
1175   dlg->show();
1176 }
1177
1178 void
1179 VisuGUI::
1180 OnCreateTable()
1181 {
1182   Handle(SALOME_InteractiveObject) anIO;
1183   CORBA::Object_var anObject = GetSelectedObj( this, &anIO );
1184   _PTR(Study) aStudy = GetCStudy( GetAppStudy( this ) );
1185   _PTR(SObject) aSObject = aStudy->FindObjectID(anIO->getEntry());
1186   VISU::CutLines_var aCutLines = VISU::CutLines::_narrow( anObject );
1187   if(!aCutLines->_is_nil() || IsSObjectTable(aSObject)) {
1188     GetVisuGen( this )->CreateTable( aSObject->GetID().c_str() );
1189     updateObjBrowser();
1190   }
1191 }
1192
1193 void
1194 VisuGUI::
1195 OnDeleteObject()
1196 {
1197   _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1198   if (CheckLock(aCStudy))
1199     return;
1200   SALOMEDS::Study_var aStudy = GetDSStudy(aCStudy);
1201
1202   Handle(SALOME_InteractiveObject) anIO;
1203   CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
1204   if (anIO.IsNull() || !anIO->hasEntry())
1205     return;
1206
1207   SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(anIO->getEntry());
1208   if (!aSObject->_is_nil()) {
1209     SALOMEDS::ChildIterator_var aChildIter = aStudy->NewChildIterator(aSObject);
1210     for (aChildIter->InitEx(true); aChildIter->More(); aChildIter->Next()) {
1211       SALOMEDS::SObject_var aChildSObject = aChildIter->Value();
1212       CORBA::Object_var aChildObj = VISU::SObjectToObject(aChildSObject);
1213       ErasePrs(aChildObj);
1214     }
1215     SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
1216     // There is a transaction
1217     aStudyBuilder->NewCommand();
1218     CORBA::Object_var anObj = VISU::SObjectToObject(aSObject);
1219     if (!CORBA::is_nil(anObj)) {
1220       VISU::Base_var aBase = VISU::Base::_narrow(anObj);
1221       if (!CORBA::is_nil(aBase)) {
1222         VISU::VISUType aType = aBase->GetType();
1223         switch (aType) {
1224         case VISU::TRESULT:
1225           {
1226             SALOMEDS::ChildIterator_var aChildIter = aStudy->NewChildIterator(aSObject);
1227             for (aChildIter->InitEx(true); aChildIter->More(); aChildIter->Next()) {
1228               SALOMEDS::SObject_var aChildSObject = aChildIter->Value();
1229               CORBA::Object_var aChildObj = VISU::SObjectToObject(aChildSObject);
1230               if (CORBA::is_nil(aChildObj)) continue;
1231               VISU::Prs3d_var aPrs3d = VISU::Prs3d::_narrow(aChildObj);
1232               if (CORBA::is_nil(aPrs3d)) continue;
1233               VISU::Prs3d_i* pPrs3d = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(aPrs3d).in());
1234               DeletePrs3d(this, pPrs3d, NULL);
1235             }
1236             break;
1237           }
1238         case VISU::TTABLE:
1239           {
1240             SALOMEDS::ChildIterator_var aChildIter = aStudy->NewChildIterator(aSObject);
1241             for (aChildIter->InitEx(true); aChildIter->More(); aChildIter->Next()) {
1242               SALOMEDS::SObject_var aChildSObject = aChildIter->Value();
1243               CORBA::Object_var aChildObj = VISU::SObjectToObject(aChildSObject);
1244               if (CORBA::is_nil(aChildObj)) continue;
1245               CORBA::Object_ptr aCurve = VISU::Curve::_narrow(aChildObj);
1246               if (CORBA::is_nil(aCurve)) continue;
1247               //VISU::Curve_i* pCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
1248               //jfa tmp:DeleteCurve(this, pCurve, NULL);
1249             }
1250             break;
1251           }
1252         }
1253       }
1254     }
1255     aStudyBuilder->RemoveObjectWithChildren(aSObject);
1256     aStudyBuilder->CommitCommand();
1257     //jfa tmp:GetActiveStudy()->unHighlightAll();
1258     updateObjBrowser(true);
1259   }
1260 }
1261
1262 void
1263 VisuGUI::
1264 OnPlotData()
1265 {
1266   Handle(SALOME_InteractiveObject) anIO;
1267   CORBA::Object_var anObject = GetSelectedObj( this, &anIO );
1268   _PTR(SObject) SO;
1269   _PTR(GenericAttribute) anAttr;
1270   _PTR(AttributeName)    aName;
1271   QString SOName;
1272   _PTR(Study) aStudy = GetCStudy( GetAppStudy( this ) );
1273
1274   if ( !CORBA::is_nil( anObject ) ) {
1275     VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
1276     if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TTABLE) {
1277       // Table (VISU object) is selected
1278       CORBA::Object_ptr aTbl = VISU::Table::_narrow( anObject );
1279       if( !CORBA::is_nil( aTbl ) ) {
1280         VISU::Table_i* table = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTbl).in());
1281         if ( table ) {
1282           _PTR(SObject) SO = aStudy->FindObjectID( table->GetObjectEntry() );
1283           if ( IsSObjectTable(SO) ) {
1284             // get name of SObject
1285             if ( SO->FindAttribute( anAttr, "AttributeName" ) ) {
1286               aName = anAttr;
1287               SOName = QString( aName->Value().c_str() );
1288             }
1289             SPlot2d_SetupPlot2dDlg* dlg = new SPlot2d_SetupPlot2dDlg( SO, GetDesktop( this ) );
1290             if ( dlg->exec() == QDialog::Accepted ) {
1291               if ( !IsStudyLocked( aStudy ) ) {
1292                 // if study is not locked - create new container, create curves
1293                 // and insert them into container, then plot container if current viewer is of VIEW_PLOT2D type
1294                 int horIndex;
1295                 QValueList<int> verIndices;
1296                 dlg->getCurvesSource( horIndex, verIndices );
1297                 if ( horIndex >= 0 && verIndices.count() > 0 ) {
1298                   CORBA::Object_var aContainer = GetVisuGen(this)->CreateContainer();
1299                   if( !CORBA::is_nil( aContainer ) ) {
1300                     VISU::Container_i* pContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
1301                     if ( pContainer ) {
1302                       for ( int i = 0; i < verIndices.count(); i++ ) {
1303                         CORBA::Object_var aNewCurve = GetVisuGen(this)->CreateCurve( table->_this(), horIndex+1, verIndices[i]+1 );
1304                         if( !CORBA::is_nil( aNewCurve ) ) {
1305                           VISU::Curve_i* pCrv = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aNewCurve).in());
1306                           if ( pCrv ) {
1307                             bool isAuto;
1308                             int  marker, line, lineWidth;
1309                             QColor color;
1310                             if ( dlg->getCurveAttributes( verIndices[i], isAuto, marker, line, lineWidth, color ) && !isAuto ) {
1311                               SALOMEDS::Color c; c.R = color.red()/255.; c.G = color.green()/255.; c.B = color.blue()/255.;
1312                               pCrv->SetColor( c );
1313                               pCrv->SetMarker( ( VISU::Curve::MarkerType )marker );
1314                               pCrv->SetLine( ( VISU::Curve::LineType )line, lineWidth );
1315                             }
1316                             pContainer->AddCurve( pCrv->_this() );
1317                           }
1318                         }
1319                       }
1320                       updateObjBrowser();
1321                       PlotContainer( this, pContainer, VISU::eDisplay );
1322                     }
1323                   }
1324                 }
1325               }
1326               else {
1327                 // if study is locked just get curves info and plot them if current viewer is of VIEW_PLOT2D type
1328                 QPtrList<Plot2d_Curve> container;
1329                 dlg->getCurves( container );
1330                 if ( !container.isEmpty() ) {
1331                   GetPlot2dViewer( this )->getActiveViewFrame()->displayCurves( container, true );
1332                   GetPlot2dViewer( this )->getActiveViewFrame()->setTitle( SOName );
1333                 }
1334               }
1335             }
1336             delete dlg;
1337           }
1338         }
1339       }
1340     }
1341   }
1342   else if ( !anIO.IsNull() ) {
1343     // check if Table SObject is selected
1344     SO = aStudy->FindObjectID( anIO->getEntry() );
1345     if ( IsSObjectTable(SO) ) {
1346       // get name of SObject
1347       if ( SO->FindAttribute( anAttr, "AttributeName" ) ) {
1348         aName = anAttr;
1349         SOName = QString( aName->Value().c_str() );
1350       }
1351       SPlot2d_SetupPlot2dDlg* dlg = new SPlot2d_SetupPlot2dDlg( SO, GetDesktop( this ) );
1352       if ( dlg->exec() == QDialog::Accepted ) {
1353         if ( !IsStudyLocked( aStudy ) ) {
1354           // if study is not locked - create new table and container objects, create curves
1355           // and insert them into container, then plot container if current viewer is of VIEW_PLOT2D type
1356           int horIndex;
1357           QValueList<int> verIndices;
1358           dlg->getCurvesSource( horIndex, verIndices );
1359           if ( horIndex >= 0 && verIndices.count() > 0 ) {
1360             CORBA::Object_var aTable = GetVisuGen(this)->CreateTable( SO->GetID().c_str() );
1361             CORBA::Object_var aContainer = GetVisuGen(this)->CreateContainer();
1362             if ( !CORBA::is_nil( aTable ) && !CORBA::is_nil( aContainer ) ) {
1363               VISU::Table_i*     pTable     = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTable).in());
1364               VISU::Container_i* pContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
1365
1366               if ( pContainer && pTable ) {
1367                 for ( int i = 0; i < verIndices.count(); i++ ) {
1368                   CORBA::Object_var aNewCurve = GetVisuGen(this)->CreateCurve( pTable->_this(), horIndex+1, verIndices[i]+1 );
1369                   if( !CORBA::is_nil( aNewCurve ) ) {
1370                     VISU::Curve_i* pCrv = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aNewCurve).in());
1371                     if ( pCrv ) {
1372                       bool isAuto;
1373                       int  marker, line, lineWidth;
1374                       QColor color;
1375                       if ( dlg->getCurveAttributes( verIndices[i], isAuto, marker, line, lineWidth, color ) && !isAuto ) {
1376                         SALOMEDS::Color c; c.R = color.red()/255.; c.G = color.green()/255.; c.B = color.blue()/255.;
1377                         pCrv->SetColor( c );
1378                         pCrv->SetMarker( ( VISU::Curve::MarkerType )marker );
1379                         pCrv->SetLine( ( VISU::Curve::LineType )line, lineWidth );
1380                       }
1381                       pContainer->AddCurve( pCrv->_this() );
1382                     }
1383                   }
1384                 }
1385                 updateObjBrowser();
1386                 PlotContainer( this, pContainer, VISU::eDisplay );
1387               }
1388             }
1389           }
1390         } else {
1391           // if study is locked just get curves info and plot them
1392           QPtrList<Plot2d_Curve> container;
1393           dlg->getCurves( container );
1394           if ( !container.isEmpty() ) {
1395             GetPlot2dViewer( this )->getActiveViewFrame()->displayCurves( container, true );
1396             GetPlot2dViewer( this )->getActiveViewFrame()->setTitle( SOName );
1397           }
1398         }
1399       }
1400       delete dlg;
1401     }
1402   }
1403 }
1404
1405 void
1406 VisuGUI::
1407 OnCurveProperties()
1408 {
1409   SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1410   SALOME_ListIO aListIO;
1411   aSelectionMgr->selectedObjects(aListIO);
1412   if (aListIO.Extent() != 1) return;
1413     
1414   SalomeApp_Study* aAppStudy = GetAppStudy(this);
1415   const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
1416   CORBA::Object_var anObject = GetSelectedObj( aAppStudy, anIO->getEntry() );
1417   if (CORBA::is_nil( anObject )) return;
1418
1419   VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
1420   if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCURVE) {
1421     // Curve object
1422     CORBA::Object_ptr aCurve = VISU::Curve::_narrow( anObject );
1423     if( !CORBA::is_nil( aCurve ) ) {
1424       VISU::Curve_i* aDSCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
1425       if ( aDSCurve && (!IsStudyLocked( GetCStudy(aAppStudy) )) ) {
1426         Plot2d_SetupCurveDlg aDlg(GetDesktop( this ));
1427
1428         aDlg.setLine( (int)aDSCurve->GetLine(), aDSCurve->GetLineWidth() );
1429         aDlg.setMarker( (int)aDSCurve->GetMarker() );
1430         SALOMEDS::Color aColor = aDSCurve->GetColor();
1431         aDlg.setColor( QColor( (int)(aColor.R*255.), (int)(aColor.G*255.), (int)(aColor.B*255.) ) );
1432         if( aDlg.exec() == QDialog::Accepted ) {
1433           aDSCurve->SetLine( (VISU::Curve::LineType)aDlg.getLine(), aDlg.getLineWidth() );
1434           aDSCurve->SetMarker( (VISU::Curve::MarkerType)aDlg.getMarker());
1435           SALOMEDS::Color newColor;
1436           newColor.R = aDlg.getColor().red()/255.;
1437           newColor.G = aDlg.getColor().green()/255.;
1438           newColor.B = aDlg.getColor().blue()/255.;
1439           aDSCurve->SetColor( newColor );
1440           PlotCurve(this, aDSCurve, VISU::eDisplay);
1441         }
1442       }
1443     }
1444   }
1445 }
1446
1447 void
1448 VisuGUI::
1449 OnClearContainer()
1450 {
1451   _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1452   if (CheckLock(aCStudy))
1453     return;
1454   SALOMEDS::Study_var aStudy = GetDSStudy(aCStudy);
1455   Handle(SALOME_InteractiveObject) anIO;
1456   CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
1457   if (anIO.IsNull() || CORBA::is_nil(anObject))
1458     return;
1459
1460   VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
1461   if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCONTAINER) {
1462     // Container object
1463     CORBA::Object_ptr aCnt = VISU::Container::_narrow(anObject);
1464     if (!CORBA::is_nil(aCnt)) {
1465       VISU::Container_i* container = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aCnt).in());
1466       if (container && container->GetNbCurves() > 0) {
1467         container->Clear();
1468         updateObjBrowser();
1469       }
1470     }
1471   }
1472 }
1473
1474 void
1475 VisuGUI::
1476 OnEditContainer()
1477 {
1478   Handle(SALOME_InteractiveObject) anIO;
1479   CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
1480   if (CORBA::is_nil(anObject)) return;
1481
1482   PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
1483   if (!aServant.in()) return;
1484   VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(aServant.in());
1485   if (!aContainer) return;
1486
1487   VisuGUI_EditContainerDlg* aDlg = new VisuGUI_EditContainerDlg (GetDesktop(this));
1488   aDlg->initFromPrsObject(aContainer);
1489   if (aDlg->exec()) {
1490     aDlg->storeToPrsObject(aContainer);
1491     updateObjBrowser(true);
1492   }
1493   delete aDlg;
1494 }
1495
1496 void
1497 VisuGUI::
1498 OnSaveViewParams()
1499 {
1500   _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1501   if (CheckLock(aCStudy))
1502     return;
1503   SALOMEDS::Study_var aStudy = GetDSStudy(aCStudy);
1504
1505   SUIT_ViewManager* aViewMgr = getApp()->activeViewManager();
1506   if (aViewMgr->getType() != SVTK_Viewer::Type())
1507     return;
1508
1509   SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1510   SALOME_ListIO aListIO;
1511   aSelectionMgr->selectedObjects(aListIO);
1512   if (aListIO.Extent() > 1)
1513     return;
1514
1515   if (aListIO.Extent() == 0) {
1516     VISU::View3D_i::SaveViewParams(aViewMgr, VISU::View3D_i::GenerateViewParamsName().latin1());
1517   } else {
1518     const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
1519     VISU::View3D_i::SaveViewParams(aViewMgr, anIO->getName());
1520   }
1521   updateObjBrowser();
1522 }
1523
1524 void
1525 VisuGUI::
1526 OnRestoreViewParams()
1527 {
1528   SUIT_ViewManager* aViewMgr = getApp()->activeViewManager();
1529   if (aViewMgr->getType() != SVTK_Viewer::Type())
1530     return;
1531
1532   SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1533   SALOME_ListIO aListIO;
1534   aSelectionMgr->selectedObjects(aListIO);
1535   if (aListIO.Extent() != 1)
1536     return;
1537
1538   const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
1539   //jfa tmp:VISU::View3D_i::RestoreViewParams(aViewMgr, anIO->getName());
1540   _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));//jfa tmp
1541   _PTR(SObject) aSObj = aCStudy->FindObjectID(anIO->getEntry());//jfa tmp
1542   VISU::View3D_i::RestoreViewParams(aViewMgr, aSObj->GetName().c_str());//jfa tmp
1543 }
1544
1545 void
1546 VisuGUI::
1547 OnDeleteViewParams()
1548 {
1549   _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1550   if (CheckLock(aCStudy))
1551     return;
1552   SALOMEDS::Study_var aStudy = GetDSStudy(aCStudy);
1553
1554   Handle(SALOME_InteractiveObject) anIO;
1555   CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
1556   _PTR(SObject) aSObject = aCStudy->FindObjectID(anIO->getEntry());
1557   if (!aSObject) return;
1558
1559   VISU::VISUType aType = (VISU::VISUType)getValue(aSObject, "myType").toInt();
1560   if (aType == VISU::TVIEW3D) {
1561     SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1562     SALOME_ListIO aListIO, aNewListIO;
1563     aSelectionMgr->selectedObjects(aListIO);
1564     for (SALOME_ListIteratorOfListIO it (aListIO); it.More(); it.Next()) {
1565       if (it.Value()->getEntry() != anIO->getEntry()) {
1566         aNewListIO.Append(it.Value());
1567       }
1568     }
1569     aSelectionMgr->setSelectedObjects(aNewListIO);
1570
1571     aCStudy->NewBuilder()->RemoveObject(aSObject);
1572
1573     updateObjBrowser();
1574   }
1575 }
1576
1577 void
1578 VisuGUI::
1579 OnRename()
1580 {
1581   _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1582   if (CheckLock(aCStudy))
1583     return;
1584
1585   Handle(SALOME_InteractiveObject) anIO;
1586   CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
1587
1588   _PTR(SObject) aSObj = aCStudy->FindObjectID(anIO->getEntry());
1589   if (!aSObj) return;
1590
1591   //TEST DU PARENT == VISU
1592   _PTR(GenericAttribute) anAttr;
1593   if (aSObj->FindAttribute(anAttr, "AttributeName")) {
1594     _PTR(AttributeName) aName (anAttr);
1595     QString Name = VisuGUI_NameDlg::getName( GetDesktop( this ), aName->Value().c_str() );
1596     if (!Name.isEmpty()) {
1597       QApplication::setOverrideCursor(Qt::waitCursor);
1598
1599       // rename specific objects
1600       if (!CORBA::is_nil(anObject)) {
1601         VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
1602         if (!CORBA::is_nil(aVisuObj)) {
1603           switch (aVisuObj->GetType()) {
1604             case VISU::TCURVE: // Curve object
1605             {
1606               CORBA::Object_ptr aCurve = VISU::Curve::_narrow(anObject);
1607               if (!CORBA::is_nil(aCurve)) {
1608                 VISU::Curve_i* curve =
1609                   dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
1610                 if (curve)
1611                   curve->SetName(Name.latin1());
1612               }
1613               break;
1614             }
1615             case VISU::TTABLE: // Table object
1616             {
1617               CORBA::Object_ptr aTable = VISU::Table::_narrow(anObject);
1618               if (!CORBA::is_nil(aTable)) {
1619                 VISU::Table_i* table =
1620                   dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTable).in());
1621                 if (table)
1622                   table->SetName(Name.latin1());
1623               }
1624               break;
1625             }
1626             case VISU::TCONTAINER: // Container object
1627             {
1628               CORBA::Object_ptr aContainer = VISU::Container::_narrow(anObject);
1629               if (!CORBA::is_nil(aContainer)) {
1630                 VISU::Container_i* container =
1631                   dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
1632                 if (container)
1633                   container->SetName(Name.latin1());
1634               }
1635               break;
1636             }
1637             default:
1638             {
1639             }
1640           }
1641         }
1642       }
1643
1644       // rename the study object
1645       //getApp()->activeStudy()->renameIObject(anIO, Name);
1646       aName->SetValue(Name.latin1()); // rename the SObject
1647       anIO->setName(Name.latin1()); // rename the InteractiveObject
1648       updateObjBrowser(false);
1649
1650       QApplication::restoreOverrideCursor();
1651     }
1652   }
1653 }
1654
1655 void
1656 VisuGUI::
1657 OnSweep()
1658 {
1659   // GetSelectedPrs3d
1660   Handle(SALOME_InteractiveObject) anIO;
1661   CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
1662   if (CORBA::is_nil(anObject)) return;
1663   PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
1664   if (!aServant.in()) return;
1665
1666   VISU::ScalarMap_i* aPrsObject = dynamic_cast<VISU::ScalarMap_i*>(aServant.in());
1667   if (!aPrsObject) return;
1668
1669   SVTK_ViewWindow* vw = GetViewWindow();
1670   if (!vw) return;
1671
1672   VISU_Actor* aActor = GetActor(aPrsObject, vw);
1673   if (!aActor) return;
1674
1675   if (!aActor->GetVisibility()) {
1676     aActor->VisibilityOn();
1677   }
1678
1679   // Get sweep parameters
1680   SUIT_ResourceMgr* aResourceMgr = GetResourceMgr();
1681
1682   double aTempoDbl = aResourceMgr->doubleValue("Visu:SweepTempo", 0.1);
1683   int aTemp = int(1.E6 * aTempoDbl);
1684
1685   int aCycles = aResourceMgr->integerValue("Visu:SweepCycles", 1);
1686   int aSteps  = aResourceMgr->integerValue("Visu:SweepSteps", 40);
1687
1688   // Sweep
1689   QApplication::setOverrideCursor(Qt::waitCursor);
1690   try {
1691     for (int j = 0; j < aCycles; j++) {
1692       for (int i = 0; i <= aSteps; i++) {
1693         float aPercents = float(i)/aSteps;
1694         aPrsObject->SetMapScale(aPercents);
1695         aPrsObject->UpdateActor(aActor);
1696         vw->getRenderWindow()->getRenderWindow()->Render();
1697         usleep(aTemp);
1698       }
1699     }
1700   } catch (std::exception& exc) {
1701     INFOS("Follow exception was occured :\n" << exc.what());
1702   } catch (...) {
1703     INFOS("Unknown exception was occured!");
1704   }
1705   QApplication::restoreOverrideCursor();
1706 }
1707
1708 void
1709 VisuGUI::
1710 OnTimeAnimation()
1711 {
1712   _PTR(Study) aStudyDS = GetCStudy(GetAppStudy(this));
1713   VisuGUI_TimeAnimationDlg* aAnimationDlg =
1714     new VisuGUI_TimeAnimationDlg(GetDesktop(this), aStudyDS);
1715
1716   SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1717   SALOME_ListIO aListIO;
1718   aSelectionMgr->selectedObjects(aListIO);
1719
1720   bool isDefined = false;
1721   long aNbTimes = 0;
1722   SALOME_ListIteratorOfListIO It (aListIO);
1723   for (; It.More(); It.Next()) {
1724     _PTR(SObject) aSObject = aStudyDS->FindObjectID(It.Value()->getEntry());
1725     if (!aSObject) continue;
1726     if (getValue(aSObject, "myComment") == QString("FIELD")) {
1727       long aNumber = getValue(aSObject, "myNbTimeStamps").toLong();
1728       if (aNumber > 1) {
1729         if (!isDefined) {
1730           aNbTimes = aNumber;
1731           aAnimationDlg->addField(aSObject);
1732           isDefined = true;
1733         } else if (aNbTimes == aNumber) {
1734           aAnimationDlg->addField(aSObject);
1735         }
1736       }
1737     }
1738   }
1739   if (isDefined) aAnimationDlg->show();
1740   else delete aAnimationDlg;
1741 }
1742
1743 void
1744 VisuGUI::
1745 OnCopyPresentation()
1746 {
1747   _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1748   if (CheckLock(aCStudy))
1749     return;
1750
1751   //VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d();
1752   Handle(SALOME_InteractiveObject) anIO;
1753   CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
1754   if (CORBA::is_nil(anObject)) return;
1755   PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
1756   if (!aServant.in()) return;
1757
1758   VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
1759   if (!aPrsObject) return;
1760
1761   switch (aPrsObject->GetType()) {
1762   case VISU::TMESH:
1763     {
1764       VISU::Mesh_i* aMeshPrs = dynamic_cast<VISU::Mesh_i*>(aPrsObject);
1765       VISU::Mesh_i* aSameMesh = new VISU::Mesh_i(aMeshPrs->GetResult());
1766       aSameMesh->SameAs(aMeshPrs);
1767       UpdateViewer(this, aSameMesh);
1768     }
1769     break;
1770   case VISU::TSCALARMAP:
1771     {
1772       VISU::ScalarMap_i* aScalarPrs = dynamic_cast<VISU::ScalarMap_i*>(aPrsObject);
1773       VISU::ScalarMap_i* aSameScalar = new VISU::ScalarMap_i(aScalarPrs->GetResult(),true);
1774       aSameScalar->SameAs(aScalarPrs);
1775       UpdateViewer(this, aSameScalar);
1776     }
1777     break;
1778   case VISU::TDEFORMEDSHAPE:
1779     {
1780       VISU::DeformedShape_i* aDefPrs = dynamic_cast<VISU::DeformedShape_i*>(aPrsObject);
1781       VISU::DeformedShape_i* aSameDeformed = new VISU::DeformedShape_i(aDefPrs->GetResult(),true);
1782       aSameDeformed->SameAs(aDefPrs);
1783       UpdateViewer(this, aSameDeformed);
1784     }
1785     break;
1786   case VISU::TCUTPLANES:
1787     {
1788       VISU::CutPlanes_i* aCutPrs = dynamic_cast<VISU::CutPlanes_i*>(aPrsObject);
1789       VISU::CutPlanes_i* aSameCut = new VISU::CutPlanes_i(aCutPrs->GetResult(),true);
1790       aSameCut->SameAs(aCutPrs);
1791       UpdateViewer(this, aSameCut);
1792     }
1793     break;
1794   case VISU::TCUTLINES:
1795     {
1796       VISU::CutLines_i* aCutPrs = dynamic_cast<VISU::CutLines_i*>(aPrsObject);
1797       VISU::CutLines_i* aSameCut = new VISU::CutLines_i(aCutPrs->GetResult(),true);
1798       aSameCut->SameAs(aCutPrs);
1799       UpdateViewer(this, aSameCut);
1800     }
1801     break;
1802   case VISU::TISOSURFACE:
1803     {
1804       VISU::IsoSurfaces_i* aIsoPrs = dynamic_cast<VISU::IsoSurfaces_i*>(aPrsObject);
1805       VISU::IsoSurfaces_i* aSameIso = new VISU::IsoSurfaces_i(aIsoPrs->GetResult(),true);
1806       aSameIso->SameAs(aIsoPrs);
1807       UpdateViewer(this, aSameIso);
1808     }
1809     break;
1810   case VISU::TSTREAMLINES:
1811     {
1812       VISU::StreamLines_i* aLinesPrs = dynamic_cast<VISU::StreamLines_i*>(aPrsObject);
1813       VISU::StreamLines_i* aSameLines = new VISU::StreamLines_i(aLinesPrs->GetResult(),true);
1814       aSameLines->SameAs(aLinesPrs);
1815       UpdateViewer(this, aSameLines);
1816     }
1817     break;
1818   case VISU::TVECTORS:
1819     {
1820       VISU::Vectors_i* aVectorsPrs = dynamic_cast<VISU::Vectors_i*>(aPrsObject);
1821       VISU::Vectors_i* aSameVectors = new VISU::Vectors_i(aVectorsPrs->GetResult(),true);
1822       aSameVectors->SameAs(aVectorsPrs);
1823       UpdateViewer(this, aSameVectors);
1824     }
1825     break;
1826   }
1827   updateObjBrowser();
1828 }
1829
1830 void
1831 VisuGUI::
1832 OnSelectionInfo()
1833 {
1834   (new VisuGUI_SelectionDlg(GetDesktop(this)))->show();
1835 }
1836
1837 void
1838 VisuGUI::
1839 OnScaling()
1840 {
1841   VisuGUI_NonIsometricDlg* m_NonIsoDlg =
1842     new VisuGUI_NonIsometricDlg (GetDesktop(this), "m_NonIsoDlg",
1843                                  false, Qt::WDestructiveClose);
1844   m_NonIsoDlg->show();
1845 }
1846
1847 void
1848 VisuGUI::
1849 initialize( CAM_Application* theApp )
1850 {
1851   SalomeApp_Module::initialize( theApp );
1852
1853   createActions();
1854   createMenus();
1855   createToolBars();
1856   createPopupMenus();
1857 }
1858
1859 void
1860 VisuGUI::
1861 createActions()
1862 {
1863   QPixmap aPixmap;
1864   QWidget* aParent = application()->desktop();
1865   SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
1866
1867   // Create actions
1868   createAction( VISU_IMPORT_FROM_FILE, "", QIconSet(), tr("MEN_IMPORT_FROM_FILE"), "", (CTRL + Key_I), aParent, false,
1869                 this, SLOT(OnImportFromFile()));
1870   createAction( VISU_EXPLORE_MED, "", QIconSet(), tr("MEN_EXPLORE_MED_FILE"), "", (CTRL + Key_M), aParent, false,
1871                 this, SLOT(OnExploreMEDFile()));
1872   createAction( VISU_IMPORT_TABLE, "", QIconSet(), tr("MEN_IMPORT_TABLE"), "", 0, aParent, false,
1873                 this, SLOT(OnImportTableFromFile()));
1874
1875   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_SCALAR_MAP"));
1876   createAction( VISU_SCALAR_MAP, tr("MEN_SCALAR_MAP"), QIconSet(aPixmap), tr("MEN_SCALAR_MAP"), "", 0, aParent, false,
1877                 this, SLOT(OnCreateScalarMap()));
1878
1879   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_DEFORMED_SHAPE"));
1880   createAction( VISU_DEFORMED_SHAPE, tr("MEN_DEFORMED_SHAPE"), QIconSet(aPixmap), tr("MEN_DEFORMED_SHAPE"), "", 0, aParent, false,
1881                 this, SLOT(OnCreateDeformedShape()));
1882
1883   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_VECTORS"));
1884   createAction( VISU_VECTORS, tr("MEN_VECTORS"), QIconSet(aPixmap), tr("MEN_VECTORS"), "", 0, aParent, false,
1885                 this, SLOT(OnCreateVectors()));
1886
1887   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_ISO_SURFACES"));
1888   createAction( VISU_ISO_SURFACES, tr("MEN_ISO_SURFACES"), QIconSet(aPixmap), tr("MEN_ISO_SURFACES"), "", 0, aParent, false,
1889                 this, SLOT(OnCreateIsoSurfaces()));
1890
1891   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_CUT_PLANES"));
1892   createAction( VISU_CUT_PLANES, tr("MEN_CUT_PLANES"), QIconSet(aPixmap), tr("MEN_CUT_PLANES"), "", 0, aParent, false,
1893                 this, SLOT(OnCreateCutPlanes()));
1894
1895   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_STREAM_LINES"));
1896   createAction( VISU_STREAM_LINES, tr("MEN_STREAM_LINES"), QIconSet(aPixmap), tr("MEN_STREAM_LINES"), "", 0, aParent, false,
1897                 this, SLOT(OnCreateStreamLines()));
1898
1899   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_CUT_LINES"));
1900   createAction( VISU_CUT_LINES, tr("MEN_CUT_LINES"), QIconSet(aPixmap), tr("MEN_CUT_LINES"), "", 0, aParent, false,
1901                 this, SLOT(OnCreateCutLines()));
1902
1903   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_PLOT2D"));
1904   createAction( VISU_PLOT2D, tr("MEN_CREATE_PLOT2D"), QIconSet(aPixmap), tr("MEN_CREATE_PLOT2D"), "", 0, aParent, false,
1905                 this, SLOT(OnCreatePlot2dView()));
1906
1907   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
1908   createAction( VISU_DELETE, tr("MEN_DELETE_OBJ"), QIconSet(), tr("MEN_DELETE_OBJ"), "", 0, aParent, false,
1909                 this, SLOT(OnDeleteObject()));
1910
1911   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
1912   //createAction( 4022, tr("MEN_RENAME_TABLE"), QIconSet(aPixmap), tr("MEN_RENAME_TABLE"), "", 0, aParent, false,
1913                 //this, SLOT(OnRenameTable()));
1914
1915   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
1916   createAction( VISU_SHOW_TABLE, tr("MEN_SHOW_TABLE"), QIconSet(), tr("MEN_SHOW_TABLE"), "", 0, aParent, false,
1917                 this, SLOT(OnShowTable()));
1918
1919   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
1920   createAction( VISU_CREATE_CURVES, tr("MEN_CREATE_CURVES"), QIconSet(), tr("MEN_CREATE_CURVES"), "", 0, aParent, false,
1921                 this, SLOT(OnPlotData()));
1922
1923   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
1924   createAction( VISU_EXPORT_TABLE, tr("MEN_EXPORT_TABLE"), QIconSet(), tr("MEN_EXPORT_TABLE"), "", 0, aParent, false,
1925                 this, SLOT(OnExportTableToFile()));
1926
1927   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
1928   createAction( VISU_CREATE_PRS, tr("MEN_CREATE_PRS"), QIconSet(), tr("MEN_CREATE_PRS"), "", 0, aParent, false,
1929                 this, SLOT(OnCreateMesh()));
1930
1931   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
1932   createAction( VISU_CREATE_MANY_PRS, tr("MEN_CREATE_MANY_PRS"), QIconSet(), tr("MEN_CREATE_MANY_PRS"), "", 0, aParent, false,
1933                 this, SLOT(OnCreateManyMesh()));
1934
1935   //aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_ERASE"));
1936   createAction( VISU_ERASE, tr("MEN_ERASE"), QIconSet(), tr("MEN_ERASE"), "", 0, aParent, false,
1937                 this, SLOT(OnErasePrs()));
1938
1939   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
1940   createAction( VISU_DISPLAY, tr("MEN_DISPLAY"), QIconSet(), tr("MEN_DISPLAY"), "", 0, aParent, false,
1941                 this, SLOT(OnDisplayPrs()));
1942
1943   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
1944   createAction( VISU_DISPLAY_ONLY, tr("MEN_DISPLAY_ONLY"), QIconSet(), tr("MEN_DISPLAY_ONLY"), "", 0, aParent, false,
1945                 this, SLOT(OnDisplayOnlyPrs()));
1946
1947   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
1948   createAction( VISU_DELETE_PRS, tr("MEN_DELETE_PRS"), QIconSet(), tr("MEN_DELETE_PRS"), "", 0, aParent, false,
1949                 this, SLOT(OnDeletePrs()));
1950
1951   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
1952   createAction( VISU_COPY_PRS, tr("MEN_COPY_PRS"), QIconSet(), tr("MEN_COPY_PRS"), "", 0, aParent, false,
1953                 this, SLOT(OnCopyPresentation()));
1954
1955   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
1956   createAction( VISU_CURVE_PROPS, tr("MEN_CURVE_PROPS"), QIconSet(), tr("MEN_CURVE_PROPS"), "", 0, aParent, false,
1957                 this, SLOT(OnCurveProperties()));
1958
1959   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
1960   createAction( VISU_RENAME, tr("MEN_RENAME"), QIconSet(), tr("MEN_RENAME"), "", 0, aParent, false,
1961                 this, SLOT(OnRename()));
1962
1963   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
1964   createAction( VISU_EDIT_CONTAINER, tr("MEN_EDIT_CONTAINER"), QIconSet(), tr("MEN_EDIT_CONTAINER"), "", 0, aParent, false,
1965                 this, SLOT(OnEditContainer()));
1966
1967   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
1968   //createAction( 4043, tr("MEN_RENAME_CONTAINER"), QIconSet(aPixmap), tr("MEN_RENAME_CONTAINER"), "", 0, aParent, false,
1969                 //this, SLOT(OnRenameContainer()));
1970
1971   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
1972   createAction( VISU_CLEAR_CONTAINER, tr("MEN_CLEAR_CONTAINER"), QIconSet(), tr("MEN_CLEAR_CONTAINER"), "", 0, aParent, false,
1973                 this, SLOT(OnClearContainer()));
1974
1975   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
1976   createAction( VISU_VIEW_PARAMS, tr("MEN_SAVE_VIEWPARAMS"), QIconSet(),
1977                 tr("MEN_SAVE_VIEWPARAMS"), "", 0, aParent, false,
1978                 this, SLOT(OnSaveViewParams()));
1979
1980   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
1981   createAction( VISU_RESTORE_VIEW_PARAMS, tr("MEN_RESTORE_VIEWPARAMS"), QIconSet(),
1982                 tr("MEN_RESTORE_VIEWPARAMS"), "", 0, aParent, false,
1983                 this, SLOT(OnRestoreViewParams()));
1984
1985   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
1986   createAction( VISU_DELETE_VIEW_PARAMS, tr("MEN_DELETE_VIEWPARAMS"), QIconSet(),
1987                 tr("MEN_DELETE_VIEWPARAMS"), "", 0, aParent, false,
1988                 this, SLOT(OnDeleteViewParams()));
1989
1990   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_POINTS"));
1991   createAction( VISU_POINTS, tr("MEN_POINTS"), QIconSet(aPixmap), tr("MEN_POINTS"), "", 0, aParent, false,
1992                 this, SLOT(OnMakePoints()));
1993
1994   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_WIREFRAME"));
1995   createAction( VISU_WIREFRAME, tr("MEN_WIREFRAME"), QIconSet(aPixmap), tr("MEN_WIREFRAME"), "", 0, aParent, false,
1996                 this, SLOT(OnMakeWireframe()));
1997
1998   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_SURFACE"));
1999   createAction( VISU_SURFACE, tr("MEN_SURFACE"), QIconSet(aPixmap), tr("MEN_SURFACE"), "", 0, aParent, false,
2000                 this, SLOT(OnMakeSurface()));
2001
2002   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
2003   createAction( VISU_INSIDEFRAME, tr("MEN_INSIDEFRAME"), QIconSet(), tr("MEN_INSIDEFRAME"), "", 0, aParent, false,
2004                 this, SLOT(OnMakeInsideframe()));
2005
2006   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
2007   createAction( VISU_SURFACEFRAME, tr("MEN_SURFACEFRAME"), QIconSet(), tr("MEN_SURFACEFRAME"), "", 0, aParent, false,
2008                 this, SLOT(OnMakeSurfaceframe()));
2009
2010   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
2011   createAction( VISU_SHRINK, tr("MEN_SHRINK"), QIconSet(), tr("MEN_SHRINK"), "", 0, aParent, false,
2012                 this, SLOT(OnMakeShrink()));
2013
2014   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
2015   createAction( VISU_UNSHRINK, tr("MEN_UNSHRINK"), QIconSet(), tr("MEN_UNSHRINK"), "", 0, aParent, false,
2016                 this, SLOT(OnMakeShrink()));
2017
2018   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
2019   createAction( VISU_CELL_COLOR, tr("MEN_CELL_COLOR"), QIconSet(), tr("MEN_CELL_COLOR"), "", 0, aParent, false,
2020                 this, SLOT(OnChangeColor()));
2021
2022   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
2023   createAction( VISU_COLOR, tr("MEN_COLOR"), QIconSet(), tr("MEN_COLOR"), "", 0, aParent, false,
2024                 this, SLOT(OnChangeColor()));
2025
2026   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
2027   createAction( VISU_EDGE_COLOR, tr("MEN_EDGE_COLOR"), QIconSet(), tr("MEN_EDGE_COLOR"), "", 0, aParent, false,
2028                 this, SLOT(OnChangeWireframeColor()));
2029
2030   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
2031   createAction( VISU_OPACITY, tr("MEN_OPACITY"), QIconSet(), tr("MEN_OPACITY"), "", 0, aParent, false,
2032                 this, SLOT(OnChangeOpacity()));
2033
2034   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
2035   createAction( VISU_LINE_WIDTH, tr("MEN_LINE_WIDTH"), QIconSet(), tr("MEN_LINE_WIDTH"), "", 0, aParent, false,
2036                 this, SLOT(OnChangeLines()));
2037
2038   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
2039   createAction( VISU_EDIT_PRS, tr("MEN_EDIT_PRS"), QIconSet(), tr("MEN_EDIT_PRS"), "", 0, aParent, false,
2040                 this, SLOT(OnEditPrs()));
2041
2042   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
2043   createAction( VISU_CREATE_TABLE, tr("MEN_CREATE_TABLE"), QIconSet(), tr("MEN_CREATE_TABLE"), "", 0, aParent, false,
2044                 this, SLOT(OnCreateTable()));
2045
2046   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_SWEEP"));
2047   createAction( VISU_SWEEP, tr("MEN_SWEEP"), QIconSet(aPixmap), tr("MEN_SWEEP"), "", 0, aParent, false,
2048                 this, SLOT(OnSweep()));
2049
2050   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
2051   createAction( VISU_SELECTION_INFO, tr("MEN_SELECTION_INFO"), QIconSet(),
2052                 tr("MEN_SELECTION_INFO"), "", 0, aParent, false,
2053                 this, SLOT(OnSelectionInfo()));
2054
2055   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_TIMEANIMATION"));
2056   createAction( VISU_ANIMATION, tr("MEN_ANIMATION"), QIconSet(aPixmap), tr("MEN_ANIMATION"), "", 0, aParent, false,
2057                 this, SLOT(OnTimeAnimation()));
2058
2059   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_ERASE_ALL"));
2060   createAction( VISU_ERASE_ALL, tr("MEN_ERASE_ALL"), QIconSet(aPixmap),
2061                 tr("MEN_ERASE_ALL"), "", 0, aParent, false,
2062                 this, SLOT(OnEraseAll()));
2063
2064   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_GLOBAL_SELECTION"));
2065   createAction( VISU_GLOBAL_SELECTION, tr("MEN_GLOBAL_SELECTION"), QIconSet(aPixmap),
2066                 tr("MEN_GLOBAL_SELECTION"), "", 0, aParent, false,
2067                 //this, SLOT(OnEraseAll()));
2068                 this);
2069
2070   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_PARTIAL_SELECTION"));
2071   createAction( VISU_PARTIAL_SELECTION, tr("MEN_PARTIAL_SELECTION"), QIconSet(aPixmap),
2072                 tr("MEN_PARTIAL_SELECTION"), "", 0, aParent, false,
2073                 //this, SLOT(OnEraseAll()));
2074                 this);
2075
2076   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_SCALING"));
2077   createAction( VISU_SCALING, tr("MEN_SCALING"), QIconSet(aPixmap),
2078                 tr("MEN_SCALING"), "", 0, aParent, false,
2079                 this, SLOT(OnScaling()));
2080 }
2081
2082 void
2083 VisuGUI::
2084 createMenus()
2085 {
2086   // Add actions to menus
2087   int aMenuId;
2088   aMenuId = createMenu( tr( "MEN_FILE" ), -1 );
2089   createMenu( separator(), aMenuId, -1, 10 );
2090   createMenu( VISU_IMPORT_FROM_FILE, aMenuId, 10 ); // import from file
2091   createMenu( VISU_EXPLORE_MED, aMenuId, 10 ); // explore MED file
2092   createMenu( VISU_IMPORT_TABLE, aMenuId, 10 ); // import table
2093
2094   aMenuId = createMenu( tr( "MEN_VISUALIZATION" ), -1, -1, 30 );
2095   createMenu( VISU_SCALAR_MAP, aMenuId, 10 ); // scalar map
2096   createMenu( VISU_DEFORMED_SHAPE, aMenuId, 10 ); // deformed shape
2097   createMenu( VISU_VECTORS, aMenuId, 10 ); // vectors
2098   createMenu( VISU_ISO_SURFACES, aMenuId, 10 ); // iso surfaces
2099   createMenu( VISU_CUT_PLANES, aMenuId, 10 ); // cut planes
2100   createMenu( VISU_STREAM_LINES, aMenuId, 10 ); // stream lines
2101   createMenu( VISU_CUT_LINES, aMenuId, 10 ); // cut lines
2102
2103   aMenuId = createMenu( tr( "MEN_SELECTION" ), -1, -1, 30 );
2104   createMenu( VISU_SELECTION_INFO, aMenuId, 10 ); // selection info
2105
2106   aMenuId = createMenu( tr( "MEN_REPRESENTATION" ), -1, -1, 30 );
2107   int parentId =
2108     createMenu( tr( "MEN_DISPLAY_SELECTION" ), aMenuId, 10 ); // display selection
2109   createMenu( VISU_POINTS, parentId, 10 ); //   points
2110   createMenu( VISU_WIREFRAME, parentId, 10 ); //   wireframe
2111   createMenu( VISU_SURFACE, parentId, 10 ); //   surface
2112   createMenu( VISU_ERASE_ALL, aMenuId, 10 ); // erase all
2113   createMenu( VISU_GLOBAL_SELECTION, aMenuId, 10 ); // global selection
2114   createMenu( VISU_PARTIAL_SELECTION, aMenuId, 10 ); // partial selection
2115   createMenu( VISU_SCALING, aMenuId, 10 ); // scaling
2116 }
2117
2118 void
2119 VisuGUI::
2120 createToolBars()
2121 {
2122   int aToolId = createTool(tr("TOOL_VISUALISATION"));
2123   createTool( VISU_SCALAR_MAP, aToolId );
2124   createTool( VISU_DEFORMED_SHAPE, aToolId );
2125   createTool( VISU_VECTORS, aToolId );
2126   createTool( VISU_ISO_SURFACES, aToolId );
2127   createTool( VISU_CUT_PLANES, aToolId );
2128   createTool( VISU_STREAM_LINES, aToolId );
2129   createTool( VISU_CUT_LINES, aToolId );
2130 }
2131
2132 void
2133 VisuGUI::
2134 createPopupMenus()
2135 {
2136   // Prepare popup menus
2137   QtxPopupMgr* mgr = popupMgr();
2138
2139   // VISU root commands
2140   QString aRule( "client='ObjectBrowser' and selcount=1 and type='VISU::TVISUGEN'" );
2141   mgr->insert( action(  VISU_IMPORT_FROM_FILE ), -1, -1, -1 ); // import MED
2142   mgr->setRule( action( VISU_IMPORT_FROM_FILE ), aRule, true );
2143   mgr->insert( action(  VISU_IMPORT_TABLE ), -1, -1, -1 ); // import tables
2144   mgr->setRule( action( VISU_IMPORT_TABLE ), aRule, true );
2145   mgr->insert( action(  VISU_PLOT2D ), -1, -1, -1 ); // create Plot2d
2146   mgr->setRule( action( VISU_PLOT2D ), aRule, true );
2147   aRule = "client='ObjectBrowser' and selcount=1 and $type in {'VISU::TRESULT' 'VISU::TTABLE' 'VISU::TCONTAINER'}";
2148   mgr->insert( action(  VISU_DELETE ), -1, -1, -1 ); // delete object
2149   mgr->setRule( action( VISU_DELETE ), aRule, true );
2150
2151   // timestamp commands
2152   aRule = "client='ObjectBrowser' and selcount=1 and type='VISU::TTIMESTAMP'";
2153   mgr->insert( action(  VISU_SCALAR_MAP ), -1, -1, -1 ); // scalar bar
2154   mgr->setRule( action( VISU_SCALAR_MAP ), aRule, true );
2155   mgr->insert( action(  VISU_ISO_SURFACES ), -1, -1, -1 ); // iso surface
2156   mgr->setRule( action( VISU_ISO_SURFACES ), aRule, true );
2157   mgr->insert( action(  VISU_CUT_PLANES ), -1, -1, -1 ); // cut planes
2158   mgr->setRule( action( VISU_CUT_PLANES ), aRule, true );
2159   mgr->insert( action(  VISU_CUT_LINES ), -1, -1, -1 ); // cut lines
2160   mgr->setRule( action( VISU_CUT_LINES ), aRule, true );
2161   aRule += " and nbComponents>1";
2162   mgr->insert( action(  VISU_DEFORMED_SHAPE ), -1, -1, -1 ); // deformed shape
2163   mgr->setRule( action( VISU_DEFORMED_SHAPE ), aRule, true );
2164   mgr->insert( action(  VISU_VECTORS ), -1, -1, -1 ); // vectors
2165   mgr->setRule( action( VISU_VECTORS ), aRule, true );
2166   mgr->insert( action(  VISU_STREAM_LINES ), -1, -1, -1 ); // stream lines
2167   mgr->setRule( action( VISU_STREAM_LINES ), aRule, true );
2168
2169   aRule = "client='ObjectBrowser' and selcount=1 and type='VISU::TTABLE'";
2170   //mgr->insert( action(  4022 ), -1, -1, -1 ); // rename table
2171   //mgr->setRule( action( 4022 ), aRule, true );
2172   mgr->insert( action(  VISU_SHOW_TABLE ), -1, -1, -1 ); // show table
2173   mgr->setRule( action( VISU_SHOW_TABLE ), aRule, true );
2174   mgr->insert( action(  VISU_CREATE_CURVES ), -1, -1, -1 ); // create curves
2175   mgr->setRule( action( VISU_CREATE_CURVES ), aRule, true );
2176   mgr->insert( action(  VISU_EXPORT_TABLE ), -1, -1, -1 ); // export table
2177   mgr->setRule( action( VISU_EXPORT_TABLE ), aRule, true );
2178   mgr->insert( separator(), -1, -1, -1 );
2179   aRule = "(client='ObjectBrowser' and selcount>0 and ((type='VISU::TTABLE' and nbChildren>0) "
2180           "or (type='VISU::TCURVE'%1) or (type='VISU::TCONTAINER'))) "
2181           " or (selcount>0 and $type in {"
2182           "'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TISOSURFACE' 'VISU::TDEFORMEDSHAPE' "
2183           "'VISU::TCUTPLANES' 'VISU::TCUTLINES' 'VISU::TVECTORS' 'VISU::TSTREAMLINES'})";
2184   mgr->insert( action(  VISU_ERASE ), -1, -1, -1 ); // erase
2185   mgr->setRule( action( VISU_ERASE ), aRule.arg(""), true );// TODO: aRule.arg(" and isVisible=1"), true );
2186   mgr->insert( action(  VISU_DISPLAY ), -1, -1, -1 ); // display
2187   mgr->setRule( action( VISU_DISPLAY ), aRule.arg(""), true );// TODO: aRule.arg(" and isVisible=0"), true );
2188   mgr->insert( action(  VISU_DISPLAY_ONLY ), -1, -1, -1 ); // display only
2189   mgr->setRule( action( VISU_DISPLAY_ONLY ), aRule.arg(""), true );
2190
2191   aRule = "client='ObjectBrowser' and selcount=1 and $type in {'VISU::TTABLE' "
2192           "'VISU::TCURVE' 'VISU::TCONTAINER' 'VISU::TMESH' 'VISU::TSCALARMAP' "
2193           "'VISU::TISOSURFACE' 'VISU::TDEFORMEDSHAPE' 'VISU::TCUTPLANES' "
2194           "'VISU::TCUTLINES' 'VISU::TVECTORS' 'VISU::TSTREAMLINES'}";
2195   mgr->insert( action(  VISU_DELETE_PRS ), -1, -1, -1 ); // delete presentation
2196   mgr->setRule( action( VISU_DELETE_PRS ), aRule, true );
2197
2198   // View parameters
2199   mgr->insert ( action( VISU_VIEW_PARAMS ), -1, -1, -1 ); // save view params
2200   //jfa tmp:mgr->setRule( action( 4046 ), "(client='VTKViewer' and selcount=0) or (selcount=1 and type='VISU::TVIEW3D')", true );
2201   mgr->setRule( action( VISU_VIEW_PARAMS ), "selcount=0", true ); //jfa tmp
2202   mgr->insert ( action( VISU_RESTORE_VIEW_PARAMS ), -1, -1, -1 ); // restore view params
2203   mgr->setRule( action( VISU_RESTORE_VIEW_PARAMS ), "selcount=1 and type='VISU::TVIEW3D'", true );
2204   mgr->insert ( action( VISU_DELETE_VIEW_PARAMS ), -1, -1, -1 ); // delete view params
2205   mgr->setRule( action( VISU_DELETE_VIEW_PARAMS ), "selcount=1 and type='VISU::TVIEW3D'", true );
2206
2207   // 3D presentations commands
2208   QString aPrsType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TISOSURFACE' 'VISU::TDEFORMEDSHAPE' "
2209                      "'VISU::TCUTPLANES' 'VISU::TCUTLINES' 'VISU::TVECTORS' 'VISU::TSTREAMLINES'}";
2210   QString aInsideType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TDEFORMEDSHAPE'}";
2211   QString aSurfType   = " and $type in {'VISU::TMESH'}";
2212   QString aShrinkType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TISOSURFACE' 'VISU::TDEFORMEDSHAPE' "
2213                         "'VISU::TCUTPLANES' 'VISU::TCUTLINES'}";
2214   QString aLineType   = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TISOSURFACE' 'VISU::TDEFORMEDSHAPE' "
2215                         "'VISU::TCUTPLANES' 'VISU::TCUTLINES' 'VISU::TSTREAMLINES'}";
2216   aRule = "selcount=1";
2217
2218   int parentId = mgr->insert( tr( "MEN_REPRESENTATION" ), -1, -1 ); // "Representation" submenu
2219   mgr->insert( action(  VISU_POINTS ), parentId, -1, -1 ); // points
2220   mgr->setRule( action( VISU_POINTS ), aRule + aPrsType +
2221                " and $representation in {'VISU::WIREFRAME' 'VISU::SHADED' 'VISU::INSIDEFRAME' 'VISU::SURFACEFRAME'}", true );
2222   mgr->insert( action(  VISU_WIREFRAME ), parentId, -1, -1 ); // wireframe
2223   mgr->setRule( action( VISU_WIREFRAME ), aRule + aPrsType +
2224                " and $representation in {'VISU::POINT' 'VISU::SHADED' 'VISU::INSIDEFRAME' 'VISU::SURFACEFRAME'}", true );
2225   mgr->insert( action(  VISU_SURFACE ), parentId, -1, -1 ); // surface
2226   mgr->setRule( action( VISU_SURFACE ), aRule + aPrsType +
2227                " and $representation in {'VISU::POINT' 'VISU::WIREFRAME' 'VISU::INSIDEFRAME' 'VISU::SURFACEFRAME'}", true );
2228   mgr->insert( action(  VISU_INSIDEFRAME ), parentId, -1, -1 ); // insideframe
2229   mgr->setRule( action( VISU_INSIDEFRAME ), aRule + aInsideType +
2230                " and $representation in {'VISU::POINT' 'VISU::WIREFRAME' 'VISU::SHADED' 'VISU::SURFACEFRAME'}", true );
2231   mgr->insert( action(  VISU_SURFACEFRAME ), parentId, -1, -1 ); // surfaceframe
2232   mgr->setRule( action( VISU_SURFACEFRAME ), aRule + aSurfType +
2233                " and $representation in {'VISU::POINT' 'VISU::WIREFRAME' 'VISU::SHADED' 'VISU::INSIDEFRAME'}", true );
2234   mgr->insert( action(  VISU_SHRINK ), parentId, -1, -1 ); // shrink
2235   mgr->setRule( action( VISU_SHRINK ), aRule + aShrinkType + " and isShrunk=0", true );
2236   mgr->insert( action(  VISU_UNSHRINK ), parentId, -1, -1 ); // unshrink
2237   mgr->setRule( action( VISU_UNSHRINK ), aRule + aShrinkType + " and isShrunk=1", true );
2238
2239   parentId = mgr->insert( tr( "MEN_PROPERTIES" ), -1, -1 ); // "Properties" submenu
2240   mgr->insert( action(  VISU_CELL_COLOR ), parentId, -1, -1 ); // cell color
2241   mgr->setRule( action( VISU_CELL_COLOR ), aRule + " and type='VISU::TMESH' and representation='VISU::SURFACEFRAME'", true );
2242   mgr->insert( action(  VISU_EDGE_COLOR ), parentId, -1, -1 ); // edge color
2243   mgr->setRule( action( VISU_EDGE_COLOR ), aRule + " and type='VISU::TMESH' and representation='VISU::SURFACEFRAME'", true );
2244   mgr->insert( action(  VISU_COLOR ), parentId, -1, -1 ); // color
2245   mgr->setRule( action( VISU_COLOR ), aRule + " and ((type='VISU::TMESH'"
2246                " and $representation in {'VISU::POINT' 'VISU::WIREFRAME' 'VISU::SHADED' 'VISU::INSIDEFRAME'}) "
2247                "or (type='VISU::TDEFORMEDSHAPE' and hasActor=1))", true );
2248   mgr->insert( action(  VISU_OPACITY ), parentId, -1, -1 ); // opacity
2249   mgr->setRule( action( VISU_OPACITY ), aRule + aShrinkType + " and hasActor=1", true );
2250   mgr->insert( action(  VISU_LINE_WIDTH ), parentId, -1, -1 ); // line width
2251   mgr->setRule( action( VISU_LINE_WIDTH ), aRule + aLineType + " and hasActor=1", true );
2252
2253   // rename command
2254   QString aCurveType = "$type in {'VISU::TTABLE' 'VISU::TCURVE' 'VISU::TCONTAINER'}";
2255   aPrsType = "$type in {'VISU::TSCALARMAP' 'VISU::TISOSURFACE' 'VISU::TDEFORMEDSHAPE' "
2256              "'VISU::TCUTPLANES' 'VISU::TCUTLINES' 'VISU::TVECTORS' 'VISU::TSTREAMLINES'}";
2257
2258   aRule = "selcount=1 and (type=VISU::TVIEW3D or " + aCurveType + " or " + aPrsType + ")";
2259   mgr->insert ( action( VISU_RENAME ), -1, -1, -1 ); // rename
2260   mgr->setRule( action( VISU_RENAME ), aRule, true );
2261
2262   // copy presentation command
2263   aRule = "selcount=1 and " + aPrsType;
2264   mgr->insert ( action( VISU_COPY_PRS ), -1, -1, -1 ); // copy
2265   mgr->setRule( action( VISU_COPY_PRS ), aRule, true );
2266
2267   // curve commands
2268   aRule = "selcount=1 and type='VISU::TCURVE'";
2269   mgr->insert( action(  VISU_CURVE_PROPS ), -1, -1, -1 ); // curve properties
2270   mgr->setRule( action( VISU_CURVE_PROPS ), aRule, true );
2271
2272   // curve container commands
2273   aRule = "client='ObjectBrowser' and selcount=1 and type='VISU::TCONTAINER'";
2274   mgr->insert( action(  VISU_EDIT_CONTAINER ), -1, -1, -1 ); // edit container
2275   mgr->setRule( action( VISU_EDIT_CONTAINER ), aRule, true );
2276   //mgr->insert( action(  4043 ), -1, -1, -1 ); // rename container
2277   //mgr->setRule( action( 4043 ), aRule, true );
2278   mgr->insert( action(  VISU_CLEAR_CONTAINER ), -1, -1, -1 ); // clear container
2279   mgr->setRule( action( VISU_CLEAR_CONTAINER ), aRule, true );
2280
2281   aRule = "selcount=1 and ";
2282   mgr->insert( action(  VISU_EDIT_PRS ), -1, -1, -1 ); // edit prs
2283   mgr->setRule( action( VISU_EDIT_PRS ), aRule + aPrsType, true );
2284
2285   aRule = "selcount=1 and type='VISU::TCUTLINES' and nbNamedChildren=0";
2286   mgr->insert( action(  VISU_CREATE_TABLE ), -1, -1, -1 ); // create table
2287   mgr->setRule( action( VISU_CREATE_TABLE ), aRule, true );
2288
2289   aRule = "client='ObjectBrowser' and selcount=1 and type='VISU::TSCALARMAP'";
2290   mgr->insert ( action( VISU_SWEEP ), -1, -1, -1 ); // sweep
2291   mgr->setRule( action( VISU_SWEEP ), aRule, true );
2292
2293   // Selection info popup item
2294   //  aRule = "client='ObjectBrowser' and selcount=1" + aInsideType;
2295   //  mgr->insert( action(  VISU_SELECTION_INFO ), -1, -1, -1 ); // Selection info
2296   //  mgr->setRule( action( VISU_SELECTION_INFO ), aRule, true );
2297
2298   aRule = "client='ObjectBrowser' and selcount>0 and $type in {'VISU::TFIELD'} and nbTimeStamps>1";
2299   mgr->insert( action(  VISU_ANIMATION ), -1, -1, -1 ); // animation
2300   mgr->setRule( action( VISU_ANIMATION ), aRule, true );
2301
2302   aRule = "client='ObjectBrowser' and $type in {'VISU::TENTITY' 'VISU::TFAMILY' 'VISU::TGROUP'}";
2303   mgr->insert( action(  VISU_CREATE_PRS ), -1, -1, -1 ); // create presentation
2304   mgr->setRule( action( VISU_CREATE_PRS ), aRule + " and selcount=1", true );
2305   mgr->insert( action(  VISU_CREATE_MANY_PRS ), -1, -1, -1 ); // create presentations
2306   mgr->setRule( action( VISU_CREATE_MANY_PRS ), aRule + " and selcount>1", true );
2307 }
2308
2309 //***************************************************************************
2310 void VisuGUI::contextMenuPopup( const QString& theClient, QPopupMenu* theMenu, QString& theTitle )
2311 {
2312   SalomeApp_Module::contextMenuPopup(theClient, theMenu, theTitle);
2313   
2314   SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
2315   SALOME_ListIO aListIO;
2316   aSelectionMgr->selectedObjects(aListIO);
2317   if (aListIO.Extent() != 1) return;
2318
2319   Handle(SALOME_InteractiveObject) anIO;
2320   CORBA::Object_var anObject = GetSelectedObj( this, &anIO );
2321   _PTR(SObject) SO = GetCStudy( GetAppStudy( this ) )->FindObjectID( anIO->getEntry() );
2322   if (IsSObjectTable(SO)) {
2323     action( VISU_SHOW_TABLE )->addTo(theMenu);
2324     action( VISU_CREATE_CURVES )->addTo(theMenu);
2325     action( VISU_EXPORT_TABLE )->addTo(theMenu);
2326     theMenu->insertSeparator();
2327     action( VISU_DELETE )->addTo(theMenu);
2328   }
2329 }
2330
2331
2332 //***************************************************************************
2333 void
2334 VisuGUI::
2335 windows( QMap<int, int>& theMap ) const
2336 {
2337   theMap.clear();
2338   theMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
2339   theMap.insert( SalomeApp_Application::WT_PyConsole, Qt::DockBottom );
2340 }
2341
2342
2343 void
2344 VisuGUI::
2345 viewManagers( QStringList& theList ) const
2346 {
2347   theList.clear();
2348   theList.append( SVTK_Viewer::Type() );
2349 }
2350
2351
2352 QString
2353 VisuGUI::
2354 engineIOR() const
2355 {
2356   CORBA::String_var anIOR = GetVisuGen(this)->GetID();
2357   return QString(anIOR.in());
2358 }
2359
2360
2361 bool
2362 VisuGUI::
2363 activateModule( SUIT_Study* theStudy )
2364 {
2365   SalomeApp_Module::activateModule( theStudy );
2366   studyActivated();
2367   setMenuShown( true );
2368   setToolShown( true );
2369   return true;
2370 }
2371
2372
2373 bool
2374 VisuGUI::
2375 deactivateModule( SUIT_Study* theStudy )
2376 {
2377   setMenuShown( false );
2378   setToolShown( false );
2379
2380   SalomeApp_Module::deactivateModule( theStudy );
2381   return true;
2382 }
2383
2384 SalomeApp_Selection*
2385 VisuGUI::
2386 createSelection() const
2387 {
2388   return new VisuGUI_Selection( (SalomeApp_Module*)this );
2389 }
2390
2391 //******************************************************************
2392 void VisuGUI::studyActivated()
2393 {
2394   GetVisuGen(this)->SetCurrentStudy(GetDSStudy(GetCStudy(GetAppStudy(this))));
2395 }
2396
2397
2398 extern "C" {
2399   CAM_Module*
2400   createModule()
2401   {
2402     return new VisuGUI();
2403   }
2404 }