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