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