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