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