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