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