Salome HOME
PAL10611: Remove popup-menu items Erase, Display, etc., provided by parent LightApp_M...
[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 "VisuGUI.h"
30
31 // STL Includes
32 #include <exception>
33 #include <typeinfo>
34 #include <vector>
35
36 // QT Includes
37 #include <qptrlist.h>
38 #include <qptrvector.h>
39 #include <qcolordialog.h>
40
41 // VTK Includes
42 #include <vtkRenderer.h>
43 #include <vtkRenderWindow.h>
44 #include <vtkActorCollection.h>
45
46 // SALOME Includes
47 #include "SALOME_LifeCycleCORBA.hxx"
48
49 #include "SUIT_ResourceMgr.h"
50 #include "SUIT_MessageBox.h"
51
52 #include "SUIT_ViewWindow.h"
53 #include "SUIT_ViewManager.h"
54
55 #include "CAM_Module.h"
56
57 #include "SVTK_RenderWindow.h"
58 #include "SVTK_ViewWindow.h"
59 #include "SVTK_ViewModel.h"
60 #include "SVTK_Functor.h"
61
62 #include "SPlot2d_ViewModel.h"
63 #include "VisuGUI_SetupPlot2dDlg.h"
64 #include "Plot2d_SetupCurveDlg.h"
65
66 #include "OB_Browser.h"
67
68 #include "SALOME_ListIO.hxx"
69 #include "SALOME_ListIteratorOfListIO.hxx"
70
71 #include "SalomeApp_Application.h"
72 #include "SalomeApp_DataModel.h"
73 #include "SalomeApp_Study.h"
74 #include "LightApp_SelectionMgr.h"
75 #include "LightApp_Selection.h"
76 #include "LightApp_Preferences.h"
77
78 #include "QtxAction.h"
79
80 #include "VISUConfig.hh"
81 #include "VISU_Gen_i.hh"
82 #include "VISU_Mesh_i.hh"
83 #include "VISU_Table_i.hh"
84 #include "VISU_Result_i.hh"
85 #include "VISU_View_i.hh"
86 #include "VISU_ViewManager_i.hh"
87 #include "VISU_Plot3D_i.hh"
88
89 #include "VISU_Actor.h"
90
91 #include "VisuGUI_Prs3dTools.h"
92 #include "VisuGUI_Tools.h"
93
94 #include "VisuGUI_PopupTools.h"
95 #include "VisuGUI_NameDlg.h"
96 #include "VisuGUI_FileDlg.h"
97 #include "VisuGUI_CursorDlg.h"
98 #include "VisuGUI_Selection.h"
99 #include "VisuGUI_TimeAnimation.h"
100 #include "VisuGUI_EditContainerDlg.h"
101 #include "VisuGUI_NonIsometricDlg.h"
102 #include "VisuGUI_ClippingDlg.h"
103 #include "VisuGUI_Plot3DDlg.h"
104 #include "VisuGUI_CubeAxesDlg.h"
105 #include "VisuGUI_OffsetDlg.h"
106 #include "VisuGUI_Displayer.h"
107
108 #include "VISU_ScalarMap_i.hh"
109 #include "VisuGUI_ScalarBarDlg.h"
110
111 #include "VISU_DeformedShape_i.hh"
112 #include "VisuGUI_DeformedShapeDlg.h"
113
114 #include "VISU_IsoSurfaces_i.hh"
115 #include "VisuGUI_IsoSurfacesDlg.h"
116
117 #include "VISU_CutPlanes_i.hh"
118 #include "VisuGUI_CutPlanesDlg.h"
119
120 #include "VISU_CutLines_i.hh"
121 #include "VisuGUI_CutLinesDlg.h"
122
123 #include "VISU_StreamLines_i.hh"
124 #include "VisuGUI_StreamLinesDlg.h"
125
126 #include "VISU_Vectors_i.hh"
127 #include "VisuGUI_VectorsDlg.h"
128
129 #include "VisuGUI_TableDlg.h"
130
131 #include "SALOMEconfig.h"
132 #include CORBA_SERVER_HEADER(MED_Gen)
133
134 #include "utilities.h"
135
136 #include "VisuGUI_ActionsDef.h"
137
138 using namespace VISU;
139
140 #ifdef _DEBUG_
141 static int MYDEBUG = 1;
142 #else
143 static int MYDEBUG = 0;
144 #endif
145
146 //////////////////////////////////////////////////
147 // Class: VisuGUI
148 //////////////////////////////////////////////////
149
150 VisuGUI::VisuGUI():
151   SalomeApp_Module( "VISU" ),
152   myDisplayer( 0 )
153 {
154 }
155
156
157 VisuGUI::~VisuGUI()
158 {
159 }
160
161
162 void
163 VisuGUI::
164 OnImportFromFile()
165 {
166   if(MYDEBUG) MESSAGE("VisuGUI::OnImportFromFile()");
167   if ( CheckLock(GetCStudy(GetAppStudy(this))) )
168     return;
169   SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
170
171   QStringList aFilter;
172   aFilter.append( tr("FLT_MED_FILES") );
173   aFilter.append( tr("FLT_ALL_FILES") );
174
175   QFileInfo aFileInfo =
176     SUIT_FileDlg::getFileName(GetDesktop(this),
177                               "",
178                               aFilter,
179                               tr("MEN_IMPORT_FROM_FILE"),
180                               true);
181   if(aFileInfo.exists()) {
182     application()->putInfo( "Importing From File " + aFileInfo.filePath() + "..." );
183
184     VISU::Result_var aResult;
185     bool anIsBuild = aResourceMgr->booleanValue("VISU", "full_med_loading", false);
186     if (VisuGUI_FileDlg::IsBuild) {
187       aResult = GetVisuGen(this)->ImportFile(aFileInfo.filePath());
188       if (!CORBA::is_nil(aResult.in()))
189         if (Result_i* aRes = dynamic_cast<Result_i*>(GetServant(aResult).in())) {
190           if (!aRes->IsPossible())
191             SUIT_MessageBox::warn1(GetDesktop(this),
192                                    tr("WRN_VISU"),
193                                    tr("ERR_CANT_BUILD_PRESENTATION"),
194                                    tr("BUT_OK"));
195           else
196             aRes->BuildAll();
197         }
198     } else {
199       aResourceMgr->setValue("VISU", "full_med_loading", false);
200       aResult = GetVisuGen(this)->ImportFile(aFileInfo.filePath());
201       aResourceMgr->setValue("VISU", "full_med_loading", anIsBuild);
202     }
203
204     if (CORBA::is_nil(aResult.in())) {
205       SUIT_MessageBox::warn1(GetDesktop(this),
206                              tr("WRN_VISU"),
207                              tr("ERR_ERROR_IN_THE_FILE"),
208                              tr("BUT_OK"));
209     }else{
210       application()->putInfo(aFileInfo.filePath() + tr("INF_DONE"));
211       UpdateObjBrowser(this);
212     }
213   }
214 }
215
216
217 void
218 VisuGUI::
219 OnExploreMEDFile()
220 {
221   if(MYDEBUG) MESSAGE("VisuGUI::OnExploreMEDFile()");
222   _PTR(Study) aStudy = GetCStudy(GetAppStudy(this));
223   if ( CheckLock(aStudy) )
224     return;
225
226   SALOME_MED::MED_Gen_var aGen = GetMEDEngine();
227
228   QStringList aFilter;
229   aFilter.append( tr("FLT_MED_FILES") );
230   aFilter.append( tr("FLT_ALL_FILES") );
231
232   QFileInfo aFileInfo =
233     SUIT_FileDlg::getFileName(GetDesktop(this),
234                               "",
235                               aFilter,
236                               tr("MEN_EXPLORE_MED_FILE"),
237                               true);
238   if(aFileInfo.exists()){
239     application()->putInfo( tr("MEN_EXPLORE_MED_FILE") + " " + aFileInfo.filePath() + "..." );
240     std::string aStudyName = aStudy->Name();
241     try
242     {
243       aGen->readStructFileWithFieldType(aFileInfo.filePath(),aStudyName.c_str());
244     }
245     catch(...)
246     {
247       SUIT_MessageBox::warn1(GetDesktop(this),
248                              tr("WRN_VISU"),
249                              tr("ERR_ERROR_IN_THE_FILE"),
250                              tr("BUT_OK"));
251     }
252     application()->putInfo(aFileInfo.filePath()+tr("INF_DONE"));
253     getApp()->updateObjectBrowser(true); // as need to update MED tree
254     getApp()->updateActions();
255   }
256 }
257
258
259 void
260 VisuGUI::
261 OnImportTableFromFile()
262 {
263   if(MYDEBUG) MESSAGE("VisuGUI::OnImportTableFromFile()");
264   if ( CheckLock(GetCStudy(GetAppStudy(this))) )
265     return;
266
267   QStringList aFilter;
268   aFilter.append( tr("FLT_TABLE_FILES") );
269   aFilter.append( tr("FLT_ALL_FILES") );
270
271   QFileInfo aFileInfo =
272     SUIT_FileDlg::getFileName(GetDesktop(this),
273                               "",
274                               aFilter,
275                               tr("MEN_IMPORT_TABLE"),
276                               true);
277   if (aFileInfo.exists()) {
278     application()->putInfo( tr("MEN_IMPORT_TABLE") + " " + aFileInfo.filePath() + " ..." );
279
280     CORBA::Object_var anObject = GetVisuGen(this)->ImportTables(aFileInfo.filePath());
281
282     if (CORBA::is_nil(anObject.in())) {
283       SUIT_MessageBox::warn1(GetDesktop(this),
284                              tr("WRN_VISU"),
285                              tr("ERR_ERROR_IN_THE_FILE"),
286                              tr("BUT_OK"));
287     } else {
288       application()->putInfo(aFileInfo.filePath()+tr("INF_DONE"));
289       UpdateObjBrowser(this);
290     }
291   }
292 }
293
294 void
295 VisuGUI::
296 OnExportTableToFile()
297 {
298   if(MYDEBUG) MESSAGE("VisuGUI::OnExportTableToFile()");
299
300   _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
301
302   LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
303   SALOME_ListIO aListIO;
304   aSelectionMgr->selectedObjects(aListIO);
305
306   if (aListIO.Extent() > 0) {
307     const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
308     if (anIO->hasEntry()) {
309       _PTR(SObject) aSObj = aCStudy->FindObjectID(anIO->getEntry());
310       if (!aSObj) return;
311
312       // find table attribute
313       bool isTOR = true;
314       _PTR(GenericAttribute) anAttr;
315
316       if (!aSObj->FindAttribute(anAttr, "AttributeTableOfReal")) {
317         isTOR = false;
318         if (!aSObj->FindAttribute(anAttr, "AttributeTableOfInteger")) {
319           // if the current SObject is a table title
320           // we take a father contaning the table
321           aSObj = aSObj->GetFather();
322
323           if (aSObj->FindAttribute(anAttr, "AttributeTableOfReal")) {
324             isTOR = true;
325           } else {
326             if (!aSObj->FindAttribute(anAttr, "AttributeTableOfInteger")) {
327               return;
328             }
329           }
330         }
331       }
332
333       // get table title in order to have default name of the file
334       QString aTitle;
335       if (isTOR) {
336         _PTR(AttributeTableOfReal) aTabAttr (anAttr);
337         if (!aTabAttr) return;
338         aTitle = aTabAttr->GetTitle().c_str();
339       } else {
340         _PTR(AttributeTableOfInteger) aTabAttr (anAttr);
341         if (!aTabAttr) return;
342         aTitle = aTabAttr->GetTitle().c_str();
343       }
344       aTitle.simplifyWhiteSpace();
345       aTitle = aTitle.replace(QRegExp(" "), "_").replace(QRegExp("\\*"), "" );
346
347       // get default path for the file
348       SUIT_ResourceMgr* aResourceMgr = GetResourceMgr();
349       QString aDir = aResourceMgr->stringValue("VISU","OutputDir","");
350       if (aDir.isEmpty()) {
351         aDir = aResourceMgr->stringValue("VISU","InputDir","");
352         if (aDir.isEmpty()) {
353           aDir = getenv("CSF_PATHData");
354         }
355       }
356       QString aPath = Qtx::addSlash(aDir) + aTitle;
357
358       // get name for the file
359       QStringList aFilter;
360       aFilter.append("Table Files (*.xls)");
361
362       QFileInfo aFileInfo =
363         SUIT_FileDlg::getFileName(GetDesktop(this),
364                                   aPath,
365                                   aFilter,
366                                   tr("MEN_EXPORT_TABLE"), // "Export Table To File"
367                                   false);
368
369       // export
370       QString aFile = aFileInfo.filePath();
371       if (!aFile.isEmpty()) {
372         application()->putInfo(tr("MEN_EXPORT_TABLE") + " " + aFile + " ...");
373         aDir = Qtx::dir(aFile, true);
374         aResourceMgr->setValue("VISU", "OutputDir", aDir);
375
376         try {
377           GetVisuGen(this)->ExportTableToFile(GetSObject(aSObj), aFile.latin1());
378           application()->putInfo(aFile + " " + tr("INF_DONE"));
379         } catch(std::exception& ex) {
380           INFOS(ex.what());
381           SUIT_MessageBox::warn1(GetDesktop(this),
382                                  tr("WRN_VISU"),
383                                  tr("ERR_ERROR_DURING_EXPORT") + " " + tr(ex.what()),
384                                  tr("BUT_OK"));
385         } catch(...) {
386           INFOS(tr("ERR_ERROR_DURING_EXPORT"));
387           SUIT_MessageBox::warn1(GetDesktop(this),
388                                  tr("WRN_VISU"),
389                                  tr("ERR_ERROR_DURING_EXPORT"),
390                                  tr("BUT_OK") );
391         }
392       }
393     }
394   }
395 }
396
397 void
398 VisuGUI::
399 OnImportMedField()
400 {
401   _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
402   if (CheckLock(aCStudy))
403     return;
404   SALOMEDS::Study_var aStudy = GetDSStudy(aCStudy);
405
406   LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
407   SALOME_ListIO aListIO;
408   aSelectionMgr->selectedObjects(aListIO);
409
410   SALOME_ListIteratorOfListIO It (aListIO);
411   QApplication::setOverrideCursor(Qt::waitCursor);
412   for (; It.More(); It.Next()) {
413     Handle(SALOME_InteractiveObject) anIO = It.Value();
414     SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(anIO->getEntry());
415     if (!aSObject->_is_nil()) {
416       CORBA::Object_var anObject = VISU::SObjectToObject(aSObject);
417       if (!CORBA::is_nil(anObject)) {
418         SALOME_MED::MED_var aMED = SALOME_MED::MED::_narrow(anObject);
419         if (!CORBA::is_nil(aMED.in()))
420           GetVisuGen(this)->ImportMed(aSObject);
421         SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow(anObject);
422         if (!CORBA::is_nil(aField.in()))
423           GetVisuGen(this)->ImportMedField(aField);
424       } else {
425         SALOMEDS::SObject_var aSFather = aSObject->GetFather();
426         SALOMEDS::GenericAttribute_var anAttr;
427         aSFather->FindAttribute(anAttr, "AttributeName");
428         SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
429         CORBA::String_var aValue = aName->Value();
430         if (strcmp(aValue.in(), "MEDFIELD") == 0)
431           GetVisuGen(this)->ImportMed(aSObject);
432       }
433     }
434   }
435   UpdateObjBrowser(this, true);
436   QApplication::restoreOverrideCursor();
437 }
438
439 void
440 CreateCurves( SalomeApp_Module* theModule,
441               VISU::CutLines_i* thePrs,
442               QDialog* theDlg,
443               const bool theCreate = true )
444 {
445   if ( !thePrs )
446     return;
447   VisuGUI_CutLinesDlg* aCutDlg = dynamic_cast<VisuGUI_CutLinesDlg*>( theDlg );
448   if ( !aCutDlg )
449     return;
450
451   _PTR(Study)   aStudy = GetCStudy( GetAppStudy( theModule ) );
452   _PTR(SObject) aSObject = aStudy->FindObjectID( thePrs->GetEntry().latin1() );
453
454   if ( !theCreate && aSObject ) {
455     // Remove old Table
456     _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
457     _PTR(ChildIterator) aIter = aStudy->NewChildIterator(aSObject);
458     for (; aIter->More(); aIter->Next()) {
459       _PTR(SObject) aTblObj = aIter->Value();
460       if ( aTblObj ) {
461         _PTR(GenericAttribute) anAttr;
462         if (aTblObj->FindAttribute( anAttr, "AttributeName" ) ) {
463           aBuilder->RemoveObjectWithChildren( aIter->Value() ); // We should have only one child
464           break;
465         }
466       }
467     }
468   }
469
470   if ( aCutDlg->isGenerateTable() ) {
471     GetVisuGen( theModule )->CreateTable( thePrs->GetEntry() );
472     if ( aCutDlg->isGenerateCurves() ) {
473       if ( aSObject ) {
474         _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
475         _PTR(ChildIterator) aIter = aStudy->NewChildIterator(aSObject);
476         for (; aIter->More(); aIter->Next()) {
477           _PTR(SObject) aTblObj = aIter->Value();
478           if ( aTblObj ) {
479             _PTR(GenericAttribute) anAttr;
480             if ( aTblObj->FindAttribute( anAttr, "AttributeName" ) ) {
481               CreatePlot( theModule, aTblObj );
482             }
483           }
484         }
485       }
486     }
487   }
488
489   if (!theCreate && aSObject) {
490     UpdateObjBrowser(theModule);
491   }
492 }
493
494 void
495 VisuGUI::
496 OnCreateMesh()
497 {
498   _PTR(Study) aStudy = GetCStudy(GetAppStudy(this));
499   if (CheckLock(aStudy))
500     return;
501
502   // Get selected SObject
503   Handle(SALOME_InteractiveObject) anIO;
504   CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
505   if (anIO.IsNull() || !anIO->hasEntry())
506     return;
507
508   // create a VTK view window if it does not exist
509   GetViewWindow( this, /*create=*/true );
510
511   CreateMesh(this, anIO);
512 }
513
514 void
515 VisuGUI::
516 OnCreateManyMesh()
517 {
518   _PTR(Study) aStudy = GetCStudy(GetAppStudy(this));
519   if (CheckLock(aStudy))
520     return;
521
522   // create a VTK view window if it does not exist
523   GetViewWindow( this, /*create=*/true );
524
525   // Get selected SObject
526   LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
527   SALOME_ListIO aListIO;
528   aSelectionMgr->selectedObjects(aListIO);
529   SALOME_ListIteratorOfListIO anIter (aListIO);
530   for (; anIter.More(); anIter.Next()) {
531     Handle(SALOME_InteractiveObject) anIO = anIter.Value();
532     if (anIO.IsNull() || !anIO->hasEntry())
533       return;
534
535     CreateMesh(this, anIO);
536   }
537 }
538
539 void
540 VisuGUI::
541 OnCreateScalarMap()
542 {
543   CreatePrs3d<VISU::ScalarMap_i,VisuGUI_ScalarBarDlg,1>(this);
544 }
545
546
547 void
548 VisuGUI::
549 OnCreateDeformedShape()
550 {
551   CreatePrs3d<VISU::DeformedShape_i,VisuGUI_DeformedShapeDlg,1>(this);
552 }
553
554 void
555 VisuGUI::
556 OnCreateVectors()
557 {
558   CreatePrs3d<VISU::Vectors_i,VisuGUI_VectorsDlg,1>(this);
559 }
560
561 void
562 VisuGUI::
563 OnCreateIsoSurfaces()
564 {
565   CreatePrs3d<VISU::IsoSurfaces_i,VisuGUI_IsoSurfacesDlg,1>(this);
566 }
567
568 void
569 VisuGUI::
570 OnCreateCutPlanes()
571 {
572   CreatePrs3d<VISU::CutPlanes_i,VisuGUI_CutPlanesDlg,0>(this);
573 }
574
575 void
576 VisuGUI::
577 OnCreateCutLines()
578 {
579   CreatePrs3d<VISU::CutLines_i,VisuGUI_CutLinesDlg,0>(this);
580 }
581
582 void
583 VisuGUI::
584 OnCreateStreamLines()
585 {
586   CreatePrs3d<VISU::StreamLines_i,VisuGUI_StreamLinesDlg,1>(this);
587 }
588
589 void
590 VisuGUI::
591 OnCreatePlot3D()
592 {
593   CreatePrs3d<VISU::Plot3D_i,VisuGUI_Plot3DDlg,0>(this);
594 }
595
596 void
597 VisuGUI::
598 OnCreatePlot2dView()
599 {
600   CheckLock(GetCStudy(GetAppStudy(this)));
601   GetVisuGen( this )->CreateContainer();
602   UpdateObjBrowser(this);
603 }
604
605 void
606 VisuGUI::
607 OnDisplayPrs()
608 {
609   if(MYDEBUG) MESSAGE("VisuGUI::OnDisplayPrs");
610
611   QApplication::setOverrideCursor(Qt::waitCursor);
612   SALOME_ListIO aList;
613   LightApp_SelectionMgr* mgr = GetSelectionMgr(this);
614   mgr->selectedObjects(aList);
615
616   Handle(SALOME_InteractiveObject) anIO;
617   for ( SALOME_ListIteratorOfListIO it( aList ); it.More(); it.Next() ) {
618     anIO = it.Value();
619     CORBA::Object_var anObject = GetSelectedObj( GetAppStudy(this), anIO->getEntry() );
620     if ( !CORBA::is_nil( anObject ) ) {
621       // is it Prs3d object ?
622       VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject).in());
623       if(aPrsObject){
624         if(MYDEBUG) MESSAGE("VisuGUI::OnDisplayPrs : Prs3d object");
625         UpdateViewer( this, aPrsObject );
626         SVTK_ViewWindow* vw = GetViewWindow( this, /*create=*/true );
627         if ( vw ) {
628           vw->highlight(anIO, 1);
629         }
630         continue;
631       }
632       // is it Curve ?
633       VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(anObject).in());
634       if(aCurve){
635         if(MYDEBUG) MESSAGE("VisuGUI::OnDisplayPrs : Curve object");
636         PlotCurve( this, aCurve, VISU::eDisplay );
637         continue;
638       }
639       // is it Container ?
640       VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(anObject).in());
641       if(aContainer){
642         if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Container object");
643         PlotContainer( this, aContainer, VISU::eDisplay );
644         continue;
645       }
646       // is it Table ?
647       VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(anObject).in());
648       if(aTable){
649         if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Table object");
650         PlotTable( this, aTable, VISU::eDisplay );
651         continue;
652       }
653     }
654   }
655   SVTK_ViewWindow* vw = GetViewWindow( this );
656   if ( vw ) {
657     vw->getRenderer()->ResetCameraClippingRange();
658     vw->Repaint();
659   }
660   QApplication::restoreOverrideCursor();
661 }
662
663 void
664 VisuGUI::
665 OnDisplayOnlyPrs()
666 {
667   OnEraseAll();
668   OnDisplayPrs();
669 }
670
671 void
672 VisuGUI::
673 OnErasePrs()
674 {
675   if(MYDEBUG) MESSAGE("OnErasePrs");
676
677   QApplication::setOverrideCursor(Qt::waitCursor);
678
679   SVTK_ViewWindow* vw = GetViewWindow( this );
680   if (vw)
681     vw->unHighlightAll();
682
683   SALOME_ListIO aList;
684   LightApp_SelectionMgr* mgr = GetSelectionMgr(this);
685   mgr->selectedObjects(aList);
686
687   Handle(SALOME_InteractiveObject) anIO;
688   for ( SALOME_ListIteratorOfListIO it( aList ); it.More(); it.Next() ) {
689     anIO = it.Value();
690     CORBA::Object_var anObject = GetSelectedObj( GetAppStudy(this), anIO->getEntry() );
691     ErasePrs( this, anObject, false );
692   }
693
694   if (vw)
695     vw->Repaint();
696
697   QApplication::restoreOverrideCursor();
698 }
699
700
701 void
702 VisuGUI::
703 OnEditScalarMap()
704 {
705   Handle(SALOME_InteractiveObject) anIO;
706   if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){
707     EditPrs3d<VISU::ScalarMap_i, VisuGUI_ScalarBarDlg,1>(this, aPrs3d);
708     if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){
709       aViewWindow->highlight(anIO, 1);
710     }
711   }
712 }
713
714
715 void
716 VisuGUI::
717 OnEditDeformedShape()
718 {
719   Handle(SALOME_InteractiveObject) anIO;
720   if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){
721     EditPrs3d<VISU::DeformedShape_i, VisuGUI_DeformedShapeDlg,1>(this, aPrs3d);
722     if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){
723       aViewWindow->highlight(anIO, 1);
724     }
725   }
726 }
727
728
729 void
730 VisuGUI::
731 OnEditCutPlanes()
732 {
733   Handle(SALOME_InteractiveObject) anIO;
734   if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){
735     EditPrs3d<VISU::CutPlanes_i, VisuGUI_CutPlanesDlg,0>(this, aPrs3d);
736     if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){
737       aViewWindow->highlight(anIO, 1);
738     }
739   }
740 }
741
742
743 void
744 VisuGUI::
745 OnEditCutLines()
746 {
747   Handle(SALOME_InteractiveObject) anIO;
748   if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){
749     EditPrs3d<VISU::CutLines_i, VisuGUI_CutLinesDlg,0>(this, aPrs3d);
750     if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){
751       aViewWindow->highlight(anIO, 1);
752     }
753   }
754 }
755
756
757 void
758 VisuGUI::
759 OnEditIsoSurfaces()
760 {
761   Handle(SALOME_InteractiveObject) anIO;
762   if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){
763     EditPrs3d<VISU::IsoSurfaces_i, VisuGUI_IsoSurfacesDlg,1>(this, aPrs3d);
764     if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){
765       aViewWindow->highlight(anIO, 1);
766     }
767   }
768 }
769
770
771 void
772 VisuGUI::
773 OnEditVectors()
774 {
775   Handle(SALOME_InteractiveObject) anIO;
776   if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){
777     EditPrs3d<VISU::Vectors_i, VisuGUI_VectorsDlg,1>(this, aPrs3d);
778     if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){
779       aViewWindow->highlight(anIO, 1);
780     }
781   }
782 }
783
784
785 void
786 VisuGUI::
787 OnEditStreamLines()
788 {
789   Handle(SALOME_InteractiveObject) anIO;
790   if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){
791     EditPrs3d<VISU::StreamLines_i, VisuGUI_StreamLinesDlg,1>(this, aPrs3d);
792     if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){
793       aViewWindow->highlight(anIO, 1);
794     }
795   }
796 }
797
798
799 void
800 VisuGUI::
801 OnEditPlot3D()
802 {
803   Handle(SALOME_InteractiveObject) anIO;
804   if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){
805     EditPrs3d<VISU::Plot3D_i, VisuGUI_Plot3DDlg,0>(this, aPrs3d);
806     if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){
807       aViewWindow->highlight(anIO, 1);
808     }
809   }
810 }
811
812
813 void
814 VisuGUI::
815 OnEraseAll()
816 {
817   startOperation( myEraseAll );
818   if (SVTK_ViewWindow* vw = GetViewWindow()) {
819     vw->unHighlightAll();
820     if (vtkRenderer *aRen = vw->getRenderer()) {
821       vtkActor *anActor;
822       vtkActorCollection *anActColl = aRen->GetActors();
823       for (anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL; ) {
824         if (anActor->GetVisibility() > 0)
825           if (VISU_Actor* anVISUActor = VISU_Actor::SafeDownCast(anActor)) {
826             anVISUActor = anVISUActor->GetParent();
827             anVISUActor->VisibilityOff();
828           }
829       }
830       vw->Repaint();
831     }
832   } else if (SPlot2d_Viewer* aPlot2d = GetPlot2dViewer(this, false)) {
833     aPlot2d->EraseAll();
834   }
835 }
836
837 void
838 VisuGUI::
839 OnMakeSurfaceframe()
840 {
841   ChangeRepresentation(this, VISU::SURFACEFRAME);
842 }
843
844 void
845 VisuGUI::
846 OnMakeInsideframe()
847 {
848   ChangeRepresentation(this, VISU::INSIDEFRAME);
849 }
850
851 void
852 VisuGUI::
853 OnMakeWireframe()
854 {
855   ChangeRepresentation(this, VISU::WIREFRAME);
856 }
857
858 void
859 VisuGUI::
860 OnMakeSurface()
861 {
862   ChangeRepresentation(this, VISU::SHADED);
863 }
864
865 void
866 VisuGUI::
867 OnMakePoints()
868 {
869   ChangeRepresentation(this, VISU::POINT);
870 }
871
872 void
873 VisuGUI::
874 OnMakeShrink()
875 {
876   ChangeRepresentation(this, VISU::SHRINK);
877 }
878
879 void
880 VisuGUI::
881 OnSetShadingOn()
882 {
883   SetShading(this, true);
884 }
885
886 void
887 VisuGUI::
888 OnSetShadingOff()
889 {
890   SetShading(this, false);
891 }
892
893 void
894 VisuGUI::
895 OnChangeColor()
896 {
897   Handle(SALOME_InteractiveObject) anIO;
898   CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
899   if (CORBA::is_nil(anObject)) return;
900   PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
901   if (!aServant.in()) return;
902
903   VISU::Prs3d_i* aPrs3d = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
904   if (!aPrs3d) return;
905
906   SVTK_ViewWindow* vw = GetViewWindow();
907   if (!vw) return;
908
909   VISU_Actor* anActor = GetActor(aPrs3d, vw);
910   if (!anActor) return;
911
912   VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrs3d);
913   VISU::DeformedShape_i* aDeformedShape = dynamic_cast<VISU::DeformedShape_i*>(aPrs3d);
914   SALOMEDS::Color anOldColor, aNewColor;
915   int aRepresent = anActor->GetRepresentation();
916   if (aMesh) {
917     switch (aRepresent) {
918       case VISU::POINT :
919         anOldColor = aMesh->GetNodeColor();
920         break;
921       case VISU::WIREFRAME :
922       case VISU::INSIDEFRAME :
923         anOldColor = aMesh->GetLinkColor();
924         break;
925       case VISU::SHADED :
926       case VISU::SURFACEFRAME :
927         anOldColor = aMesh->GetCellColor();
928         break;
929     }
930   } else if (aDeformedShape) {
931     anOldColor = aDeformedShape->GetColor();
932   } else {
933     return;
934   }
935
936   QColor aColor (int(255*anOldColor.R),
937                  int(255*anOldColor.G),
938                  int(255*anOldColor.B));
939   QColor aColorNew = QColorDialog::getColor(aColor, GetDesktop(this));
940   if (aColorNew.isValid()) {
941     aNewColor.R = aColorNew.red()/255.;
942     aNewColor.G = aColorNew.green()/255.;
943     aNewColor.B = aColorNew.blue()/255.;
944     if (aMesh) {
945       switch (aRepresent) {
946         case VISU::POINT :
947           aMesh->SetNodeColor(aNewColor);
948           break;
949         case VISU::WIREFRAME :
950         case VISU::INSIDEFRAME :
951           aMesh->SetLinkColor(aNewColor);
952           break;
953         case VISU::SHADED :
954         case VISU::SURFACEFRAME :
955           aMesh->SetCellColor(aNewColor);
956           break;
957       }
958     } else {
959       aDeformedShape->SetColor(aNewColor);
960     }
961     RecreateActor(this, aPrs3d);
962   }
963 }
964
965 void
966 VisuGUI::
967 OnChangeWireframeColor()
968 {
969   Handle(SALOME_InteractiveObject) anIO;
970   CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
971   if (CORBA::is_nil(anObject)) return;
972   PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
973   if (!aServant.in()) return;
974
975   VISU::Prs3d_i* aPrs3d = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
976   if (!aPrs3d) return;
977
978   SVTK_ViewWindow* vw = GetViewWindow();
979   if (!vw) return;
980
981   VISU_Actor* anActor = GetActor(aPrs3d, vw);
982   if (!anActor) return;
983
984   if (VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrs3d)) {
985     SALOMEDS::Color anOldColor = aMesh->GetLinkColor(), aNewColor;
986     QColor aColor (int(255*anOldColor.R),
987                    int(255*anOldColor.G),
988                    int(255*anOldColor.B));
989     QColor aColorNew = QColorDialog::getColor(aColor, GetDesktop(this));
990     if (aColorNew.isValid()) {
991       aNewColor.R = aColorNew.red()/255.;
992       aNewColor.G = aColorNew.green()/255.;
993       aNewColor.B = aColorNew.blue()/255.;
994       aMesh->SetLinkColor(aNewColor);
995       RecreateActor(this, aMesh);
996     }
997   }
998 }
999
1000 void
1001 VisuGUI::
1002 OnChangeOpacity()
1003 {
1004   Handle(SALOME_InteractiveObject) anIO;
1005   CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
1006   if (CORBA::is_nil(anObject)) return;
1007   PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
1008   if (!aServant.in()) return;
1009
1010   VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
1011   if (!aPrsObject) return;
1012
1013   SVTK_ViewWindow* vw = GetViewWindow();
1014   if (!vw) return;
1015
1016   VISU_Actor* anActor = GetActor(aPrsObject, vw);
1017   if (!anActor) return;
1018
1019   VisuGUI_CursorDlg* CursorDlg =
1020     new VisuGUI_CursorDlg (GetDesktop(this), tr("DLG_OPACITY_TITLE"), TRUE);
1021
1022   CursorDlg->Comment1->setText(tr("DLG_OPACITY_CMT1"));
1023   CursorDlg->Comment2->setText(tr("DLG_OPACITY_CMT2"));
1024   CursorDlg->SpinBox1->setMinValue(0);
1025   CursorDlg->SpinBox1->setMaxValue(100);
1026
1027   float oldopac = anActor->GetOpacity();
1028   int intopac = int(oldopac*100. + 0.5);
1029   CursorDlg->SpinBox1->setValue(intopac);
1030
1031   int ret = CursorDlg->exec();
1032   if (ret == 1) {
1033     intopac = CursorDlg->SpinBox1->value();
1034     float newopac = intopac/100.;
1035     anActor->SetOpacity(newopac);
1036   }
1037   delete CursorDlg;
1038 }
1039
1040 void
1041 VisuGUI::
1042 OnChangeLines()
1043 {
1044   Handle(SALOME_InteractiveObject) anIO;
1045   CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
1046   if (CORBA::is_nil(anObject)) return;
1047   PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
1048   if (!aServant.in()) return;
1049
1050   VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
1051   if (!aPrsObject) return;
1052
1053   SVTK_ViewWindow* vw = GetViewWindow();
1054   if (!vw) return;
1055
1056   VISU_Actor* anActor = GetActor(aPrsObject, vw);
1057   if (!anActor) return;
1058
1059   VisuGUI_CursorDlg* CursorDlg =
1060     new VisuGUI_CursorDlg (GetDesktop(this), tr("DLG_LINEWIDTH_TITLE"), TRUE);
1061
1062   CursorDlg->Comment1->setText(tr("DLG_LINEWIDTH_CMT1"));
1063   CursorDlg->Comment2->setText(tr("DLG_LINEWIDTH_CMT2"));
1064   CursorDlg->SpinBox1->setMinValue(1);
1065   CursorDlg->SpinBox1->setMaxValue(10);
1066
1067   float oldlwid = anActor->GetLineWidth();
1068   int intlwid = int(oldlwid);
1069   CursorDlg->SpinBox1->setValue(intlwid);
1070
1071   int ret = CursorDlg->exec();
1072   if (ret == 1) {
1073     intlwid  = CursorDlg->SpinBox1->value();
1074     float newlwid = intlwid;
1075     anActor->SetLineWidth(newlwid);
1076   }
1077   delete CursorDlg;
1078 }
1079
1080 void
1081 VisuGUI::
1082 OnShowTable()
1083 {
1084   Handle(SALOME_InteractiveObject) anIO;
1085   CORBA::Object_var anObject = GetSelectedObj( this, &anIO );
1086   _PTR(SObject) SO;
1087   if ( !CORBA::is_nil( anObject ) ) {
1088     VISU::Base_var aVisuObj = VISU::Base::_narrow( anObject );
1089     if ( !CORBA::is_nil( aVisuObj ) && aVisuObj->GetType() == VISU::TTABLE ) {
1090       CORBA::Object_ptr aTable = VISU::Table::_narrow( anObject );
1091       if( !CORBA::is_nil( aTable ) ) {
1092         VISU::Table_i* table = dynamic_cast<VISU::Table_i*>( VISU::GetServant(aTable).in() );
1093         if ( table ) {
1094           SO = GetCStudy( GetAppStudy( this ) )->FindObjectID( table->GetObjectEntry() );
1095         }
1096       }
1097     }
1098   } else {
1099     // possibly this is Table SObject
1100     SO = GetCStudy( GetAppStudy( this ) )->FindObjectID( anIO->getEntry() );
1101   }
1102
1103   if( !IsSObjectTable( SO ) )
1104     return;
1105
1106   VisuGUI_TableDlg* dlg = new VisuGUI_TableDlg( GetDesktop( this ),
1107                                                SO,
1108                                                false,
1109                                                //SAL2670 Orientation of show tables
1110                                                VisuGUI_TableDlg::ttAuto,
1111                                                Qt::Vertical );
1112   dlg->show();
1113 }
1114
1115 void
1116 VisuGUI::
1117 OnCreateTable()
1118 {
1119   Handle(SALOME_InteractiveObject) anIO;
1120   CORBA::Object_var anObject = GetSelectedObj( this, &anIO );
1121   _PTR(Study) aStudy = GetCStudy( GetAppStudy( this ) );
1122   _PTR(SObject) aSObject = aStudy->FindObjectID(anIO->getEntry());
1123   VISU::CutLines_var aCutLines = VISU::CutLines::_narrow( anObject );
1124   if(!aCutLines->_is_nil() || IsSObjectTable(aSObject)) {
1125     GetVisuGen( this )->CreateTable( aSObject->GetID().c_str() );
1126     UpdateObjBrowser(this);
1127   }
1128 }
1129
1130 void
1131 VisuGUI::
1132 OnDeleteObjects()
1133 {
1134   _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1135   if (CheckLock(aCStudy))
1136     return;
1137
1138   SALOME_ListIO aList;
1139   LightApp_SelectionMgr* mgr = GetSelectionMgr(this);
1140   mgr->selectedObjects(aList,QString::null,false);
1141   int i = 0, nbSelected = aList.Extent();
1142   if (nbSelected < 1) return;
1143
1144   const char* entries [nbSelected];
1145   Handle(SALOME_InteractiveObject) anIO;
1146   for (SALOME_ListIteratorOfListIO it (aList); it.More(); it.Next()) {
1147     anIO = it.Value();
1148     if (anIO->hasEntry())
1149       entries[i++] = anIO->getEntry();
1150   }
1151   nbSelected = i;
1152   if (nbSelected < 1) return;
1153
1154   // There is a transaction
1155   _PTR(StudyBuilder) aStudyBuilder = aCStudy->NewBuilder();
1156   aStudyBuilder->NewCommand();
1157
1158   for (i = 0; i < nbSelected; i++) {
1159     _PTR(SObject) aSObject = aCStudy->FindObjectID(entries[i]);
1160     if (aSObject) {
1161       DeleteSObject(this, aCStudy, aSObject);
1162     }
1163   }
1164
1165   // Finish transaction
1166   aStudyBuilder->CommitCommand();
1167
1168   //GetActiveStudy()->unHighlightAll();
1169   UpdateObjBrowser(this, true);
1170 }
1171
1172 void
1173 VisuGUI::
1174 OnPlotData()
1175 {
1176   Handle(SALOME_InteractiveObject) anIO;
1177   CORBA::Object_var anObject = GetSelectedObj( this, &anIO );
1178   _PTR(SObject) SO;
1179   _PTR(GenericAttribute) anAttr;
1180   _PTR(AttributeName)    aName;
1181   QString SOName;
1182   _PTR(Study) aStudy = GetCStudy( GetAppStudy( this ) );
1183
1184   if ( !CORBA::is_nil( anObject ) ) {
1185     VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
1186     if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TTABLE) {
1187       // Table (VISU object) is selected
1188       CORBA::Object_ptr aTbl = VISU::Table::_narrow( anObject );
1189       if( !CORBA::is_nil( aTbl ) ) {
1190         VISU::Table_i* table = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTbl).in());
1191         if ( table ) {
1192           _PTR(SObject) SO = aStudy->FindObjectID( table->GetObjectEntry() );
1193           if ( IsSObjectTable(SO) ) {
1194             // get name of SObject
1195             if ( SO->FindAttribute( anAttr, "AttributeName" ) ) {
1196               aName = anAttr;
1197               SOName = QString( aName->Value().c_str() );
1198             }
1199             VisuGUI_SetupPlot2dDlg* dlg = new VisuGUI_SetupPlot2dDlg( SO, GetDesktop( this ) );
1200             if ( dlg->exec() == QDialog::Accepted ) {
1201               if ( !IsStudyLocked( aStudy ) ) {
1202                 // if study is not locked - create new container, create curves and insert them
1203                 // into container, then plot container if current viewer is of VIEW_PLOT2D type
1204                 int horIndex;
1205                 QValueList<int> verIndices;
1206                 dlg->getCurvesSource( horIndex, verIndices );
1207                 if ( horIndex >= 0 && verIndices.count() > 0 ) {
1208                   CORBA::Object_var aContainer = GetVisuGen(this)->CreateContainer();
1209                   if( !CORBA::is_nil( aContainer ) ) {
1210                     VISU::Container_i* pContainer =
1211                       dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
1212                     if ( pContainer ) {
1213                       for ( int i = 0; i < verIndices.count(); i++ ) {
1214                         CORBA::Object_var aNewCurve =
1215                           GetVisuGen(this)->CreateCurve( table->_this(), horIndex+1, verIndices[i]+1 );
1216                         if( !CORBA::is_nil( aNewCurve ) ) {
1217                           VISU::Curve_i* pCrv =
1218                             dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aNewCurve).in());
1219                           if ( pCrv ) {
1220                             bool isAuto;
1221                             int  marker, line, lineWidth;
1222                             QColor color;
1223                             if ( dlg->getCurveAttributes(verIndices[i], isAuto, marker,
1224                                                          line, lineWidth, color) && !isAuto ) {
1225                               SALOMEDS::Color c;
1226                               c.R = color.red()  /255.;
1227                               c.G = color.green()/255.;
1228                               c.B = color.blue() /255.;
1229                               pCrv->SetColor( c );
1230                               pCrv->SetMarker( ( VISU::Curve::MarkerType )marker );
1231                               pCrv->SetLine( ( VISU::Curve::LineType )line, lineWidth );
1232                             }
1233                             pContainer->AddCurve( pCrv->_this() );
1234                           }
1235                         }
1236                       }
1237                       UpdateObjBrowser(this);
1238                       PlotContainer( this, pContainer, VISU::eDisplay );
1239                     }
1240                   }
1241                 }
1242               }
1243               else {
1244                 // if study is locked just get curves info and plot them
1245                 // if current viewer is of VIEW_PLOT2D type
1246                 QPtrList<Plot2d_Curve> container;
1247                 dlg->getCurves( container );
1248                 if ( !container.isEmpty() ) {
1249                   GetPlot2dViewer( this )->getActiveViewFrame()->displayCurves( container, true );
1250                   GetPlot2dViewer( this )->getActiveViewFrame()->setTitle( SOName );
1251                 }
1252               }
1253             }
1254             delete dlg;
1255           }
1256         }
1257       }
1258     }
1259   }
1260   else if ( !anIO.IsNull() ) {
1261     // check if Table SObject is selected
1262     SO = aStudy->FindObjectID( anIO->getEntry() );
1263     if ( IsSObjectTable(SO) ) {
1264       // get name of SObject
1265       if ( SO->FindAttribute( anAttr, "AttributeName" ) ) {
1266         aName = anAttr;
1267         SOName = QString( aName->Value().c_str() );
1268       }
1269       VisuGUI_SetupPlot2dDlg* dlg = new VisuGUI_SetupPlot2dDlg( SO, GetDesktop( this ) );
1270       if ( dlg->exec() == QDialog::Accepted ) {
1271         if ( !IsStudyLocked( aStudy ) ) {
1272           // if study is not locked - create new table and container objects, 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 aTable = GetVisuGen(this)->CreateTable( SO->GetID().c_str() );
1279             CORBA::Object_var aContainer = GetVisuGen(this)->CreateContainer();
1280             if ( !CORBA::is_nil( aTable ) && !CORBA::is_nil( aContainer ) ) {
1281               VISU::Table_i*     pTable     = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTable).in());
1282               VISU::Container_i* pContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
1283
1284               if ( pContainer && pTable ) {
1285                 for ( int i = 0; i < verIndices.count(); i++ ) {
1286                   CORBA::Object_var aNewCurve = GetVisuGen(this)->CreateCurve
1287                     ( pTable->_this(), horIndex+1, verIndices[i]+1 );
1288                   if( !CORBA::is_nil( aNewCurve ) ) {
1289                     VISU::Curve_i* pCrv = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aNewCurve).in());
1290                     if ( pCrv ) {
1291                       bool isAuto;
1292                       int  marker, line, lineWidth;
1293                       QColor color;
1294                       if ( dlg->getCurveAttributes(verIndices[i], isAuto, marker,
1295                                                    line, lineWidth, color) && !isAuto ) {
1296                         SALOMEDS::Color c;
1297                         c.R = color.red()/255.;
1298                         c.G = color.green()/255.;
1299                         c.B = color.blue()/255.;
1300                         pCrv->SetColor( c );
1301                         pCrv->SetMarker( ( VISU::Curve::MarkerType )marker );
1302                         pCrv->SetLine( ( VISU::Curve::LineType )line, lineWidth );
1303                       }
1304                       pContainer->AddCurve( pCrv->_this() );
1305                     }
1306                   }
1307                 }
1308                 UpdateObjBrowser(this);
1309                 PlotContainer( this, pContainer, VISU::eDisplay );
1310               }
1311             }
1312           }
1313         } else {
1314           // if study is locked just get curves info and plot them
1315           QPtrList<Plot2d_Curve> container;
1316           dlg->getCurves( container );
1317           if ( !container.isEmpty() ) {
1318             GetPlot2dViewer( this )->getActiveViewFrame()->displayCurves( container, true );
1319             GetPlot2dViewer( this )->getActiveViewFrame()->setTitle( SOName );
1320           }
1321         }
1322       }
1323       delete dlg;
1324     }
1325   }
1326 }
1327
1328 void
1329 VisuGUI::
1330 OnCurveProperties()
1331 {
1332   LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1333   SALOME_ListIO aListIO;
1334   aSelectionMgr->selectedObjects(aListIO);
1335   if (aListIO.Extent() != 1) return;
1336
1337   SalomeApp_Study* aAppStudy = GetAppStudy(this);
1338   const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
1339   CORBA::Object_var anObject = GetSelectedObj( aAppStudy, anIO->getEntry() );
1340   if (CORBA::is_nil( anObject )) return;
1341
1342   VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
1343   if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCURVE) {
1344     // Curve object
1345     CORBA::Object_ptr aCurve = VISU::Curve::_narrow( anObject );
1346     if( !CORBA::is_nil( aCurve ) ) {
1347       VISU::Curve_i* aDSCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
1348       if ( aDSCurve && (!IsStudyLocked( GetCStudy(aAppStudy) )) ) {
1349         Plot2d_SetupCurveDlg aDlg(GetDesktop( this ));
1350
1351         aDlg.setLine( (int)aDSCurve->GetLine(), aDSCurve->GetLineWidth() );
1352         aDlg.setMarker( (int)aDSCurve->GetMarker() );
1353         SALOMEDS::Color aColor = aDSCurve->GetColor();
1354         aDlg.setColor( QColor( (int)(aColor.R*255.), (int)(aColor.G*255.), (int)(aColor.B*255.) ) );
1355         if( aDlg.exec() == QDialog::Accepted ) {
1356           aDSCurve->SetLine( (VISU::Curve::LineType)aDlg.getLine(), aDlg.getLineWidth() );
1357           aDSCurve->SetMarker( (VISU::Curve::MarkerType)aDlg.getMarker());
1358           SALOMEDS::Color newColor;
1359           newColor.R = aDlg.getColor().red()/255.;
1360           newColor.G = aDlg.getColor().green()/255.;
1361           newColor.B = aDlg.getColor().blue()/255.;
1362           aDSCurve->SetColor( newColor );
1363           PlotCurve(this, aDSCurve, VISU::eDisplay);
1364         }
1365       }
1366     }
1367   }
1368 }
1369
1370 void
1371 VisuGUI::
1372 OnClearContainer()
1373 {
1374   _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1375   if (CheckLock(aCStudy))
1376     return;
1377   Handle(SALOME_InteractiveObject) anIO;
1378   CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
1379   if (anIO.IsNull() || CORBA::is_nil(anObject))
1380     return;
1381
1382   VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
1383   if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCONTAINER) {
1384     // Container object
1385     CORBA::Object_ptr aCnt = VISU::Container::_narrow(anObject);
1386     if (!CORBA::is_nil(aCnt)) {
1387       VISU::Container_i* container = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aCnt).in());
1388       if (container && container->GetNbCurves() > 0) {
1389         container->Clear();
1390         UpdateObjBrowser(this);
1391       }
1392     }
1393   }
1394 }
1395
1396 void
1397 VisuGUI::
1398 OnEditContainer()
1399 {
1400   Handle(SALOME_InteractiveObject) anIO;
1401   CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
1402   if (CORBA::is_nil(anObject)) return;
1403
1404   PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
1405   if (!aServant.in()) return;
1406   VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(aServant.in());
1407   if (!aContainer) return;
1408
1409   VisuGUI_EditContainerDlg* aDlg = new VisuGUI_EditContainerDlg (this);
1410   aDlg->initFromPrsObject(aContainer);
1411   if (aDlg->exec()) {
1412     aDlg->storeToPrsObject(aContainer);
1413     UpdateObjBrowser(this, true);
1414   }
1415   delete aDlg;
1416 }
1417
1418 void
1419 VisuGUI::
1420 OnSaveViewParams()
1421 {
1422   _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1423   if (CheckLock(aCStudy))
1424     return;
1425
1426   SUIT_ViewManager* aViewMgr = getApp()->activeViewManager();
1427   if (aViewMgr->getType() != SVTK_Viewer::Type())
1428     return;
1429
1430   LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1431   SALOME_ListIO aListIO;
1432   aSelectionMgr->selectedObjects(aListIO);
1433   if (aListIO.Extent() > 1)
1434     return;
1435
1436   if (aListIO.Extent() == 0) {
1437     VISU::View3D_i::SaveViewParams(aViewMgr, VISU::View3D_i::GenerateViewParamsName().latin1());
1438   } else {
1439     const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
1440     VISU::View3D_i::SaveViewParams(aViewMgr, anIO->getName());
1441   }
1442   UpdateObjBrowser(this);
1443 }
1444
1445 void
1446 VisuGUI::
1447 OnRestoreViewParams()
1448 {
1449   SUIT_ViewManager* aViewMgr = getApp()->activeViewManager();
1450   if (aViewMgr->getType() != SVTK_Viewer::Type())
1451     return;
1452
1453   LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1454   SALOME_ListIO aListIO;
1455   aSelectionMgr->selectedObjects(aListIO);
1456   if (aListIO.Extent() != 1)
1457     return;
1458
1459   const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
1460   //jfa tmp:VISU::View3D_i::RestoreViewParams(aViewMgr, anIO->getName());
1461   _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));//jfa tmp
1462   _PTR(SObject) aSObj = aCStudy->FindObjectID(anIO->getEntry());//jfa tmp
1463   VISU::View3D_i::RestoreViewParams(aViewMgr, aSObj->GetName().c_str());//jfa tmp
1464 }
1465
1466 void
1467 VisuGUI::
1468 OnRename()
1469 {
1470   _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1471   if (CheckLock(aCStudy))
1472     return;
1473
1474   Handle(SALOME_InteractiveObject) anIO;
1475   CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
1476
1477   _PTR(SObject) aSObj = aCStudy->FindObjectID(anIO->getEntry());
1478   if (!aSObj) return;
1479
1480   //TEST DU PARENT == VISU
1481   _PTR(StudyBuilder) aBuilder = aCStudy->NewBuilder();
1482   _PTR(GenericAttribute) anAttr = aBuilder->FindOrCreateAttribute(aSObj, "AttributeName");
1483   if (anAttr) {
1484     _PTR(AttributeName) aName (anAttr);
1485     QString Name = VisuGUI_NameDlg::getName( GetDesktop( this ), aName->Value().c_str() );
1486     if (!Name.isEmpty()) {
1487       QApplication::setOverrideCursor(Qt::waitCursor);
1488
1489       // rename specific objects
1490       if (!CORBA::is_nil(anObject)) {
1491         VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
1492         if (!CORBA::is_nil(aVisuObj)) {
1493           switch (aVisuObj->GetType()) {
1494             case VISU::TCURVE: // Curve object
1495             {
1496               CORBA::Object_ptr aCurve = VISU::Curve::_narrow(anObject);
1497               if (!CORBA::is_nil(aCurve)) {
1498                 VISU::Curve_i* curve =
1499                   dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
1500                 if (curve)
1501                   curve->SetName(Name.latin1());
1502               }
1503               break;
1504             }
1505             case VISU::TTABLE: // Table object
1506             {
1507               CORBA::Object_ptr aTable = VISU::Table::_narrow(anObject);
1508               if (!CORBA::is_nil(aTable)) {
1509                 VISU::Table_i* table =
1510                   dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTable).in());
1511                 if (table)
1512                   table->SetName(Name.latin1());
1513               }
1514               break;
1515             }
1516             case VISU::TCONTAINER: // Container object
1517             {
1518               CORBA::Object_ptr aContainer = VISU::Container::_narrow(anObject);
1519               if (!CORBA::is_nil(aContainer)) {
1520                 VISU::Container_i* container =
1521                   dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
1522                 if (container)
1523                   container->SetName(Name.latin1());
1524               }
1525               break;
1526             }
1527             default:
1528             {
1529             }
1530           }
1531         }
1532       }
1533
1534       // rename the study object
1535       aName->SetValue(Name.latin1()); // rename the SObject
1536       anIO->setName(Name.latin1()); // rename the InteractiveObject
1537       UpdateObjBrowser(this, false);
1538
1539       QApplication::restoreOverrideCursor();
1540     }
1541   }
1542 }
1543
1544 void
1545 VisuGUI::
1546 OnClippingPlanes()
1547 {
1548   new VisuGUI_ClippingDlg (this, "", false);
1549 }
1550
1551 void
1552 VisuGUI::
1553 OnSweep()
1554 {
1555   // GetSelectedPrs3d
1556   Handle(SALOME_InteractiveObject) anIO;
1557   CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
1558   if (CORBA::is_nil(anObject)) return;
1559   PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
1560   if (!aServant.in()) return;
1561
1562   VISU::ScalarMap_i* aPrsObject = dynamic_cast<VISU::ScalarMap_i*>(aServant.in());
1563   if (!aPrsObject) return;
1564
1565   SVTK_ViewWindow* vw = GetViewWindow();
1566   if (!vw) return;
1567
1568   VISU_Actor* aActor = GetActor(aPrsObject, vw);
1569   if (!aActor) return;
1570
1571   if (!aActor->GetVisibility()) {
1572     aActor->VisibilityOn();
1573   }
1574
1575   // Get sweep parameters
1576   SUIT_ResourceMgr* aResourceMgr = GetResourceMgr();
1577
1578   double aTempoDbl = aResourceMgr->doubleValue("VISU", "sweeping_time_step", 0.1);
1579   int aTemp = int(1.E6 * aTempoDbl);
1580
1581   int aCycles = aResourceMgr->integerValue("VISU", "sweeping_number_cycles", 1);
1582   int aSteps  = aResourceMgr->integerValue("VISU", "sweeping_time_step", 40);
1583
1584   // Sweep
1585   QApplication::setOverrideCursor(Qt::waitCursor);
1586   for (int j = 0; j < aCycles; j++) {
1587     for (int i = 0; i <= aSteps; i++) {
1588       try {
1589         float aPercents = float(i)/aSteps;
1590         aPrsObject->SetMapScale(aPercents);
1591         aPrsObject->UpdateActor(aActor);
1592         vw->getRenderWindow()->getRenderWindow()->Render();
1593         usleep(aTemp);
1594       } catch (std::exception& exc) {
1595         INFOS("Follow exception was occured :\n" << exc.what());
1596       } catch (...) {
1597         INFOS("Unknown exception was occured!");
1598       }
1599     }
1600   }
1601   QApplication::restoreOverrideCursor();
1602 }
1603
1604 void
1605 VisuGUI::
1606 OnTimeAnimation()
1607 {
1608   _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1609   VisuGUI_TimeAnimationDlg* aAnimationDlg =
1610 //    new VisuGUI_TimeAnimationDlg(GetDesktop(this), aCStudy);
1611     new VisuGUI_TimeAnimationDlg (this, aCStudy);
1612
1613   LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1614   SALOME_ListIO aListIO;
1615   aSelectionMgr->selectedObjects(aListIO);
1616
1617   bool isDefined = false;
1618   long aNbTimes = 0;
1619   SALOME_ListIteratorOfListIO It (aListIO);
1620   for (; It.More(); It.Next()) {
1621     _PTR(SObject) aSObject = aCStudy->FindObjectID(It.Value()->getEntry());
1622     if (!aSObject) continue;
1623     if (getValue(aSObject, "myComment") == QString("FIELD")) {
1624       long aNumber = getValue(aSObject, "myNbTimeStamps").toLong();
1625       if (aNumber > 1) {
1626         if (!isDefined) {
1627           aNbTimes = aNumber;
1628           aAnimationDlg->addField(aSObject);
1629           isDefined = true;
1630         } else if (aNbTimes == aNumber) {
1631           aAnimationDlg->addField(aSObject);
1632         }
1633       }
1634     }
1635   }
1636   if (isDefined) aAnimationDlg->show();
1637   else delete aAnimationDlg;
1638 }
1639
1640 //************************************************************************
1641 void
1642 VisuGUI::
1643 OnShowAnimation()
1644 {
1645   LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1646   SALOME_ListIO aListIO;
1647   aSelectionMgr->selectedObjects(aListIO);
1648
1649   if (aListIO.Extent() != 1)
1650     return;
1651
1652   const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
1653
1654   _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1655
1656   _PTR(SObject) aSObj = aCStudy->FindObjectID(anIO->getEntry());
1657   if (!aSObj) return;
1658
1659   VISU::Storable::TRestoringMap aMap;
1660   _PTR(GenericAttribute) anAttr;
1661   if (!aSObj->FindAttribute(anAttr, "AttributeComment")) return;
1662
1663   _PTR(AttributeComment) aComment (anAttr);
1664   string aComm = aComment->Value();
1665   QString strIn (aComm.c_str());
1666   VISU::Storable::StrToMap(strIn, aMap);
1667   bool isExist;
1668   VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt();
1669   if (aType != VISU::TANIMATION) return;
1670
1671   VisuGUI_TimeAnimationDlg* aAnimationDlg =
1672     new VisuGUI_TimeAnimationDlg(this, aCStudy);
1673   aAnimationDlg->restoreFromStudy(aSObj);
1674   aAnimationDlg->show();
1675 }
1676
1677 void
1678 VisuGUI::
1679 OnCopyPresentation()
1680 {
1681   _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1682   if (CheckLock(aCStudy))
1683     return;
1684
1685   Handle(SALOME_InteractiveObject) anIO;
1686   CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
1687   if (CORBA::is_nil(anObject)) return;
1688   PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
1689   if (!aServant.in()) return;
1690
1691   VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
1692   if (!aPrsObject) return;
1693
1694   switch (aPrsObject->GetType()) {
1695   case VISU::TMESH:
1696     {
1697       VISU::Mesh_i* aMeshPrs = dynamic_cast<VISU::Mesh_i*>(aPrsObject);
1698       VISU::Mesh_i* aSameMesh = new VISU::Mesh_i(aMeshPrs->GetResult());
1699       aSameMesh->SameAs(aMeshPrs);
1700       UpdateViewer(this, aSameMesh);
1701     }
1702     break;
1703   case VISU::TSCALARMAP:
1704     {
1705       VISU::ScalarMap_i* aScalarPrs = dynamic_cast<VISU::ScalarMap_i*>(aPrsObject);
1706       VISU::ScalarMap_i* aSameScalar = new VISU::ScalarMap_i(aScalarPrs->GetResult(),true);
1707       aSameScalar->SameAs(aScalarPrs);
1708       UpdateViewer(this, aSameScalar);
1709     }
1710     break;
1711   case VISU::TDEFORMEDSHAPE:
1712     {
1713       VISU::DeformedShape_i* aDefPrs = dynamic_cast<VISU::DeformedShape_i*>(aPrsObject);
1714       VISU::DeformedShape_i* aSameDeformed = new VISU::DeformedShape_i(aDefPrs->GetResult(),true);
1715       aSameDeformed->SameAs(aDefPrs);
1716       UpdateViewer(this, aSameDeformed);
1717     }
1718     break;
1719   case VISU::TCUTPLANES:
1720     {
1721       VISU::CutPlanes_i* aCutPrs = dynamic_cast<VISU::CutPlanes_i*>(aPrsObject);
1722       VISU::CutPlanes_i* aSameCut = new VISU::CutPlanes_i(aCutPrs->GetResult(),true);
1723       aSameCut->SameAs(aCutPrs);
1724       UpdateViewer(this, aSameCut);
1725     }
1726     break;
1727   case VISU::TCUTLINES:
1728     {
1729       VISU::CutLines_i* aCutPrs = dynamic_cast<VISU::CutLines_i*>(aPrsObject);
1730       VISU::CutLines_i* aSameCut = new VISU::CutLines_i(aCutPrs->GetResult(),true);
1731       aSameCut->SameAs(aCutPrs);
1732       UpdateViewer(this, aSameCut);
1733     }
1734     break;
1735   case VISU::TISOSURFACE:
1736     {
1737       VISU::IsoSurfaces_i* aIsoPrs = dynamic_cast<VISU::IsoSurfaces_i*>(aPrsObject);
1738       VISU::IsoSurfaces_i* aSameIso = new VISU::IsoSurfaces_i(aIsoPrs->GetResult(),true);
1739       aSameIso->SameAs(aIsoPrs);
1740       UpdateViewer(this, aSameIso);
1741     }
1742     break;
1743   case VISU::TSTREAMLINES:
1744     {
1745       VISU::StreamLines_i* aLinesPrs = dynamic_cast<VISU::StreamLines_i*>(aPrsObject);
1746       VISU::StreamLines_i* aSameLines = new VISU::StreamLines_i(aLinesPrs->GetResult(),true);
1747       aSameLines->SameAs(aLinesPrs);
1748       UpdateViewer(this, aSameLines);
1749     }
1750     break;
1751   case VISU::TVECTORS:
1752     {
1753       VISU::Vectors_i* aVectorsPrs = dynamic_cast<VISU::Vectors_i*>(aPrsObject);
1754       VISU::Vectors_i* aSameVectors = new VISU::Vectors_i(aVectorsPrs->GetResult(),true);
1755       aSameVectors->SameAs(aVectorsPrs);
1756       UpdateViewer(this, aSameVectors);
1757     }
1758     break;
1759   case VISU::TPLOT3D:
1760     {
1761       VISU::Plot3D_i* aPlot3DPrs = dynamic_cast<VISU::Plot3D_i*>(aPrsObject);
1762       VISU::Plot3D_i* aSamePlot3D = new VISU::Plot3D_i(aPlot3DPrs->GetResult());
1763       aSamePlot3D->SameAs(aPlot3DPrs);
1764       UpdateViewer(this, aSamePlot3D);
1765     }
1766     break;
1767   }
1768   UpdateObjBrowser(this);
1769 }
1770
1771 void
1772 VisuGUI::
1773 OnSelectionInfo()
1774 {
1775   if (GetViewWindow())
1776     (new VisuGUI_SelectionDlg(GetDesktop(this)))->show();
1777   else
1778     SUIT_MessageBox::warn1(GetDesktop(this),
1779                            tr("WRN_VISU"),
1780                            tr("ERR_ACTIVATE_VIEW3D"),
1781                            tr("BUT_OK") );
1782 }
1783
1784 void
1785 VisuGUI::
1786 OnScaling()
1787 {
1788   VisuGUI_NonIsometricDlg* m_NonIsoDlg =
1789     new VisuGUI_NonIsometricDlg (GetDesktop(this), "m_NonIsoDlg",
1790                                  false, Qt::WDestructiveClose);
1791   m_NonIsoDlg->show();
1792 }
1793
1794 void
1795 VisuGUI::
1796 OnCubeAxes()
1797 {
1798   //Show dialog that allows to select scale function and corresponding scale factor
1799   VisuGUI_CubeAxesDlg* aDlg = new VisuGUI_CubeAxesDlg (GetDesktop(this));
1800   aDlg->show();
1801 }
1802
1803 void
1804 VisuGUI::
1805 OnMergeScalarBars()
1806 {
1807   LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1808   SALOME_ListIO aListIO;
1809   aSelectionMgr->selectedObjects(aListIO);
1810
1811   SALOME_ListIteratorOfListIO It (aListIO);
1812
1813   // first find the bounds
1814   double aMin, aMax; bool first = true;
1815   for (; It.More(); It.Next()) {
1816     Handle(SALOME_InteractiveObject)& anIO = It.Value();
1817     std::vector<VISU::Prs3d_i*> aPrsList = GetPrs3dList(this, anIO);
1818     if (!aPrsList.empty()) {
1819       for (int i = 0, n = aPrsList.size(); i < n; i++) {
1820         VISU::Prs3d_i* aPrsObject = aPrsList[i];
1821         if (aPrsObject) {
1822           VISU::ScalarMap_i* aScalar = dynamic_cast<VISU::ScalarMap_i*>(aPrsObject);
1823           if (aScalar) {
1824             if (first) {
1825               first = false;
1826               aMin = aScalar->GetMin(); aMax = aScalar->GetMax();
1827             } else {
1828               if (aScalar->GetMin() < aMin) aMin = aScalar->GetMin();
1829               if (aScalar->GetMax() > aMax) aMax = aScalar->GetMax();
1830             }
1831           }
1832         }
1833       }
1834     }
1835   }
1836
1837   // set the computed range to every selected ScalarMap
1838   bool update = false;
1839   for (It.Initialize(aListIO); It.More(); It.Next() ) {
1840     Handle(SALOME_InteractiveObject)& anIO = It.Value();
1841     std::vector<VISU::Prs3d_i*> aPrsList = GetPrs3dList(this, anIO);
1842     if (!aPrsList.empty()) {
1843       for (int i = 0, n = aPrsList.size(); i < n; i++) {
1844         VISU::Prs3d_i* aPrsObject = aPrsList[i];
1845         if(aPrsObject){
1846           VISU::ScalarMap_i* aScalar = dynamic_cast<VISU::ScalarMap_i*>(aPrsObject);
1847           if (aScalar) {
1848             aScalar->SetRange(aMin, aMax);
1849             RecreateActor(this, aScalar);
1850             update = true;
1851           }
1852         }
1853       }
1854     }
1855   }
1856   if (update) {
1857     if (SVTK_ViewWindow* vw = GetViewWindow(this)) {
1858 //if (vw->getRenderer()->GetActors()->GetNumberOfItems() > 0) {
1859         vw->getRenderer()->ResetCameraClippingRange();
1860         vw->Repaint();
1861 //}
1862     }
1863   }
1864 }
1865
1866 void
1867 VisuGUI::
1868 OnFreeScalarBars()
1869 {
1870   LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1871   SALOME_ListIO aListIO;
1872   aSelectionMgr->selectedObjects(aListIO);
1873
1874   SALOME_ListIteratorOfListIO It (aListIO);
1875
1876   // restore the source range for every ScalarMap
1877   bool update = false;
1878   for (; It.More(); It.Next()) {
1879     Handle(SALOME_InteractiveObject)& anIO = It.Value();
1880     std::vector<VISU::Prs3d_i*> aPrsList = GetPrs3dList(this, anIO);
1881     if (!aPrsList.empty()) {
1882       for (int i = 0, n = aPrsList.size(); i < n; i++) {
1883         VISU::Prs3d_i* aPrsObject = aPrsList[i];
1884         if (aPrsObject) {
1885           VISU::ScalarMap_i* aScalar = dynamic_cast<VISU::ScalarMap_i*>(aPrsObject);
1886           if (aScalar) {
1887             aScalar->SetSourceRange();
1888             RecreateActor(this, aScalar);
1889             update = true;
1890           }
1891         }
1892       }
1893     }
1894   }
1895   if (update) {
1896     if (SVTK_ViewWindow* vw = GetViewWindow(this)) {
1897 //if (vw->getRenderer()->GetActors()->GetNumberOfItems() > 0) {
1898         vw->getRenderer()->ResetCameraClippingRange();
1899         vw->Repaint();
1900 //}
1901     }
1902   }
1903 }
1904
1905 void
1906 VisuGUI::
1907 OnTranslatePrs()
1908 {
1909   if(MYDEBUG) MESSAGE("VisuGUI::OnTranslatePrs");
1910   VisuGUI_OffsetDlg* aDlg = new VisuGUI_OffsetDlg (this);
1911
1912   _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1913
1914   LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1915   SALOME_ListIO aListIO;
1916   aSelectionMgr->selectedObjects(aListIO);
1917
1918   SALOME_ListIteratorOfListIO It (aListIO);
1919   for (; It.More(); It.Next()) {
1920     Handle(SALOME_InteractiveObject)& anIO = It.Value();
1921     if (anIO->hasEntry()) {
1922       _PTR(SObject) aSObject = aCStudy->FindObjectID(anIO->getEntry());
1923       if (aSObject) {
1924         CORBA::Object_var aCORBAObject = VISU::ClientSObjectToObject(aSObject);
1925         if (!CORBA::is_nil(aCORBAObject)) {
1926           PortableServer::ServantBase_var aServant = VISU::GetServant(aCORBAObject);
1927           if (VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(aServant.in())) {
1928             aDlg->addPresentation(aPrsObject);
1929           }
1930         }
1931       }
1932     }
1933   }
1934   if (aDlg->getPrsCount() > 0)
1935     aDlg->show();
1936   else
1937     delete aDlg;
1938 }
1939
1940 void
1941 VisuGUI::
1942 OnArrangeActors()
1943 {
1944   SVTK_ViewWindow* vw = GetViewWindow();
1945   if (vw) {
1946     ArrangeDlg* aDlg = new ArrangeDlg (GetDesktop(this), vw);
1947     aDlg->exec();
1948     delete aDlg;
1949   }
1950 }
1951
1952
1953 void
1954 VisuGUI::
1955 initialize( CAM_Application* theApp )
1956 {
1957   SalomeApp_Module::initialize( theApp );
1958
1959   createActions();
1960   createMenus();
1961   createToolBars();
1962   createPopupMenus();
1963 }
1964
1965 void
1966 VisuGUI::
1967 createActions()
1968 {
1969   QPixmap aPixmap;
1970   QWidget* aParent = application()->desktop();
1971   SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
1972
1973   // Create actions
1974   createAction( VISU_IMPORT_FROM_FILE, "", QIconSet(),
1975                 tr("MEN_IMPORT_FROM_FILE"), "", (CTRL + Key_I), aParent, false,
1976                 this, SLOT(OnImportFromFile()));
1977
1978   createAction( VISU_EXPLORE_MED, "", QIconSet(),
1979                 tr("MEN_EXPLORE_MED_FILE"), "", (CTRL + Key_M), aParent, false,
1980                 this, SLOT(OnExploreMEDFile()));
1981
1982   createAction( VISU_IMPORT_TABLE, "", QIconSet(),
1983                 tr("MEN_IMPORT_TABLE"), "", 0, aParent, false,
1984                 this, SLOT(OnImportTableFromFile()));
1985
1986   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_SCALAR_MAP"));
1987   createAction( VISU_SCALAR_MAP, tr("MEN_SCALAR_MAP"), QIconSet(aPixmap),
1988                 tr("MEN_SCALAR_MAP"), "", 0, aParent, false,
1989                 this, SLOT(OnCreateScalarMap()));
1990
1991   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_DEFORMED_SHAPE"));
1992   createAction( VISU_DEFORMED_SHAPE, tr("MEN_DEFORMED_SHAPE"), QIconSet(aPixmap),
1993                 tr("MEN_DEFORMED_SHAPE"), "", 0, aParent, false,
1994                 this, SLOT(OnCreateDeformedShape()));
1995
1996   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_VECTORS"));
1997   createAction( VISU_VECTORS, tr("MEN_VECTORS"), QIconSet(aPixmap),
1998                 tr("MEN_VECTORS"), "", 0, aParent, false,
1999                 this, SLOT(OnCreateVectors()));
2000
2001   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_ISO_SURFACES"));
2002   createAction( VISU_ISO_SURFACES, tr("MEN_ISO_SURFACES"), QIconSet(aPixmap),
2003                 tr("MEN_ISO_SURFACES"), "", 0, aParent, false,
2004                 this, SLOT(OnCreateIsoSurfaces()));
2005
2006   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_CUT_PLANES"));
2007   createAction( VISU_CUT_PLANES, tr("MEN_CUT_PLANES"), QIconSet(aPixmap),
2008                 tr("MEN_CUT_PLANES"), "", 0, aParent, false,
2009                 this, SLOT(OnCreateCutPlanes()));
2010
2011   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_STREAM_LINES"));
2012   createAction( VISU_STREAM_LINES, tr("MEN_STREAM_LINES"), QIconSet(aPixmap),
2013                 tr("MEN_STREAM_LINES"), "", 0, aParent, false,
2014                 this, SLOT(OnCreateStreamLines()));
2015
2016   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_CUT_LINES"));
2017   createAction( VISU_CUT_LINES, tr("MEN_CUT_LINES"), QIconSet(aPixmap),
2018                 tr("MEN_CUT_LINES"), "", 0, aParent, false,
2019                 this, SLOT(OnCreateCutLines()));
2020
2021   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_PLOT_3D"));
2022   createAction( VISU_PLOT_3D, tr("MEN_PLOT_3D"), QIconSet(aPixmap),
2023                 tr("MEN_PLOT_3D"), "", 0, aParent, false,
2024                 this, SLOT(OnCreatePlot3D()));
2025
2026   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_PLOT2D"));
2027   createAction( VISU_PLOT2D, tr("MEN_CREATE_PLOT2D"), QIconSet(aPixmap),
2028                 tr("MEN_CREATE_PLOT2D"), "", 0, aParent, false,
2029                 this, SLOT(OnCreatePlot2dView()));
2030
2031   createAction( VISU_DELETE_OBJS, tr("MEN_DELETE_OBJS"), QIconSet(),
2032                 tr("MEN_DELETE_OBJS"), "", 0, aParent, false,
2033                 this, SLOT(OnDeleteObjects()));
2034
2035   createAction( VISU_SHOW_TABLE, tr("MEN_SHOW_TABLE"), QIconSet(),
2036                 tr("MEN_SHOW_TABLE"), "", 0, aParent, false,
2037                 this, SLOT(OnShowTable()));
2038
2039   createAction( VISU_CREATE_CURVES, tr("MEN_CREATE_CURVES"), QIconSet(),
2040                 tr("MEN_CREATE_CURVES"), "", 0, aParent, false,
2041                 this, SLOT(OnPlotData()));
2042
2043   createAction( VISU_EXPORT_TABLE, tr("MEN_EXPORT_TABLE"), QIconSet(),
2044                 tr("MEN_EXPORT_TABLE"), "", 0, aParent, false,
2045                 this, SLOT(OnExportTableToFile()));
2046
2047   createAction( VISU_IMPORT_MED_STRUCTURE, tr("MEN_IMPORT_MED_STRUCTURE"), QIconSet(),
2048                 tr("MEN_IMPORT_MED_STRUCTURE"), "", 0, aParent, false,
2049                 this, SLOT(OnImportMedField()));
2050
2051   createAction( VISU_IMPORT_MED_TIMESTAMP, tr("MEN_IMPORT_MED_TIMESTAMP"), QIconSet(),
2052                 tr("MEN_IMPORT_MED_TIMESTAMP"), "", 0, aParent, false,
2053                 this, SLOT(OnImportMedField()));
2054
2055   createAction( VISU_IMPORT_MED_FIELD, tr("MEN_IMPORT_MED_FIELD"), QIconSet(),
2056                 tr("MEN_IMPORT_MED_FIELD"), "", 0, aParent, false,
2057                 this, SLOT(OnImportMedField()));
2058
2059   createAction( VISU_CREATE_PRS, tr("MEN_CREATE_PRS"), QIconSet(),
2060                 tr("MEN_CREATE_PRS"), "", 0, aParent, false,
2061                 this, SLOT(OnCreateMesh()));
2062
2063   createAction( VISU_CREATE_MANY_PRS, tr("MEN_CREATE_MANY_PRS"), QIconSet(),
2064                 tr("MEN_CREATE_MANY_PRS"), "", 0, aParent, false,
2065                 this, SLOT(OnCreateManyMesh()));
2066
2067   createAction( VISU_TRANSLATE_PRS, tr("MEN_TRANSLATE_PRS"), QIconSet(),
2068                 tr("MEN_TRANSLATE_PRS"), "", 0, aParent, false,
2069                 this, SLOT(OnTranslatePrs()));
2070
2071   createAction( VISU_MERGE_SCALAR_BARS, tr("MEN_MERGE_SCALAR_BARS"), QIconSet(),
2072                 tr("MEN_MERGE_SCALAR_BARS"), "", 0, aParent, false,
2073                 this, SLOT(OnMergeScalarBars()));
2074
2075   createAction( VISU_FREE_SCALAR_BARS, tr("MEN_FREE_SCALAR_BARS"), QIconSet(),
2076                 tr("MEN_FREE_SCALAR_BARS"), "", 0, aParent, false,
2077                 this, SLOT(OnFreeScalarBars()));
2078
2079   createAction( VISU_ERASE, tr("MEN_ERASE"), QIconSet(),
2080                 tr("MEN_ERASE"), "", 0, aParent, false,
2081                 this, SLOT(OnErasePrs()));
2082
2083   createAction( VISU_DISPLAY, tr("MEN_DISPLAY"), QIconSet(),
2084                 tr("MEN_DISPLAY"), "", 0, aParent, false,
2085                 this, SLOT(OnDisplayPrs()));
2086
2087   createAction( VISU_DISPLAY_ONLY, tr("MEN_DISPLAY_ONLY"), QIconSet(),
2088                 tr("MEN_DISPLAY_ONLY"), "", 0, aParent, false,
2089                 this, SLOT(OnDisplayOnlyPrs()));
2090
2091   createAction( VISU_COPY_PRS, tr("MEN_COPY_PRS"), QIconSet(),
2092                 tr("MEN_COPY_PRS"), "", 0, aParent, false,
2093                 this, SLOT(OnCopyPresentation()));
2094
2095   createAction( VISU_CURVE_PROPS, tr("MEN_CURVE_PROPS"), QIconSet(),
2096                 tr("MEN_CURVE_PROPS"), "", 0, aParent, false,
2097                 this, SLOT(OnCurveProperties()));
2098
2099   createAction( VISU_RENAME, tr("MEN_RENAME"), QIconSet(), tr("MEN_RENAME"), "", 0, aParent, false,
2100                 this, SLOT(OnRename()));
2101
2102   createAction( VISU_EDIT_CONTAINER, tr("MEN_EDIT_CONTAINER"), QIconSet(),
2103                 tr("MEN_EDIT_CONTAINER"), "", 0, aParent, false,
2104                 this, SLOT(OnEditContainer()));
2105
2106   createAction( VISU_CLEAR_CONTAINER, tr("MEN_CLEAR_CONTAINER"), QIconSet(),
2107                 tr("MEN_CLEAR_CONTAINER"), "", 0, aParent, false,
2108                 this, SLOT(OnClearContainer()));
2109
2110   createAction( VISU_SAVE_VIEW_PARAMS, tr("MEN_SAVE_VIEWPARAMS"), QIconSet(),
2111                 tr("MEN_SAVE_VIEWPARAMS"), "", 0, aParent, false,
2112                 this, SLOT(OnSaveViewParams()));
2113   createAction( VISU_SAVE_VIEW_PARAMS_1, tr("MEN_SAVE_VIEWPARAMS"), QIconSet(),
2114                 tr("MEN_SAVE_VIEWPARAMS"), "", 0, aParent, false,
2115                 this, SLOT(OnSaveViewParams()));
2116
2117   createAction( VISU_RESTORE_VIEW_PARAMS, tr("MEN_RESTORE_VIEWPARAMS"), QIconSet(),
2118                 tr("MEN_RESTORE_VIEWPARAMS"), "", 0, aParent, false,
2119                 this, SLOT(OnRestoreViewParams()));
2120
2121   //createAction( VISU_DELETE_VIEW_PARAMS, tr("MEN_DELETE_VIEWPARAMS"), QIconSet(),
2122   //              tr("MEN_DELETE_VIEWPARAMS"), "", 0, aParent, false,
2123   //              this, SLOT(OnDeleteObjects()));
2124
2125   createAction( VISU_ARRANGE_ACTORS, tr("MEN_ARRANGE_ACTORS"), QIconSet(),
2126                 tr("MEN_ARRANGE_ACTORS"), "", 0, aParent, false,
2127                 this, SLOT(OnArrangeActors()));
2128
2129   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_POINTS"));
2130   createAction( VISU_POINTS, tr("MEN_POINTS"), QIconSet(aPixmap),
2131                 tr("MEN_POINTS"), "", 0, aParent, false,
2132                 this, SLOT(OnMakePoints()));
2133
2134   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_WIREFRAME"));
2135   createAction( VISU_WIREFRAME, tr("MEN_WIREFRAME"), QIconSet(aPixmap),
2136                 tr("MEN_WIREFRAME"), "", 0, aParent, false,
2137                 this, SLOT(OnMakeWireframe()));
2138
2139   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_SURFACE"));
2140   createAction( VISU_SURFACE, tr("MEN_SURFACE"), QIconSet(aPixmap),
2141                 tr("MEN_SURFACE"), "", 0, aParent, false,
2142                 this, SLOT(OnMakeSurface()));
2143
2144   createAction( VISU_INSIDEFRAME, tr("MEN_INSIDEFRAME"), QIconSet(),
2145                 tr("MEN_INSIDEFRAME"), "", 0, aParent, false,
2146                 this, SLOT(OnMakeInsideframe()));
2147
2148   createAction( VISU_SURFACEFRAME, tr("MEN_SURFACEFRAME"), QIconSet(),
2149                 tr("MEN_SURFACEFRAME"), "", 0, aParent, false,
2150                 this, SLOT(OnMakeSurfaceframe()));
2151
2152   createAction( VISU_SHRINK, tr("MEN_SHRINK"), QIconSet(),
2153                 tr("MEN_SHRINK"), "", 0, aParent, false,
2154                 this, SLOT(OnMakeShrink()));
2155
2156   createAction( VISU_UNSHRINK, tr("MEN_UNSHRINK"), QIconSet(),
2157                 tr("MEN_UNSHRINK"), "", 0, aParent, false,
2158                 this, SLOT(OnMakeShrink()));
2159   
2160   createAction( VISU_SHADING, tr("MEN_SHADING"), QIconSet(),
2161                 tr("MEN_SHADING"), "", 0, aParent, false,
2162                 this, SLOT(OnSetShadingOn()));
2163   
2164   createAction( VISU_NOSHADING, tr("MEN_NOSHADING"), QIconSet(),
2165                 tr("MEN_NOSHADING"), "", 0, aParent, false,
2166                 this, SLOT(OnSetShadingOff()));
2167
2168   createAction( VISU_CELL_COLOR, tr("MEN_CELL_COLOR"), QIconSet(),
2169                 tr("MEN_CELL_COLOR"), "", 0, aParent, false,
2170                 this, SLOT(OnChangeColor()));
2171
2172   createAction( VISU_COLOR, tr("MEN_COLOR"), QIconSet(),
2173                 tr("MEN_COLOR"), "", 0, aParent, false,
2174                 this, SLOT(OnChangeColor()));
2175
2176   createAction( VISU_EDGE_COLOR, tr("MEN_EDGE_COLOR"), QIconSet(),
2177                 tr("MEN_EDGE_COLOR"), "", 0, aParent, false,
2178                 this, SLOT(OnChangeWireframeColor()));
2179
2180   createAction( VISU_OPACITY, tr("MEN_OPACITY"), QIconSet(),
2181                 tr("MEN_OPACITY"), "", 0, aParent, false,
2182                 this, SLOT(OnChangeOpacity()));
2183
2184   createAction( VISU_LINE_WIDTH, tr("MEN_LINE_WIDTH"), QIconSet(),
2185                 tr("MEN_LINE_WIDTH"), "", 0, aParent, false,
2186                 this, SLOT(OnChangeLines()));
2187
2188
2189   createAction( VISU_EDIT_SCALARMAP, tr("MEN_EDIT_PRS"), QIconSet(),
2190                 tr("MEN_EDIT_PRS"), "", 0, aParent, false,
2191                 this, SLOT(OnEditScalarMap()));
2192
2193   createAction( VISU_EDIT_DEFORMEDSHAPE, tr("MEN_EDIT_PRS"), QIconSet(),
2194                 tr("MEN_EDIT_PRS"), "", 0, aParent, false,
2195                 this, SLOT(OnEditDeformedShape()));
2196
2197   createAction( VISU_EDIT_CUTPLANES, tr("MEN_EDIT_PRS"), QIconSet(),
2198                 tr("MEN_EDIT_PRS"), "", 0, aParent, false,
2199                 this, SLOT(OnEditCutPlanes()));
2200
2201   createAction( VISU_EDIT_CUTLINES, tr("MEN_EDIT_PRS"), QIconSet(),
2202                 tr("MEN_EDIT_PRS"), "", 0, aParent, false,
2203                 this, SLOT(OnEditCutLines()));
2204
2205   createAction( VISU_EDIT_ISOSURFACE, tr("MEN_EDIT_PRS"), QIconSet(),
2206                 tr("MEN_EDIT_PRS"), "", 0, aParent, false,
2207                 this, SLOT(OnEditIsoSurfaces()));
2208
2209   createAction( VISU_EDIT_VECTORS, tr("MEN_EDIT_PRS"), QIconSet(),
2210                 tr("MEN_EDIT_PRS"), "", 0, aParent, false,
2211                 this, SLOT(OnEditVectors()));
2212
2213   createAction( VISU_EDIT_STREAMLINES, tr("MEN_EDIT_PRS"), QIconSet(),
2214                 tr("MEN_EDIT_PRS"), "", 0, aParent, false,
2215                 this, SLOT(OnEditStreamLines()));
2216
2217   createAction( VISU_EDIT_PLOT3D, tr("MEN_EDIT_PRS"), QIconSet(),
2218                 tr("MEN_EDIT_PRS"), "", 0, aParent, false,
2219                 this, SLOT(OnEditPlot3D()));
2220
2221
2222   createAction( VISU_CREATE_TABLE, tr("MEN_CREATE_TABLE"), QIconSet(),
2223                 tr("MEN_CREATE_TABLE"), "", 0, aParent, false,
2224                 this, SLOT(OnCreateTable()));
2225
2226   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_SWEEP"));
2227   createAction( VISU_SWEEP, tr("MEN_SWEEP"), QIconSet(aPixmap),
2228                 tr("MEN_SWEEP"), "", 0, aParent, false,
2229                 this, SLOT(OnSweep()));
2230
2231   createAction( VISU_CLIPPING, tr("MEN_CLIPPING"), QIconSet(),
2232                 tr("MEN_CLIPPING"), "", 0, aParent, false,
2233                 this, SLOT(OnClippingPlanes()));
2234
2235   createAction( VISU_SELECTION_INFO, tr("MEN_SELECTION_INFO"), QIconSet(),
2236                 tr("MEN_SELECTION_INFO"), "", 0, aParent, false,
2237                 this, SLOT(OnSelectionInfo()));
2238
2239   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_TIMEANIMATION"));
2240   createAction( VISU_ANIMATION, tr("MEN_ANIMATION"), QIconSet(aPixmap),
2241                 tr("MEN_ANIMATION"), "", 0, aParent, false,
2242                 this, SLOT(OnTimeAnimation()));
2243
2244   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_ERASE_ALL"));
2245   createAction( VISU_ERASE_ALL, tr("MEN_ERASE_ALL"), QIconSet(aPixmap),
2246                 tr("MEN_ERASE_ALL"), "", 0, aParent, false,
2247                 this, SLOT(OnEraseAll()));
2248
2249   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_GLOBAL_SELECTION"));
2250   createAction( VISU_GLOBAL_SELECTION, tr("MEN_GLOBAL_SELECTION"), QIconSet(aPixmap),
2251                 tr("MEN_GLOBAL_SELECTION"), "", 0, aParent, false,
2252                 //this, SLOT(OnEraseAll()));
2253                 this);
2254
2255   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_PARTIAL_SELECTION"));
2256   createAction( VISU_PARTIAL_SELECTION, tr("MEN_PARTIAL_SELECTION"), QIconSet(aPixmap),
2257                 tr("MEN_PARTIAL_SELECTION"), "", 0, aParent, false,
2258                 //this, SLOT(OnEraseAll()));
2259                 this);
2260
2261   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_SCALING"));
2262   createAction( VISU_SCALING, tr("MEN_SCALING"), QIconSet(aPixmap),
2263                 tr("MEN_SCALING"), "", 0, aParent, false,
2264                 this, SLOT(OnScaling()));
2265
2266   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_CUBE_AXES"));
2267   createAction( VISU_CUBE_AXES, tr("MEN_CUBE_AXES"), QIconSet(aPixmap),
2268                 tr("MEN_CUBE_AXES"), "", 0, aParent, false,
2269                 this, SLOT(OnCubeAxes()));
2270
2271   createAction( VISU_SHOW_ANIMATION, tr("MEN_SHOW_ANIMATION"), QIconSet(),
2272                 tr("MEN_SHOW_ANIMATION"), "", 0, aParent, false,
2273                 this, SLOT(OnShowAnimation()));
2274 }
2275
2276 void
2277 VisuGUI::
2278 createMenus()
2279 {
2280   // Add actions to menus
2281   int aMenuId;
2282   aMenuId = createMenu( tr( "MEN_DESK_FILE" ), -1 );
2283   createMenu( separator(), aMenuId, -1, 10 );
2284   createMenu( VISU_IMPORT_FROM_FILE, aMenuId, 10 ); // import from file
2285   createMenu( VISU_EXPLORE_MED, aMenuId, 10 ); // explore MED file
2286   createMenu( VISU_IMPORT_TABLE, aMenuId, 10 ); // import table
2287
2288   aMenuId = createMenu( tr( "MEN_VISUALIZATION" ), -1, -1, 30 );
2289   createMenu( VISU_SCALAR_MAP, aMenuId, 10 ); // scalar map
2290   createMenu( VISU_DEFORMED_SHAPE, aMenuId, 10 ); // deformed shape
2291   createMenu( VISU_VECTORS, aMenuId, 10 ); // vectors
2292   createMenu( VISU_ISO_SURFACES, aMenuId, 10 ); // iso surfaces
2293   createMenu( VISU_CUT_PLANES, aMenuId, 10 ); // cut planes
2294   createMenu( VISU_CUT_LINES, aMenuId, 10 ); // cut lines
2295   createMenu( VISU_STREAM_LINES, aMenuId, 10 ); // stream lines
2296   createMenu( VISU_PLOT_3D, aMenuId, 10 ); // Plot3d
2297
2298   aMenuId = createMenu( tr( "MEN_SELECTION" ), -1, -1, 30 );
2299   createMenu( VISU_SELECTION_INFO, aMenuId, 10 ); // selection info
2300
2301   aMenuId = createMenu( tr( "MEN_REPRESENTATION" ), -1, -1, 30 );
2302   int parentId =
2303     createMenu( tr( "MEN_DISPLAY_SELECTION" ), aMenuId, 10 ); // display selection
2304   createMenu( VISU_POINTS, parentId, 10 ); //   points
2305   createMenu( VISU_WIREFRAME, parentId, 10 ); //   wireframe
2306   createMenu( VISU_SURFACE, parentId, 10 ); //   surface
2307   createMenu( VISU_ERASE_ALL, aMenuId, 10 ); // erase all
2308   createMenu( VISU_GLOBAL_SELECTION, aMenuId, 10 ); // global selection
2309   createMenu( VISU_PARTIAL_SELECTION, aMenuId, 10 ); // partial selection
2310   createMenu( VISU_SCALING, aMenuId, 10 ); // scaling
2311   createMenu( VISU_CUBE_AXES, aMenuId, 10 ); // scaling
2312 }
2313
2314 void
2315 VisuGUI::
2316 createToolBars()
2317 {
2318   int aToolId = createTool(tr("TOOL_VISUALISATION"));
2319   createTool( VISU_SCALAR_MAP, aToolId );
2320   createTool( VISU_DEFORMED_SHAPE, aToolId );
2321   createTool( VISU_VECTORS, aToolId );
2322   createTool( VISU_ISO_SURFACES, aToolId );
2323   createTool( VISU_CUT_PLANES, aToolId );
2324   createTool( VISU_CUT_LINES, aToolId );
2325   createTool( VISU_STREAM_LINES, aToolId );
2326   createTool( VISU_PLOT_3D, aToolId );
2327
2328   aToolId = createTool(tr("TOOL_REPRESENTATION"));
2329   createTool( VISU_POINTS, aToolId );
2330   createTool( VISU_WIREFRAME, aToolId );
2331   createTool( VISU_SURFACE, aToolId );
2332   createTool( VISU_ERASE_ALL, aToolId );
2333   createTool( VISU_GLOBAL_SELECTION, aToolId );
2334   createTool( VISU_PARTIAL_SELECTION, aToolId );
2335   createTool( VISU_SCALING, aToolId );
2336   createTool( VISU_CUBE_AXES, aToolId );
2337 }
2338
2339 void
2340 VisuGUI::
2341 createPopupMenus()
2342 {
2343   // Prepare popup menus
2344   QtxPopupMgr* mgr = popupMgr();
2345
2346   // VISU root commands
2347   mgr->insert( action( VISU_IMPORT_FROM_FILE ), -1, -1, -1 ); // import MED file
2348   mgr->insert( action( VISU_IMPORT_TABLE ), -1, -1, -1 ); // import tables from file
2349   mgr->insert( action( VISU_PLOT2D ), -1, -1, -1 ); // create Plot2d View
2350
2351   //mgr->insert( action( VISU_IMPORT_MED ), -1, -1, -1 ); // import MED structure from MED module
2352
2353   // create
2354   mgr->insert( action( VISU_SCALAR_MAP ), -1, -1, -1 ); // scalar bar
2355   mgr->insert( action( VISU_ISO_SURFACES ), -1, -1, -1 ); // iso surface
2356   mgr->insert( action( VISU_CUT_PLANES ), -1, -1, -1 ); // cut planes
2357   mgr->insert( action( VISU_CUT_LINES ), -1, -1, -1 ); // cut lines
2358   mgr->insert( action( VISU_DEFORMED_SHAPE ), -1, -1, -1 ); // deformed shape
2359   mgr->insert( action( VISU_VECTORS ), -1, -1, -1 ); // vectors
2360   mgr->insert( action( VISU_STREAM_LINES ), -1, -1, -1 ); // stream lines
2361   mgr->insert( action( VISU_PLOT_3D ), -1, -1, -1 ); // Plot3d
2362
2363   mgr->insert( action( VISU_CREATE_PRS ), -1, -1, -1 ); // create presentation
2364   mgr->insert( action( VISU_CREATE_MANY_PRS ), -1, -1, -1 ); // create presentations
2365
2366   mgr->insert( action( VISU_CREATE_TABLE ), -1, -1, -1 ); // create table
2367
2368   // edit
2369   mgr->insert( action( VISU_EDIT_SCALARMAP ), -1, -1, -1 );
2370   mgr->insert( action( VISU_EDIT_DEFORMEDSHAPE ), -1, -1, -1 );
2371   mgr->insert( action( VISU_EDIT_CUTPLANES ), -1, -1, -1 );
2372   mgr->insert( action( VISU_EDIT_CUTLINES ), -1, -1, -1 );
2373   mgr->insert( action( VISU_EDIT_ISOSURFACE ), -1, -1, -1 );
2374   mgr->insert( action( VISU_EDIT_VECTORS ), -1, -1, -1 );
2375   mgr->insert( action( VISU_EDIT_STREAMLINES ), -1, -1, -1 );
2376   mgr->insert( action( VISU_EDIT_PLOT3D ), -1, -1, -1 );
2377   mgr->insert( action( VISU_EDIT_CONTAINER ), -1, -1, -1 );
2378
2379   // rename
2380   mgr->insert( action( VISU_RENAME ), -1, -1, -1 );
2381
2382   // copy
2383   mgr->insert( action( VISU_COPY_PRS ), -1, -1, -1 );
2384
2385   // delete
2386   mgr->insert( action( VISU_CLEAR_CONTAINER ), -1, -1, -1 );
2387
2388   // table commands
2389   //mgr->insert( action( VISU_SHOW_TABLE ), -1, -1, -1 ); // show table
2390   //mgr->insert( action( VISU_CREATE_CURVES ), -1, -1, -1 ); // create curves
2391   //mgr->insert( action( VISU_EXPORT_TABLE ), -1, -1, -1 ); // export table
2392
2393   mgr->insert( separator(), -1, -1, -1 );
2394
2395   mgr->insert( action( VISU_ERASE ), -1, -1, -1 ); // erase
2396   mgr->insert( action( VISU_DISPLAY ), -1, -1, -1 ); // display
2397   mgr->insert( action( VISU_DISPLAY_ONLY ), -1, -1, -1 ); // display only
2398
2399   // "Representation" submenu
2400   int parentId = mgr->insert( tr( "MEN_REPRESENTATION" ), -1, -1 );
2401   mgr->insert( action( VISU_POINTS )      , parentId, -1, -1 ); // points
2402   mgr->insert( action( VISU_WIREFRAME )   , parentId, -1, -1 ); // wireframe
2403   mgr->insert( action( VISU_SURFACE )     , parentId, -1, -1 ); // surface
2404   mgr->insert( action( VISU_INSIDEFRAME ) , parentId, -1, -1 ); // insideframe
2405   mgr->insert( action( VISU_SURFACEFRAME ), parentId, -1, -1 ); // surfaceframe
2406   mgr->insert( action( VISU_SHRINK )      , parentId, -1, -1 ); // shrink
2407   mgr->insert( action( VISU_UNSHRINK )    , parentId, -1, -1 ); // unshrink
2408   mgr->insert( separator(), parentId, -1, -1 );
2409   mgr->insert( action( VISU_SHADING )     , parentId, -1, -1 ); // shading
2410   mgr->insert( action( VISU_NOSHADING )   , parentId, -1, -1 ); // noshading
2411
2412   // "Properties" submenu
2413   parentId = mgr->insert( tr( "MEN_PROPERTIES" ), -1, -1 );
2414   mgr->insert( action( VISU_CELL_COLOR ), parentId, -1, -1 ); // cell color
2415   mgr->insert( action( VISU_EDGE_COLOR ), parentId, -1, -1 ); // edge color
2416   mgr->insert( action( VISU_COLOR )     , parentId, -1, -1 ); // color
2417   mgr->insert( action( VISU_OPACITY )   , parentId, -1, -1 ); // opacity
2418   mgr->insert( action( VISU_LINE_WIDTH ), parentId, -1, -1 ); // line width
2419
2420   mgr->insert( separator(), -1, -1, -1 );
2421
2422   // Other presentations management
2423   mgr->insert( action( VISU_TRANSLATE_PRS ), -1, -1, -1 );
2424   mgr->insert( action( VISU_CLIPPING ), -1, -1, -1 );
2425
2426   mgr->insert( action( VISU_MERGE_SCALAR_BARS ), -1, -1, -1 );
2427   mgr->insert( action( VISU_FREE_SCALAR_BARS ), -1, -1, -1 );
2428
2429   mgr->insert( action( VISU_SWEEP ), -1, -1, -1 );
2430   mgr->insert( action( VISU_ANIMATION ), -1, -1, -1 );
2431
2432   mgr->insert( separator(), -1, -1, -1 );
2433
2434   // view parameters commands
2435   mgr->insert( action( VISU_SAVE_VIEW_PARAMS ), -1, -1, -1 ); // save view params
2436   mgr->insert( action( VISU_SAVE_VIEW_PARAMS_1 ), -1, -1, -1 ); // save view params
2437   mgr->insert( action( VISU_RESTORE_VIEW_PARAMS ), -1, -1, -1 ); // restore view params
2438   //mgr->insert( action( VISU_DELETE_VIEW_PARAMS ), -1, -1, -1 ); // delete view params
2439
2440   mgr->insert( action( VISU_ARRANGE_ACTORS ), -1, -1, -1 ); // arrange actors
2441
2442   mgr->insert( action( VISU_CURVE_PROPS ), -1, -1, -1 ); // curve properties
2443
2444   mgr->insert( action( VISU_SELECTION_INFO ), -1, -1, -1 ); // Selection info
2445
2446   // Rules
2447
2448   QString aPrsAll ("'VISU::TSCALARMAP' 'VISU::TISOSURFACE' 'VISU::TDEFORMEDSHAPE' 'VISU::TCUTPLANES' "
2449                    "'VISU::TCUTLINES' 'VISU::TVECTORS' 'VISU::TSTREAMLINES' 'VISU::TPLOT3D'");
2450
2451   // VISU root commands
2452   QString aRule = "client='ObjectBrowser' and selcount=1 and type='VISU::TVISUGEN'";
2453   mgr->setRule( action( VISU_IMPORT_FROM_FILE ), aRule, true );
2454   mgr->setRule( action( VISU_IMPORT_TABLE ), aRule, true );
2455   mgr->setRule( action( VISU_PLOT2D ), aRule, true );
2456
2457   // timestamp commands
2458   aRule = "client='ObjectBrowser' and selcount=1 and type='VISU::TTIMESTAMP'";
2459   mgr->setRule( action( VISU_SCALAR_MAP ), aRule, true );
2460   mgr->setRule( action( VISU_ISO_SURFACES ), aRule, true );
2461   mgr->setRule( action( VISU_CUT_PLANES ), aRule, true );
2462   mgr->setRule( action( VISU_CUT_LINES ), aRule, true );
2463   mgr->setRule( action( VISU_PLOT_3D ), aRule, true );
2464   aRule += " and nbComponents>1";
2465   mgr->setRule( action( VISU_DEFORMED_SHAPE ), aRule, true );
2466   mgr->setRule( action( VISU_VECTORS ), aRule, true );
2467   mgr->setRule( action( VISU_STREAM_LINES ), aRule, true );
2468
2469   // display/erase commands
2470   QString andInvisible = " and (((not isVisible) and isActiveView) or (not isActiveView))";
2471   QString aTableOrCont = "(type='VISU::TTABLE' and nbChildren>0) or type='VISU::TCONTAINER'";
2472   QString orCurveVisible   = "or (type='VISU::TCURVE' and isVisible)";
2473   QString orCurveInvisible = "or (type='VISU::TCURVE'" + andInvisible + ")";
2474   QString aPrsVisible   = "(($type in {'VISU::TMESH' " + aPrsAll + "}) and isVisible)";
2475   QString aPrsInvisible = "(($type in {'VISU::TMESH' " + aPrsAll + "})" + andInvisible + ")";
2476
2477   QString anEraseRule = "selcount>0 and (" + aPrsVisible +
2478     " or (client='ObjectBrowser' and (" + aTableOrCont + orCurveVisible + ")))";
2479
2480   QString aDisplayRule = "selcount>0 and (" + aPrsInvisible +
2481     " or (client='ObjectBrowser' and (" + aTableOrCont + orCurveInvisible + ")))";
2482
2483   QString aDOnlyRule = "selcount>0 and (($type in {'VISU::TMESH' " + aPrsAll + "})"
2484     " or (client='ObjectBrowser' and ((type='VISU::TTABLE' and nbChildren>0) or"
2485     " ($type in {'VISU::TCURVE' 'VISU::TCONTAINER'}))))";
2486
2487   mgr->setRule( action( VISU_ERASE ), anEraseRule, true );
2488   mgr->setRule( action( VISU_DISPLAY ), aDisplayRule, true );
2489   mgr->setRule( action( VISU_DISPLAY_ONLY ), aDOnlyRule, true );
2490
2491   aRule = "selcount>0 and $type in {'VISU::TMESH' " + aPrsAll + "}";
2492   mgr->setRule( action( VISU_TRANSLATE_PRS ), aRule, true );
2493
2494   aRule = "selcount>1 and $type in {'VISU::TMESH' " + aPrsAll + "}";
2495   mgr->setRule( action( VISU_MERGE_SCALAR_BARS ), aRule, true );
2496   mgr->setRule( action( VISU_FREE_SCALAR_BARS ), aRule, true );
2497
2498   // view parameters
2499   aRule = "selcount=1 and type='VISU::TVIEW3D'";
2500   mgr->setRule( action( VISU_SAVE_VIEW_PARAMS_1 ), aRule, true );
2501   mgr->setRule( action( VISU_SAVE_VIEW_PARAMS ), "client='VTKViewer' and selcount=0", true );
2502   mgr->setRule( action( VISU_RESTORE_VIEW_PARAMS ), "selcount=1 and type='VISU::TVIEW3D'", true );
2503   //mgr->setRule( action( VISU_DELETE_VIEW_PARAMS ), "selcount=1 and type='VISU::TVIEW3D'", true );
2504
2505   mgr->setRule( action( VISU_ARRANGE_ACTORS ), "client='VTKViewer' and selcount=0", true );
2506
2507   // 3D presentations commands
2508   QString aPrsType    = " and $type in {'VISU::TMESH' " + aPrsAll + "}";
2509   QString aInsideType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TDEFORMEDSHAPE'}";
2510   QString aSurfType   = " and $type in {'VISU::TMESH'}";
2511   QString aShrinkType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TISOSURFACE' "
2512                         "'VISU::TDEFORMEDSHAPE' 'VISU::TCUTPLANES' 'VISU::TCUTLINES' 'VISU::TPLOT3D'}";
2513   QString aLineType   = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TISOSURFACE' 'VISU::TDEFORMEDSHAPE' "
2514                         "'VISU::TCUTPLANES' 'VISU::TCUTLINES' 'VISU::TSTREAMLINES' 'VISU::TPLOT3D'}";
2515
2516   aRule = "selcount=1";
2517   mgr->setRule( action( VISU_CLIPPING ), aRule + aPrsType, true );
2518
2519   // "Representation" submenu
2520   QString aNotPoints = " and $representation in {'VISU::WIREFRAME' 'VISU::SHADED' 'VISU::INSIDEFRAME' 'VISU::SURFACEFRAME'}";
2521   QString aNotWirefr = " and $representation in {'VISU::POINT' 'VISU::SHADED' 'VISU::INSIDEFRAME' 'VISU::SURFACEFRAME'}";
2522   QString aNotSurfac = " and $representation in {'VISU::POINT' 'VISU::WIREFRAME' 'VISU::INSIDEFRAME' 'VISU::SURFACEFRAME'}";
2523   QString aNotInside = " and $representation in {'VISU::POINT' 'VISU::WIREFRAME' 'VISU::SHADED' 'VISU::SURFACEFRAME'}";
2524   QString aNotSurffr = " and $representation in {'VISU::POINT' 'VISU::WIREFRAME' 'VISU::SHADED' 'VISU::INSIDEFRAME'}";
2525
2526   mgr->setRule( action( VISU_POINTS )      , aRule + aPrsType + aNotPoints, true );
2527   mgr->setRule( action( VISU_WIREFRAME )   , aRule + aPrsType + aNotWirefr, true );
2528   mgr->setRule( action( VISU_SURFACE )     , aRule + aPrsType + aNotSurfac, true );
2529   mgr->setRule( action( VISU_INSIDEFRAME ) , aRule + aInsideType + aNotInside, true );
2530   mgr->setRule( action( VISU_SURFACEFRAME ), aRule + aSurfType + aNotSurffr, true );
2531
2532   mgr->setRule( action( VISU_SHRINK )  , aRule + aShrinkType + " and isShrunk=0", true );
2533   mgr->setRule( action( VISU_UNSHRINK ), aRule + aShrinkType + " and isShrunk=1", true );
2534
2535   mgr->setRule( action( VISU_SHADING )  , aRule + " and isScalarMapAct=1 and isShading=0", true );
2536   mgr->setRule( action( VISU_NOSHADING ), aRule + " and isScalarMapAct=1 and isShading=1", true );
2537
2538   // "Properties" submenu
2539   mgr->setRule( action( VISU_CELL_COLOR ), aRule + " and type='VISU::TMESH' and representation='VISU::SURFACEFRAME'", true );
2540   mgr->setRule( action( VISU_EDGE_COLOR ), aRule + " and type='VISU::TMESH' and representation='VISU::SURFACEFRAME'", true );
2541   mgr->setRule( action( VISU_COLOR ), aRule + " and ((type='VISU::TMESH'"
2542                " and $representation in {'VISU::POINT' 'VISU::WIREFRAME' 'VISU::SHADED' 'VISU::INSIDEFRAME'}) "
2543                "or (type='VISU::TDEFORMEDSHAPE' and hasActor=1))", true );
2544   mgr->setRule( action( VISU_OPACITY ), aRule + aShrinkType + " and hasActor=1", true );
2545   mgr->setRule( action( VISU_LINE_WIDTH ), aRule + aLineType + " and hasActor=1", true );
2546
2547   // rename command
2548   QString aCurveAll = "'VISU::TTABLE' 'VISU::TCURVE' 'VISU::TCONTAINER'";
2549
2550   aRule = "selcount=1 and ($type in {'VISU::TVIEW3D' 'VISU::TMESH' " + aCurveAll + " " + aPrsAll + "})";
2551   mgr->setRule( action( VISU_RENAME ), aRule, true );
2552
2553   // copy presentation command
2554   aRule = "selcount=1 and ($type in {" + aPrsAll + "})";
2555   mgr->setRule( action( VISU_COPY_PRS ), aRule, true );
2556
2557   // curve commands
2558   aRule = "selcount=1 and type='VISU::TCURVE'";
2559   mgr->setRule( action( VISU_CURVE_PROPS ), aRule, true );
2560
2561   // curve container commands
2562   aRule = "client='ObjectBrowser' and selcount=1 and type='VISU::TCONTAINER'";
2563   mgr->setRule( action( VISU_EDIT_CONTAINER ), aRule, true );
2564   mgr->setRule( action( VISU_CLEAR_CONTAINER ), aRule, true );
2565
2566   mgr->setRule( action( VISU_EDIT_SCALARMAP ),
2567                 "selcount=1 and type='VISU::TSCALARMAP'", true );
2568   mgr->setRule( action( VISU_EDIT_DEFORMEDSHAPE ),
2569                 "selcount=1 and type='VISU::TDEFORMEDSHAPE'", true );
2570   mgr->setRule( action( VISU_EDIT_CUTPLANES ),
2571                 "selcount=1 and type='VISU::TCUTPLANES'", true );
2572   mgr->setRule( action( VISU_EDIT_CUTLINES ),
2573                 "selcount=1 and type='VISU::TCUTLINES'", true );
2574   mgr->setRule( action( VISU_EDIT_ISOSURFACE ),
2575                 "selcount=1 and type='VISU::TISOSURFACE'", true );
2576   mgr->setRule( action( VISU_EDIT_VECTORS ),
2577                 "selcount=1 and type='VISU::TVECTORS'", true );
2578   mgr->setRule( action( VISU_EDIT_STREAMLINES ),
2579                 "selcount=1 and type='VISU::TSTREAMLINES'", true );
2580   mgr->setRule( action( VISU_EDIT_PLOT3D ),
2581                 "selcount=1 and type='VISU::TPLOT3D'", true );
2582
2583   aRule = "selcount=1 and type='VISU::TCUTLINES' and nbNamedChildren=0";
2584   mgr->setRule( action( VISU_CREATE_TABLE ), aRule, true );
2585
2586   aRule = "selcount=1 and ($type in {" + aPrsAll + "})";
2587   mgr->setRule( action( VISU_SWEEP ), aRule, true );
2588
2589   // "Selection info" popup item
2590   aRule = "client='VTKViewer' and selcount=1" + aInsideType;
2591   mgr->setRule( action( VISU_SELECTION_INFO ), aRule, true );
2592
2593   aRule = "client='ObjectBrowser' and selcount>0 and $type in {'VISU::TFIELD'} and nbTimeStamps>1";
2594   mgr->setRule( action( VISU_ANIMATION ), aRule, true );
2595
2596   aRule = "client='ObjectBrowser' and $type in {'VISU::TENTITY' 'VISU::TFAMILY' 'VISU::TGROUP'}";
2597   mgr->setRule( action( VISU_CREATE_PRS ), aRule + " and selcount=1", true );
2598   mgr->setRule( action( VISU_CREATE_MANY_PRS ), aRule + " and selcount>1", true );
2599
2600   //aRule = "client='ObjectBrowser' and type='MEDFIELD'";
2601   //mgr->setRule( action( VISU_IMPORT_MED ), aRule, true );
2602 }
2603
2604 //***************************************************************************
2605 void VisuGUI::contextMenuPopup( const QString& theClient, QPopupMenu* theMenu, QString& theTitle )
2606 {
2607   SalomeApp_Module::contextMenuPopup(theClient, theMenu, theTitle);
2608
2609   OB_Browser* ob = getApp()->objectBrowser();
2610   bool isOBClient = (ob && theClient == ob->popupClientType());
2611
2612   LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
2613   SALOME_ListIO aListIO;
2614   aSelectionMgr->selectedObjects(aListIO);
2615
2616   if (aListIO.Extent() < 1) return;
2617
2618   _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
2619
2620   // Check if "Merge Scalar Range" can be applied
2621   int nbPrs = 0;
2622   SALOME_ListIteratorOfListIO It (aListIO);
2623   for (; It.More(); It.Next()) {
2624     Handle(SALOME_InteractiveObject)& anIO = It.Value();
2625
2626     if (!anIO.IsNull() && anIO->hasEntry()) {
2627       _PTR(SObject) aSObject = aCStudy->FindObjectID(anIO->getEntry());
2628       CORBA::Object_var aCORBAObject = VISU::ClientSObjectToObject(aSObject);
2629       if (CORBA::is_nil(aCORBAObject)) {
2630         _PTR(GenericAttribute) anAttr;
2631         if (aSObject->FindAttribute(anAttr, "AttributeComment")) {
2632           _PTR(AttributeComment) aComment (anAttr);
2633           string aComm = aComment->Value();
2634           QString strIn (aComm.c_str());
2635           VISU::Storable::TRestoringMap pMap;
2636           VISU::Storable::StrToMap(strIn, pMap);
2637           bool isExist;
2638           VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(pMap,"myType",&isExist).toInt();
2639           if (isExist && aType == VISU::TTIMESTAMP) {
2640             _PTR(ChildIterator) anIter = aCStudy->NewChildIterator(aSObject);
2641             _PTR(SObject) aPrs;
2642             for (; anIter->More(); anIter->Next()) {
2643               aPrs = anIter->Value();
2644               if (!aPrs) continue;
2645               std::vector<VISU::Prs3d_i*> aSubList = GetPrs3dList(this, aPrs);
2646               nbPrs += aSubList.size();
2647             }
2648           }
2649         }
2650       }
2651     }
2652   }
2653
2654   if (nbPrs > 1) {
2655     theMenu->insertSeparator();
2656     action( VISU_MERGE_SCALAR_BARS )->addTo(theMenu);
2657     action( VISU_FREE_SCALAR_BARS  )->addTo(theMenu);
2658   }
2659
2660   theMenu->insertSeparator();
2661
2662   // Check if some (nb > 0) removable objects selected
2663   if (isOBClient && IsRemovableSelected(this)) {
2664     action( VISU_DELETE_OBJS )->addTo(theMenu);
2665   }
2666
2667   // Check if some curves selected (for bug PAL10611)
2668   bool isCurves = false;
2669   SALOME_ListIteratorOfListIO It1 (aListIO);
2670   for (; It1.More() && !isCurves; It1.Next()) {
2671     Handle(SALOME_InteractiveObject)& anIO = It1.Value();
2672
2673     if (!anIO.IsNull() && anIO->hasEntry()) {
2674       _PTR(SObject) aSObject = aCStudy->FindObjectID(anIO->getEntry());
2675       _PTR(GenericAttribute) anAttr;
2676       if (aSObject->FindAttribute(anAttr, "AttributeComment")) {
2677         _PTR(AttributeComment) aComment (anAttr);
2678         string aComm = aComment->Value();
2679         QString strIn (aComm.c_str());
2680         VISU::Storable::TRestoringMap pMap;
2681         VISU::Storable::StrToMap(strIn, pMap);
2682         bool isExist;
2683         VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(pMap,"myType",&isExist).toInt();
2684         if (isExist && aType == VISU::TCURVE) {
2685           isCurves = true;
2686         }
2687       }
2688     }
2689   }
2690   if (isCurves) {
2691     action( myDisplay     )->removeFrom(theMenu);
2692     action( myErase       )->removeFrom(theMenu);
2693     action( myDisplayOnly )->removeFrom(theMenu);
2694     action( myEraseAll    )->removeFrom(theMenu);
2695   }
2696
2697   // Check single selection
2698   if (aListIO.Extent() != 1) return;
2699
2700   Handle(SALOME_InteractiveObject) anIO;
2701   VISU::Storable::TRestoringMap aMap;
2702   CORBA::Object_var anObject = GetSelectedObj( this, &anIO, &aMap);
2703
2704   _PTR(SObject) SO = aCStudy->FindObjectID(anIO->getEntry());
2705   bool isExist;
2706   VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt();
2707
2708   if (aType == VISU::TANIMATION) {
2709     action( VISU_SHOW_ANIMATION )->addTo(theMenu);
2710
2711   } else if (isOBClient) {
2712     if (IsSObjectTable(SO)) {
2713       action( VISU_SHOW_TABLE )->addTo(theMenu);
2714       action( VISU_CREATE_CURVES )->addTo(theMenu);
2715       action( VISU_EXPORT_TABLE )->addTo(theMenu);
2716       theMenu->insertSeparator();
2717     } else {
2718       if (!CORBA::is_nil(anObject)) {
2719         SALOME_MED::MED_var aMED = SALOME_MED::MED::_narrow(anObject);
2720         if (!CORBA::is_nil(aMED.in())) {
2721           action( VISU_IMPORT_MED_STRUCTURE )->addTo(theMenu);
2722         }
2723
2724         SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow(anObject); // "Import Structure"
2725         if (!CORBA::is_nil(aField)) {
2726           action( VISU_IMPORT_MED_TIMESTAMP )->addTo(theMenu); // "Import TimeStamp"
2727         }
2728       } else {
2729         _PTR(SObject) aSFather = SO->GetFather();
2730         if (aSFather) {
2731           _PTR(GenericAttribute) anAttr;
2732           aSFather->FindAttribute(anAttr, "AttributeName");
2733           if (anAttr) {
2734             _PTR(AttributeName) aName (anAttr);
2735             std::string aValue = aName->Value();
2736             if (strcmp(aValue.c_str(), "MEDFIELD") == 0) {
2737               action( VISU_IMPORT_MED_FIELD )->addTo(theMenu); // "Import Field"
2738             }
2739           }
2740         }
2741       }
2742     }
2743   }
2744 }
2745
2746
2747 //***************************************************************************
2748 void
2749 VisuGUI::
2750 windows( QMap<int, int>& theMap ) const
2751 {
2752   theMap.clear();
2753   theMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
2754   theMap.insert( SalomeApp_Application::WT_PyConsole, Qt::DockBottom );
2755 }
2756
2757
2758 void
2759 VisuGUI::
2760 viewManagers( QStringList& theList ) const
2761 {
2762   theList.clear();
2763   theList.append( SVTK_Viewer::Type() );
2764 }
2765
2766
2767 QString
2768 VisuGUI::
2769 engineIOR() const
2770 {
2771   CORBA::String_var anIOR = GetVisuGen(this)->GetID();
2772   return QString(anIOR.in());
2773 }
2774
2775
2776 bool
2777 VisuGUI::
2778 activateModule( SUIT_Study* theStudy )
2779 {
2780   SalomeApp_Module::activateModule( theStudy );
2781   studyActivated();
2782   setMenuShown( true );
2783   setToolShown( true );
2784   return true;
2785 }
2786
2787
2788 bool
2789 VisuGUI::
2790 deactivateModule( SUIT_Study* theStudy )
2791 {
2792   setMenuShown( false );
2793   setToolShown( false );
2794
2795   SalomeApp_Module::deactivateModule( theStudy );
2796   return true;
2797 }
2798
2799 LightApp_Selection*
2800 VisuGUI::
2801 createSelection() const
2802 {
2803   return new VisuGUI_Selection( (SalomeApp_Module*)this );
2804 }
2805
2806 //******************************************************************
2807 void VisuGUI::studyActivated()
2808 {
2809   GetVisuGen(this)->SetCurrentStudy(GetDSStudy(GetCStudy(GetAppStudy(this))));
2810 }
2811
2812 /*
2813 extern "C" {
2814   CAM_Module*
2815   createModule()
2816   {
2817     return new VisuGUI();
2818   }
2819 }
2820 */
2821 void VisuGUI::createPreferences()
2822 {
2823   int sbarTab = addPreference( tr( "VISU_SCALAR_BAR" ) );
2824
2825   int fontGr = addPreference( tr( "VISU_FONT" ), sbarTab );
2826   int tfont = addPreference( tr( "VISU_TITLE" ), fontGr, LightApp_Preferences::Font, "VISU", "scalar_bar_title_font" );
2827   addPreference( tr( "VISU_TITLE" ), fontGr, LightApp_Preferences::Color, "VISU", "scalar_bar_title_color" );
2828   int lfont = addPreference( tr( "VISU_LABELS" ), fontGr, LightApp_Preferences::Font, "VISU", "scalar_bar_label_font" );
2829   addPreference( tr( "VISU_LABELS" ), fontGr, LightApp_Preferences::Color, "VISU", "scalar_bar_label_color" );
2830
2831   QStringList fam;
2832   fam.append( tr( "VISU_FONT_ARIAL" ) );
2833   fam.append( tr( "VISU_FONT_COURIER" ) );
2834   fam.append( tr( "VISU_FONT_TIMES" ) );
2835   int wflag = ( QtxListResourceEdit::FontItem::All & ( ~( QtxListResourceEdit::FontItem::Size | QtxListResourceEdit::FontItem::UserSize ) ) );
2836
2837   setPreferenceProperty( tfont, "families", fam );
2838   setPreferenceProperty( tfont, "system", false );
2839   setPreferenceProperty( tfont, "widget_flags", wflag );
2840   setPreferenceProperty( lfont, "families", fam );
2841   setPreferenceProperty( lfont, "system", false );
2842   setPreferenceProperty( lfont, "widget_flags", wflag );
2843
2844   int colorsLabelsGr = addPreference( tr( "VISU_COLORS_AND_LABELS" ), sbarTab );
2845
2846   int numcol = addPreference( tr( "VISU_NB_COLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "VISU", "scalar_bar_num_colors" );
2847   setPreferenceProperty( numcol, "min", 2 );
2848   setPreferenceProperty( numcol, "max", 64 );
2849
2850   int numlab = addPreference( tr( "VISU_NB_LABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "VISU", "scalar_bar_num_labels" );
2851   setPreferenceProperty( numlab, "min", 2 );
2852   setPreferenceProperty( numlab, "max", 65 );
2853
2854   int orientGr = addPreference( tr( "VISU_ORIENTATION" ), sbarTab );
2855   int orient = addPreference( tr( "VISU_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "VISU", "scalar_bar_orientation" );
2856   QStringList orients;
2857   orients.append( tr( "VISU_VERTICAL" ) );
2858   orients.append( tr( "VISU_HORIZONTAL" ) );
2859   QValueList<QVariant> indices;
2860   indices.append( 0 );
2861   indices.append( 1 );
2862   setPreferenceProperty( orient, "strings", orients );
2863   setPreferenceProperty( orient, "indexes", indices );
2864
2865   int posVSizeGr = addPreference( tr( "VISU_ORIGIN_AND_SIZE" ) + " " + tr( "VISU_VERTICAL" ), sbarTab );
2866   int xv = addPreference( tr( "VISU_X" ), posVSizeGr, LightApp_Preferences::DblSpin, "VISU", "scalar_bar_vertical_x" );
2867   int yv = addPreference( tr( "VISU_Y" ), posVSizeGr, LightApp_Preferences::DblSpin, "VISU", "scalar_bar_vertical_y" );
2868   int wv = addPreference( tr( "VISU_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "VISU", "scalar_bar_vertical_width" );
2869   int hv = addPreference( tr( "VISU_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "VISU", "scalar_bar_vertical_height" );
2870   setPreferenceProperty( xv, "step", 0.1 );
2871   setPreferenceProperty( yv, "step", 0.1 );
2872   setPreferenceProperty( wv, "step", 0.1 );
2873   setPreferenceProperty( hv, "step", 0.1 );
2874   setPreferenceProperty( xv, "min", 0.0 );
2875   setPreferenceProperty( yv, "min", 0.0 );
2876   setPreferenceProperty( wv, "min", 0.0 );
2877   setPreferenceProperty( hv, "min", 0.0 );
2878   setPreferenceProperty( xv, "max", 1.0 );
2879   setPreferenceProperty( yv, "max", 1.0 );
2880   setPreferenceProperty( wv, "max", 1.0 );
2881   setPreferenceProperty( hv, "max", 1.0 );
2882
2883   int posHSizeGr = addPreference( tr( "VISU_ORIGIN_AND_SIZE" ) + " " + tr( "VISU_HORIZONTAL" ), sbarTab );
2884   int xh = addPreference( tr( "VISU_X" ), posHSizeGr, LightApp_Preferences::DblSpin, "VISU", "scalar_bar_horizontal_x" );
2885   int yh = addPreference( tr( "VISU_Y" ), posHSizeGr, LightApp_Preferences::DblSpin, "VISU", "scalar_bar_horizontal_y" );
2886   int wh = addPreference( tr( "VISU_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "VISU", "scalar_bar_horizontal_width" );
2887   int hh = addPreference( tr( "VISU_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "VISU", "scalar_bar_horizontal_height" );
2888   setPreferenceProperty( xh, "step", 0.1 );
2889   setPreferenceProperty( yh, "step", 0.1 );
2890   setPreferenceProperty( wh, "step", 0.1 );
2891   setPreferenceProperty( hh, "step", 0.1 );
2892   setPreferenceProperty( xh, "min", 0.0 );
2893   setPreferenceProperty( yh, "min", 0.0 );
2894   setPreferenceProperty( wh, "min", 0.0 );
2895   setPreferenceProperty( hh, "min", 0.0 );
2896   setPreferenceProperty( xh, "max", 1.0 );
2897   setPreferenceProperty( yh, "max", 1.0 );
2898   setPreferenceProperty( wh, "max", 1.0 );
2899   setPreferenceProperty( hh, "max", 1.0 );
2900
2901   int srangeTab = addPreference( tr( "Scalar range, Sweep, MED import" ) );
2902
2903   int rangeGr = addPreference( tr( "VISU_SCALAR_RANGE" ), srangeTab );
2904   setPreferenceProperty( rangeGr, "columns", 1 );
2905
2906   int mode = addPreference( tr( "VISU_SCALAR_MODE" ), rangeGr, LightApp_Preferences::Selector, "VISU", "scalar_bar_mode" );
2907   QStringList modes;
2908   modes.append( tr( "VISU_MODULUS" ) );
2909   modes.append( tr( "VISU_COMPONENT" ) + tr("1") );
2910   modes.append( tr( "VISU_COMPONENT" ) + tr("2") );
2911   modes.append( tr( "VISU_COMPONENT" ) + tr("3") );
2912   indices.clear();
2913   indices.append( 0 );
2914   indices.append( 1 );
2915   indices.append( 2 );
2916   indices.append( 3 );
2917   setPreferenceProperty( mode, "strings", modes );
2918   setPreferenceProperty( mode, "indexes", indices );
2919
2920   addPreference( tr( "VISU_LOGARITHMIC_SCALING" ), rangeGr, LightApp_Preferences::Bool, "VISU", "scalar_bar_logarithmic" );
2921
2922   int rangetype = addPreference( tr( "VISU_RANGE_TO_USE" ), rangeGr, LightApp_Preferences::Selector, "VISU", "scalar_range_type" );
2923   QStringList types;
2924   types.append( tr( "VISU_FIELD_RANGE" ) );
2925   types.append( tr( "VISU_IMPOSED_RANGE" ) );
2926   indices.clear();
2927   indices.append( 0 );
2928   indices.append( 1 );
2929   setPreferenceProperty( rangetype, "strings", types );
2930   setPreferenceProperty( rangetype, "indexes", indices );
2931
2932   int imposedGr = addPreference( tr( "VISU_MINMAX_IMPOSED_RANGE" ), srangeTab );
2933
2934   int min = addPreference( tr( "VISU_MIN" ), imposedGr, LightApp_Preferences::DblSpin, "VISU", "scalar_range_min" );
2935   int max = addPreference( tr( "VISU_MAX" ), imposedGr, LightApp_Preferences::DblSpin, "VISU", "scalar_range_max" );
2936   setPreferenceProperty( min, "step", 0.1 );
2937   setPreferenceProperty( max, "step", 0.1 );
2938
2939   int sweepGr = addPreference( tr( "VISU_SWEEPING_PREF" ), srangeTab );
2940   setPreferenceProperty( sweepGr, "columns", 1 );
2941
2942   int timestep   = addPreference( tr( "VISU_TIME_STEP" ), sweepGr, LightApp_Preferences::DblSpin, "VISU", "sweeping_time_step" );
2943   int nbcycles   = addPreference( tr( "VISU_NB_CYCLES" ), sweepGr, LightApp_Preferences::IntSpin, "VISU", "sweeping_number_cycles" );
2944   int nbsteps    = addPreference( tr( "VISU_NB_STEPS" ),  sweepGr, LightApp_Preferences::IntSpin, "VISU", "sweeping_number_steps" );
2945   setPreferenceProperty( timestep, "min",  0.1 );
2946   setPreferenceProperty( timestep, "step", 0.1 );
2947   setPreferenceProperty( timestep, "max",  1000 );
2948   setPreferenceProperty( nbcycles, "max",  100  );
2949   setPreferenceProperty( nbsteps,  "max",  200  );
2950
2951   int importGr = addPreference( tr( "MED files import" ), srangeTab );
2952   addPreference( tr( "Full MED loading" ), importGr, LightApp_Preferences::Bool, "VISU", "full_med_loading" );
2953 }
2954
2955 void VisuGUI::preferencesChanged( const QString&, const QString& )
2956 {
2957 }
2958
2959 SUIT_ViewManager*
2960 VisuGUI
2961 ::getViewManager(const QString& theType,
2962                  const bool theIsCreate)
2963 {
2964   return getApp()->getViewManager(theType,theIsCreate);
2965 }
2966
2967 LightApp_Displayer* VisuGUI::displayer()
2968 {
2969   if( !myDisplayer )
2970     myDisplayer = new VisuGUI_Displayer( getApp() );
2971     
2972   return myDisplayer;
2973 }