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