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