Salome HOME
eb81af8ac08ee601a6babe536dcaf8384cad09bc
[modules/visu.git] / src / VISUGUI / VisuGUI.cxx
1 //  VISU VISUGUI : GUI of VISU component
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
6 //  This library is free software; you can redistribute it and/or 
7 //  modify it under the terms of the GNU Lesser General Public 
8 //  License as published by the Free Software Foundation; either 
9 //  version 2.1 of the License. 
10 // 
11 //  This library is distributed in the hope that it will be useful, 
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of 
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
14 //  Lesser General Public License for more details. 
15 // 
16 //  You should have received a copy of the GNU Lesser General Public 
17 //  License along with this library; if not, write to the Free Software 
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
19 // 
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : VisuGUI.cxx
25 //  Author : Laurent CORNABE
26 //  Module : VISU
27 //  $Header$
28
29 #include "VisuGUI.h"
30
31 #include "VISU_Gen_i.hh"
32 #include "VISU_Result_i.hh"
33 #include "VISU_PrsObject_i.hh"
34 #include "VISU_ViewManager_i.hh"
35
36 #include "VISU_PipeLine.hxx"
37
38 #include "VISU_Prs3d_i.hh"
39 #include "VISU_Mesh_i.hh"
40 #include "VISU_ScalarMap_i.hh"
41 #include "VISU_IsoSurfaces_i.hh"
42 #include "VISU_DeformedShape_i.hh"
43 #include "VISU_CutPlanes_i.hh"
44 #include "VISU_CutLines_i.hh"
45 #include "VISU_Vectors_i.hh"
46 #include "VISU_StreamLines_i.hh"
47 #include "VISU_Table_i.hh"
48
49 #include "VISU_Actor.h"
50 #include "VISU_MeshAct.h"
51
52 #include "VisuGUI_MagnitudeDlg.h"
53 #include "VisuGUI_CursorDlg.h"
54 #include "VisuGUI_ScalarBarDlg.h"
55 #include "VisuGUI_SweepPrefDlg.h"
56 #include "VisuGUI_CutPlanesDlg.h"
57 #include "VisuGUI_CutLinesDlg.h"
58 #include "VisuGUI_VectorsDlg.h"
59 #include "VisuGUI_IsoSurfacesDlg.h"
60 #include "VisuGUI_StreamLinesDlg.h"
61 #include "VisuGUI_EditContainerDlg.h"
62 #include "VisuGUI_TimeAnimation.h"
63
64 #include "VisuGUI_Selection.h"
65 #include "VisuGUI_NonIsometricDlg.h"
66
67 #include "SALOMEGUI_ImportOperation.h"
68 #include "SALOMEGUI_QtCatchCorbaException.hxx"
69 #include "utilities.h"
70
71 #include "QAD_Config.h"
72
73 #include "QAD_Settings.h"
74 #include "QAD_Tools.h"
75 #include "QAD_LeftFrame.h"
76 #include "QAD_RightFrame.h"
77 #include "QAD_MessageBox.h"
78 #include "QAD_ObjectBrowser.h"
79 #include "QAD_ObjectBrowserItem.h"
80 #include "QAD_Menus.h"
81 #include "QAD_Resource.h"
82 #include "QAD_ResourceMgr.h"
83 #include "QAD_FileDlg.h"
84 #include "QAD_WaitCursor.h"
85 #include "SALOME_Selection.h"
86 #include "SALOMEGUI_NameDlg.h"
87 #include "SALOMEGUI_TableDlg.h"
88 #include "SALOMEGUI_SetupCurveDlg.h"
89 #include "SALOMEGUI_SetValueDlg.h"
90 #include "SALOMEGUI_Desktop.h"
91 #include "Plot2d_SetupPlot2dDlg.h"
92 #include "Plot2d_ViewFrame.h"
93 #include "VTKViewer_ViewFrame.h"
94 #include "VTKViewer_RenderWindow.h"
95 #include "VTKViewer_InteractorStyleSALOME.h"
96 #include "VTKViewer_RenderWindowInteractor.h"
97 #include "VisuGUI_FileDlg.h"
98
99 // QT Includes
100 #define  INCLUDE_MENUITEM_DEF
101 #include <qpopupmenu.h>
102 #include <qfont.h>
103 #include <qpainter.h>
104 #include <qstring.h>
105 #include <qapplication.h>
106 #include <qinputdialog.h>  
107 #include <qcolordialog.h>
108 #include <qlabel.h>
109 #include <qspinbox.h>
110 #include <qradiobutton.h>
111 #include <qthread.h>
112 #include <qlistbox.h>
113 #include <qcombobox.h>
114 #include <qregexp.h> 
115
116 //VRV: porting on Qt 3.0.5
117 #if QT_VERSION >= 0x030005
118 #include <qlistview.h>
119 #endif
120 //VRV: porting on Qt 3.0.5
121 #include <qmessagebox.h>
122
123 #include <med.h>
124 #include CORBA_CLIENT_HEADER(MED_Gen)
125
126 #include <vtkActor.h>
127 #include <vtkRenderer.h>
128 #include <vtkDataSetMapper.h>
129 #include <vtkActorCollection.h>
130
131 // Open CASCADE Include
132 #include <TCollection_AsciiString.hxx>
133
134 //#define CHECKTIME 
135 #ifdef CHECKTIME
136 static int MYCHECKTIME = 1;
137 #else
138 static int MYCHECKTIME = 0;
139 #endif
140 #include <Utils_Timer.hxx>
141
142 using namespace std;
143
144 #ifdef _DEBUG_
145 static int MYDEBUG = 0;
146 static int MYDEBUGWITHFILES = 0;
147 #else
148 static int MYDEBUG = 0;
149 static int MYDEBUGWITHFILES = 0;
150 #endif
151
152 class CustomItem : public QCustomMenuItem{
153 public:
154   CustomItem( const QString& s, const QFont& f )
155     : string( s ), font( f ){};
156   ~CustomItem(){}
157   
158   void paint( QPainter* p, const QColorGroup& /*cg*/, bool /*act*/, bool /*enabled*/, int x, int y, int w, int h )
159   {
160     p->setFont ( font );
161     p->drawText( x, y, w, h, AlignHCenter | AlignVCenter | ShowPrefix | DontClip, string );
162   }
163   
164   QSize sizeHint()
165   {
166     return QFontMetrics( font ).size( AlignHCenter | AlignVCenter | ShowPrefix | DontClip,  string );
167   }
168 private:
169   QString string;
170   QFont font;
171 };
172
173
174 inline bool IsSObjectTable(SALOMEDS::SObject_ptr theSObject){
175   if(!theSObject->_is_nil()) {
176     SALOMEDS::GenericAttribute_var anAttr;
177     if(theSObject->FindAttribute( anAttr, "AttributeTableOfInteger" ))
178       return true;
179     if(theSObject->FindAttribute( anAttr, "AttributeTableOfReal" ))
180       return true;
181   }  
182   return false;
183 }
184
185
186 static VisuGUI MYVISUGUI;
187 VisuGUI *visuGUI = &MYVISUGUI;
188
189 VISU::VISU_Gen_i* VisuGUI::GetVisuGen(){
190   VISU::VISU_Gen_i::GetVisuGenImpl()->SetCurrentStudy(GetStudyDocument());
191   return VISU::VISU_Gen_i::GetVisuGenImpl();
192 }
193
194 static int ComputeVisiblePropBounds(VTKViewer_ViewFrame* theViewFrame, float allBounds[6], 
195                                     const char* theActorClassName = "VISU_Actor")
196 {
197   vtkRenderer *aRen = theViewFrame->getRenderer();
198   vtkActorCollection *anActColl = aRen->GetActors(); 
199   vtkProp    *prop;
200   float      *bounds;
201   int        nothingVisible=1;
202
203   allBounds[0] = allBounds[2] = allBounds[4] = VTK_LARGE_FLOAT;
204   allBounds[1] = allBounds[3] = allBounds[5] = -VTK_LARGE_FLOAT;
205   // loop through all props
206   for (anActColl->InitTraversal(); (prop = anActColl->GetNextProp()); ){
207     // if it's invisible, or has no geometry, we can skip the rest 
208     if ( prop->GetVisibility() && prop->IsA(theActorClassName)){
209       bounds = prop->GetBounds();
210       // make sure we haven't got bogus bounds
211       if ( bounds != NULL &&
212            bounds[0] > -VTK_LARGE_FLOAT && bounds[1] < VTK_LARGE_FLOAT &&
213            bounds[2] > -VTK_LARGE_FLOAT && bounds[3] < VTK_LARGE_FLOAT &&
214            bounds[4] > -VTK_LARGE_FLOAT && bounds[5] < VTK_LARGE_FLOAT )
215         {
216           nothingVisible = 0;
217           if (bounds[0] < allBounds[0]) allBounds[0] = bounds[0]; 
218           if (bounds[1] > allBounds[1]) allBounds[1] = bounds[1]; 
219           if (bounds[2] < allBounds[2]) allBounds[2] = bounds[2]; 
220           if (bounds[3] > allBounds[3]) allBounds[3] = bounds[3]; 
221           if (bounds[4] < allBounds[4]) allBounds[4] = bounds[4]; 
222           if (bounds[5] > allBounds[5]) allBounds[5] = bounds[5]; 
223         }//not bogus
224       }
225     }  
226   return nothingVisible;
227 }
228
229 VisuGUI::CameraOrient VisuGUI::SetFitAll(VTKViewer_ViewFrame* theViewFrame){ 
230   static float PRECISION = 0.000001;
231   static float DEVIATION = 600;
232   float XYZ_Bnd[6];
233   if(ComputeVisiblePropBounds(theViewFrame,XYZ_Bnd)) return e3D;
234
235   float absX = XYZ_Bnd[1]-XYZ_Bnd[0];
236  
237   float absY = XYZ_Bnd[3]-XYZ_Bnd[2];
238   
239   float absZ = XYZ_Bnd[5]-XYZ_Bnd[4];
240   
241   CameraOrient aCameraOrient = e3D;
242   if(absX <= PRECISION) aCameraOrient = eFront;
243   else {if(absY <= PRECISION) aCameraOrient = eLeft;
244   else {if(absZ <= PRECISION) aCameraOrient = eTop;}}
245   
246     float dev_abs_XY = absX / absY;
247     float dev_abs_YZ = absY / absZ;
248     float dev_abs_XZ = absX / absZ;
249     if(dev_abs_XY >= DEVIATION || 1./dev_abs_YZ >= DEVIATION) aCameraOrient = eLeft;
250     else{if(1./dev_abs_XY >= DEVIATION || 1./dev_abs_XZ >= DEVIATION) aCameraOrient = eFront; 
251     else {if(dev_abs_XZ >= DEVIATION || dev_abs_YZ >= DEVIATION) aCameraOrient = eTop;}}  
252  
253   switch(aCameraOrient){
254   case eFront: theViewFrame->onViewFront();  break;
255   case eLeft:  theViewFrame->onViewLeft();   break;
256   case eTop:   theViewFrame->onViewTop();    break;
257   case e3D:    theViewFrame->onViewReset();  break; 
258   }
259   theViewFrame->getRenderer()->ResetCameraClippingRange();
260   theViewFrame->onViewFitAll();
261   return aCameraOrient;
262 }
263  
264 QAD_Desktop* VisuGUI::GetDesktop(){
265   return QAD_Application::getDesktop() ;
266 }
267
268 QAD_Study* VisuGUI::GetActiveStudy(){
269   return GetDesktop()->getActiveStudy() ;
270 }
271
272 vtkRenderer* VisuGUI::GetRenderer(){
273   if(VTKViewer_ViewFrame* aViewFrame = GetVtkViewFrame())
274     return aViewFrame->getRenderer();
275   return NULL;
276 }
277
278 VTKViewer_ViewFrame* VisuGUI::GetVtkViewFrame(){
279   QAD_ViewFrame* aViewFrame = GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame();
280   return dynamic_cast<VTKViewer_ViewFrame*>(aViewFrame);
281 }
282
283 static void UpdateViewFrame() {
284   QList<QAD_StudyFrame> aFrameList = VisuGUI::GetActiveStudy()->getStudyFrames();
285
286   for (QAD_StudyFrame* aStudyFrame = aFrameList.first(); aStudyFrame; aStudyFrame = aFrameList.next()) {
287     if (aStudyFrame->getTypeView() == VIEW_VTK) {
288       QAD_ViewFrame* aViewFrame = aStudyFrame->getRightFrame()->getViewFrame();
289       VTKViewer_ViewFrame* aVtkViewFrame = dynamic_cast<VTKViewer_ViewFrame*>(aViewFrame);
290       if (!aVtkViewFrame) continue;
291       VTKViewer_RenderWindowInteractor* anInteractor = aVtkViewFrame->getRWInteractor();
292       if (anInteractor) {
293         anInteractor->SetSelectionProp();
294         anInteractor->SetSelectionTolerance();
295         VTKViewer_InteractorStyleSALOME* aStyle = anInteractor->GetInteractorStyleSALOME();
296         if (aStyle) {
297           aStyle->setPreselectionProp();
298         }
299       }
300     }
301   }
302 }
303
304 SALOMEDS::Study_var VisuGUI::GetStudyDocument(){
305   return GetActiveStudy()->getStudyDocument();
306 }
307
308 SALOMEDS::StudyBuilder_var VisuGUI::NewBuilder(){
309   return GetStudyDocument()->NewBuilder();
310 }
311
312
313 /**
314  * Finds value by given key
315  */
316
317 VISU::Storable::TRestoringMap VisuGUI::getMapOfValue(SALOMEDS::SObject_var theSObject) {
318   VISU::Storable::TRestoringMap aMap;
319   if(!theSObject->_is_nil()){
320     SALOMEDS::GenericAttribute_var anAttr;
321     if (theSObject->FindAttribute(anAttr, "AttributeComment")) {
322       SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(anAttr);
323       CORBA::String_var aString = aComment->Value();
324       QString strIn(aString.in());
325       VISU::Storable::StrToMap(strIn,aMap);
326     }
327   }
328   return aMap;
329 }
330
331 QString VisuGUI::getValue(SALOMEDS::SObject_var theSObject, QString theKey) {
332   QString aStr("");
333   VISU::Storable::TRestoringMap aMap = getMapOfValue(theSObject);
334   if(!aMap.empty())
335     aStr = VISU::Storable::FindValue(aMap, theKey.latin1());
336   return aStr;
337 }
338
339
340 CORBA::Object_var GetSelectedObj(Handle(SALOME_InteractiveObject)* pIO = NULL, QAD_Study* theStudy = NULL,
341                                  VISU::Storable::TRestoringMap* pMap = NULL)
342 {
343   if(theStudy == NULL) theStudy = VisuGUI::GetActiveStudy();
344   SALOME_Selection* aSel = SALOME_Selection::Selection(theStudy->getSelection());
345   if(aSel->IObjectCount() > 0){
346     const Handle(SALOME_InteractiveObject)& anIO = aSel->firstIObject();
347     if(pIO != NULL) *pIO = anIO;
348     if(anIO->hasEntry()){
349       SALOMEDS::Study_var aStudy = theStudy->getStudyDocument();
350       SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(anIO->getEntry());
351       if(!aSObject->_is_nil()){
352         SALOMEDS::GenericAttribute_var anAttr;
353         if (pMap != NULL && aSObject->FindAttribute(anAttr, "AttributeComment")) {
354           SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(anAttr);
355           string aComm = aComment->Value();
356           QString strIn(aComm.c_str());
357           VISU::Storable::StrToMap(strIn,*pMap);
358         }
359         return VISU::SObjectToObject(aSObject);
360       }
361     }
362   }
363   return CORBA::Object::_nil();
364 }
365
366
367 int IsTrihedronDisplayed(){
368   if(VTKViewer_ViewFrame* aVTKViewFrame = VisuGUI::GetVtkViewFrame())
369     return aVTKViewFrame->isTrihedronDisplayed();
370   return 1;
371 }
372
373
374 void RepaintCurrentView(){
375   if(VTKViewer_ViewFrame* vf = VisuGUI::GetVtkViewFrame()) vf->Repaint();
376 }
377
378
379 VisuGUI::VisuGUI( const QString& theName, QObject* theParent ): 
380   SALOMEGUI( theName, theParent ) 
381 {    
382   mySelectionDlg = 0;
383 }
384
385 /* ==================================================================================== */
386 /* ==================================================================================== */
387 /*                                      ONGUI EVENT                                     */
388 /* ==================================================================================== */
389 /* ==================================================================================== */
390
391 static int isStudyLocked(const SALOMEDS::Study_var& theStudy){
392   return theStudy->GetProperties()->IsLocked();
393 }
394
395 static int checkLock(const SALOMEDS::Study_var& theStudy) {
396   if (isStudyLocked(theStudy)) {
397     QAD_MessageBox::warn1 ( (QWidget*)QAD_Application::getDesktop(),
398                            QObject::tr("WRN_WARNING"), 
399                            QObject::tr("WRN_STUDY_LOCKED"),
400                            QObject::tr("BUT_OK") );
401     return true;
402   }
403   return false;
404 }
405
406
407
408 bool VisuGUI::OnGUIEvent(int theCommandID,  QAD_Desktop* parent)
409 {
410   try{
411     QString VisuInputDir = getVisuInputDir();
412     QString VisuOutputDir = getVisuOutputDir();
413     vtkRenderer *theRenderer = GetRenderer();
414     
415     SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument(); //Document OCAF de l'etude active
416     SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
417     SALOMEDS::GenericAttribute_var anAttr;
418     SALOMEDS::AttributeName_var    aName;
419     SALOMEDS::AttributeIOR_var     anIOR;
420     
421     switch (theCommandID){
422       /* ======================================================================================== */
423       /* Import Table from file                                                                   */
424       /* ======================================================================================== */
425     case 199:
426       {
427         if(checkLock(aStudy)) break;
428         visuGUI->ImportTablesFromFile();
429         break;
430       }
431
432       /* ======================================================================================== */
433       /* Import Mesh from MED, DAT file                                                                   */
434       /* ======================================================================================== */
435
436     case 111:
437       {
438         visuGUI->CopyAndImportFile();
439         break;
440       }
441     case 112:
442       {
443         visuGUI->ImportFile();
444         break;
445       }
446
447       /* ======================================================================================== */
448       /* Export results and mesh into a file format                                               */
449       /* ======================================================================================== */
450
451     case 122:
452       {
453         //visuGUI->ExportToFile();
454         break;
455       }
456
457      /* ========================================================================== */
458      /* Visualization of Results :                                                 */
459      /* 4011 : Scalar Map                                                          */
460      /* 4012 : Deformed Shape                                                      */
461      /* 4013 : Vectors                                                             */
462      /* 4014 : Iso-Surfaces                                                        */
463      /* 4015 : Cut Planes                                                          */
464      /* 4016 : Stream Lines                                                        */
465      /* ========================================================================== */
466
467     case 4011 :
468       visuGUI->CreateScalarMap();
469       break;
470     case 4012 :
471       visuGUI->CreateDeformedShape();
472       break;
473     case 4013 :
474       visuGUI->CreateVectors();
475       break;
476     case 4014 :
477       visuGUI->CreateIsoSurfaces();
478       break;
479     case 4015 :
480       visuGUI->CreateCutPlanes();
481       break;
482     case 4018 :
483       visuGUI->CreateCutLines();
484       break;
485     case 4016 :
486       visuGUI->CreateStreamLines();
487       break;
488
489     case 4111 :
490       visuGUI->SelectionInfo();
491       break;
492
493       /* ========================================================================================================================= */
494       /* Visualization - Wireframe                                                                                                 */
495       /* ========================================================================================================================= */
496
497     case 4211 :
498       ChangeViewer(1);
499       break;
500
501       /* ========================================================================================================================= */
502       /* Visualization - Surface                                                                                                   */
503       /* ========================================================================================================================= */
504
505     case 4212 :
506       ChangeViewer(2);
507       break;
508
509       /* ========================================================================================================================= */
510       /* Visualization - Points                                                                                                    */
511       /* ========================================================================================================================= */
512
513     case 4213 :
514       ChangeViewer(0);
515       break;
516
517       /* ========================================================================================================================= */
518       /* Visualization - Erase                                                                                                     */
519       /* ========================================================================================================================= */
520
521     case 422 :
522       ChangeViewer(-1);
523       break;
524
525       /* ========================================================================================================================= */
526       /* Visualization - Global                                                                                                    */
527       /* ========================================================================================================================= */
528
529       //case 423 :
530                    
531       /* ========================================================================================================================= */
532       /* Visualization - Partial                                                                                                   */
533       /* ========================================================================================================================= */
534
535       //case 424 :
536
537       case 430 :
538        {  
539          //Show dialog that allows to select scale function and corresponding scale factor
540          VisuGUI_NonIsometricDlg* m_NonIsoDlg = new VisuGUI_NonIsometricDlg ( QAD_Application::getDesktop(), "m_NonIsoDlg",
541                                                                               FALSE, Qt::WDestructiveClose );
542          m_NonIsoDlg->show();
543          break;
544        }
545
546       /* ============================ */
547       /*  POP-UP OBJECTS BROWSER      */
548       /* ============================ */
549
550     case 900 : // Rename object
551       visuGUI->Rename();
552       break;
553
554                 // ---------------- For Popup in Viewer
555     case 802  : // Erase
556     case 902  : // Erase
557       visuGUI->ErasePrs();
558       break;
559
560     case 803  : // Display only
561     case 903  : // Display only
562       visuGUI->DisplayOnlyPrs();
563       break;
564
565     case 901  : // Display
566       visuGUI->DisplayPrs();
567       break;
568
569     case 8041 : // Object representation : Wireframe
570     case 9041 : // Object representation : Wireframe
571       visuGUI->ChangeRepresentation(VISU::WIREFRAME);
572       break;
573
574     case 8042 : // Object representation : Surface
575     case 9042 : // Object representation : Surface
576       visuGUI->ChangeRepresentation(VISU::SHADED);
577       break;
578
579     case 8043 : // Object representation : Points
580     case 9043 : // Object representation : Points
581       visuGUI->ChangeRepresentation(VISU::POINT);
582       break;
583
584     case 8044 : // Object representation : Shrink/Unshrink
585     case 9044 : // Object representation : Shrink/Unshrink
586       visuGUI->ChangeRepresentation(VISU::SHRINK);
587       break;
588
589     case 8051 : // Change object color
590     case 9051 : // Change object color
591       visuGUI->ChageColor();
592       break;
593
594     case 8052 : // Change object opacity
595     case 9052 : // Change object opacity
596       visuGUI->ChangeOpacity();
597       break;
598
599     case 8053 : // Change object line width
600     case 9053 : // Change object line width
601       visuGUI->ChangeLines();
602       break;
603
604     case 808  : // Sweep IsoSurfaces or Cutplanes
605     case 908  : // Sweep IsoSurfaces or Cutplanes
606       visuGUI->Sweep();
607       break;
608
609 /* ======================================================================================== */
610 /* Preferences for Scalar Bar                                                               */
611 /* ======================================================================================== */
612     case 51:
613       {
614         ChangeScalarBar();
615         break;
616       }
617
618 /* ======================================================================================== */
619 /* Preferences for Sweeping                                                               */
620 /* ======================================================================================== */
621     case 52:
622       {
623         SetSweepingPreferences();
624       }
625       break;
626
627 /* ======================================================================================== */
628 /* Preferences for Full loading                                                             */
629 /* ======================================================================================== */
630     case 53:
631     case 54:
632       {
633         QMenuData* pp;
634         QMenuItem* item = parent->menuBar()->findItem(theCommandID,&pp);
635         bool check = !pp->isItemChecked(theCommandID);
636         pp->setItemChecked(theCommandID,check);
637         switch(theCommandID){
638         case 53:
639           QAD_CONFIG->addSetting( "Visu:BuildResult", check );
640           break;
641         case 54:
642           QAD_CONFIG->addSetting( "Visu:BuildDefaultPrs3d", check );
643           break;
644         }
645       }
646       break;
647
648     case 113: // Load MED using MED component
649       {
650         if (checkLock(GetStudyDocument())) break;
651
652         Engines::Component_var aMedComp = GetDesktop()->getEngine("FactoryServer", "MED");
653         if (CORBA::is_nil(aMedComp)) return false;
654         SALOME_MED::MED_Gen_var aMedGen = SALOME_MED::MED_Gen::_narrow(aMedComp);
655         if (CORBA::is_nil(aMedGen)) return false;
656
657         QStringList filtersList ;       
658         
659         filtersList.append( tr("MED_MEN_IMPORT_MED") );
660         filtersList.append( tr("MED_MEN_ALL_FILES") ) ;
661         QString aFileName = QAD_FileDlg::getFileName(GetDesktop(),
662                                                      "",
663                                              filtersList,
664                                                      tr("MED_MEN_IMPORT"),
665                                                      true);
666         if (!aFileName.isEmpty()) {
667           QApplication::setOverrideCursor( Qt::waitCursor );
668           aMedGen->readStructFileWithFieldType(aFileName.latin1(), GetActiveStudy()->getTitle());
669           GetActiveStudy()->updateObjBrowser();
670           QApplication::restoreOverrideCursor();
671         }
672       }
673       break;
674
675     default:
676       QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
677                               tr ("MSG_NOT_IMPLEMENTED"),
678                               tr ("VISU_BUT_OK") );
679       break;
680     } 
681   } catch (const std::bad_alloc& e ) { 
682     INFOS("bad_alloc exception is caught "<<e.what());
683     QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
684                           tr("ERR_NO_MEMORY") + " " + tr(e.what()),
685                           tr("VISU_BUT_OK") );
686     return false;
687     }
688   catch (std::exception& e){
689     INFOS(e.what());
690     QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
691                           tr(e.what()),
692                           tr("VISU_BUT_OK") );
693   }catch (const SALOME::SALOME_Exception& S_ex) {
694     INFOS("const SALOME::SALOME_Exception& S_ex");
695     QtCatchCorbaException(S_ex);
696     return false;
697   }
698   catch(...) {
699     INFOS(tr("ERR_UNKNOWN_EXCEPTION").latin1());
700     QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
701                           tr("ERR_UNKNOWN_EXCEPTION"),
702                           tr("VISU_BUT_OK") );
703     return false;
704   }
705   return true;
706 }
707
708 void VisuGUI::SelectionInfo() {
709   mySelectionDlg = new VisuGUI_SelectionDlg();
710   mySelectionDlg->show();
711 }
712
713
714
715
716 /* ********************************************************************************** */
717 /* Function ShowTrihedron                                                             */
718 /* ********************************************************************************** */
719
720 void VisuGUI::ShowTrihedron(bool ShowThd){
721   bool ThdIsVisible = true; 
722   if( ShowThd && !ThdIsVisible)
723     ((VTKViewer_ViewFrame*)visuGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->onViewTrihedron();
724   if( !ShowThd && ThdIsVisible)
725     ((VTKViewer_ViewFrame*)visuGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->onViewTrihedron();
726 }
727
728 /* ********************************************************************************** */
729 /* Destructor                                                                         */
730 /* Clear all tmp files used in VISU                                                   */
731 /* ********************************************************************************** */
732
733 VisuGUI::~VisuGUI(){
734   if(MYDEBUG) MESSAGE("VisuGUI::~VisuGUI");
735 }
736                         
737 /* ********************************************************************************** */
738 /* Function ChangeViewer                                                              */
739 /* Change representation of all actors                                                */
740 /* ********************************************************************************** */
741
742 void VisuGUI::ChangeViewer(int theType){
743   if(theType < 0 ) 
744     GetActiveStudy()->unHighlightAll();
745   if(vtkRenderer *aRen = GetRenderer()){
746     vtkActor *anActor;
747     vtkActorCollection *anActColl = aRen->GetActors();
748     for(anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL; ){
749       if(anActor->GetVisibility() > 0)
750         if(VISU_Actor* anVISUActor = VISU_Actor::SafeDownCast(anActor)){ 
751           anVISUActor = anVISUActor->GetParent();
752           if(theType >= 0)
753             anVISUActor->SetRepresentation(theType); 
754           else
755             anVISUActor->VisibilityOff();
756         }
757     }
758     RepaintCurrentView();
759   }
760 }
761
762 // -----------------------------------------------------------------------------------------
763 // EVENTS
764 // -----------------------------------------------------------------------------------------
765
766 bool VisuGUI::OnMousePress (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
767 {
768   return true;
769 }
770
771 // ====================================================================================================================
772
773 bool VisuGUI::OnMouseMove (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
774 {
775   return true;
776 }
777
778 // ===================================================================================================================
779
780 bool VisuGUI::OnKeyPress (QKeyEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
781 {
782   if (GetActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_VTK) // true = Viewer OCC
783     return false;
784
785   if(MYDEBUG) MESSAGE( "VisuGUI::onKeyPress : " << pe->key() )
786
787   switch ( pe->key() )
788     {
789     case Key_Escape :
790       {
791           if(MYDEBUG) MESSAGE("--> Key : Escape")
792           return true;    
793       }
794     default :
795         return true;
796         break;
797    }
798  return true;
799 }
800
801
802
803 //=====================================================================================
804 // Slot-functions for presentations creation
805 //=====================================================================================
806
807 #define CREATEPRESENTATION(FunctionName)  \
808  void FunctionName() { \
809    if (checkLock(GetStudyDocument())) return; \
810    SALOMEDS::SObject_var objVisu;  \
811    if (!TestObjectBrowser(objVisu)) return;  \
812    if(!FunctionName(objVisu)) return; \
813    GetActiveStudy()->updateObjBrowser(); \
814    GetDesktop()->putInfo("Ready"); \
815    VTKViewer_ViewFrame* vf = GetVtkViewFrame(); \
816    if (vf) { \
817      /*vf->getRenderer()->ResetCameraClippingRange();*/ \
818      vf->onViewFitAll(); \
819    } \
820  } 
821
822
823 CREATEPRESENTATION(VisuGUI::CreateScalarMap);
824 CREATEPRESENTATION(VisuGUI::CreateDeformedShape);
825 CREATEPRESENTATION(VisuGUI::CreateVectors);
826 CREATEPRESENTATION(VisuGUI::CreateIsoSurfaces);
827 CREATEPRESENTATION(VisuGUI::CreateCutPlanes);
828 CREATEPRESENTATION(VisuGUI::CreateCutLines);
829 CREATEPRESENTATION(VisuGUI::CreateStreamLines);
830
831
832
833 //=====================================================================================
834 // function : SetSettings()
835 // purpose  :
836 //=====================================================================================
837 bool VisuGUI::SetSettings(QAD_Desktop* parent)
838 {
839   int anId = 53;
840   QMenuData* pp;
841   QMenuItem* item = parent->menuBar()->findItem(anId,&pp);
842   QString aValue = QAD_CONFIG->getSetting("Visu:BuildResult");
843   
844   if(aValue.isEmpty()? 0 : aValue.toInt()) 
845     pp->setItemChecked(anId, true);
846   
847   anId = 54;
848   item = parent->menuBar()->findItem(anId,&pp);
849   aValue  = QAD_CONFIG->getSetting("Visu:BuildDefaultPrs3d");
850   
851   if(aValue.isEmpty()? 0 : aValue.toInt()) 
852     pp->setItemChecked(anId, true);
853   
854   anId = 50;
855   parent->menuBar()->changeItem(anId,parent->getComponentUserName("VISU"));
856
857   ::UpdateViewFrame();
858
859   return true;
860 }
861
862 //=====================================================================================
863 // function : DisplayPrs()
864 // purpose  :
865 //=====================================================================================
866 void VisuGUI::DisplayPrs() {
867   if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs");
868   Handle(SALOME_InteractiveObject) anIO;
869   CORBA::Object_var anObject = GetSelectedObj(&anIO);
870   if ( !CORBA::is_nil( anObject ) ) {
871     // is it Prs3d object ?
872     VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject).in());
873     if(aPrsObject){
874       if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Prs3d object");
875       UpdateViewer(aPrsObject);
876       if (VTKViewer_ViewFrame* vf = GetVtkViewFrame()) {
877         vf->getRenderer()->ResetCameraClippingRange();
878         vf->Repaint();
879         vf->highlight(anIO, 1);
880       }
881       return;
882     }
883     // is it Curve ?
884     VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(anObject).in());
885     if(aCurve){
886       if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Curve object");
887       PlotCurve(aCurve, VISU::eDisplay );
888       return;
889     }
890     // is it Container ?
891     VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(anObject).in());
892     if(aContainer){
893       if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Container object");
894       PlotContainer(aContainer, VISU::eDisplay );
895       return;
896     }
897     // is it Table ?
898     VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(anObject).in());
899     if(aTable){
900       if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Table object");
901       PlotTable(aTable, VISU::eDisplay );
902       return;
903     }
904   }
905 }
906
907 //=====================================================================================
908 // function : DisplayOnlyPrs()
909 // purpose  :
910 //=====================================================================================
911 void VisuGUI::DisplayOnlyPrs() {
912   if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyPrs");
913   CORBA::Object_var anObject = GetSelectedObj();
914   if ( !CORBA::is_nil( anObject ) ) {
915     // is it Prs3d object ?
916     PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
917     if(VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(aServant.in())){
918       if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyPrs : Prs3d object");
919       UpdateViewer(aPrsObject, true);
920       VTKViewer_ViewFrame* vf = GetVtkViewFrame();
921       if (vf) {
922         vf->getRenderer()->ResetCameraClippingRange();
923         vf->Repaint();
924       }
925     }else if(VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(aServant.in())){
926       if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyPrs : Curve object");
927       PlotCurve(aCurve, VISU::eDisplayOnly );
928     }else if(VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(aServant.in())){
929       if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyPrs : Container object");
930       PlotContainer(aContainer, VISU::eDisplayOnly );
931     }else if(VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(aServant.in())){
932       if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyPrs : Table object");
933       PlotTable(aTable, VISU::eDisplayOnly );
934     }
935   }
936 }
937
938 //=====================================================================================
939 // function : ErasePrs()
940 // purpose  :
941 //=====================================================================================
942 static void ErasePrs(CORBA::Object_ptr theObject) {
943   if(MYDEBUG) MESSAGE("ErasePrs");
944   if ( !CORBA::is_nil( theObject ) ) {
945     VISU::Base_var aBase = VISU::Base::_narrow(theObject);
946     if ( CORBA::is_nil( aBase ) ) return;
947     VISU::VISUType aType = aBase->GetType();
948     switch (aType){
949     case VISU::TCURVE:{
950       if(VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aBase).in()))
951         VisuGUI::PlotCurve(aCurve, VISU::eErase );
952       break;
953     }
954     case VISU::TCONTAINER:{
955       if(VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aBase).in()))
956         VisuGUI::PlotContainer(aContainer, VISU::eErase );
957       break;
958     }
959     case VISU::TTABLE:{
960       if(VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aBase).in()))
961         VisuGUI::PlotTable(aTable, VISU::eErase );
962       break;
963     }
964     default:{
965       if(VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(aBase).in())){
966         VisuGUI::ErasePrs(aPrsObject);
967         if (VTKViewer_ViewFrame* vf = VisuGUI::GetVtkViewFrame())
968           vf->Repaint();
969       }
970     }}
971   }
972 }
973
974 void VisuGUI::ErasePrs() {
975   ::ErasePrs(GetSelectedObj());
976 }
977
978
979 //=====================================================================================
980 // function : DisplayManyPrs()
981 // purpose  :
982 //=====================================================================================
983 void VisuGUI::DisplayManyPrs()
984 {
985   if(MYDEBUG) MESSAGE("VisuGUI::DisplayManyPrs");
986   SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection());
987   SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
988   for ( ; It.More(); It.Next() ) {
989     Handle(SALOME_InteractiveObject)& anIO = It.Value();
990     if ( anIO->hasEntry() ) {
991       SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
992       SALOMEDS::SObject_var aSObject = aStudy->FindObjectID( anIO->getEntry() );
993       VISU::Storable::TRestoringMap pMap;
994       if( !aSObject->_is_nil() ) {
995         CORBA::Object_var aCORBAObject = VISU::SObjectToObject(aSObject);
996         if ( !CORBA::is_nil( aCORBAObject ) ) {
997           // is it Prs3d object ?
998           VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(aCORBAObject).in());
999           if(aPrsObject){
1000             if(MYDEBUG) MESSAGE("VisuGUI::DisplayManyPrs : Prs3d object");
1001             UpdateViewer(aPrsObject);
1002             VTKViewer_ViewFrame* vf = GetVtkViewFrame();
1003             if (vf) {
1004               vf->getRenderer()->ResetCameraClippingRange();
1005               vf->Repaint();
1006               vf->highlight(anIO, 1);
1007             }
1008             continue;
1009           }
1010           // is it Curve ?
1011           VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCORBAObject).in());
1012           if(aCurve){
1013             if(MYDEBUG) MESSAGE("VisuGUI::DisplayManyPrs: Curve object");
1014             PlotCurve(aCurve, VISU::eDisplay );
1015             continue;
1016           }
1017           // is it Container ?
1018           VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aCORBAObject).in());
1019           if(aContainer){
1020             if(MYDEBUG) MESSAGE("VisuGUI::DisplayManyPrs : Container object");
1021             PlotContainer(aContainer, VISU::eDisplay );
1022             continue;
1023           }
1024           // is it Table ?
1025           VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aCORBAObject).in());
1026           if(aTable){
1027             if(MYDEBUG) MESSAGE("VisuGUI::DisplayManyPrs : Table object");
1028             PlotTable(aTable, VISU::eDisplay );
1029             continue;
1030           }
1031         }
1032       }
1033     }
1034   }
1035 }
1036
1037 //=====================================================================================
1038 // function : DisplayOnlyManyPrs()
1039 // purpose  :
1040 //=====================================================================================
1041 void VisuGUI::DisplayOnlyManyPrs() {
1042   if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyManyPrs");
1043   SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection());
1044   SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
1045   bool aFirstElem = true;
1046   for ( ; It.More(); It.Next() ) {
1047     Handle(SALOME_InteractiveObject)& anIO = It.Value();
1048     if ( anIO->hasEntry() ) {
1049       SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
1050       SALOMEDS::SObject_var aSObject = aStudy->FindObjectID( anIO->getEntry() );
1051       VISU::Storable::TRestoringMap pMap;
1052       if( !aSObject->_is_nil() ) {
1053         CORBA::Object_var aCORBAObject = VISU::SObjectToObject(aSObject);
1054         if ( !CORBA::is_nil( aCORBAObject ) ) {
1055           // is it Prs3d object ?
1056           VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(aCORBAObject).in());
1057           if(aPrsObject){
1058             if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyManyPrs : Prs3d object");
1059             UpdateViewer(aPrsObject, aFirstElem);
1060             if (aFirstElem) aFirstElem = false;
1061             VTKViewer_ViewFrame* vf = GetVtkViewFrame();
1062             if (vf) {
1063               vf->getRenderer()->ResetCameraClippingRange();
1064               vf->Repaint();
1065               vf->highlight(anIO, 1);
1066             }
1067             continue;
1068           }
1069           // is it Curve ?
1070           VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCORBAObject).in());
1071           if(aCurve){
1072             if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyManyPrs: Curve object");
1073             if (aFirstElem) {
1074               PlotCurve(aCurve, VISU::eDisplayOnly );
1075               aFirstElem = false;
1076             }
1077             else PlotCurve(aCurve, VISU::eDisplay );
1078             continue;
1079           }
1080           // is it Container ?
1081           VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aCORBAObject).in());
1082           if(aContainer){
1083             if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyManyPrs : Container object");
1084             if (aFirstElem) {
1085               PlotContainer(aContainer, VISU::eDisplayOnly );
1086               aFirstElem = false;
1087             }
1088             else PlotContainer(aContainer, VISU::eDisplay );
1089             continue;
1090           }
1091           // is it Table ?
1092           VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aCORBAObject).in());
1093           if(aTable){
1094             if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyManyPrs : Table object");
1095             if (aFirstElem) {
1096               PlotTable(aTable, VISU::eDisplayOnly );
1097               aFirstElem = false;
1098             }
1099             else PlotTable(aTable, VISU::eDisplay );
1100             continue;
1101           }
1102         }
1103       }
1104     }
1105   }
1106 }
1107
1108
1109 //=====================================================================================
1110 // function : EraseManyPrs()
1111 // purpose  :
1112 //=====================================================================================
1113 void VisuGUI::EraseManyPrs()
1114 {
1115   if(MYDEBUG) MESSAGE("VisuGUI::EraseManyPrs");
1116   SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection());
1117   SALOME_ListIO LIO; LIO = Sel->StoredIObjects();
1118   SALOME_ListIteratorOfListIO It( LIO );
1119   for ( ; It.More(); It.Next() ) {
1120     Handle(SALOME_InteractiveObject)& anIO = It.Value();
1121     if ( anIO->hasEntry() ) {
1122       SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
1123       SALOMEDS::SObject_var aSObject = aStudy->FindObjectID( anIO->getEntry() );
1124       VISU::Storable::TRestoringMap pMap;
1125       if( !aSObject->_is_nil() ) {
1126         CORBA::Object_var aCORBAObject = VISU::SObjectToObject(aSObject);
1127         if ( !CORBA::is_nil( aCORBAObject ) ) {
1128           // is it Prs3d object ?
1129           VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(aCORBAObject).in());
1130           if(aPrsObject){
1131             if(MYDEBUG) MESSAGE("VisuGUI::EraseManyPrs : Prs3d object");
1132             ErasePrs(aPrsObject);
1133             VTKViewer_ViewFrame* vf = GetVtkViewFrame();
1134             if (vf) {
1135               vf->Repaint();
1136             }
1137             continue;
1138           }
1139           // is it Curve ?
1140           VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCORBAObject).in());
1141           if(aCurve){
1142             if(MYDEBUG) MESSAGE("VisuGUI::EraseManyPrs : Curve object");
1143             PlotCurve(aCurve, VISU::eErase );
1144             continue;
1145           }
1146           // is it Container ?
1147           VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aCORBAObject).in());
1148           if(aContainer){
1149             if(MYDEBUG) MESSAGE("VisuGUI::EraseManyPrs : Container object");
1150             PlotContainer(aContainer, VISU::eErase );
1151             continue;
1152           }
1153           // is it Table ?
1154           VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aCORBAObject).in());
1155           if(aTable){
1156             if(MYDEBUG) MESSAGE("VisuGUI::EraseManyPrs : Table object");
1157             PlotTable(aTable, VISU::eErase );
1158             continue;
1159           }
1160         }
1161       }
1162     }
1163   }
1164 }
1165
1166 //=====================================================================================
1167 // function : RecreateActor()
1168 // purpose  :
1169 //=====================================================================================
1170 void VisuGUI::RecreateActor(VISU::Prs3d_i* thePrs) {
1171   QApplication::setOverrideCursor(Qt::waitCursor);
1172   try{
1173     thePrs->Update();
1174     //UpdateViewer(thePrs); Avoid unnessary settings of visibility on for thePrs
1175     for(int i = 0, nbFrames = GetActiveStudy()->getStudyFramesCount(); i < nbFrames; i++)
1176       if(QAD_StudyFrame* aFrame = GetActiveStudy()->getStudyFrame(i)){
1177         QAD_ViewFrame* aVFrame = aFrame->getRightFrame()->getViewFrame();
1178         if(VTKViewer_ViewFrame* aViewFrame = dynamic_cast<VTKViewer_ViewFrame*>(aVFrame))
1179           if(VISU_Actor* anActor = GetActor(thePrs,aViewFrame))
1180             thePrs->UpdateActor(anActor);
1181       }
1182   }catch(std::runtime_error& ex){
1183     INFOS(ex.what());
1184     QApplication::restoreOverrideCursor();
1185     QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"), 
1186                             tr ("ERR_CANT_BUILD_PRESENTATION") + " " + tr(ex.what()), 
1187                             tr ("VISU_BUT_OK") );
1188     for(int i = 0, nbFrames = GetActiveStudy()->getStudyFramesCount(); i < nbFrames; i++)
1189       if(QAD_StudyFrame* aFrame = GetActiveStudy()->getStudyFrame(i)){
1190         QAD_ViewFrame* aVFrame = aFrame->getRightFrame()->getViewFrame();
1191         if(VTKViewer_ViewFrame* aViewFrame = dynamic_cast<VTKViewer_ViewFrame*>(aVFrame)) {
1192           if(VISU_Actor* anActor = GetActor(thePrs,aViewFrame)) {
1193             aViewFrame->RemoveActor(anActor);
1194             anActor->Delete();
1195           }
1196         }
1197       }
1198     return;
1199   }
1200   QApplication::restoreOverrideCursor();
1201 }
1202
1203
1204 //=====================================================================================
1205 // function : EditPrs()
1206 // purpose  :
1207 //=====================================================================================
1208 #define EDITPRS(PrsName, DlgName)  \
1209     { \
1210       PrsName* aPrsObject = dynamic_cast<PrsName*>(aPrs3d); \
1211       if (aPrsObject) { \
1212         DlgName* aDlg = new DlgName(); \
1213         aDlg->initFromPrsObject(aPrsObject); \
1214         if ( aDlg->exec() )  { \
1215           if(!(aDlg->storeToPrsObject(aPrsObject))){ \
1216             delete aDlg; \
1217             return; \
1218           } \
1219           RecreateActor(aPrsObject); \
1220           if (VTKViewer_ViewFrame* vf = GetVtkViewFrame()) { \
1221             if ( vf->getRenderer()->GetActors()->GetNumberOfItems () > 0 ) { \
1222                  vf->getRenderer()->ResetCameraClippingRange(); \
1223                  vf->Repaint(); \
1224               }\
1225           } \
1226         } \
1227         delete aDlg; \
1228       } \
1229     }
1230
1231 void VisuGUI::EditPrs() {
1232   VISU::Prs3d_i* aPrs3d = GetSelectedPrs3d();
1233
1234   switch (aPrs3d->GetType()) {
1235   case VISU::TMESH: // Mesh 13
1236     break;
1237
1238   case VISU::TSCALARMAP: // ScalarMap 18
1239     EDITPRS(VISU::ScalarMap_i, VisuGUI_ScalarBarDlg);
1240     break;
1241     
1242   case VISU::TDEFORMEDSHAPE: // Deformed Shape 28
1243     EDITPRS(VISU::DeformedShape_i, VisuGUI_MagnitudeDlg);
1244     break;
1245     
1246   case VISU::TCUTPLANES: // Cut planes 42
1247     //EDITPRS(VISU::CutPlanes_i, VisuGUI_CutPlanesDlg);
1248     {
1249       VISU::CutPlanes_i* aPrsObject = dynamic_cast<VISU::CutPlanes_i*>(aPrs3d);
1250       if (aPrsObject) {
1251         VisuGUI_CutPlanesDlg* aDlg = new VisuGUI_CutPlanesDlg(false, false); 
1252         aDlg->initFromPrsObject(aPrsObject);
1253         aDlg->show();
1254         myActiveDialogBox = aDlg;      
1255 //      if ( aDlg->exec() )  {
1256 //        if(!(aDlg->storeToPrsObject(aPrsObject))){
1257 //          delete aDlg;
1258 //             return;
1259 //           }
1260 //        RecreateActor(aPrsObject);
1261 //        if (VTKViewer_ViewFrame* vf = GetVtkViewFrame()) {
1262 //          if ( vf->getRenderer()->GetActors()->GetNumberOfItems () > 0 ) {
1263 //                  vf->getRenderer()->ResetCameraClippingRange();
1264 //               vf->Repaint();
1265 //            }
1266 //        }
1267 //      }
1268 //      delete aDlg;
1269       }
1270     }
1271     break;
1272
1273   case VISU::TCUTLINES: // Cut planes 42
1274     //EDITPRS(VISU::CutLines_i, VisuGUI_CutLinesDlg);
1275     {
1276       VISU::CutLines_i* aPrsObject = dynamic_cast<VISU::CutLines_i*>(aPrs3d); 
1277       if (aPrsObject) { 
1278         VisuGUI_CutLinesDlg* aDlg = new VisuGUI_CutLinesDlg(false); 
1279         aDlg->initFromPrsObject(aPrsObject); 
1280         aDlg->show();
1281         myActiveDialogBox = aDlg;
1282 //      if ( aDlg->exec() )  { 
1283 //        aDlg->storeToPrsObject(aPrsObject); 
1284 //        RecreateActor(aPrsObject); 
1285 //        if (VTKViewer_ViewFrame* vf = GetVtkViewFrame()) { 
1286 //          if ( vf->getRenderer()->GetActors()->GetNumberOfItems () > 0 ) { 
1287 //            vf->getRenderer()->ResetCameraClippingRange(); 
1288 //            vf->Repaint(); 
1289 //          }
1290 //        }
1291 //        // Remove old Table
1292 //        SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument();
1293 //        SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(aPrsObject->GetEntry());
1294 //        if(!aSObject->_is_nil()) {
1295 //          SALOMEDS::ChildIterator_var aIter = aStudy->NewChildIterator( aSObject );
1296 //          SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder();
1297 //          for ( ;aIter->More(); aIter->Next()) {
1298 //            SALOMEDS::SObject_var aTblObj = aIter->Value();
1299 //            if (!aTblObj->_is_nil()) {
1300 //              SALOMEDS::GenericAttribute_var anAttr;
1301 //              if (aTblObj->FindAttribute(anAttr, "AttributeName")) {
1302 //                aBuilder->RemoveObjectWithChildren(aIter->Value()); // We should have only one child
1303 //                break;
1304 //              }
1305 //            }
1306 //          }
1307 //          if (aDlg->isGenerateTable()) {
1308 //            GetVisuGen()->CreateTable(aSObject->GetID());
1309 //            if (aDlg->isGenerateCurves()) {
1310 //              SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument();
1311 //              SALOMEDS::ChildIterator_var aIter = aStudy->NewChildIterator( aSObject );
1312 //              SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder();
1313 //              for ( ;aIter->More(); aIter->Next()) {
1314 //                SALOMEDS::SObject_var aTblObj = aIter->Value();
1315 //                if (!aTblObj->_is_nil()) {
1316 //                  SALOMEDS::GenericAttribute_var anAttr;
1317 //                  if (aTblObj->FindAttribute(anAttr, "AttributeName")) {
1318 //                    CreatePlot(aTblObj);
1319 //                  }
1320 //                }
1321
1322 //              }
1323 //            }
1324 //          }
1325 //          GetActiveStudy()->updateObjBrowser();
1326 //        }
1327 //      } 
1328 //      delete aDlg; 
1329       } 
1330     } 
1331     break;
1332
1333   case VISU::TISOSURFACE: // Iso surfaces
1334     EDITPRS(VISU::IsoSurfaces_i, VisuGUI_IsoSurfacesDlg);
1335     break;
1336   case VISU::TVECTORS: // Vectors 64
1337     EDITPRS(VISU::Vectors_i, VisuGUI_VectorsDlg);
1338     break;
1339
1340   case VISU::TSTREAMLINES:
1341     EDITPRS(VISU::StreamLines_i, VisuGUI_StreamLinesDlg);
1342     break;
1343   default: 
1344     return;        
1345   }
1346   
1347   Handle(SALOME_InteractiveObject) anIO;
1348   CORBA::Object_var anObject = GetSelectedObj(&anIO);
1349   if ( !CORBA::is_nil( anObject ) ) 
1350     if (VTKViewer_ViewFrame* vf = GetVtkViewFrame()) 
1351       vf->highlight(anIO, 1);
1352 }
1353
1354
1355 //=====================================================================================
1356 // function : CreateMesh()
1357 // purpose  :
1358 //=====================================================================================
1359 void VisuGUI::CreateMesh() {
1360   SALOME_Selection* Sel = SALOME_Selection::Selection(GetActiveStudy()->getSelection());
1361   SALOMEDS::SObject_var aSObject  = GetActiveStudy()->getStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() );
1362   
1363   if (checkLock(GetStudyDocument())) return;
1364
1365   SALOMEDS::SObject_var aSObj = aSObject->GetFather();
1366   aSObj = aSObj->GetFather();
1367   aSObj = aSObj->GetFather();
1368   CORBA::Object_var anObject = VISU::SObjectToObject(aSObj);
1369   if(CORBA::is_nil(anObject)) {
1370     aSObj = aSObj->GetFather();
1371     anObject = VISU::SObjectToObject(aSObj);
1372   }
1373   VISU::Result_var aResult;
1374   if (!CORBA::is_nil(anObject)) {
1375     aResult = VISU::Result::_narrow(anObject);
1376   }
1377   if(CORBA::is_nil(aResult)) {
1378     QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
1379                           tr ("WRN_NO_AVAILABLE_DATA"),
1380                           tr ("VISU_BUT_OK"));
1381     return;
1382   }
1383   VISU::Storable::TRestoringMap aMap;
1384   SALOMEDS::GenericAttribute_var anAttr;
1385   if(aSObject->FindAttribute(anAttr, "AttributeComment")) {
1386     SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(anAttr);
1387     string aComm = aComment->Value();
1388     QString strIn(aComm.c_str());
1389     VISU::Storable::StrToMap(strIn,aMap);
1390   }
1391   bool isExist;
1392   string aComment = VISU::Storable::FindValue(aMap,"myComment",&isExist).latin1();
1393   if(!isExist) return;
1394   CORBA::Object_var aMesh;
1395   string aMeshName = VISU::Storable::FindValue(aMap,"myMeshName").latin1();
1396 #ifdef CHECKTIME
1397   Utils_Timer timer;
1398   timer.Start();
1399 #endif
1400   VISU::Result_i* pResult = dynamic_cast<VISU::Result_i*>(VISU::GetServant(aResult.in()).in());
1401   if(aComment == "ENTITY"){
1402     VISU::Entity anEntity = (VISU::Entity)VISU::Storable::FindValue(aMap,"myId").toInt();
1403     if(VISU::Mesh_i::IsPossible(pResult,aMeshName.c_str(),anEntity))
1404       aMesh = GetVisuGen()->MeshOnEntity(aResult,aMeshName.c_str(),anEntity);
1405   }else if(aComment == "FAMILY"){
1406     VISU::Entity anEntity = (VISU::Entity)VISU::Storable::FindValue(aMap,"myEntityId").toInt();
1407     string aFamilyName = VISU::Storable::FindValue(aMap,"myName").latin1();
1408     if(VISU::Mesh_i::IsPossible(pResult,aMeshName.c_str(),anEntity,aFamilyName.c_str()))
1409       aMesh = GetVisuGen()->FamilyMeshOnEntity(aResult,aMeshName.c_str(),anEntity,aFamilyName.c_str());
1410   }else if(aComment == "GROUP"){
1411     string aGroupName = VISU::Storable::FindValue(aMap,"myName").latin1();
1412     if(VISU::Mesh_i::IsPossible(pResult,aMeshName.c_str(),aGroupName.c_str()))
1413       aMesh = GetVisuGen()->GroupMesh(aResult,aMeshName.c_str(),aGroupName.c_str());
1414   }
1415 #ifdef CHECKTIME
1416   timer.Stop();
1417   MESSAGE("VisuGUI::CreateMesh() - CREATE MESH");
1418   timer.Show();
1419 #endif
1420
1421   QApplication::restoreOverrideCursor();
1422   VISU::Mesh_i* pPresent = NULL;
1423   if(!CORBA::is_nil(aMesh)) 
1424     pPresent = dynamic_cast<VISU::Mesh_i*>(VISU::GetServant(aMesh).in());
1425   if (pPresent == NULL) {
1426     QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"), 
1427                             tr ("ERR_CANT_BUILD_PRESENTATION"), 
1428                             tr ("VISU_BUT_OK") ); 
1429     return;
1430   }
1431
1432   if(VTKViewer_ViewFrame* vf = GetVtkViewFrame()){
1433     try{
1434       VISU_Actor *anActor = pPresent->CreateActor();
1435 #ifdef CHECKTIME
1436       Utils_Timer timer;
1437       timer.Start();
1438 #endif
1439       vf->AddActor(anActor);
1440       SetFitAll(vf);
1441 #ifdef CHECKTIME
1442       timer.Stop();
1443       MESSAGE("VisuGUI::CreateMesh() - DISPLAY MESH");
1444       timer.Show();
1445 #endif
1446       //GetActiveStudy()->updateObjBrowser(); //not necessary
1447       GetDesktop()->putInfo("Ready");
1448     }catch(std::runtime_error& exc){
1449       INFOS(exc.what());
1450       QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"), 
1451                               tr ("ERR_CANT_CREATE_ACTOR") + " " + tr(exc.what()), 
1452                               tr ("VISU_BUT_OK") ); 
1453     }
1454   }
1455 }
1456
1457 //=====================================================================================
1458 // function : CreateManyMesh()
1459 // purpose  :
1460 //=====================================================================================
1461 void VisuGUI::CreateManyMesh(){
1462   if (checkLock(GetStudyDocument())) return;
1463
1464   SALOME_Selection* Sel = SALOME_Selection::Selection(GetActiveStudy()->getSelection());
1465   SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
1466   for ( ; It.More(); It.Next() ) {
1467     SALOMEDS::SObject_var aSObject  = GetStudyDocument()->FindObjectID(It.Value()->getEntry());
1468     SALOMEDS::SObject_var aSObj = aSObject->GetFather();
1469     aSObj = aSObj->GetFather();
1470     aSObj = aSObj->GetFather();
1471     CORBA::Object_var anObject = VISU::SObjectToObject(aSObj);
1472     if(CORBA::is_nil(anObject)) {
1473       aSObj = aSObj->GetFather();
1474       anObject = VISU::SObjectToObject(aSObj);
1475       if(CORBA::is_nil(anObject)) return;
1476     }
1477     VISU::Result_var aResult = VISU::Result::_narrow(anObject);
1478     if(CORBA::is_nil(aResult)) return;
1479     
1480     VISU::Storable::TRestoringMap aMap;
1481     SALOMEDS::GenericAttribute_var anAttr;
1482     if(aSObject->FindAttribute(anAttr, "AttributeComment")) {
1483       SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(anAttr);
1484       string aComm = aComment->Value();
1485       QString strIn(aComm.c_str());
1486       VISU::Storable::StrToMap(strIn,aMap);
1487     }
1488     bool isExist;
1489     string aComment = VISU::Storable::FindValue(aMap,"myComment",&isExist).latin1();
1490     if(!isExist) return;
1491     CORBA::Object_var aMesh;
1492     string aMeshName = VISU::Storable::FindValue(aMap,"myMeshName").latin1();
1493     if(aComment == "ENTITY"){
1494       VISU::Entity anEntity = (VISU::Entity)VISU::Storable::FindValue(aMap,"myId").toInt();
1495       aMesh = GetVisuGen()->MeshOnEntity(aResult,aMeshName.c_str(),anEntity);
1496     }else if(aComment == "FAMILY"){
1497       VISU::Entity anEntity = (VISU::Entity)VISU::Storable::FindValue(aMap,"myEntityId").toInt();
1498       string aFamilyName = VISU::Storable::FindValue(aMap,"myName").latin1();
1499       aMesh = GetVisuGen()->FamilyMeshOnEntity(aResult,aMeshName.c_str(),anEntity,aFamilyName.c_str());
1500     }else if(aComment == "GROUP"){
1501       string aGroupName = VISU::Storable::FindValue(aMap,"myName").latin1();
1502       aMesh = GetVisuGen()->GroupMesh(aResult,aMeshName.c_str(),aGroupName.c_str());
1503     }
1504     QApplication::restoreOverrideCursor();
1505     if(CORBA::is_nil(aMesh)) return;
1506     
1507     VISU::Mesh_i* pPresent = dynamic_cast<VISU::Mesh_i*>(VISU::GetServant(aMesh).in());
1508     try{
1509       VISU_Actor *anActor = pPresent->CreateActor();
1510       if(VTKViewer_ViewFrame* vf = GetVtkViewFrame()){
1511         vf->AddActor(anActor);
1512         SetFitAll(vf);
1513       }
1514       GetDesktop()->putInfo("Ready");
1515     }catch(std::runtime_error& exc){
1516       INFOS(exc.what());
1517     }
1518   }
1519 }
1520
1521 //=====================================================================================
1522 // function : ChangeRepresentation()
1523 // purpose  :
1524 //=====================================================================================
1525
1526 static void ShrinkMesh(VISU_Actor *theActor){
1527   if(theActor->IsShrunk()) 
1528     theActor->UnShrink();
1529   else
1530     theActor->SetShrink();
1531 }
1532
1533 void VisuGUI::ChangeRepresentation(VISU::PresentationType theType) {
1534   if(VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d())
1535     if(VISU_Actor* anActor = GetActor(aPrsObject)){
1536       switch (theType) {
1537       case VISU::SHRINK:
1538         ShrinkMesh(anActor);
1539         break;
1540       default:
1541         if(VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrsObject)){
1542           aMesh->SetPresentationType(theType);
1543           RecreateActor(aMesh);
1544         }else
1545           anActor->SetRepresentation(theType);
1546       }
1547       if (VTKViewer_ViewFrame* vf = GetVtkViewFrame()) 
1548         vf->Repaint();
1549     }
1550 }
1551
1552
1553 void VisuGUI::MakeSurfaceframe() {
1554   ChangeRepresentation(VISU::SURFACEFRAME);
1555 }
1556
1557 void VisuGUI::MakeInsideframe() {
1558   ChangeRepresentation(VISU::INSIDEFRAME);
1559 }
1560
1561 void VisuGUI::MakeWireframe() {
1562   ChangeRepresentation(VISU::WIREFRAME);
1563 }
1564
1565 void VisuGUI::MakeSurface() {
1566   ChangeRepresentation(VISU::SHADED);
1567 }
1568
1569 void VisuGUI::MakePoints() {
1570   ChangeRepresentation(VISU::POINT);
1571 }
1572
1573 void VisuGUI::MakeShrink() {
1574   ChangeRepresentation(VISU::SHRINK);
1575 }
1576
1577
1578
1579 //=====================================================================================
1580 // functions : Change Propertise
1581 // purpose  :
1582 //=====================================================================================
1583 VISU::Prs3d_i* VisuGUI::GetSelectedPrs3d(Handle(SALOME_InteractiveObject)* theIO) {
1584   CORBA::Object_var anObject = GetSelectedObj(theIO);
1585   if(CORBA::is_nil(anObject)) return NULL;
1586   PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
1587   if(!aServant.in()) return NULL;
1588   return dynamic_cast<VISU::Prs3d_i*>(aServant.in());
1589 }
1590
1591 void VisuGUI::ChageColor() {
1592   VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d();
1593   if(!aPrsObject) return;
1594
1595   VISU_Actor* anActor = GetActor(aPrsObject);  
1596   if (!anActor) return;
1597   NewColor(anActor);
1598 }
1599
1600 void VisuGUI::ChangeWireframeColor() {
1601   VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d();
1602   if(!aPrsObject) return;
1603
1604   VISU_MeshAct* anActor = dynamic_cast<VISU_MeshAct*>(GetActor(aPrsObject));
1605   if (!anActor) return;
1606   NewWireframeColor(anActor);
1607 }
1608
1609
1610 void VisuGUI::ChangeOpacity() {
1611   VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d();
1612   if(!aPrsObject) return;
1613
1614   VISU_Actor* anActor = GetActor(aPrsObject);  
1615   if (!anActor) return;
1616   NewOpacity(anActor);
1617 }
1618
1619
1620 void VisuGUI::ChangeLines() {
1621   VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d();
1622   if(!aPrsObject) return;
1623
1624   VISU_Actor* anActor = GetActor(aPrsObject);  
1625   if (!anActor) return;
1626   NewLinewidth(anActor);
1627 }
1628 void VisuGUI::PlotTable( VISU::Table_i* table, int theDisplaying )
1629 {
1630   if ( table && GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
1631     Plot2d_ViewFrame* aPlot = (Plot2d_ViewFrame*)GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame();
1632     if ( theDisplaying == VISU::eDisplayOnly ) 
1633       aPlot->EraseAll();
1634     QList<Plot2d_Curve> clist;
1635     aPlot->getCurves( clist );
1636     SALOMEDS::SObject_var TableSO = GetActiveStudy()->getStudyDocument()->FindObjectID( table->GetEntry() );
1637     if ( !TableSO->_is_nil() ) {
1638       SALOMEDS::ChildIterator_var Iter = GetActiveStudy()->getStudyDocument()->NewChildIterator( TableSO );
1639       for ( ; Iter->More(); Iter->Next() ) {
1640         CORBA::Object_var childObject = VISU::SObjectToObject( Iter->Value() );
1641         if( !CORBA::is_nil( childObject ) ) {
1642           CORBA::Object_ptr aCurve = VISU::Curve::_narrow( childObject );
1643           if( !CORBA::is_nil( aCurve ) ) {
1644             VISU::Curve_i* theCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
1645             Plot2d_Curve* plotCurve = 0;
1646             for ( int i = 0; i < clist.count(); i++ ) {
1647               if ( clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) ) {
1648                 plotCurve = clist.at( i );
1649                 break;
1650               }
1651             }
1652             if ( theDisplaying == VISU::eErase ) {
1653               if ( plotCurve ) {
1654                 aPlot->eraseCurve( plotCurve, false );
1655                 clist.remove( plotCurve );
1656               }
1657             }
1658             else if ( theDisplaying == VISU::eDisplay || theDisplaying == VISU::eDisplayOnly ) {
1659               if ( plotCurve ) {
1660                 plotCurve->setHorTitle( theCurve->GetHorTitle().c_str() );
1661                 //plotCurve->setVerTitle(  theCurve->GetVerTitle().c_str() );
1662                 plotCurve->setVerTitle( theCurve->GetName() );
1663                 plotCurve->setHorUnits( theCurve->GetHorUnits().c_str() );
1664                 plotCurve->setVerUnits( theCurve->GetVerUnits().c_str() );
1665                 /* - DATA NOT UPDATED */
1666                 double* xList = 0;
1667                 double* yList = 0;
1668                 int     nbPoints = theCurve->GetData( xList, yList );
1669                 if ( nbPoints > 0 && xList && yList ) {
1670                   plotCurve->setData( xList, yList, nbPoints );
1671                 }
1672                 if ( !theCurve->IsAuto() ) {
1673                   plotCurve->setLine( (Plot2d_Curve::LineType)theCurve->GetLine(), theCurve->GetLineWidth() );
1674                   plotCurve->setMarker( (Plot2d_Curve::MarkerType)theCurve->GetMarker() ); 
1675                   SALOMEDS::Color color = theCurve->GetColor();
1676                   plotCurve->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
1677                 }
1678                 plotCurve->setAutoAssign( theCurve->IsAuto() );
1679                 aPlot->displayCurve( plotCurve, false );
1680               }
1681               else {
1682                 Plot2d_Curve* crv = theCurve->CreatePresentation();
1683                 if ( crv ) {
1684                   aPlot->displayCurve( crv, false );
1685                   theCurve->SetLine( (VISU::Curve::LineType)crv->getLine(), crv->getLineWidth() );
1686                   theCurve->SetMarker( (VISU::Curve::MarkerType)crv->getMarker());
1687                   SALOMEDS::Color newColor;
1688                   newColor.R = crv->getColor().red()/255.;
1689                   newColor.G = crv->getColor().green()/255.;
1690                   newColor.B = crv->getColor().blue()/255.;
1691                   theCurve->SetColor( newColor );
1692                   crv->setAutoAssign( theCurve->IsAuto() );
1693                 }
1694               }
1695             }
1696           }
1697         }
1698       }
1699       aPlot->Repaint();
1700     }
1701   }
1702 }
1703 void VisuGUI::PlotCurve( VISU::Curve_i* theCurve, int theDisplaying )
1704 {
1705   if ( theCurve && GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
1706     Plot2d_ViewFrame* aPlot = (Plot2d_ViewFrame*)GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame();
1707 //  if ( theDisplaying == VISU::eDisplayOnly ) 
1708 //    aPlot->EraseAll();
1709     QList<Plot2d_Curve> clist;
1710     aPlot->getCurves( clist );
1711     Plot2d_Curve* plotCurve = 0;
1712     for ( int i = 0; i < clist.count(); i++ ) {
1713       if ( clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) ) {
1714         plotCurve = clist.at( i );
1715       }
1716       else if ( theDisplaying == VISU::eDisplayOnly ) {
1717         aPlot->eraseCurve( clist.at( i ) );
1718       }
1719     }
1720     if ( theDisplaying == VISU::eErase ) {
1721       if ( plotCurve )
1722         aPlot->eraseCurve( plotCurve, false );
1723     }
1724     else if ( theDisplaying == VISU::eDisplay || theDisplaying == VISU::eDisplayOnly ) {
1725       if ( plotCurve ) {
1726         plotCurve->setHorTitle( theCurve->GetHorTitle().c_str() );
1727         //plotCurve->setVerTitle( ( theCurve->GetVerTitle().c_str() ) );
1728         plotCurve->setVerTitle( theCurve->GetName() );
1729         plotCurve->setHorUnits( theCurve->GetHorUnits().c_str() );
1730         plotCurve->setVerUnits( theCurve->GetVerUnits().c_str() );
1731         double* xList = 0;
1732         double* yList = 0;
1733         int     nbPoints = theCurve->GetData( xList, yList );
1734         if ( nbPoints > 0 && xList && yList ) {
1735           plotCurve->setData( xList, yList, nbPoints );
1736         }
1737         if ( !theCurve->IsAuto() ) {
1738           plotCurve->setLine( (Plot2d_Curve::LineType)theCurve->GetLine(), theCurve->GetLineWidth() );
1739           plotCurve->setMarker( (Plot2d_Curve::MarkerType)theCurve->GetMarker() ); 
1740           SALOMEDS::Color color = theCurve->GetColor();
1741           plotCurve->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
1742         }
1743         plotCurve->setAutoAssign( theCurve->IsAuto() );
1744         aPlot->displayCurve( plotCurve, false );
1745       }
1746       else {
1747         Plot2d_Curve* crv = theCurve->CreatePresentation();
1748         if ( crv ) {
1749           aPlot->displayCurve( crv, false );
1750           theCurve->SetLine( (VISU::Curve::LineType)crv->getLine(), crv->getLineWidth() );
1751           theCurve->SetMarker( (VISU::Curve::MarkerType)crv->getMarker());
1752           SALOMEDS::Color newColor;
1753           newColor.R = crv->getColor().red()/255.;
1754           newColor.G = crv->getColor().green()/255.;
1755           newColor.B = crv->getColor().blue()/255.;
1756           theCurve->SetColor( newColor );
1757           crv->setAutoAssign( theCurve->IsAuto() );
1758         }
1759       }
1760     }
1761     aPlot->Repaint();
1762   }
1763 }
1764 void VisuGUI::PlotContainer( VISU::Container_i* container, int theDisplaying )
1765 {
1766   if ( container && GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
1767     Plot2d_ViewFrame* aPlot = (Plot2d_ViewFrame*)GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame();
1768     if ( theDisplaying == VISU::eDisplayOnly ) 
1769       aPlot->EraseAll();
1770     QList<Plot2d_Curve> clist;
1771     aPlot->getCurves( clist );
1772     if ( container->GetNbCurves() > 0 ) {
1773       int nbCurves = container->GetNbCurves();
1774       for ( int k = 1; k <= nbCurves; k++ ) {
1775         VISU::Curve_i* theCurve = container->GetCurve( k );
1776         if ( theCurve && theCurve->IsValid() ) {
1777           Plot2d_Curve* plotCurve = aPlot->getCurveByIO( new SALOME_InteractiveObject( theCurve->GetEntry(), "", "" ) );
1778 //        for ( int i = 0; i < clist.count(); i++ ) {
1779 //          if ( clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) ) {
1780 //            plotCurve = clist.at( i );
1781 //            break;
1782 //          }
1783 //        }
1784           if ( theDisplaying == VISU::eErase ) {
1785             if ( plotCurve ) {
1786               aPlot->eraseCurve( plotCurve, false );
1787               clist.remove( plotCurve );
1788             }
1789           }
1790           else if ( theDisplaying == VISU::eDisplay || theDisplaying == VISU::eDisplayOnly ) {
1791             if ( plotCurve ) {
1792               plotCurve->setHorTitle( theCurve->GetHorTitle().c_str() );
1793               //plotCurve->setVerTitle( ( theCurve->GetVerTitle().c_str() ) );
1794               plotCurve->setVerTitle( theCurve->GetName() );
1795               plotCurve->setHorUnits( theCurve->GetHorUnits().c_str() );
1796               plotCurve->setVerUnits( theCurve->GetVerUnits().c_str() );
1797               double* xList = 0;
1798               double* yList = 0;
1799               int     nbPoints = theCurve->GetData( xList, yList );
1800               if ( nbPoints > 0 && xList && yList ) {
1801                 plotCurve->setData( xList, yList, nbPoints );
1802               }
1803               if ( !theCurve->IsAuto() ) {
1804                 plotCurve->setLine( (Plot2d_Curve::LineType)theCurve->GetLine(), theCurve->GetLineWidth() );
1805                 plotCurve->setMarker( (Plot2d_Curve::MarkerType)theCurve->GetMarker() ); 
1806                 SALOMEDS::Color color = theCurve->GetColor();
1807                 plotCurve->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
1808               }
1809               plotCurve->setAutoAssign( theCurve->IsAuto() );
1810               aPlot->displayCurve( plotCurve, false );
1811             }
1812             else {
1813               Plot2d_Curve* crv = theCurve->CreatePresentation();
1814               if ( crv ) {
1815                 aPlot->displayCurve( crv, false );
1816                 theCurve->SetLine( (VISU::Curve::LineType)crv->getLine(), crv->getLineWidth() );
1817                 theCurve->SetMarker( (VISU::Curve::MarkerType)crv->getMarker());
1818                 SALOMEDS::Color newColor;
1819                 newColor.R = crv->getColor().red()/255.;
1820                 newColor.G = crv->getColor().green()/255.;
1821                 newColor.B = crv->getColor().blue()/255.;
1822                 theCurve->SetColor( newColor );
1823                 crv->setAutoAssign( theCurve->IsAuto() );
1824               }
1825             }
1826           }
1827         }
1828       }
1829     }
1830     aPlot->Repaint();
1831   }
1832 }
1833
1834 /*!
1835   Slot : opens Table view : for Table object or SObject with table attribute selected
1836 */
1837 void VisuGUI::ShowTable() {
1838   SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
1839   if( Sel->IObjectCount() !=1 )
1840     return;
1841   Handle(SALOME_InteractiveObject) anIO;
1842   CORBA::Object_var anObject = GetSelectedObj(&anIO);
1843   SALOMEDS::SObject_var SO;
1844   if ( !CORBA::is_nil( anObject ) ) {
1845     VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
1846     if ( !CORBA::is_nil( aVisuObj ) && aVisuObj->GetType() == VISU::TTABLE ) {
1847       CORBA::Object_ptr aTable = VISU::Table::_narrow( anObject );
1848       if( !CORBA::is_nil( aTable ) ) {
1849         VISU::Table_i* table = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTable).in());
1850         if ( table ) {
1851           SO = GetActiveStudy()->getStudyDocument()->FindObjectID( table->GetObjectEntry() );
1852         }
1853       }
1854     } 
1855   } else {
1856     // possibly this is Table SObject
1857     SO = GetActiveStudy()->getStudyDocument()->FindObjectID( anIO->getEntry() );
1858   }
1859
1860   if(!IsSObjectTable(SO))
1861     return;
1862
1863   SALOMEGUI_TableDlg* dlg = new SALOMEGUI_TableDlg( QAD_Application::getDesktop(),
1864                                                     SO, 
1865                                                     false, 
1866                                                    //SAL2670 Orientation of show tables
1867                                                     SALOMEGUI_TableDlg::ttAuto, 
1868                                                     Qt::Vertical );
1869   dlg->show();
1870 }
1871
1872
1873 /*!
1874   Slot : opens Table view : for Table object or SObject with table attribute selected
1875 */
1876 void VisuGUI::CreateTable() {
1877   SALOME_Selection* aSel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
1878   if( aSel->IObjectCount() !=1 )
1879     return;
1880
1881   Handle(SALOME_InteractiveObject) anIO = aSel->firstIObject();
1882   if (anIO->hasEntry()){
1883     SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument();
1884     SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(anIO->getEntry());
1885     if(!aSObject->_is_nil()) {
1886       CORBA::Object_var anObject = VISU::SObjectToObject(aSObject);
1887       VISU::CutLines_var aCutLines = VISU::CutLines::_narrow( anObject );
1888       if(!aCutLines->_is_nil() || IsSObjectTable(aSObject)) {
1889         GetVisuGen()->CreateTable(aSObject->GetID());
1890         GetActiveStudy()->updateObjBrowser();
1891       }
1892     }
1893   }
1894 }
1895
1896
1897 /*!
1898   Slot : deletes SObject with all subobjects
1899 */
1900 void VisuGUI::DeleteObject() {
1901   SALOMEDS::Study_var aStudy = GetStudyDocument();
1902   if (checkLock(aStudy)) return;
1903
1904   SALOME_Selection* aSel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
1905   if( aSel->IObjectCount() !=1 )
1906     return;
1907   Handle(SALOME_InteractiveObject) anIO = aSel->firstIObject();
1908   if (anIO->hasEntry()){
1909     SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(anIO->getEntry());
1910     if(!aSObject->_is_nil()){
1911       SALOMEDS::ChildIterator_var aChildIter = aStudy->NewChildIterator(aSObject);
1912       for(aChildIter->InitEx(true); aChildIter->More(); aChildIter->Next()){
1913         SALOMEDS::SObject_var aChildSObject = aChildIter->Value();
1914         CORBA::Object_var aChildObj = VISU::SObjectToObject(aChildSObject);
1915         ::ErasePrs(aChildObj);
1916       }
1917       SALOMEDS::StudyBuilder_var aStudyBuilder = VisuGUI::NewBuilder();
1918       // There is a transaction
1919       aStudyBuilder->NewCommand();
1920       CORBA::Object_var anObj = VISU::SObjectToObject(aSObject);
1921       if(!CORBA::is_nil(anObj)){
1922         VISU::Base_var aBase = VISU::Base::_narrow(anObj);
1923         if(!CORBA::is_nil(aBase)){
1924           VISU::VISUType aType = aBase->GetType();
1925           switch (aType){
1926           case VISU::TRESULT:{
1927             SALOMEDS::ChildIterator_var aChildIter = aStudy->NewChildIterator(aSObject);
1928             for(aChildIter->InitEx(true); aChildIter->More(); aChildIter->Next()){
1929               SALOMEDS::SObject_var aChildSObject = aChildIter->Value();
1930               CORBA::Object_var aChildObj = VISU::SObjectToObject(aChildSObject);
1931               if(CORBA::is_nil(aChildObj)) continue;
1932               VISU::Prs3d_var aPrs3d = VISU::Prs3d::_narrow(aChildObj);
1933               if(CORBA::is_nil(aPrs3d)) continue;
1934               VISU::Prs3d_i* pPrs3d = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(aPrs3d).in());
1935               DeletePresentation(pPrs3d);
1936             }
1937             break;
1938           }}
1939         }
1940       }
1941       aStudyBuilder->RemoveObjectWithChildren(aSObject);
1942       aStudyBuilder->CommitCommand();
1943       GetActiveStudy()->unHighlightAll();
1944       GetActiveStudy()->updateObjBrowser(true);
1945     }
1946   }
1947 }
1948
1949
1950 /*!
1951   Slot : deletes empty container
1952 */
1953 void VisuGUI::CreatePlot2dView() {
1954   if (checkLock(GetStudyDocument())) return;
1955   GetVisuGen()->CreateContainer();
1956   GetActiveStudy()->updateObjBrowser( true );
1957 }
1958
1959
1960
1961 /*!
1962   Opens dialog box for curves creation. Acts only for selected SObject with table attribute.
1963 */
1964 void VisuGUI::PlotData() {
1965   SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
1966   if( Sel->IObjectCount() !=1 )
1967     return;
1968   CORBA::Object_var anObject = GetSelectedObj();
1969   SALOMEDS::SObject_var SO;
1970   if ( !CORBA::is_nil( anObject ) ) {
1971     VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
1972     if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TTABLE) {
1973       // Table (VISU object) is selected
1974       CORBA::Object_ptr aTbl = VISU::Table::_narrow( anObject );
1975       if( !CORBA::is_nil( aTbl ) ) {
1976         VISU::Table_i* table = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTbl).in());
1977         if ( table ) {
1978           SALOMEDS::GenericAttribute_var anAttr;
1979           SALOMEDS::AttributeName_var    aName;
1980           QString SOName;
1981           SALOMEDS::SObject_var SO = GetActiveStudy()->getStudyDocument()->FindObjectID( table->GetObjectEntry() );
1982           if ( IsSObjectTable(SO) ) {
1983             // get name of SObject
1984             if ( SO->FindAttribute( anAttr, "AttributeName" ) ) {
1985               aName = SALOMEDS::AttributeName::_narrow( anAttr );
1986               SOName = aName->Value();
1987             }
1988             Plot2d_SetupPlot2dDlg* dlg = new Plot2d_SetupPlot2dDlg( SO, QAD_Application::getDesktop() );
1989             if ( dlg->exec() == QDialog::Accepted ) {
1990               if ( !isStudyLocked( GetActiveStudy()->getStudyDocument() ) ) {
1991                 // if study is not locked - create new container, create curves
1992                 // and insert them into container, then plot container if current viewer is of VIEW_PLOT2D type
1993                 int horIndex;
1994                 QValueList<int> verIndices;
1995                 dlg->getCurvesSource( horIndex, verIndices );
1996                 if ( horIndex >= 0 && verIndices.count() > 0 ) { 
1997                   CORBA::Object_var aContainer = GetVisuGen()->CreateContainer();
1998                   if( !CORBA::is_nil( aContainer ) ) {
1999                     VISU::Container_i* pContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
2000                     if ( pContainer ) {
2001                       for ( int i = 0; i < verIndices.count(); i++ ) {
2002                         CORBA::Object_var aNewCurve = GetVisuGen()->CreateCurve( table->_this(), horIndex+1, verIndices[i]+1 );
2003                         if( !CORBA::is_nil( aNewCurve ) ) {
2004                           VISU::Curve_i* pCrv = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aNewCurve).in());
2005                           if ( pCrv ) {
2006                             bool isAuto;
2007                             int  marker, line, lineWidth;
2008                             QColor color;
2009                             if ( dlg->getCurveAttributes( verIndices[i], isAuto, marker, line, lineWidth, color ) && !isAuto ) {
2010                               SALOMEDS::Color c; c.R = color.red()/255.; c.G = color.green()/255.; c.B = color.blue()/255.;
2011                               pCrv->SetColor( c );
2012                               pCrv->SetMarker( ( VISU::Curve::MarkerType )marker );
2013                               pCrv->SetLine( ( VISU::Curve::LineType )line, lineWidth );
2014                             }
2015                             pContainer->AddCurve( pCrv->_this() );
2016                           }
2017                         }
2018                       }
2019                       GetActiveStudy()->updateObjBrowser( true );
2020                       PlotContainer( pContainer, VISU::eDisplay );
2021                     }
2022                   }
2023                 }
2024               }
2025               else {
2026                 // if study is locked just get curves info and plot them if current viewer is of VIEW_PLOT2D type
2027                 Plot2d_CurveContainer container;
2028                 dlg->getCurves( container );
2029                 if ( !container.isEmpty() ) {
2030                   ((Plot2d_ViewFrame*)(GetActiveStudy()->getActiveStudyFrame()->
2031                                        getRightFrame()->getViewFrame()))->displayCurves( container, true );
2032                   ((Plot2d_ViewFrame*)(GetActiveStudy()->getActiveStudyFrame()->
2033                                        getRightFrame()->getViewFrame()))->setTitle( SOName );
2034                 }
2035               }
2036             }
2037             delete dlg;
2038           }
2039         }
2040       }
2041     }
2042   }
2043   else {
2044     // possibly this is Table SObject
2045     SALOMEDS::GenericAttribute_var anAttr;
2046     SALOMEDS::AttributeName_var    aName;
2047     QString SOName;
2048       
2049     // check if Table SObject is selected
2050     SALOMEDS::SObject_var SO = GetActiveStudy()->getStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() );
2051     if ( IsSObjectTable(SO) ) {
2052       // get name of SObject
2053       if ( SO->FindAttribute( anAttr, "AttributeName" ) ) {
2054         aName = SALOMEDS::AttributeName::_narrow( anAttr );
2055         SOName = aName->Value();
2056       }
2057       Plot2d_SetupPlot2dDlg* dlg = new Plot2d_SetupPlot2dDlg( SO, QAD_Application::getDesktop() );
2058       if ( dlg->exec() == QDialog::Accepted ) {
2059         if ( !isStudyLocked( GetActiveStudy()->getStudyDocument() ) ) {
2060           // if study is not locked - create new table and container objects, create curves
2061           // and insert them into container, then plot container if current viewer is of VIEW_PLOT2D type
2062           int horIndex;
2063           QValueList<int> verIndices;
2064           dlg->getCurvesSource( horIndex, verIndices );
2065           if ( horIndex >= 0 && verIndices.count() > 0 ) { 
2066             CORBA::Object_var aTable = GetVisuGen()->CreateTable( SO->GetID() );
2067             CORBA::Object_var aContainer = GetVisuGen()->CreateContainer();
2068             if ( !CORBA::is_nil( aTable ) && !CORBA::is_nil( aContainer ) ) {
2069               VISU::Table_i*     pTable     = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTable).in());
2070               VISU::Container_i* pContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
2071             
2072               if ( pContainer && pTable ) {
2073                 for ( int i = 0; i < verIndices.count(); i++ ) {
2074                   CORBA::Object_var aNewCurve = GetVisuGen()->CreateCurve( pTable->_this(), horIndex+1, verIndices[i]+1 );
2075                   if( !CORBA::is_nil( aNewCurve ) ) {
2076                     VISU::Curve_i* pCrv = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aNewCurve).in());
2077                     if ( pCrv ) {
2078                       bool isAuto;
2079                       int  marker, line, lineWidth;
2080                       QColor color;
2081                       if ( dlg->getCurveAttributes( verIndices[i], isAuto, marker, line, lineWidth, color ) && !isAuto ) {
2082                         SALOMEDS::Color c; c.R = color.red()/255.; c.G = color.green()/255.; c.B = color.blue()/255.;
2083                         pCrv->SetColor( c );
2084                         pCrv->SetMarker( ( VISU::Curve::MarkerType )marker );
2085                         pCrv->SetLine( ( VISU::Curve::LineType )line, lineWidth );
2086                       }
2087                       pContainer->AddCurve( pCrv->_this() );
2088                     }
2089                   }
2090                 }
2091                 GetActiveStudy()->updateObjBrowser( true );
2092                 PlotContainer( pContainer, VISU::eDisplay );
2093               }
2094             }
2095           }
2096         } else {
2097           // if study is locked just get curves info and plot them if current viewer is of VIEW_PLOT2D type
2098           if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
2099             Plot2d_CurveContainer container;
2100             dlg->getCurves( container );
2101             if ( !container.isEmpty() ) {
2102               ((Plot2d_ViewFrame*)(GetActiveStudy()->getActiveStudyFrame()->
2103                                    getRightFrame()->getViewFrame()))->displayCurves( container, true );
2104               ((Plot2d_ViewFrame*)(GetActiveStudy()->getActiveStudyFrame()->
2105                                    getRightFrame()->getViewFrame()))->setTitle( SOName );
2106             }
2107           }
2108         }
2109       }
2110       delete dlg;
2111     } 
2112   }
2113 }
2114
2115
2116 void VisuGUI::CreatePlot(SALOMEDS::SObject_var theTableSO) {
2117   SALOMEDS::GenericAttribute_var anAttr;
2118   SALOMEDS::AttributeName_var    aName;
2119
2120   if ( IsSObjectTable(theTableSO) ) {
2121     CORBA::Object_var aTable = VISU::SObjectToObject(theTableSO);
2122     CORBA::Object_var aContainer = GetVisuGen()->CreateContainer();
2123     if ( !CORBA::is_nil( aTable ) && !CORBA::is_nil( aContainer ) ) {
2124       VISU::Table_i*     pTable     = dynamic_cast<VISU::Table_i*>( VISU::GetServant(aTable).in() );
2125       VISU::Container_i* pContainer = dynamic_cast<VISU::Container_i*>( VISU::GetServant(aContainer).in() );
2126       
2127       if ( pContainer && pTable ) {
2128         for ( int i = 2; i <= pTable->GetNbRows(); i++ ) {
2129           CORBA::Object_var aNewCurve = GetVisuGen()->CreateCurve( pTable->_this(), 1, i );
2130           if( !CORBA::is_nil( aNewCurve ) ) {
2131             VISU::Curve_i* pCrv = dynamic_cast<VISU::Curve_i*>( VISU::GetServant(aNewCurve).in() );
2132             if ( pCrv ) {
2133               pContainer->AddCurve( pCrv->_this() );
2134             }
2135           }
2136         }
2137         GetActiveStudy()->updateObjBrowser( true );
2138         PlotContainer( pContainer, VISU::eDisplay );
2139       }
2140     }
2141   }
2142 }
2143
2144
2145 /*!
2146   Slot : Opens "Setup curve" dialog to set curve properties : for Curve object selected
2147 */
2148 void VisuGUI::CurveProperties() {
2149   SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2150   if( Sel->IObjectCount() !=1 )
2151     return;
2152   CORBA::Object_var anObject = GetSelectedObj();
2153   SALOMEDS::SObject_var SO;
2154   if (CORBA::is_nil( anObject )) return;
2155
2156   VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
2157   if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCURVE) {
2158     // Curve object
2159     CORBA::Object_ptr aCurve = VISU::Curve::_narrow( anObject );
2160     if( !CORBA::is_nil( aCurve ) ) {
2161       VISU::Curve_i* curve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
2162       if ( curve && !isStudyLocked( GetActiveStudy()->getStudyDocument() ) ) {
2163         SALOMEGUI_SetupCurveDlg* dlg = new SALOMEGUI_SetupCurveDlg( QAD_Application::getDesktop() );    
2164         dlg->setLine( (int)curve->GetLine(), curve->GetLineWidth() );
2165         dlg->setMarker( (int)curve->GetMarker() );
2166         SALOMEDS::Color color = curve->GetColor();
2167         dlg->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
2168         if( dlg->exec() == QDialog::Accepted ) {
2169           curve->SetLine( (VISU::Curve::LineType)dlg->getLine(), dlg->getLineWidth() );
2170           curve->SetMarker( (VISU::Curve::MarkerType)dlg->getMarker());
2171           SALOMEDS::Color newColor;
2172           newColor.R = dlg->getColor().red()/255.;
2173           newColor.G = dlg->getColor().green()/255.;
2174           newColor.B = dlg->getColor().blue()/255.;
2175           curve->SetColor( newColor );
2176           QList<QAD_StudyFrame> sfList = GetActiveStudy()->getStudyFrames();
2177           if ( sfList.count() > 0 ) {
2178             QListIterator<QAD_StudyFrame> it( sfList );
2179             for ( ; it.current(); ++it ) {
2180               if ( it.current()->getTypeView() == VIEW_PLOT2D ) {
2181                 Plot2d_ViewFrame* aPlot = (Plot2d_ViewFrame*)it.current()->getRightFrame()->getViewFrame();
2182                 Handle(SALOME_InteractiveObject) IO = aPlot->FindIObject( curve->GetEntry() );
2183                 if ( IO.IsNull() )
2184                   continue;
2185                 Plot2d_Curve* plotCurve = aPlot->getCurveByIO( IO );
2186                 if ( plotCurve ) {
2187                   plotCurve->setLine( (Plot2d_Curve::LineType)dlg->getLine(), dlg->getLineWidth() );
2188                   plotCurve->setMarker( (Plot2d_Curve::MarkerType)dlg->getMarker() );
2189                   plotCurve->setColor( dlg->getColor() );
2190                   aPlot->updateCurve( plotCurve, true );
2191                 }
2192               }
2193             }
2194           }
2195         }
2196       } 
2197     }
2198   }
2199 }
2200
2201
2202 /*!
2203   Slot : Clears container contents : for Container object selected
2204 */
2205 void VisuGUI::ClearContainer() {
2206   SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2207   if( Sel->IObjectCount() !=1 )
2208     return;
2209
2210   CORBA::Object_var anObject = GetSelectedObj();
2211   SALOMEDS::SObject_var SO;
2212   if (CORBA::is_nil( anObject )) return;
2213
2214   VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
2215   if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCONTAINER) {
2216     // Container object
2217     CORBA::Object_ptr aCnt = VISU::Container::_narrow( anObject );
2218     if( !CORBA::is_nil( aCnt ) ) {
2219       VISU::Container_i* container = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aCnt).in());
2220       if ( container && container->GetNbCurves() > 0 && !isStudyLocked( GetActiveStudy()->getStudyDocument() ) ) {
2221         container->Clear();
2222         GetActiveStudy()->updateObjBrowser();
2223       }
2224     }
2225   }
2226 }
2227
2228 /*!
2229   Slot : Edit container contents : for Container object selected
2230 */
2231 void VisuGUI::EditContainer() {
2232   CORBA::Object_var anObject = GetSelectedObj();
2233   if(CORBA::is_nil(anObject)) return;
2234   PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
2235   if(!aServant.in()) return;
2236   VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(aServant.in());
2237   if(!aContainer) return;
2238   
2239   VisuGUI_EditContainerDlg* aDlg = new VisuGUI_EditContainerDlg();
2240   aDlg->initFromPrsObject(aContainer);
2241   if (aDlg->exec()) {
2242     aDlg->storeToPrsObject(aContainer);
2243     GetActiveStudy()->updateObjBrowser( true );
2244   }
2245   delete aDlg;
2246 }
2247
2248
2249 void VisuGUI::DeletePrs() {
2250   SALOMEDS::Study_var aStudy = GetStudyDocument();
2251   if (checkLock(aStudy)) return;
2252   
2253   // There is a transaction
2254   SALOMEDS::StudyBuilder_var aStudyBuilder = VisuGUI::NewBuilder();
2255   aStudyBuilder->NewCommand();
2256
2257   DeletePresentation(GetSelectedPrs3d());
2258
2259   aStudyBuilder->CommitCommand();
2260 }
2261
2262
2263 void VisuGUI::SaveViewParams()
2264 {
2265   if (checkLock(GetStudyDocument())) return;
2266   SALOME_Selection* aSel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2267   QAD_StudyFrame* aStudyFrame = GetActiveStudy()->getActiveStudyFrame();
2268   if ( aSel->IObjectCount() > 1 || aStudyFrame->getTypeView() != VIEW_VTK ) 
2269     return;
2270   if ( aSel->IObjectCount()  == 0 ) {
2271     VISU::View3D_i::SaveViewParams(aStudyFrame,VISU::View3D_i::GenerateViewParamsName().latin1());
2272   }else{
2273     const Handle(SALOME_InteractiveObject)& anIO = aSel->firstIObject();
2274     VISU::View3D_i::SaveViewParams(aStudyFrame,anIO->getName());
2275   }
2276   GetActiveStudy()->updateObjBrowser( true );
2277 }
2278
2279
2280 void VisuGUI::RestoreViewParams()
2281 {
2282   SALOME_Selection* aSel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2283   QAD_StudyFrame* aStudyFrame = GetActiveStudy()->getActiveStudyFrame();
2284   if ( aSel->IObjectCount() > 1 || aStudyFrame->getTypeView() != VIEW_VTK ) 
2285     return;
2286   const Handle(SALOME_InteractiveObject)& anIO = aSel->firstIObject();
2287   VISU::View3D_i::RestoreViewParams(aStudyFrame,anIO->getName());
2288 }
2289
2290
2291 //=====================================================================================
2292 // function : DeleteViewParams()
2293 // purpose  :
2294 //=====================================================================================
2295 void VisuGUI::DeleteViewParams() {
2296   bool isExist;
2297   VISU::Storable::TRestoringMap aMap;
2298   Handle(SALOME_InteractiveObject) anIO;    
2299   CORBA::Object_var anObject = GetSelectedObj(&anIO,GetActiveStudy(),&aMap);
2300   VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt();
2301   if(isExist && aType == VISU::TVIEW3D){
2302     SALOMEDS::Study_var aStudy = GetStudyDocument();
2303     SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(anIO->getEntry());
2304     aStudy->NewBuilder()->RemoveObject(aSObject);
2305
2306     SALOME_Selection* aSel = SALOME_Selection::Selection(GetActiveStudy()->getSelection());
2307     aSel->RemoveIObject(anIO, 0);
2308
2309     GetActiveStudy()->updateObjBrowser( true );
2310   }
2311 }
2312
2313
2314 //=====================================================================================
2315 // function : Sweep()
2316 // purpose  :
2317 //=====================================================================================
2318 void VisuGUI::Sweep() {
2319   VISU::ScalarMap_i* aPrsObject = dynamic_cast<VISU::ScalarMap_i*>(GetSelectedPrs3d());
2320   if (!aPrsObject) return;
2321
2322   VTKViewer_ViewFrame* vf = VisuGUI::GetVtkViewFrame();
2323   if(!vf) return;
2324
2325   int aTemp=100000;
2326   QString aTempoStr = QAD_CONFIG->getSetting("Visu:SweepTempo");
2327   if ( !aTempoStr.isEmpty() )
2328     aTemp = int(1.E6*(aTempoStr.toFloat()));
2329
2330   int aCycles=1;
2331   QString aCyclesStr = QAD_CONFIG->getSetting("Visu:SweepCycles");
2332   if ( !aCyclesStr.isEmpty() )
2333     aCycles = aCyclesStr.toInt();
2334
2335   int aSteps=40;
2336   QString aStepsStr = QAD_CONFIG->getSetting("Visu:SweepSteps");
2337   if ( !aStepsStr.isEmpty() )
2338     aSteps = aStepsStr.toInt();
2339
2340   VISU_Actor* aActor = GetActor(aPrsObject);
2341   if (!aActor) return;
2342   
2343   if (!aActor->GetVisibility()) {
2344     aActor->VisibilityOn();
2345   }
2346
2347   QApplication::setOverrideCursor( Qt::waitCursor );
2348   try{
2349     for (int j=0 ; j<aCycles; j++) {
2350       for (int i=0 ; i<=aSteps; i++) {
2351         float aPercents = float(i)/aSteps;
2352         aPrsObject->SetMapScale(aPercents);
2353         aPrsObject->UpdateActor(aActor);
2354         vf->getRW()->getRenderWindow()->Render();
2355         usleep(aTemp);
2356       }
2357     }
2358   }catch(std::exception& exc){
2359     INFOS("Follow exception was occured :\n"<<exc.what());
2360   }catch(...){
2361     INFOS("Unknown exception was occured!");
2362   }
2363   QApplication::restoreOverrideCursor();
2364 }
2365
2366
2367
2368 void VisuGUI::TimeAnimation() {
2369   VisuGUI_TimeAnimationDlg* aAnimationDlg = new VisuGUI_TimeAnimationDlg(GetStudyDocument());
2370   SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2371   
2372   bool isDefined = false;
2373   long aNbTimes = 0;
2374   SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
2375   for (; It.More(); It.Next()) {
2376     SALOMEDS::SObject_var aSObject  = GetStudyDocument()->FindObjectID( It.Value()->getEntry() ); 
2377     if (aSObject->_is_nil()) continue;
2378     if (getValue(aSObject, "myComment") == QString("FIELD")) {
2379       long aNumber = getValue(aSObject, "myNbTimeStamps").toLong();
2380       if (aNumber > 1) {
2381         if (!isDefined) {
2382           aNbTimes = aNumber;
2383           aAnimationDlg->addField(aSObject);
2384           isDefined = true;
2385         } else if (aNbTimes == aNumber) {
2386           aAnimationDlg->addField(aSObject);
2387         }
2388       }
2389     }
2390   }
2391   if (isDefined) aAnimationDlg->show();
2392   else delete aAnimationDlg;
2393 }
2394
2395
2396 void VisuGUI::ImportMedField() {
2397   if (checkLock(GetStudyDocument())) return;
2398   SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2399   SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
2400   QApplication::setOverrideCursor( Qt::waitCursor );
2401   for(;It.More();It.Next()) {
2402     Handle(SALOME_InteractiveObject) anIO = It.Value();
2403     SALOMEDS::SObject_var aSObject = GetStudyDocument()->FindObjectID(anIO->getEntry());
2404     if(!aSObject->_is_nil()){
2405       CORBA::Object_var anObject = VISU::SObjectToObject(aSObject);
2406       if(!CORBA::is_nil(anObject)){
2407         SALOME_MED::MED_var aMED = SALOME_MED::MED::_narrow( anObject );
2408         if(!CORBA::is_nil(aMED.in()))
2409           GetVisuGen()->ImportMed( aSObject );
2410         SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow( anObject );
2411         if(!CORBA::is_nil(aField.in()))
2412           GetVisuGen()->ImportMedField( aField );
2413       }else{
2414         SALOMEDS::SObject_var aSFather = aSObject->GetFather();
2415         SALOMEDS::GenericAttribute_var anAttr;
2416         aSFather->FindAttribute(anAttr, "AttributeName");
2417         SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
2418         CORBA::String_var aValue = aName->Value();
2419         if(strcmp(aValue.in(),"MEDFIELD") == 0)
2420           GetVisuGen()->ImportMed(aSObject);
2421         //if(strcmp(aValue.in(),"MEDMESH") == 0)
2422         //  VisuGUI::myComponent->ImportMed(aSObject);
2423       }
2424     }
2425   }
2426   GetActiveStudy()->updateObjBrowser( true );
2427   QApplication::restoreOverrideCursor();
2428 }
2429
2430 //=====================================================================================
2431 // functions : Rename()
2432 // purpose  :
2433 //=====================================================================================
2434 void VisuGUI::Rename() {
2435   if (checkLock(GetStudyDocument())) return;
2436   SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2437   if ( Sel->IObjectCount() != 1 )
2438     return;
2439   SALOMEDS::SObject_var aSObj = GetStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() );
2440   if( aSObj->_is_nil() ) return;
2441    
2442   VISU::Curve_i* curve = 0;
2443   CORBA::Object_var anObject = GetSelectedObj();
2444   if ( !CORBA::is_nil( anObject )) {
2445     VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
2446     if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCURVE) {
2447       // Curve object
2448       CORBA::Object_ptr aCurve = VISU::Curve::_narrow( anObject );
2449       if( !CORBA::is_nil( aCurve ) ) {
2450         curve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
2451       }
2452     }
2453   }
2454
2455   //TEST DU PARENT == VISU
2456   SALOMEDS::GenericAttribute_var anAttr;  
2457   SALOMEDS::AttributeName_var    aName;
2458   if ( aSObj->FindAttribute(anAttr, "AttributeName") ) {
2459     aName = SALOMEDS::AttributeName::_narrow( anAttr );
2460     QString Name = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), aName->Value() );
2461     if ( !Name.isEmpty() ) {
2462       QApplication::setOverrideCursor( Qt::waitCursor );
2463       if ( curve )
2464         curve->SetName( Name.latin1() );
2465       GetActiveStudy()->renameIObject( Sel->firstIObject(), Name );
2466       QApplication::restoreOverrideCursor();
2467       
2468       //int TypeMode;  bool InViewer;
2469       //VISU_Actor *ActorTmp = ActorSelected(parent,InViewer,&TypeMode);
2470       //ActorTmp->setName((Standard_CString)Name.latin1());
2471     }
2472   }
2473 }
2474
2475 //=====================================================================================
2476 // functions : RenameTable()
2477 // purpose  :
2478 //=====================================================================================
2479 void VisuGUI::RenameTable() {
2480   if (checkLock(GetStudyDocument())) return;
2481   SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2482   if ( Sel->IObjectCount() != 1 )
2483     return;
2484   SALOMEDS::SObject_var aSObj = GetStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() );
2485   if( aSObj->_is_nil() ) return;
2486    
2487   VISU::Table_i* table = 0;
2488   CORBA::Object_var anObject = GetSelectedObj();
2489   if ( !CORBA::is_nil( anObject )) {
2490     VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
2491     if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TTABLE) {
2492       // Table object
2493       CORBA::Object_ptr aTable = VISU::Table::_narrow( anObject );
2494       if( !CORBA::is_nil( aTable ) ) {
2495         table = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTable).in());
2496       }
2497     }
2498   }
2499
2500   //TEST DU PARENT == VISU
2501   SALOMEDS::GenericAttribute_var anAttr;  
2502   SALOMEDS::AttributeName_var    aName;
2503   if ( aSObj->FindAttribute(anAttr, "AttributeName") ) {
2504     aName = SALOMEDS::AttributeName::_narrow( anAttr );
2505     QString Name = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), aName->Value() );
2506     if ( !Name.isEmpty() ) {
2507       QApplication::setOverrideCursor( Qt::waitCursor );
2508       if ( table )
2509         table->SetName( Name.latin1() );
2510       GetActiveStudy()->renameIObject( Sel->firstIObject(), Name );
2511       QApplication::restoreOverrideCursor();
2512       
2513       //int TypeMode;  bool InViewer;
2514       //VISU_Actor *ActorTmp = ActorSelected(parent,InViewer,&TypeMode);
2515       //ActorTmp->setName((Standard_CString)Name.latin1());
2516     }
2517   }
2518 }
2519
2520
2521
2522 //=====================================================================================
2523 // functions : RenameContainer()
2524 // purpose  :
2525 //=====================================================================================
2526 void VisuGUI::RenameContainer() {
2527   if (checkLock(GetStudyDocument())) return;
2528   SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2529   if ( Sel->IObjectCount() != 1 )
2530     return;
2531   SALOMEDS::SObject_var aSObj = GetStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() );
2532   if( aSObj->_is_nil() ) return;
2533    
2534   VISU::Container_i* container = 0;
2535   CORBA::Object_var anObject = GetSelectedObj();
2536   if ( !CORBA::is_nil( anObject )) {
2537     VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
2538     if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCONTAINER) {
2539       // Curve object
2540       CORBA::Object_ptr aContainer = VISU::Container::_narrow( anObject );
2541       if( !CORBA::is_nil( aContainer ) ) {
2542         container = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
2543       }
2544     }
2545   }
2546
2547   //TEST DU PARENT == VISU
2548   SALOMEDS::GenericAttribute_var anAttr;  
2549   SALOMEDS::AttributeName_var    aName;
2550   if ( aSObj->FindAttribute(anAttr, "AttributeName") ) {
2551     aName = SALOMEDS::AttributeName::_narrow( anAttr );
2552     QString Name = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), aName->Value() );
2553     if ( !Name.isEmpty() ) {
2554       QApplication::setOverrideCursor( Qt::waitCursor );
2555       if ( container )
2556         container->SetName( Name.latin1() );
2557       GetActiveStudy()->renameIObject( Sel->firstIObject(), Name );
2558       QApplication::restoreOverrideCursor();
2559       
2560       //int TypeMode;  bool InViewer;
2561       //VISU_Actor *ActorTmp = ActorSelected(parent,InViewer,&TypeMode);
2562       //ActorTmp->setName((Standard_CString)Name.latin1());
2563     }
2564   }
2565 }
2566
2567
2568
2569 //=====================================================================================
2570 // function : CopyPresentation()
2571 // purpose  :
2572 //=====================================================================================
2573 void VisuGUI::CopyPresentation(){
2574   if (checkLock(GetStudyDocument())) return;
2575   VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d();
2576   if (!aPrsObject) return;
2577   switch (aPrsObject->GetType()) {
2578   case VISU::TMESH:
2579     {
2580       VISU::Mesh_i* aMeshPrs = dynamic_cast<VISU::Mesh_i*>(aPrsObject);
2581       VISU::Mesh_i* aSameMesh = new VISU::Mesh_i(aMeshPrs->GetResult());
2582       aSameMesh->SameAs(aMeshPrs);
2583       UpdateViewer(aSameMesh);
2584     }    
2585     break;
2586    case VISU::TSCALARMAP:
2587     {
2588       VISU::ScalarMap_i* aScalarPrs = dynamic_cast<VISU::ScalarMap_i*>(aPrsObject);
2589       VISU::ScalarMap_i* aSameScalar = new VISU::ScalarMap_i(aScalarPrs->GetResult());
2590       aSameScalar->SameAs(aScalarPrs);
2591       UpdateViewer(aSameScalar);
2592     }    
2593     break;
2594    case VISU::TDEFORMEDSHAPE:
2595     {
2596       VISU::DeformedShape_i* aDefPrs = dynamic_cast<VISU::DeformedShape_i*>(aPrsObject);
2597       VISU::DeformedShape_i* aSameDeformed = new VISU::DeformedShape_i(aDefPrs->GetResult());
2598       aSameDeformed->SameAs(aDefPrs);
2599       UpdateViewer(aSameDeformed);
2600     }    
2601     break;
2602    case VISU::TCUTPLANES:
2603     {
2604       VISU::CutPlanes_i* aCutPrs = dynamic_cast<VISU::CutPlanes_i*>(aPrsObject);
2605       VISU::CutPlanes_i* aSameCut = new VISU::CutPlanes_i(aCutPrs->GetResult());
2606       aSameCut->SameAs(aCutPrs);
2607       UpdateViewer(aSameCut);
2608     }    
2609     break;
2610     case VISU::TCUTLINES:
2611     {
2612       VISU::CutLines_i* aCutPrs = dynamic_cast<VISU::CutLines_i*>(aPrsObject);
2613       VISU::CutLines_i* aSameCut = new VISU::CutLines_i(aCutPrs->GetResult());
2614       aSameCut->SameAs(aCutPrs);
2615       UpdateViewer(aSameCut);
2616     }    
2617     break;
2618   case VISU::TISOSURFACE:
2619     {
2620       VISU::IsoSurfaces_i* aIsoPrs = dynamic_cast<VISU::IsoSurfaces_i*>(aPrsObject);
2621       VISU::IsoSurfaces_i* aSameIso = new VISU::IsoSurfaces_i(aIsoPrs->GetResult());
2622       aSameIso->SameAs(aIsoPrs);
2623       UpdateViewer(aSameIso);
2624     }    
2625     break;
2626    case VISU::TSTREAMLINES:
2627     {
2628       VISU::StreamLines_i* aLinesPrs = dynamic_cast<VISU::StreamLines_i*>(aPrsObject);
2629       VISU::StreamLines_i* aSameLines = new VISU::StreamLines_i(aLinesPrs->GetResult());
2630       aSameLines->SameAs(aLinesPrs);
2631       UpdateViewer(aSameLines);
2632     }    
2633     break;
2634    case VISU::TVECTORS:
2635     {
2636       VISU::Vectors_i* aVectorsPrs = dynamic_cast<VISU::Vectors_i*>(aPrsObject);
2637       VISU::Vectors_i* aSameVectors = new VISU::Vectors_i(aVectorsPrs->GetResult());
2638       aSameVectors->SameAs(aVectorsPrs);
2639       UpdateViewer(aSameVectors);
2640     }    
2641     break;
2642  }
2643   GetActiveStudy()->updateObjBrowser();
2644 }
2645
2646
2647
2648 //=====================================================================================
2649 // function : DefinePopup()
2650 // purpose  :
2651 //=====================================================================================
2652 void VisuGUI::DefinePopup( QString & theContext, QString & theParent, QString & theObject )
2653 {
2654   theObject = "";
2655   theContext = "";
2656 }
2657
2658
2659 //=====================================================================================
2660 // function : checkHomoSelection()
2661 // purpose  : 
2662 //=====================================================================================
2663 enum { homoNone=0, homoCurves, homoPresentations, homoPresentable, homoAnimatable, homoOther };
2664 int VisuGUI::checkHomoSelection()
2665 {
2666   int selMode = homoNone;
2667   SALOME_Selection* Sel = SALOME_Selection::Selection(GetActiveStudy()->getSelection());
2668   SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
2669   for ( ; It.More(); It.Next() ) {
2670     int selNext = homoOther;
2671     Handle(SALOME_InteractiveObject)& anIO = It.Value();
2672     if ( anIO->hasEntry() ) {
2673       SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument();
2674       SALOMEDS::SObject_var aSObject = aStudy->FindObjectID( anIO->getEntry() );
2675       VISU::Storable::TRestoringMap pMap;
2676       if( !aSObject->_is_nil() ) {
2677         CORBA::Object_var aCORBAObject = VISU::SObjectToObject(aSObject);
2678         if ( !CORBA::is_nil( aCORBAObject ) ) {
2679           VISU::Base_var aVisuObj = VISU::Base::_narrow( aCORBAObject );
2680           if ( !CORBA::is_nil( aVisuObj ) ) {
2681             VISU::VISUType aType = aVisuObj->GetType();
2682             switch( aType ) {
2683             case VISU::TTABLE:
2684             case VISU::TCURVE:
2685             case VISU::TCONTAINER:
2686               selNext = homoCurves; break;
2687             case VISU::TMESH:
2688             case VISU::TSCALARMAP:
2689             case VISU::TISOSURFACE:
2690             case VISU::TDEFORMEDSHAPE:
2691             case VISU::TCUTPLANES:
2692             case VISU::TCUTLINES:
2693             case VISU::TVECTORS:
2694             case VISU::TSTREAMLINES:
2695               selNext = homoPresentations; break;
2696             case VISU::TFIELD:
2697               if (getValue(aSObject, "myNbTimeStamps").toLong() > 1) {
2698                 selNext = homoAnimatable; break;
2699               }
2700               selNext = homoOther; break;
2701             default:
2702               selNext = homoOther;
2703             }
2704           }
2705         }
2706         else {
2707           SALOMEDS::GenericAttribute_var anAttr;
2708           if ( aSObject->FindAttribute( anAttr, "AttributeComment") ) {
2709             SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow( anAttr );
2710             string aComm = aComment->Value();
2711             QString strIn( aComm.c_str() );
2712             VISU::Storable::StrToMap( strIn, pMap );
2713             bool isExist;
2714             VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(pMap,"myType",&isExist).toInt();
2715             if( isExist ) {
2716               switch ( aType ) {
2717               case VISU::TENTITY:
2718               case VISU::TFAMILY:
2719               case VISU::TGROUP: 
2720                 selNext = homoPresentable; break;
2721               case VISU::TFIELD:
2722                 if (getValue(aSObject, "myNbTimeStamps").toLong() > 1) {
2723                   selNext = homoAnimatable; break;
2724                 }
2725                 selNext = homoOther; break;
2726               default:
2727                 selNext = homoOther;
2728               }
2729             }
2730           }
2731         }
2732       }
2733     }
2734     if ( selMode == homoNone ) 
2735       selMode = selNext;
2736     else {
2737       if ( selMode != selNext )
2738         return homoNone;
2739     }
2740   }
2741   return selMode;
2742 }
2743
2744 //=====================================================================================
2745 // function : GetNbChildren() [ static ]
2746 // purpose  : get number of children
2747 //=====================================================================================
2748 int GetNbChildren( SALOMEDS::SObject_var SO, bool refToo )
2749 {
2750   if ( SO->_is_nil() )
2751     return 0;
2752   int cnt = 0;
2753   SALOMEDS::ChildIterator_var Iter = SO->GetStudy()->NewChildIterator( SO );
2754   for ( ; Iter->More(); Iter->Next() ) {
2755     SALOMEDS::SObject_var refSO;
2756     if ( !Iter->Value()->ReferencedObject( refSO ) || refToo )
2757       cnt++;
2758   }
2759   return cnt;
2760 }
2761
2762 //=====================================================================================
2763 // function : CustomPopup()
2764 // purpose  :
2765 //=====================================================================================
2766 bool VisuGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* thePopup, const QString & theContext,
2767                           const QString & theParent, const QString & theObject)
2768 {
2769   int isViewer = (theParent.compare("ObjectBrowser") != 0), initId = isViewer? 800: 900;
2770   QAD_ResourceMgr* rmgr = parent->createResourceManager();
2771
2772   bool aIsLocked = isStudyLocked( GetActiveStudy()->getStudyDocument() );
2773   
2774   bool isVTKViewer = (GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK);
2775   SALOME_Selection* aSelection = SALOME_Selection::Selection(GetActiveStudy()->getSelection());
2776   QString aParentComponent     = ((SALOMEGUI_Desktop*)parent)->getComponentFromSelection();
2777   int nbSel = aSelection->IObjectCount();
2778
2779   thePopup->clear();
2780
2781   if ( nbSel == 0 ) {
2782     if ( theParent == "Viewer" && isVTKViewer && !aIsLocked)
2783       thePopup->insertItem( "Save view parameters", visuGUI, SLOT( SaveViewParams() ) );
2784     return false;
2785   }
2786   if( nbSel > 1 ) {
2787     int selMode = checkHomoSelection();
2788     if(MYDEBUG) MESSAGE("VisuGUI::CustomPopup: multiple selection : selMode = "<<selMode );
2789     if ( selMode == homoCurves ) {
2790       if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
2791         thePopup->insertItem( "Display", visuGUI, SLOT( DisplayManyPrs() ) );
2792         thePopup->insertItem( "Erase", visuGUI, SLOT( EraseManyPrs () ) );
2793         thePopup->insertItem( "Display Only", visuGUI, SLOT( DisplayOnlyManyPrs() ) );
2794       }
2795     }
2796     else if ( selMode == homoPresentations ) {
2797       if (isVTKViewer) {
2798         thePopup->insertItem( "Display", visuGUI, SLOT( DisplayManyPrs() ) );
2799         thePopup->insertItem( "Erase", visuGUI, SLOT( EraseManyPrs () ) );
2800       }
2801     }
2802     else if ( selMode == homoPresentable ) {
2803       if (!aIsLocked) thePopup->insertItem("Create Presentations", visuGUI, SLOT(CreateManyMesh()));    
2804     }
2805     else if ( selMode == homoAnimatable ) {
2806       thePopup->insertItem( "Animation...", visuGUI, SLOT( TimeAnimation() ) );
2807     }
2808     return true;
2809   }
2810   VISU::Storable::TRestoringMap aMap;
2811   Handle(SALOME_InteractiveObject) anIO;
2812   CORBA::Object_var anObject = GetSelectedObj(&anIO,GetActiveStudy(),&aMap);
2813   if (!CORBA::is_nil(anObject)) {
2814     SALOMEDS::SObject_var aSObject = GetStudyDocument()->FindObjectID(anIO->getEntry());
2815     VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
2816     if (!CORBA::is_nil(aVisuObj)) {
2817       VISU::VISUType aType = aVisuObj->GetType();
2818       if(MYDEBUG) MESSAGE("VisuGUI::CustomPopup - VISU object :: "<<aType);
2819       switch (aType) {
2820       case VISU::TVISUGEN:
2821         thePopup->insertItem("Import MED", visuGUI, SLOT(ImportFile()));
2822         thePopup->insertItem("Import TABLE", visuGUI, SLOT(ImportTablesFromFile()));
2823         thePopup->insertItem("Create Plot2d View", visuGUI, SLOT(CreatePlot2dView()));
2824         break;
2825
2826       case VISU::TRESULT:
2827         if (!aIsLocked) thePopup->insertItem("Delete", visuGUI, SLOT(DeleteObject()));
2828         break;
2829         
2830       case VISU::TTABLE:
2831         if (!aIsLocked) thePopup->insertItem( "Rename...", visuGUI, SLOT( RenameTable() ) );
2832         thePopup->insertItem( "Show Table",    visuGUI, SLOT( ShowTable() ) );
2833         if (!aIsLocked) thePopup->insertItem( "Create Curves", visuGUI, SLOT( PlotData() ) );
2834         thePopup->insertItem( "Export Table", visuGUI, SLOT( ExportTableToFile() ) );
2835         thePopup->insertSeparator();
2836         if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
2837           if ( GetNbChildren( aSObject, false ) > 0 ) {
2838             thePopup->insertItem( "Erase",        visuGUI, SLOT( ErasePrs () ) );
2839             thePopup->insertItem( "Display",      visuGUI, SLOT( DisplayPrs() ) );
2840             thePopup->insertItem( "Display Only", visuGUI, SLOT( DisplayOnlyPrs() ) );
2841           }
2842         }
2843         thePopup->insertItem( "Delete", visuGUI, SLOT( DeleteObject() ) );
2844         break;
2845  
2846       case VISU::TCURVE:
2847         if ( !aIsLocked ) {
2848           thePopup->insertItem( "Properties", visuGUI, SLOT( CurveProperties() ) );
2849           thePopup->insertItem( "Rename...", visuGUI, SLOT(Rename()));
2850         }
2851         if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
2852           if ( GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame()->isVisible( anIO ) ) 
2853             thePopup->insertItem( "Erase", visuGUI, SLOT( ErasePrs () ) );
2854           else 
2855             thePopup->insertItem( "Display", visuGUI, SLOT( DisplayPrs() ) );
2856           thePopup->insertItem( "Display Only", visuGUI, SLOT( DisplayOnlyPrs() ) );
2857         }
2858         break;
2859
2860       case VISU::TCONTAINER:
2861 //      if( !CORBA::is_nil( anObject ) ) {
2862 //        CORBA::Object_ptr aCnt = VISU::Container::_narrow( anObject );
2863 //        if( !CORBA::is_nil( aCnt ) ) {
2864 //          VISU::Container_i* container = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aCnt).in());
2865 //          if ( container ) {
2866 //            if ( !aIsLocked ) {
2867 //              thePopup->insertItem( "Edit...", visuGUI, SLOT( EditContainer() ) );
2868 //              thePopup->insertItem( "Rename...", visuGUI, SLOT( RenameContainer() ) );
2869 //              if (container->GetNbCurves() > 0)
2870 //                thePopup->insertItem( "Clear", visuGUI, SLOT( ClearContainer() ) );
2871 //            }
2872 //            if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
2873 //              thePopup->insertSeparator();
2874 //              thePopup->insertItem( "Display", visuGUI, SLOT( DisplayPrs() ) );
2875 //              thePopup->insertItem( "Erase", visuGUI, SLOT( ErasePrs () ) );
2876 //              thePopup->insertItem( "Display Only", visuGUI, SLOT( DisplayOnlyPrs() ) );
2877 //            }
2878 //          }
2879 //        }
2880 //      }
2881         if ( !aIsLocked ) {
2882           thePopup->insertItem( "Edit...", visuGUI, SLOT( EditContainer() ) );
2883           thePopup->insertItem( "Rename...", visuGUI, SLOT( RenameContainer() ) );
2884           thePopup->insertItem( "Clear", visuGUI, SLOT( ClearContainer() ) );
2885         }
2886         if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
2887           thePopup->insertSeparator();
2888           thePopup->insertItem( "Display", visuGUI, SLOT( DisplayPrs() ) );
2889           thePopup->insertItem( "Erase", visuGUI, SLOT( ErasePrs () ) );
2890           thePopup->insertItem( "Display Only", visuGUI, SLOT( DisplayOnlyPrs() ) );
2891         }
2892         if ( !aIsLocked ) thePopup->insertItem( "Delete", visuGUI, SLOT( DeleteObject() ) );
2893         break;
2894
2895       default: // Presentation
2896         {
2897           VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject).in());
2898           if (aPrsObject) {
2899             if (isVTKViewer) {
2900               // Add Presentation menu
2901               if (VISU_Actor* anVISUActor = visuGUI->GetActor(aPrsObject)){
2902                 QPopupMenu* aPresMenu = new QPopupMenu(GetDesktop());
2903                 int aRepresent = anVISUActor->GetRepresentation();
2904                 switch(aRepresent){
2905                 case VISU::POINT :
2906                   aPresMenu->insertItem("Wireframe", visuGUI, SLOT(MakeWireframe()));
2907                   aPresMenu->insertItem("Surface", visuGUI, SLOT(MakeSurface()));
2908                   if (aType == VISU::TMESH || aType == VISU::TSCALARMAP || aType == VISU::TDEFORMEDSHAPE)
2909                     aPresMenu->insertItem("Insideframe", visuGUI, SLOT(MakeInsideframe()));
2910                   if (aType == VISU::TMESH)  
2911                     aPresMenu->insertItem("Surfaceframe", visuGUI, SLOT(MakeSurfaceframe()));
2912                   break;
2913                 case VISU::WIREFRAME :
2914                   aPresMenu->insertItem("Points", visuGUI, SLOT(MakePoints()));
2915                   aPresMenu->insertItem("Surface", visuGUI, SLOT(MakeSurface()));
2916                   if (aType == VISU::TMESH || aType == VISU::TSCALARMAP || aType == VISU::TDEFORMEDSHAPE)
2917                     aPresMenu->insertItem("Insideframe", visuGUI, SLOT(MakeInsideframe()));
2918                   if (aType == VISU::TMESH)
2919                     aPresMenu->insertItem("Surfaceframe", visuGUI, SLOT(MakeSurfaceframe()));
2920                   break;
2921                 case VISU::SHADED :
2922                   aPresMenu->insertItem("Points", visuGUI, SLOT(MakePoints()));
2923                   aPresMenu->insertItem("Wireframe", visuGUI, SLOT(MakeWireframe()));
2924                   if (aType == VISU::TMESH || aType == VISU::TSCALARMAP || aType == VISU::TDEFORMEDSHAPE)
2925                     aPresMenu->insertItem("Insideframe", visuGUI, SLOT(MakeInsideframe()));
2926                   if (aType == VISU::TMESH)
2927                     aPresMenu->insertItem("Surfaceframe", visuGUI, SLOT(MakeSurfaceframe()));
2928                   break;
2929                 case VISU::INSIDEFRAME :
2930                   aPresMenu->insertItem("Points", visuGUI, SLOT(MakePoints()));
2931                   aPresMenu->insertItem("Surface", visuGUI, SLOT(MakeSurface()));
2932                   aPresMenu->insertItem("Wireframe", visuGUI, SLOT(MakeWireframe()));
2933                   if (aType == VISU::TMESH)
2934                     aPresMenu->insertItem("Surfaceframe", visuGUI, SLOT(MakeSurfaceframe()));
2935                   break;
2936                 case VISU::SURFACEFRAME :
2937                   aPresMenu->insertItem("Points", visuGUI, SLOT(MakePoints()));
2938                   aPresMenu->insertItem("Surface", visuGUI, SLOT(MakeSurface()));
2939                   aPresMenu->insertItem("Wireframe", visuGUI, SLOT(MakeWireframe()));
2940                   aPresMenu->insertItem("Insideframe", visuGUI, SLOT(MakeInsideframe()));
2941                   break;
2942                 }
2943                 if(anVISUActor->IsShrunkable())
2944                   if(aType != VISU::TVECTORS && aType != VISU::TSTREAMLINES){
2945                     if (anVISUActor->IsShrunk())
2946                       aPresMenu->insertItem("Unshrink", visuGUI, SLOT(MakeShrink()));
2947                     else
2948                       aPresMenu->insertItem("Shrink", visuGUI, SLOT(MakeShrink()));
2949                   }
2950                 thePopup->insertItem("Representation", aPresMenu);
2951
2952                 // Add Properties
2953                 QPopupMenu* aPropMenu = new QPopupMenu(GetDesktop());
2954                 if(aType == VISU::TMESH){
2955                   if(aRepresent == VISU::SURFACEFRAME){
2956                     aPropMenu->insertItem("Cell Color", visuGUI, SLOT(ChageColor()));
2957                     aPropMenu->insertItem("Edge Color", visuGUI, SLOT(ChangeWireframeColor()));
2958                   }else
2959                     aPropMenu->insertItem("Color", visuGUI, SLOT(ChageColor()));
2960                 }else if(aType == VISU::TDEFORMEDSHAPE)
2961                   aPropMenu->insertItem("Color", visuGUI, SLOT(ChageColor()));
2962
2963                 if (aType != VISU::TVECTORS && aType != VISU::TSTREAMLINES)
2964                   aPropMenu->insertItem("Opacity", visuGUI, SLOT(ChangeOpacity()));
2965                 if (aType != VISU::TVECTORS){
2966                   aPropMenu->insertItem("Line width", visuGUI, SLOT(ChangeLines()));
2967                   thePopup->insertItem("Properties", aPropMenu);                  
2968                 }
2969                 thePopup->insertSeparator();
2970               }
2971             }
2972             if ( !aIsLocked ) thePopup->insertItem("Rename...", visuGUI, SLOT(Rename()));
2973             if (aType != VISU::TMESH) {
2974               //if (aType != VISU::TSCALARMAP)
2975               if ( !aIsLocked ) thePopup->insertItem("Edit...", visuGUI, SLOT(EditPrs()));
2976               
2977               if (aType == VISU::TCUTLINES) {
2978                 // Check: Does it has living children (tables)
2979                 SALOMEDS::ChildIterator_var aIter = 
2980                   GetActiveStudy()->getStudyDocument()->NewChildIterator( aSObject );
2981                 bool isPresent = false;
2982                 for ( ;aIter->More(); aIter->Next()) {
2983                   SALOMEDS::SObject_var aTblObj = aIter->Value();
2984                   isPresent = !aTblObj->_is_nil();
2985                   if (isPresent) {
2986                     SALOMEDS::GenericAttribute_var    anAttr;
2987                     isPresent = aTblObj->FindAttribute(anAttr, "AttributeName");
2988                     if (isPresent) break; // We have at least a one child
2989                   }
2990                 }
2991                 if ((!isPresent) && (!aIsLocked) )
2992                   thePopup->insertItem( "Create Table", visuGUI, SLOT( CreateTable() ) );
2993               }
2994               thePopup->insertItem("Sweep", visuGUI, SLOT(Sweep()));
2995               
2996             }
2997             if (isVTKViewer) {
2998               if ( theParent == "Viewer" && 
2999                    ( aType == VISU::TMESH      || 
3000                      aType == VISU::TSCALARMAP || 
3001                      aType == VISU::TDEFORMEDSHAPE ) ) {
3002                 thePopup->insertSeparator();
3003                 thePopup->insertItem("Selection info...",   visuGUI, SLOT(SelectionInfo()));
3004               }
3005               thePopup->insertSeparator();
3006              
3007               if (visuGUI->IsDisplayed(aPrsObject) ){
3008                 thePopup->insertItem("Erase", visuGUI, SLOT(ErasePrs()));
3009               }
3010               else
3011                 thePopup->insertItem("Display", visuGUI, SLOT(DisplayPrs()));
3012               
3013               thePopup->insertItem("Display Only", visuGUI, SLOT(DisplayOnlyPrs()));
3014             }
3015             thePopup->insertItem("Delete", visuGUI, SLOT(DeletePrs()));
3016             if ((aType != VISU::TMESH) && (!aIsLocked)) {
3017               thePopup->insertSeparator();
3018               thePopup->insertItem("Same As", visuGUI, SLOT(CopyPresentation()));
3019             }
3020           }
3021         }
3022       }
3023       return false;
3024     }
3025     
3026     else {
3027       // possibly this is the MED field/mesh and support objects
3028       SALOME_MED::MED_ptr aMED = SALOME_MED::MED::_narrow( anObject );
3029       if(!CORBA::is_nil(aMED))
3030         thePopup->insertItem( "Import Structure", visuGUI, SLOT( ImportMedField() ) );
3031       SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow( anObject );
3032       if(!CORBA::is_nil(aField))
3033         thePopup->insertItem( "Import TimeStamp", visuGUI, SLOT( ImportMedField() ) );
3034       if ( aParentComponent != parent->getActiveComponent() )  {
3035         //insert pre-defined Display/Erase items
3036         if ( thePopup->count() > 0 ) {
3037           thePopup->insertSeparator();
3038         }
3039         thePopup->insertItem (tr ("MEN_APP_DISPLAY"),      GetActiveStudy()->getApp(), SLOT(onDisplay(int)), 0, QAD_Display_Popup_ID);
3040         thePopup->insertItem (tr ("MEN_APP_DISPLAY_ONLY"), GetActiveStudy()->getApp(), SLOT(onDisplay(int)), 0, QAD_DisplayOnly_Popup_ID);
3041         thePopup->insertItem (tr ("MEN_APP_ERASE"),        GetActiveStudy()->getApp(), SLOT(onErase()),      0, QAD_Erase_Popup_ID);
3042       }
3043       return false;
3044     }
3045   }else{
3046     SALOMEDS::SObject_var aSObject = GetStudyDocument()->FindObjectID(anIO->getEntry());
3047     if(!aSObject->_is_nil()){
3048       bool isExist;
3049       VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt();
3050       if(isExist){
3051         switch (aType) {
3052         case VISU::TENTITY:
3053         case VISU::TFAMILY:
3054         case VISU::TGROUP: 
3055           if ( !aIsLocked )thePopup->insertItem("Create Presentation", visuGUI, SLOT(CreateMesh()));    
3056           break;
3057         case VISU::TVIEW3D: 
3058           if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK )
3059             thePopup->insertItem( "Restore view parameters", visuGUI, SLOT( RestoreViewParams() ) );
3060           if ( !aIsLocked ) {
3061             if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { 
3062               // Available only for VTK viewer
3063               thePopup->insertItem( "Save view parameters", visuGUI, SLOT( SaveViewParams() ) );
3064             }
3065             thePopup->insertItem( "Rename...", visuGUI, SLOT( Rename() ) );
3066             thePopup->insertItem("Delete", visuGUI, SLOT(DeleteViewParams()));
3067           }
3068           break;
3069         case VISU::TFIELD:
3070           if ((getValue(aSObject, "myNbTimeStamps").toLong() > 1) && isVTKViewer)
3071             thePopup->insertItem( "Animation...", visuGUI, SLOT( TimeAnimation() ) );
3072           break;
3073         case VISU::TTIMESTAMP: {
3074           int aNunComponent = VISU::Storable::FindValue(aMap,"myNumComponent",&isExist).toInt();
3075           thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_SCALAR_MAP") ), 
3076                                "Scalar Map...", visuGUI, SLOT(CreateScalarMap()));
3077           thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_ISO_SURFACES") ),
3078                                "Iso Surfaces...", visuGUI, SLOT(CreateIsoSurfaces()));
3079           thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_CUT_PLANES") ),
3080                                "Cut Planes...", visuGUI, SLOT(CreateCutPlanes()));
3081           thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_CUT_LINES") ),
3082                                "Cut Lines...", visuGUI, SLOT(CreateCutLines()));
3083           if(aNunComponent > 1){
3084             thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_DEFORMED_SHAPE") ),
3085                                  "Deformed Shape...", visuGUI, SLOT(CreateDeformedShape()));
3086             thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_VECTORS") ),
3087                                  "Vectors...", visuGUI, SLOT(CreateVectors()));
3088             thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_STREAM_LINES") ),
3089                                  "Stream lines...", visuGUI, SLOT(CreateStreamLines()));
3090           }
3091           break;
3092         }
3093         }
3094         return false;
3095       }else{
3096
3097         if(IsSObjectTable(aSObject)){
3098           thePopup->insertItem( "Show Table",    visuGUI, SLOT(ShowTable()));
3099           thePopup->insertItem( "Create Curves", visuGUI, SLOT(PlotData()));
3100           thePopup->insertItem( "Export Table", visuGUI, SLOT( ExportTableToFile() ) );
3101           thePopup->insertSeparator();
3102           thePopup->insertItem( "Delete", visuGUI, SLOT( DeleteObject() ) );
3103           return false;
3104         }
3105
3106         CORBA::Long aTag = 1;
3107         SALOMEDS::SObject_var aSubObject;
3108         if(aSObject->FindSubObject(aTag,aSubObject) && IsSObjectTable(aSubObject)) {
3109           thePopup->insertItem( "Delete", visuGUI, SLOT( DeleteObject() ) );
3110           return false;
3111         }
3112
3113         aSObject = aSObject->GetFather();
3114         if(aSObject->_is_nil()) return false;
3115         SALOMEDS::GenericAttribute_var anAttr;
3116         aSObject->FindAttribute(anAttr, "AttributeName");
3117         SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
3118         if(aName->_is_nil()) return false;
3119         CORBA::String_var aValue = aName->Value();
3120         //if(strcmp(aValue.in(),"MEDMESH") == 0)
3121         //  thePopup->insertItem( "Import MED", visuGUI, SLOT( ImportMedField() ) );
3122         if(strcmp(aValue.in(),"MEDFIELD") == 0)
3123           thePopup->insertItem( "Import Field", visuGUI, SLOT( ImportMedField() ) );
3124         if ( aParentComponent != parent->getActiveComponent() )  {
3125           //insert pre-defined Display/Erase items
3126           if ( thePopup->count() > 0 ) {
3127             thePopup->insertSeparator();
3128           }
3129           thePopup->insertItem (tr ("MEN_APP_DISPLAY"),      GetActiveStudy()->getApp(), SLOT(onDisplay(int)), 0, QAD_Display_Popup_ID);
3130           thePopup->insertItem (tr ("MEN_APP_DISPLAY_ONLY"), GetActiveStudy()->getApp(), SLOT(onDisplay(int)), 0, QAD_DisplayOnly_Popup_ID);
3131           thePopup->insertItem (tr ("MEN_APP_ERASE"),        GetActiveStudy()->getApp(), SLOT(onErase()),      0, QAD_Erase_Popup_ID);
3132         }
3133         return false;
3134       }
3135     }
3136   }
3137   return false;
3138 }
3139
3140 //===========================================================================
3141 // BuildPresentation
3142 //===========================================================================
3143 void VisuGUI::BuildPresentation( const Handle(SALOME_InteractiveObject)& theIO,
3144                                  QAD_ViewFrame* )
3145 {
3146   BEGIN_OF("VisuGUI::BuildPresentation");
3147
3148   if (theIO.IsNull()) {
3149     if(MYDEBUG) MESSAGE("VisuGUI::BuildPresentation(): null SALOME_InteractiveObject passed");
3150     return;
3151   }
3152
3153   SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument();
3154   SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
3155
3156   if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_VTK ) return;
3157
3158   vtkRenderer *Renderer = GetRenderer();
3159
3160   SALOMEDS::SObject_var aSObj = aStudy -> FindObjectID ( theIO->getEntry() );
3161   SCRUTE(aSObj);
3162   if (aSObj -> _is_nil() ) {
3163     if(MYDEBUG) MESSAGE("No SObject for interacative object is found");
3164     return;
3165   }
3166   
3167   CORBA::Object_var anObject = VISU::SObjectToObject(aSObj);
3168   if(!CORBA::is_nil(anObject)) {
3169     VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject).in());
3170     if ( !aPrsObject ) {
3171       if(MYDEBUG) MESSAGE("The object is not VISU::Prs3d_i");
3172       return;
3173     }
3174     VISU_Actor *SelectedActor = visuGUI->GetActor(aPrsObject);
3175     if(!SelectedActor)
3176       try{
3177         SelectedActor = aPrsObject -> CreateActor();
3178         if(VTKViewer_ViewFrame* vf = GetVtkViewFrame())
3179           vf->AddActor(SelectedActor);
3180       }catch(std::runtime_error& exc){
3181         INFOS(exc.what());
3182         throw exc; 
3183       }
3184   }else
3185     if(MYDEBUG) MESSAGE("CORBA::is_nil(anObject) = true");
3186   END_OF("VisuGUI::BuildPresentation");
3187 }
3188
3189
3190 //===========================================================================
3191 // SupportedViewType
3192 //===========================================================================
3193 void VisuGUI::SupportedViewType(int* buffer, int bufferSize)
3194 {
3195   if (!buffer || !bufferSize) return;
3196   buffer[0] = (int)VIEW_VTK;
3197   if (--bufferSize) buffer[1] = (int)VIEW_PLOT2D;
3198
3199
3200 extern "C"
3201 {
3202   Standard_EXPORT SALOMEGUI* GetComponentGUI() {
3203     if ( !visuGUI )
3204       visuGUI = new VisuGUI( "" );
3205     return visuGUI;
3206   }
3207 }
3208
3209
3210 //////////////////////////////////////////////////////////////////////////////////
3211 ////////////////               CHANGE ACTOR COLOR         ////////////////////////
3212 //////////////////////////////////////////////////////////////////////////////////
3213 ///////////////// /////////////////////////////////////////////////////////////////
3214 // change actor color
3215 // In : Name of Actor
3216 //
3217 //
3218
3219 void VisuGUI::NewColor(VISU_Actor *theActor){
3220   if(VISU::Prs3d_i* aPrs3d = theActor->GetPrs3d()){
3221     VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrs3d);
3222     VISU::DeformedShape_i* aDeformedShape = dynamic_cast<VISU::DeformedShape_i*>(aPrs3d);
3223     SALOMEDS::Color anOldColor, aNewColor;
3224     int aRepresent = theActor->GetRepresentation();
3225     if(aMesh)
3226       switch(aRepresent){
3227       case VISU::POINT :
3228         anOldColor = aMesh->GetNodeColor();
3229         break;
3230       case VISU::WIREFRAME :
3231       case VISU::INSIDEFRAME :
3232         anOldColor = aMesh->GetLinkColor();
3233         break;
3234       case VISU::SHADED :
3235       case VISU::SURFACEFRAME :
3236         anOldColor = aMesh->GetCellColor();
3237         break;
3238       }
3239     else if(aDeformedShape)
3240       anOldColor = aDeformedShape->GetColor();
3241     else
3242       return;
3243     QColor aColor = QColor(int(255*anOldColor.R),int(255*anOldColor.G),int(255*anOldColor.B));
3244     QColor aColorNew = QColorDialog::getColor(aColor, GetDesktop());
3245     if(aColorNew.isValid()){
3246       aNewColor.R = aColorNew.red()/255.;
3247       aNewColor.G = aColorNew.green()/255.;
3248       aNewColor.B = aColorNew.blue()/255.;
3249       if(aMesh)
3250         switch(aRepresent){
3251         case VISU::POINT :
3252           aMesh->SetNodeColor(aNewColor);
3253           break;
3254         case VISU::WIREFRAME :
3255         case VISU::INSIDEFRAME :
3256           aMesh->SetLinkColor(aNewColor);
3257           break;
3258         case VISU::SHADED :
3259         case VISU::SURFACEFRAME :
3260           aMesh->SetCellColor(aNewColor);
3261           break;
3262         }
3263       else
3264         aDeformedShape->SetColor(aNewColor);
3265       RecreateActor(aPrs3d);
3266     }
3267   }
3268 }
3269
3270 void VisuGUI::NewWireframeColor(VISU_MeshAct *theActor){
3271   if(VISU::Prs3d_i* aPrs3d = theActor->GetPrs3d()){
3272     if(VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrs3d)){
3273       SALOMEDS::Color anOldColor = aMesh->GetLinkColor(), aNewColor;
3274       QColor aColor = QColor(int(255*anOldColor.R),int(255*anOldColor.G),int(255*anOldColor.B));
3275       QColor aColorNew = QColorDialog::getColor(aColor, GetDesktop());
3276       if(aColorNew.isValid()){
3277         aNewColor.R = aColorNew.red()/255.;
3278         aNewColor.G = aColorNew.green()/255.;
3279         aNewColor.B = aColorNew.blue()/255.;
3280         aMesh->SetLinkColor(aNewColor);
3281         VisuGUI::RecreateActor(aMesh);
3282       }
3283     }
3284   }
3285 }
3286
3287 //////////////////////////////////////////////////////////////////////////////////
3288 ////////////////               CHANGE ACTOR OPACITY       ////////////////////////
3289 //////////////////////////////////////////////////////////////////////////////////
3290 //////////////////////////////////////////////////////////////////////////////////
3291 // change actor opacity
3292 // In : Name of Actor
3293 //
3294 // Use CursorDlg to select a value between 0 and 100
3295 //
3296
3297 void VisuGUI::NewOpacity(VISU_Actor *Actor)
3298 {
3299   
3300   VisuGUI_CursorDlg* CursorDlg = new VisuGUI_CursorDlg(QAD_Application::getDesktop(), tr("Opacity"), TRUE );
3301   
3302   float oldopac,newopac;
3303   int intopac;
3304   CursorDlg->Comment1->setText( tr( "Set value between") );
3305   CursorDlg->Comment2->setText( tr( "0 (transparent) and 100 (opaque)" ) );
3306   oldopac=Actor->GetOpacity();
3307   intopac=int(oldopac*100.+0.5);
3308   CursorDlg->SpinBox1->setMinValue(0);
3309   CursorDlg->SpinBox1->setMaxValue(100);
3310   CursorDlg->SpinBox1->setValue(intopac);
3311   
3312   int ret = CursorDlg->exec();
3313   if (ret == 1)
3314     {
3315       intopac  = CursorDlg->SpinBox1->value() ;
3316       newopac = intopac/100.;
3317       Actor->SetOpacity(newopac);
3318     }
3319   delete CursorDlg;
3320 }
3321
3322 //////////////////////////////////////////////////////////////////////////////////
3323 ////////////////               CHANGE ACTOR LINEWIDTH     ////////////////////////
3324 //////////////////////////////////////////////////////////////////////////////////
3325 //////////////////////////////////////////////////////////////////////////////////
3326 // change actor linewidth
3327 // In : Name of Actor
3328 //
3329 // Use CursorDlg to select a value between 0 and 10
3330 //
3331
3332 void VisuGUI::NewLinewidth(VISU_Actor *Actor)
3333 {
3334
3335   VisuGUI_CursorDlg* CursorDlg = new VisuGUI_CursorDlg(QAD_Application::getDesktop(), tr("Line Width"), TRUE );
3336   
3337   float oldlwid,newlwid;
3338   int intlwid;
3339   CursorDlg->Comment1->setText("Set value between");
3340   CursorDlg->Comment2->setText("1 (thin) and 10 (thick)");
3341   oldlwid=Actor->GetLineWidth();
3342   intlwid=int(oldlwid);
3343   CursorDlg->SpinBox1->setMinValue(1);
3344   CursorDlg->SpinBox1->setMaxValue(10);
3345   CursorDlg->SpinBox1->setValue(intlwid);
3346   
3347   int ret = CursorDlg->exec();
3348   if (ret == 1) {
3349     intlwid  = CursorDlg->SpinBox1->value() ;
3350     newlwid = intlwid;
3351     Actor->SetLineWidth(newlwid);
3352   }
3353   delete CursorDlg;
3354 }
3355
3356 /* ======================================================================================== */
3357 /* Setting parameters for Scalar Bar                                                        */
3358 /* ======================================================================================== */
3359 void VisuGUI::ChangeScalarBar()
3360 {
3361   VisuGUI_ScalarBarDlg* Scbar = new VisuGUI_ScalarBarDlg(TRUE);
3362   Scbar->initFromResources();
3363   int ret = Scbar->exec();
3364   if ( ret )  {
3365     Scbar->storeToResources();
3366   }
3367   delete Scbar;
3368 }
3369
3370 /* ======================================================================================== */
3371 /* Setting parameters for Sweeping                                                        */
3372 /* ======================================================================================== */
3373 void VisuGUI::SetSweepingPreferences()
3374 {
3375         float tempo=0.2;
3376         int cycles=1;
3377         int steps=20;
3378
3379         QString Tempo = QAD_CONFIG->getSetting("Visu:SweepTempo");
3380         if ( !Tempo.isEmpty() )
3381                 tempo = Tempo.toFloat();
3382
3383         QString Cycles = QAD_CONFIG->getSetting("Visu:SweepCycles");
3384         if ( !Cycles.isEmpty() )
3385                 cycles = Cycles.toInt();
3386
3387         QString Steps = QAD_CONFIG->getSetting("Visu:SweepSteps");
3388         if ( !Steps.isEmpty() )
3389                 steps = Steps.toInt();
3390
3391         VisuGUI_SweepPrefDlg* Sweep = new VisuGUI_SweepPrefDlg(QAD_Application::getDesktop(), 0, TRUE, 0);
3392
3393         Sweep->setTimeStep( tempo );
3394         Sweep->setNbCycles( cycles );
3395         Sweep->setNbSteps ( steps );
3396
3397         if ( Sweep->exec() )
3398         {
3399                 tempo  = Sweep->getTimeStep();
3400                 cycles = Sweep->getNbCycles();
3401                 steps  = Sweep->getNbSteps();
3402
3403                 QAD_CONFIG->addSetting("Visu:SweepTempo",  tempo);
3404                 QAD_CONFIG->addSetting("Visu:SweepCycles", cycles);
3405                 QAD_CONFIG->addSetting("Visu:SweepSteps",  steps);
3406         }
3407         delete Sweep;
3408 }
3409
3410 /* ======================================================================================== */
3411 /* Returns Visu input files directory (default is CSF_PATHData)                             */
3412 /* ======================================================================================== */
3413 QString VisuGUI::getVisuInputDir()
3414 {
3415         QString Tmp = QAD_CONFIG->getSetting("Visu:InputDir");
3416         if ( Tmp.isEmpty() )
3417                 Tmp =  QAD_Tools::addSlash(getenv("CSF_PATHData"));
3418         Tmp = QAD_Tools::addSlash(Tmp);
3419         return (Tmp);
3420 }
3421
3422 /* ======================================================================================== */
3423 /* Returns Visu output files directory (default is InputDir)                                */
3424 /* ======================================================================================== */
3425 QString VisuGUI::getVisuOutputDir()
3426 {
3427         QString Tmp = QAD_CONFIG->getSetting("Visu:OutputDir");
3428         if ( Tmp.isEmpty() )
3429         {
3430                 QString Tmp2 = QAD_CONFIG->getSetting("Visu:InputDir");
3431                 if ( Tmp2.isEmpty() )
3432                         Tmp =  QAD_Tools::addSlash(getenv("CSF_PATHData"));
3433                 else
3434                         Tmp = Tmp2;
3435         }
3436         Tmp = QAD_Tools::addSlash(Tmp);
3437         return (Tmp);
3438 }
3439
3440
3441 /* ======================================================================================== */
3442 /* Global Method for Scalar Map                                                  */
3443 /* ======================================================================================== */
3444 VISU::Result_i* VisuGUI::CreatePresent(SALOMEDS::SObject_var theField, VISU::Result_var& theResult){
3445   if(MYDEBUG) MESSAGE("VisuGUI::CreatePresent");
3446   SALOMEDS::SObject_var aSObj = theField->GetFather(); 
3447   if (CORBA::is_nil(aSObj)) return NULL;
3448   aSObj = aSObj->GetFather(); if (CORBA::is_nil(aSObj)) return NULL;
3449   aSObj = aSObj->GetFather(); if (CORBA::is_nil(aSObj)) return NULL;
3450   aSObj = aSObj->GetFather(); if (CORBA::is_nil(aSObj)) return NULL;
3451   CORBA::Object_var anObject = VISU::SObjectToObject(aSObj);
3452   if(CORBA::is_nil(anObject)) return NULL;
3453   theResult = VISU::Result::_narrow(anObject);
3454   VISU::Result_i* pResult = dynamic_cast<VISU::Result_i*>(VISU::GetServant(anObject).in());
3455   if(pResult == NULL)
3456     QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3457                           tr ("WRN_NO_AVAILABLE_DATA"),
3458                           tr ("VISU_BUT_OK"));
3459   return pResult;
3460 }
3461
3462 #define CREATEPRS(PRSTYPE, FNAME, FCREATE) \
3463 PRSTYPE* FNAME(SALOMEDS::SObject_var theField, \
3464                const char* theMeshName, VISU::Entity theEntity, \
3465                const char* theFieldName, int theTimeId) {\
3466   VISU::Result_var aResult; \
3467   VISU::Result_i* pResult = CreatePresent(theField,aResult); \
3468   if(pResult != NULL){ \
3469     QApplication::setOverrideCursor( Qt::waitCursor ); \
3470     CORBA::Object_var anObject =  \
3471       GetVisuGen()->FCREATE(aResult,theMeshName,theEntity,theFieldName,theTimeId); \
3472     QApplication::restoreOverrideCursor(); \
3473     if(!CORBA::is_nil(anObject))  \
3474       return dynamic_cast<PRSTYPE*>(VISU::GetServant(anObject).in()); \
3475   } \
3476   QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"), \
3477                           tr ("ERR_CANT_BUILD_PRESENTATION"), \
3478                           tr ("VISU_BUT_OK") ); \
3479   return NULL; \
3480
3481
3482 CREATEPRS(VISU::ScalarMap_i, VisuGUI::CreateScalarMapPrs, ScalarMapOnField);
3483 CREATEPRS(VISU::DeformedShape_i, VisuGUI::CreateDeformedShapePrs, DeformedShapeOnField);
3484 CREATEPRS(VISU::Vectors_i, VisuGUI::CreateVectorsPrs, VectorsOnField);
3485 CREATEPRS(VISU::IsoSurfaces_i, VisuGUI::CreateIsoSurfacesPrs, IsoSurfacesOnField);
3486 CREATEPRS(VISU::CutPlanes_i, VisuGUI::CreateCutPlanesPrs, CutPlanesOnField);
3487 CREATEPRS(VISU::CutLines_i, VisuGUI::CreateCutLinesPrs, CutLinesOnField);
3488 CREATEPRS(VISU::StreamLines_i, VisuGUI::CreateStreamLinesPrs, StreamLinesOnField);
3489
3490
3491 #define BUILDPRS(TYPE, FCREATE, FNAME, DLGNAME) \
3492 bool FNAME(SALOMEDS::SObject_var theField) { \
3493   VISU::Storable::TRestoringMap aMap = getMapOfValue(theField); \
3494   bool isExist; \
3495   QString aType = VISU::Storable::FindValue(aMap,"myType",&isExist); \
3496   if(!isExist || aType.toInt() != VISU::TTIMESTAMP ) return false; \
3497   QString aMeshName = VISU::Storable::FindValue(aMap,"myMeshName",&isExist).latin1(); \
3498   QString anEntity = VISU::Storable::FindValue(aMap,"myEntityId",&isExist).latin1(); \
3499   QString aFieldName = VISU::Storable::FindValue(aMap,"myFieldName",&isExist).latin1(); \
3500   QString aTimeStampId = VISU::Storable::FindValue(aMap,"myTimeStampId",&isExist).latin1(); \
3501   Utils_Timer timer; \
3502   if(MYCHECKTIME) timer.Start(); \
3503   TYPE* pPresent = FCREATE(theField,aMeshName,(VISU::Entity)anEntity.toInt(),aFieldName,aTimeStampId.toInt()); \
3504   if(MYCHECKTIME) { \
3505     timer.Stop(); \
3506     MESSAGE("BUILDPRS(TYPE, FCREATE, FNAME, DLGNAME) - CREATE PRSOBJECT"); \
3507     timer.Show(); \
3508   } \
3509   if (pPresent) { \
3510     QString aValue = QAD_CONFIG->getSetting("Visu:BuildDefaultPrs3d"); \
3511     if(aValue.isEmpty() || (!aValue.isEmpty() && !aValue.toInt())){ \
3512       DLGNAME* aDlg = new DLGNAME(); \
3513       aDlg->initFromPrsObject(pPresent); \
3514       if (aDlg->exec() && (aDlg->storeToPrsObject(pPresent))) { \
3515         delete aDlg; \
3516       } else { \
3517         DeletePresentation(pPresent); \
3518         delete aDlg; \
3519         return false; \
3520       } \
3521     } \
3522      try { \
3523        CreateActor(pPresent); \
3524      }catch (...) {\
3525        return false;} \
3526     return true; \
3527   } \
3528   return false; \
3529 }
3530
3531 BUILDPRS(VISU::ScalarMap_i, CreateScalarMapPrs, VisuGUI::CreateScalarMap, VisuGUI_ScalarBarDlg);
3532 BUILDPRS(VISU::DeformedShape_i, CreateDeformedShapePrs, VisuGUI::CreateDeformedShape, VisuGUI_MagnitudeDlg);
3533 BUILDPRS(VISU::Vectors_i, CreateVectorsPrs, VisuGUI::CreateVectors, VisuGUI_VectorsDlg);
3534 BUILDPRS(VISU::IsoSurfaces_i, CreateIsoSurfacesPrs, VisuGUI::CreateIsoSurfaces, VisuGUI_IsoSurfacesDlg);
3535 //BUILDPRS(VISU::CutPlanes_i, CreateCutPlanesPrs, VisuGUI::CreateCutPlanes, VisuGUI_CutPlanesDlg);
3536 //BUILDPRS(VISU::CutLines_i, CreateCutLinesPrs, VisuGUI::CreateCutLines, VisuGUI_CutLinesDlg);
3537 BUILDPRS(VISU::StreamLines_i, CreateStreamLinesPrs, VisuGUI::CreateStreamLines, VisuGUI_StreamLinesDlg);
3538
3539
3540 bool VisuGUI::CreateCutPlanes(SALOMEDS::SObject_var theField) { 
3541   try {
3542   VISU::Storable::TRestoringMap aMap = getMapOfValue(theField); 
3543   bool isExist; 
3544   QString aType = VISU::Storable::FindValue(aMap,"myType",&isExist); 
3545   if(!isExist || aType.toInt() != VISU::TTIMESTAMP ) return false; 
3546   QString aMeshName = VISU::Storable::FindValue(aMap,"myMeshName",&isExist).latin1(); 
3547   QString anEntity = VISU::Storable::FindValue(aMap,"myEntityId",&isExist).latin1();
3548   QString aFieldName = VISU::Storable::FindValue(aMap,"myFieldName",&isExist).latin1(); 
3549   QString aTimeStampId = VISU::Storable::FindValue(aMap,"myTimeStampId",&isExist).latin1();
3550   Utils_Timer timer;
3551   if(MYCHECKTIME) timer.Start();
3552   VISU::CutPlanes_i* pPresent = 
3553     CreateCutPlanesPrs(theField,aMeshName,(VISU::Entity)anEntity.toInt(),aFieldName,aTimeStampId.toInt());
3554   if(MYCHECKTIME) {
3555     timer.Stop();
3556     MESSAGE("BUILDPRS(TYPE, FCREATE, FNAME, DLGNAME) - CREATE PRSOBJECT");
3557     timer.Show();
3558   }
3559   if (pPresent) {
3560     QString aValue = QAD_CONFIG->getSetting("Visu:BuildDefaultPrs3d");
3561     if(aValue.isEmpty() || (!aValue.isEmpty() && !aValue.toInt())){
3562       VisuGUI_CutPlanesDlg* aDlg = new VisuGUI_CutPlanesDlg(true, false);
3563       aDlg->initFromPrsObject(pPresent);
3564       aDlg->show();
3565       myActiveDialogBox = aDlg;      
3566 //       if (aDlg->exec() && (aDlg->storeToPrsObject(pPresent))) {
3567 //         delete aDlg;
3568 //       } else {
3569 //         DeletePresentation(pPresent);
3570 //         delete aDlg;
3571 //         return false;
3572 //       }
3573 //     }
3574 //     CreateActor(pPresent);
3575       return true;
3576     }
3577   }
3578 }catch (...){return false;}
3579   return false;
3580 }
3581
3582 bool VisuGUI::CreateCutLines(SALOMEDS::SObject_var theField) { 
3583 try {
3584   VISU::Storable::TRestoringMap aMap = getMapOfValue(theField); 
3585   bool isExist; 
3586   QString aType = VISU::Storable::FindValue(aMap,"myType",&isExist); 
3587   if(!isExist || aType.toInt() != VISU::TTIMESTAMP ) return false; 
3588   QString aMeshName = VISU::Storable::FindValue(aMap,"myMeshName",&isExist).latin1(); 
3589   QString anEntity = VISU::Storable::FindValue(aMap,"myEntityId",&isExist).latin1(); 
3590   QString aFieldName = VISU::Storable::FindValue(aMap,"myFieldName",&isExist).latin1(); 
3591   QString aTimeStampId = VISU::Storable::FindValue(aMap,"myTimeStampId",&isExist).latin1(); 
3592   Utils_Timer timer; 
3593   if(MYCHECKTIME) timer.Start(); 
3594   VISU::CutLines_i* pPresent = CreateCutLinesPrs(theField,aMeshName,
3595                                      (VISU::Entity)anEntity.toInt(),
3596                                      aFieldName,aTimeStampId.toInt()); 
3597   if(MYCHECKTIME) { 
3598     timer.Stop(); 
3599     MESSAGE("BUILDPRS(VISU::CutLines_i, CreateCutLinesPrs, VisuGUI::CreateCutLines, VisuGUI_CutLinesDlg) - CREATE PRSOBJECT");
3600     timer.Show(); 
3601   } 
3602   if (pPresent) { 
3603     QString aValue = QAD_CONFIG->getSetting("Visu:BuildDefaultPrs3d"); 
3604     if(aValue.isEmpty() || (!aValue.isEmpty() && !aValue.toInt())){ 
3605       VisuGUI_CutLinesDlg* aDlg = new VisuGUI_CutLinesDlg(true); 
3606       aDlg->initFromPrsObject(pPresent); 
3607       aDlg->show();
3608       myActiveDialogBox = aDlg;
3609       return true;
3610 //       if (aDlg->exec()) { 
3611 //         aDlg->storeToPrsObject(pPresent);
3612 //      if (aDlg->isGenerateTable()) {
3613 //        GetVisuGen()->CreateTable(pPresent->GetEntry());
3614 //        if (aDlg->isGenerateCurves()) {
3615 //          SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument();
3616 //          SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(pPresent->GetEntry());
3617 //          if(!aSObject->_is_nil()) {
3618 //            SALOMEDS::ChildIterator_var aIter = aStudy->NewChildIterator( aSObject );
3619 //            SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder();
3620 //            for ( ;aIter->More(); aIter->Next()) {
3621 //              SALOMEDS::SObject_var aTblObj = aIter->Value();
3622 //              if (!aTblObj->_is_nil()) {
3623 //                SALOMEDS::GenericAttribute_var anAttr;
3624 //                if (aTblObj->FindAttribute(anAttr, "AttributeName")) {
3625 //                  CreatePlot(aTblObj);
3626 //                }
3627 //              }
3628 //            }
3629 //          }
3630 //        }
3631 //        GetActiveStudy()->updateObjBrowser();  
3632 //      }
3633 //       } else { 
3634 //         DeletePresentation(pPresent); 
3635 //         delete aDlg; 
3636 //         return false; 
3637 //       } 
3638 //       delete aDlg; 
3639 //     } 
3640 //     CreateActor(pPresent); 
3641 //     return true; 
3642     } 
3643   }
3644 }catch (...){return false; }
3645   return false; 
3646 }
3647
3648
3649
3650 /* ======================================================================================== */
3651 /* Global Method to import tables from file */
3652 /* ======================================================================================== */
3653 void VisuGUI::ImportTablesFromFile(){
3654   if (checkLock(GetActiveStudy()->getStudyDocument())) return;
3655   QStringList flt;
3656   flt.append( "Files (*.xls *.txt *.tab)" );
3657   flt.append( "All Files (*.*)" );
3658   QString aDir = getVisuInputDir();
3659   QFileInfo aFileInfo = QAD_FileDlg::getFileName(QAD_Application::getDesktop(),
3660                                            aDir,flt,tr("Import From File"),true);
3661   
3662   if(aFileInfo.exists()){
3663     QAD_Application::getDesktop()->putInfo( "Importing From File " + aFileInfo.filePath() + "..." );
3664     aDir = QAD_Tools::getDirFromPath(aFileInfo.filePath());
3665     QAD_CONFIG->addSetting("Visu:InputDir",aDir);
3666     QAD_WaitCursor wc;
3667
3668     CORBA::Object_var anObject;
3669 #ifdef CHECKTIME
3670     Utils_Timer timer;
3671     timer.Start();
3672 #endif
3673    
3674     anObject=GetVisuGen()->ImportTables(aFileInfo.filePath());
3675     
3676 #ifdef CHECKTIME
3677     timer.Stop();
3678     MESSAGE("VisuGUI::ImportTablesFromFile() - IMPORT FILE");
3679     timer.Show();
3680 #endif
3681     
3682     if(CORBA::is_nil(anObject)) {
3683       wc.stop();
3684       QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3685                               tr ("ERR_ERROR_IN_THE_FILE"),
3686                               tr ("VISU_BUT_OK") );
3687       wc.start();
3688     }
3689     else {
3690       QAD_Application::getDesktop()->putInfo(aFileInfo.filePath()+" imported.");
3691     }
3692     GetActiveStudy()->updateObjBrowser(); //update Object browser
3693   }
3694
3695
3696 void VisuGUI::ExportTableToFile() 
3697 {
3698   QAD_Study *aQADStudy = VisuGUI::GetActiveStudy();
3699   SALOME_Selection* aSel = SALOME_Selection::Selection (  aQADStudy -> getSelection() );
3700
3701   if( aSel->IObjectCount() > 0 ) {
3702     const Handle(SALOME_InteractiveObject)& anIO = aSel->firstIObject();
3703     if(anIO->hasEntry()){
3704       SALOMEDS::Study_var aStudy = aQADStudy->getStudyDocument();
3705       SALOMEDS::SObject_var aSObj = aStudy -> FindObjectID(anIO->getEntry());
3706       if(CORBA::is_nil(aSObj))  return; 
3707
3708       QString aTitle;
3709       SALOMEDS::GenericAttribute_var anAttr;
3710
3711       if (!aSObj->FindAttribute(anAttr, "AttributeTableOfReal") && 
3712           !aSObj->FindAttribute(anAttr, "AttributeTableOfInteger")) {
3713         aSObj = aSObj->GetFather(); //if the current SObject is a table title
3714                                     // we take a father contaning the table 
3715         if (!CORBA::is_nil(aSObj)) {
3716           if (!aSObj->FindAttribute(anAttr, "AttributeTableOfReal") && 
3717               !aSObj->FindAttribute(anAttr, "AttributeTableOfInteger"))
3718             return;
3719         }
3720         else return;
3721       }
3722       if (CORBA::is_nil(anAttr)) return;
3723
3724       SALOMEDS::AttributeTableOfReal_var aTabAttr = SALOMEDS::AttributeTableOfReal::_narrow(anAttr);
3725       if (!CORBA::is_nil(aTabAttr)) 
3726         aTitle  = aTabAttr->GetTitle(); //get table title in order to have default name of the file 
3727       else {
3728         SALOMEDS::AttributeTableOfInteger_var aTabAttr = SALOMEDS::AttributeTableOfInteger::_narrow(anAttr);
3729         if (!CORBA::is_nil(aTabAttr))
3730           aTitle  = aTabAttr->GetTitle(); //get table title in order to have default name of the file 
3731         else return;
3732       }
3733       aTitle.simplifyWhiteSpace();
3734       QStringList flt;
3735       flt.append("Table Files (*.xls)");
3736       
3737       QAD_FileDlg *aDlg = new QAD_FileDlg(QAD_Application::getDesktop(), false, true, true);
3738       aDlg -> setCaption("Export Table To File");
3739       aDlg -> setDir( getVisuOutputDir() );
3740       aDlg -> setFilters(flt);
3741       aDlg -> setSelection(aTitle.replace(QRegExp(" "), "_"));
3742       aDlg -> exec();
3743       QString aFile = aDlg -> selectedFile();
3744       delete aDlg;
3745
3746       if(!aFile.isEmpty()){
3747         QAD_Application::getDesktop()->putInfo( "Exporting To File " + aFile + "..." );
3748         QString aDir = QAD_Tools::getDirFromPath(aFile);
3749         QAD_CONFIG->addSetting("Visu:OutputDir",aDir);
3750         
3751         try {
3752           GetVisuGen() -> ExportTableToFile(aSObj, aFile.latin1());
3753           QAD_Application::getDesktop()->putInfo(aFile+" exported.");
3754         } catch(std::exception& ex) {
3755           INFOS(ex.what());
3756           QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3757                                  tr ("ERR_ERROR_DURING_EXPORT") + " " + tr(ex.what()),
3758                                  tr ("VISU_BUT_OK") );
3759         } catch(...) {
3760           INFOS(tr ("ERR_ERROR_DURING_EXPORT"));
3761           QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3762                                  tr ("ERR_ERROR_DURING_EXPORT"),
3763                                  tr ("VISU_BUT_OK") );
3764         } 
3765       } 
3766     }
3767   }
3768 }
3769 /* ======================================================================================== */
3770 /* Global Method to import mesh results in MED and DAT format                               */
3771 /* ======================================================================================== */
3772 void VisuGUI::ImportFile(){
3773   VisuGUI::ImportFromFile(&VISU::VISU_Gen_i::ImportFile);
3774 }
3775 void VisuGUI::CopyAndImportFile(){
3776   VisuGUI::ImportFromFile(&VISU::VISU_Gen_i::CopyAndImportFile);
3777 }
3778 void VisuGUI::ImportFromFile(TImportFun theImportFun){
3779   if (checkLock(GetActiveStudy()->getStudyDocument())) return;
3780   QStringList flt;
3781   //flt.append( "Exportable Files (*.med *.dat)" );
3782   //flt.append( "Dat Files (*.dat)" );
3783   flt.append( "Med Files (*.med)" );
3784   QString aDir = getVisuInputDir();
3785   QFileInfo aFileInfo = VisuGUI_FileDlg::getFileName(QAD_Application::getDesktop(),
3786                                                      aDir,flt,tr("Import From File"),true);
3787   
3788   if(aFileInfo.exists()){
3789     QAD_Application::getDesktop()->putInfo( "Importing From File " + aFileInfo.filePath() + "..." );
3790     aDir = QAD_Tools::getDirFromPath(aFileInfo.filePath());
3791     QAD_CONFIG->addSetting("Visu:InputDir",aDir);
3792     QAD_WaitCursor wc;
3793     
3794     VISU::Result_var aResult;
3795     
3796 #ifdef CHECKTIME
3797     Utils_Timer timer;
3798     timer.Start();
3799 #endif
3800     if(aFileInfo.extension(false) == "med"){
3801       QString IsBuild = QAD_CONFIG->getSetting("Visu:BuildResult");
3802       bool isBuild = (IsBuild.isEmpty()? 0 : IsBuild.toInt());
3803       if (VisuGUI_FileDlg::IsBuild){
3804         aResult = GetVisuGen()->ImportFile(aFileInfo.filePath());
3805         if(!CORBA::is_nil(aResult.in())) 
3806           if(VISU::Result_i* pResult = dynamic_cast<VISU::Result_i*>(GetServant(aResult).in())){
3807             if(!pResult->IsPossible())
3808               QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3809                                       tr ("ERR_CANT_BUILD_PRESENTATION"),
3810                                       tr ("VISU_BUT_OK") );
3811             else
3812               aResult->BuildAll();  
3813           }
3814       }else{
3815         QAD_CONFIG->addSetting( "Visu:BuildResult", false );
3816         //aResult=(GetVisuGen()->*theImportFun)(aFileInfo.filePath()); APO: 18/12/03 - fix crash on Linux RedHat 7.1
3817         aResult=GetVisuGen()->ImportFile(aFileInfo.filePath());     // APO: 18/12/03 - fix crash on Linux RedHat 7.1
3818         QAD_CONFIG->addSetting( "Visu:BuildResult", isBuild );
3819       }
3820     }
3821 #ifdef CHECKTIME
3822     timer.Stop();
3823     MESSAGE("VisuGUI::ImportFromFile() - IMPORT FILE");
3824     timer.Show();
3825 #endif
3826
3827     if(CORBA::is_nil(aResult.in())) {
3828       wc.stop();
3829       QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3830                              tr ("ERR_ERROR_IN_THE_FILE"),
3831                              tr ("VISU_BUT_OK") );
3832       wc.start();
3833     }
3834     else {
3835       QAD_Application::getDesktop()->putInfo(aFileInfo.filePath()+" imported.");
3836     }
3837     GetActiveStudy()->updateObjBrowser(); //update Object browser
3838   }
3839 }
3840
3841 void VisuGUI::ExportToFile(){
3842   CORBA::Object_var anObject = GetSelectedObj();
3843   if(CORBA::is_nil(anObject)) return;
3844   VISU::Base_i* aBase = dynamic_cast<VISU::Base_i*>(VISU::GetServant(anObject).in());
3845   if(aBase != NULL && aBase->GetType() == VISU::TRESULT){
3846     QStringList flt;
3847     flt.append( "Dat Files (*.dat)" );
3848     flt.append( "Med Files (*.med)" );
3849     QString aDir = getVisuOutputDir();
3850     QString aFile = QAD_FileDlg::getFileName(QAD_Application::getDesktop(),
3851                                              aDir,flt,tr("Export To File"),false);
3852     if(!aFile.isEmpty()){
3853       QAD_Application::getDesktop()->putInfo( "Exporting To File " + aFile + "..." );
3854       aDir = QAD_Tools::getDirFromPath(aFile);
3855       QAD_CONFIG->addSetting("Visu:OutputDir",aDir);
3856       if(VISU::Result_i* aResult = dynamic_cast<VISU::Result_i*>(aBase)){
3857         try{
3858           //APO - aResult->GetInput()->ToFile(aFile.latin1());
3859           QAD_Application::getDesktop()->putInfo(aFile+" exported.");
3860         }catch(std::exception& ex) {
3861           INFOS(ex.what());
3862           QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3863                                  tr ("ERR_ERROR_DURING_EXPORT") + " " +tr(ex.what()),
3864                                  tr ("VISU_BUT_OK") );
3865         } 
3866         catch(...){
3867           INFOS(tr ("ERR_ERROR_DURING_EXPORT").latin1());
3868           QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3869                                  tr ("ERR_ERROR_DURING_EXPORT"),
3870                                  tr ("VISU_BUT_OK") );
3871         } 
3872       }
3873     }
3874   }else
3875     QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3876                           tr ("WRN_NO_AVAILABLE_DATA"),
3877                           tr ("VISU_BUT_OK"));
3878 }
3879
3880 /* ======================================================================================== */
3881 /* Test and Read Object Browser before display                                              */
3882 /* ======================================================================================== */
3883 bool VisuGUI::TestObjectBrowser(SALOMEDS::SObject_var& objVisu ){
3884   if(MYDEBUG) MESSAGE("VisuGUI::TestObjectBrowser");
3885   Handle(SALOME_InteractiveObject) anIO;    
3886   CORBA::Object_var anObject = GetSelectedObj(&anIO);
3887   if(!anIO.IsNull() && anIO->hasEntry()){
3888     objVisu = GetStudyDocument()->FindObjectID(anIO->getEntry());
3889     QString aValue = getValue(objVisu,"myType");
3890     if((VISU::VISUType)aValue.toInt() == VISU::TTIMESTAMP) return true;
3891   }
3892   QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3893                         tr("WRN_NO_AVAILABLE_DATA"),
3894                         tr("VISU_BUT_OK") );
3895   return false;
3896 }
3897
3898 /**
3899  * Returns Actor of presentation if it exists
3900  */
3901 VISU_Actor* VisuGUI::GetActor(VISU::Prs3d_i* thePrs, VTKViewer_ViewFrame* theViewFrame){
3902   VTKViewer_ViewFrame* vf = theViewFrame? theViewFrame: GetVtkViewFrame();
3903   if (!vf) return NULL;
3904   vtkActor *anActor;
3905   vtkActorCollection *anActColl = vf->getRenderer()->GetActors();
3906   for(anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL;)
3907     if(VISU_Actor* anVISUActor = dynamic_cast<VISU_Actor*>(anActor))
3908       if(thePrs == anVISUActor->GetPrs3d())
3909         return anVISUActor->GetParent();
3910   return NULL;
3911 }
3912
3913 /** 
3914  * Displays only actor of given presentation
3915  * Creates it if it is abcent
3916  */
3917 VISU_Actor* VisuGUI::UpdateViewer(VISU::Prs3d_i* thePrs, bool theDispOnly){
3918   VTKViewer_ViewFrame* vf = GetVtkViewFrame();
3919   if (!vf) return NULL;
3920
3921   vtkRenderer *aRen = vf->getRenderer();
3922   vtkActorCollection *anActColl = aRen->GetActors();
3923
3924   vtkActor *anActor;
3925   VISU_Actor* anVISUActor = NULL;
3926   VISU_Actor* aResActor = NULL;
3927   VISU::Prs3d_i* aSrcAddr = thePrs;
3928   for(anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL; ){
3929     if(anActor->IsA("VISU_Actor")){ 
3930       anVISUActor = VISU_Actor::SafeDownCast(anActor);
3931       VISU::Prs3d_i* aPrs = anVISUActor->GetPrs3d();      
3932       if(aPrs == NULL) continue;
3933       if (thePrs == aPrs) {
3934         aResActor = anVISUActor->GetParent();
3935         thePrs->UpdateActor(aResActor);
3936         aResActor->VisibilityOn();
3937         
3938       } else if (theDispOnly) {
3939         anVISUActor->GetParent()->VisibilityOff();
3940       } else {
3941       }
3942     } else if (theDispOnly && anActor->GetVisibility()) {
3943       anActor->VisibilityOff();
3944     } else {
3945     } 
3946   }
3947   if (aResActor) return aResActor;
3948   try{
3949     anVISUActor = thePrs->CreateActor();
3950     vf->AddActor(anVISUActor);
3951   } catch ( std::runtime_error& exc ){
3952     INFOS(exc.what());
3953     QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3954                            tr("ERR_CANT_VISUALIZE_OBJECT") + " " + tr(exc.what()),
3955                            tr ("VISU_BUT_OK") );
3956     anVISUActor = NULL;
3957   }
3958   return anVISUActor;
3959 }
3960
3961
3962 /** 
3963  * Returns TRUE if Presentation is displayed                                               
3964  */
3965 bool VisuGUI::IsDisplayed(VISU::Prs3d_i* thePrs) {
3966   VISU_Actor* anVISUActor = GetActor(thePrs);
3967   return (anVISUActor)? anVISUActor->GetVisibility() : false;
3968 }
3969
3970 /** 
3971  * Erases Presentation
3972  */
3973 void VisuGUI::ErasePrs(VISU::Prs3d_i* thePrs) {
3974   GetActiveStudy()->unHighlightAll();
3975   VISU_Actor* anVISUActor = GetActor(thePrs);
3976   if (anVISUActor) {
3977     anVISUActor->VisibilityOff();
3978   }
3979 }
3980
3981 /**
3982  * Deletes given presentation from Data structure
3983  */
3984 void VisuGUI::DeletePresentation(VISU::Prs3d_i* thePrs) {
3985   if(checkLock(GetStudyDocument()) || !thePrs) return;
3986   GetActiveStudy()->unHighlightAll();
3987   for(int i = 0, nbFrames = GetActiveStudy()->getStudyFramesCount(); i < nbFrames; i++)
3988     if(QAD_StudyFrame* aFrame = GetActiveStudy()->getStudyFrame(i)){
3989       QAD_ViewFrame* aVFrame = aFrame->getRightFrame()->getViewFrame();
3990       if(VTKViewer_ViewFrame* aViewFrame = dynamic_cast<VTKViewer_ViewFrame*>(aVFrame)){
3991         if(VISU_Actor* anActor = GetActor(thePrs,aViewFrame)){
3992           aViewFrame->RemoveActor(anActor);
3993           anActor->Delete();
3994         }
3995         aViewFrame->unHighlightAll();
3996       }
3997     }
3998   thePrs->RemoveFromStudy(); 
3999   GetActiveStudy()->updateObjBrowser(); //update Object browser
4000 }
4001
4002 /**
4003  * Creates new actor of presentation
4004  */
4005 void VisuGUI::CreateActor(VISU::Prs3d_i* thePrs) {
4006   if (GetActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_VTK) return;
4007   if (!thePrs) return;
4008   QApplication::setOverrideCursor( Qt::waitCursor );
4009   if(VTKViewer_ViewFrame* vf = GetVtkViewFrame()){
4010 #ifdef CHECKTIME
4011     Utils_Timer timer;
4012     timer.Start();
4013 #endif
4014     try{
4015       MESSAGE("Available memory : "<<VISU_PipeLine::GetAvailableMemory());
4016       VISU_Actor* aActor = thePrs->CreateActor();
4017       vf->AddActor(aActor);
4018     }catch(std::runtime_error& exc) {
4019       INFOS("std::runtime_error "<<exc.what());
4020       INFOS("Available memory : "<<VISU_PipeLine::GetAvailableMemory());
4021       QApplication::restoreOverrideCursor();
4022       QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
4023                                 tr ("WRN_CANT_VISUALIZE_PRS") + " " + tr(exc.what()),
4024                                 tr ("VISU_BUT_OK") );
4025       throw exc;
4026     } catch (...) {
4027       MESSAGE(" Unknown exception");
4028       QApplication::restoreOverrideCursor();
4029       INFOS("Unknown exception is caught in VisuGUI::CreateActor");
4030       INFOS("Available memory : "<<VISU_PipeLine::GetAvailableMemory());
4031       QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
4032                              tr ("WRN_CANT_VISUALIZE_PRS") + " " + tr("ERR_UNKNOWN_EXCEPTION"),
4033                              tr ("VISU_BUT_OK") );
4034       throw ;
4035     }
4036 #ifdef CHECKTIME
4037     timer.Stop();
4038     MESSAGE("VisuGUI::CreateActor(VISU::Prs3d_i* thePrs) - DISPLAY ACTOR");
4039     timer.Show();
4040 #endif
4041   }
4042   QApplication::restoreOverrideCursor();
4043 }
4044
4045
4046
4047 /* ======================================================================================== */
4048 /* Functions to State of VisuGUI and Dialog Box                                             */
4049 /* ======================================================================================== */
4050
4051 void VisuGUI::SetState(int aState )
4052 {  
4053         this->myState = aState ;  
4054         return ; 
4055 }
4056
4057
4058 void VisuGUI::ResetState()
4059 {  
4060         this->myState = -1 ;  
4061         return ; 
4062 }
4063
4064 void VisuGUI::EmitSignalDeactivateDialog()
4065 {
4066         emit this->SignalDeactivateActiveDialog() ;
4067         return ;
4068 }
4069
4070 void VisuGUI::EmitSignalCloseAllDialogs()
4071 {
4072         emit this->SignalCloseAllDialogs() ;
4073         return ;
4074 }
4075
4076 QDialog* VisuGUI::GetActiveDialogBox()
4077 {
4078         return this->myActiveDialogBox ;
4079 }
4080
4081 void VisuGUI::SetActiveDialogBox(QDialog* aDlg)
4082 {
4083         this->myActiveDialogBox = (QDialog*)aDlg ;
4084         return ;
4085 }