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