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