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