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