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