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