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