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