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