Salome HOME
Join modifications from branch OCC_development_for_3_2_0a2
[modules/visu.git] / src / VISUGUI / VisuGUI.cxx
index 6e4b1d19734b8a90f3ac7a86b8aa3e82be241ed3..3c2ad86737b9aaf2a87f8df20288fd1f937663c3 100644 (file)
 //  VISU VISUGUI : GUI of VISU component
 //
 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
-// 
-//  This library is free software; you can redistribute it and/or 
-//  modify it under the terms of the GNU Lesser General Public 
-//  License as published by the Free Software Foundation; either 
-//  version 2.1 of the License. 
-// 
-//  This library is distributed in the hope that it will be useful, 
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of 
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
-//  Lesser General Public License for more details. 
-// 
-//  You should have received a copy of the GNU Lesser General Public 
-//  License along with this library; if not, write to the Free Software 
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
-// 
-//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
+//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of the GNU Lesser General Public
+//  License as published by the Free Software Foundation; either
+//  version 2.1 of the License.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
 //
 //
 //
 //  File   : VisuGUI.cxx
-//  Author : Laurent CORNABE
+//  Author :
 //  Module : VISU
 //  $Header$
 
 #include "VisuGUI.h"
 
-#include "VISU_Gen_i.hh"
-#include "VISU_Result_i.hh"
-#include "VISU_PrsObject_i.hh"
-#include "VISU_ViewManager_i.hh"
+// STL Includes
+#include <exception>
+#include <typeinfo>
+#include <vector>
+
+// QT Includes
+#include <qptrlist.h>
+#include <qptrvector.h>
+#include <qcolordialog.h>
+#include <qdatetime.h>
+
+// VTK Includes
+#include <vtkRenderer.h>
+#include <vtkRenderWindow.h>
+#include <vtkActorCollection.h>
+#include <vtkTimerLog.h>
+
+// SALOME Includes
+#include "SALOME_LifeCycleCORBA.hxx"
+
+#include "SUIT_ResourceMgr.h"
+#include "SUIT_MessageBox.h"
+
+#include "SUIT_ViewWindow.h"
+#include "SUIT_ViewManager.h"
+
+#include "CAM_Module.h"
+
+#include "SVTK_ViewWindow.h"
+#include "SVTK_ViewModel.h"
+#include "SVTK_Functor.h"
+
+#include "SPlot2d_ViewModel.h"
+#include "VisuGUI_SetupPlot2dDlg.h"
+#include "Plot2d_SetupCurveDlg.h"
+#include "Plot2d_ViewManager.h"
+
+#include "OB_Browser.h"
+
+#include "SALOME_ListIO.hxx"
+#include "SALOME_ListIteratorOfListIO.hxx"
+
+#include "SalomeApp_Application.h"
+#include "SalomeApp_DataModel.h"
+#include "SalomeApp_Study.h"
+#include "SalomeApp_CheckFileDlg.h"
+#include "LightApp_SelectionMgr.h"
+#include "LightApp_Selection.h"
+#include "LightApp_Preferences.h"
 
-#include "VISU_PipeLine.hxx"
+#include "QtxAction.h"
 
-#include "VISU_Prs3d_i.hh"
+#include "VISUConfig.hh"
+#include "VISU_Gen_i.hh"
 #include "VISU_Mesh_i.hh"
-#include "VISU_ScalarMap_i.hh"
-#include "VISU_IsoSurfaces_i.hh"
-#include "VISU_DeformedShape_i.hh"
-#include "VISU_CutPlanes_i.hh"
-#include "VISU_CutLines_i.hh"
-#include "VISU_Vectors_i.hh"
-#include "VISU_StreamLines_i.hh"
 #include "VISU_Table_i.hh"
+#include "VISU_Result_i.hh"
+#include "VISU_View_i.hh"
+#include "VISU_ViewManager_i.hh"
+#include "VISU_Plot3D_i.hh"
 
 #include "VISU_Actor.h"
-#include "VISU_MeshAct.h"
 
-#include "VisuGUI_MagnitudeDlg.h"
+#include "VisuGUI_Prs3dTools.h"
+#include "VisuGUI_Tools.h"
+
+#include "VisuGUI_PopupTools.h"
+#include "VisuGUI_NameDlg.h"
 #include "VisuGUI_CursorDlg.h"
+#include "VisuGUI_Selection.h"
+#include "VisuGUI_TimeAnimation.h"
+#include "VisuGUI_EditContainerDlg.h"
+#include "VisuGUI_ClippingDlg.h"
+#include "VisuGUI_Plot3DDlg.h"
+#include "VisuGUI_OffsetDlg.h"
+#include "VisuGUI_Displayer.h"
+#include "VisuGUI_BuildProgressDlg.h"
+#include "VisuGUI_TransparencyDlg.h"
+
+#include "VISU_ScalarMap_i.hh"
 #include "VisuGUI_ScalarBarDlg.h"
-#include "VisuGUI_SweepPrefDlg.h"
+
+#include "VISU_DeformedShape_i.hh"
+#include "VisuGUI_DeformedShapeDlg.h"
+
+#include "VISU_ScalarMapOnDeformedShape_i.hh"
+#include "VisuGUI_ScalarMapOnDeformedShapeDlg.h"
+
+#include "VISU_IsoSurfaces_i.hh"
+#include "VisuGUI_IsoSurfacesDlg.h"
+
+#include "VISU_CutPlanes_i.hh"
 #include "VisuGUI_CutPlanesDlg.h"
+
+#include "VISU_CutLines_i.hh"
 #include "VisuGUI_CutLinesDlg.h"
-#include "VisuGUI_VectorsDlg.h"
-#include "VisuGUI_IsoSurfacesDlg.h"
-#include "VisuGUI_StreamLinesDlg.h"
-#include "VisuGUI_EditContainerDlg.h"
-#include "VisuGUI_TimeAnimation.h"
 
-#include "VisuGUI_Selection.h"
-#include "VisuGUI_NonIsometricDlg.h"
+#include "VISU_StreamLines_i.hh"
+#include "VisuGUI_StreamLinesDlg.h"
 
-#include "SALOMEGUI_ImportOperation.h"
-#include "SALOMEGUI_QtCatchCorbaException.hxx"
-#include "utilities.h"
+#include "VISU_Vectors_i.hh"
+#include "VisuGUI_VectorsDlg.h"
 
-#include "QAD_Config.h"
-
-#include "QAD_Settings.h"
-#include "QAD_Tools.h"
-#include "QAD_LeftFrame.h"
-#include "QAD_RightFrame.h"
-#include "QAD_MessageBox.h"
-#include "QAD_ObjectBrowser.h"
-#include "QAD_ObjectBrowserItem.h"
-#include "QAD_Menus.h"
-#include "QAD_Resource.h"
-#include "QAD_ResourceMgr.h"
-#include "QAD_FileDlg.h"
-#include "QAD_WaitCursor.h"
-#include "SALOME_Selection.h"
-#include "SALOMEGUI_NameDlg.h"
-#include "SALOMEGUI_TableDlg.h"
-#include "SALOMEGUI_SetupCurveDlg.h"
-#include "SALOMEGUI_SetValueDlg.h"
-#include "SALOMEGUI_Desktop.h"
-#include "Plot2d_SetupPlot2dDlg.h"
-#include "Plot2d_ViewFrame.h"
-#include "VTKViewer_ViewFrame.h"
-#include "VTKViewer_RenderWindow.h"
-#include "VTKViewer_InteractorStyleSALOME.h"
-#include "VTKViewer_RenderWindowInteractor.h"
-#include "VisuGUI_FileDlg.h"
+#include "VisuGUI_TableDlg.h"
 
-// QT Includes
-#define  INCLUDE_MENUITEM_DEF
-#include <qpopupmenu.h>
-#include <qfont.h>
-#include <qpainter.h>
-#include <qstring.h>
-#include <qapplication.h>
-#include <qinputdialog.h>  
-#include <qcolordialog.h>
-#include <qlabel.h>
-#include <qspinbox.h>
-#include <qradiobutton.h>
-#include <qthread.h>
-#include <qlistbox.h>
-#include <qcombobox.h>
-#include <qregexp.h> 
-
-//VRV: porting on Qt 3.0.5
-#if QT_VERSION >= 0x030005
-#include <qlistview.h>
-#endif
-//VRV: porting on Qt 3.0.5
-#include <qmessagebox.h>
+#include "SALOMEconfig.h"
+#include CORBA_SERVER_HEADER(MED_Gen)
 
-#include CORBA_CLIENT_HEADER(MED_Gen)
+#include "utilities.h"
 
-#include <vtkActor.h>
-#include <vtkRenderer.h>
-#include <vtkDataSetMapper.h>
-#include <vtkActorCollection.h>
+#include "VisuGUI_ActionsDef.h"
 
-// Open CASCADE Include
-#include <TCollection_AsciiString.hxx>
+#include "VisuGUI_Timer.h"
 
-//#define CHECKTIME 
-#ifdef CHECKTIME
-static int MYCHECKTIME = 1;
-#else
-static int MYCHECKTIME = 0;
-#endif
-#include <Utils_Timer.hxx>
+#include "VVTK_ViewModel.h"
 
-using namespace std;
+using namespace VISU;
 
 #ifdef _DEBUG_
-static int MYDEBUG = 0;
+static int MYDEBUG = 1;
 #else
 static int MYDEBUG = 0;
 #endif
 
-class CustomItem : public QCustomMenuItem
-{
-public:
-  CustomItem(const QString& s, const QFont& f) : myString(s), myFont(f) {}
-  ~CustomItem() {}
-
-  void paint(QPainter* p, const QColorGroup& cg, bool act, bool /*enabled*/, int x, int y, int w, int h)
-  {
-    p->save();
-    p->fillRect( x, y, w, h, act ? cg.highlight() : cg.mid() );
-    p->setPen( act ? cg.highlightedText() : cg.buttonText() );
-    p->setFont( myFont );
-    p->drawText( x, y, w, h, AlignHCenter | AlignVCenter | ShowPrefix | DontClip | SingleLine, myString );
-    p->restore();
-  }
-
-  QSize sizeHint()
-  {
-    return QFontMetrics( myFont ).size( AlignHCenter | AlignVCenter | ShowPrefix | DontClip | SingleLine, myString );
-  }
+//////////////////////////////////////////////////
+// Class: VisuGUI
+//////////////////////////////////////////////////
 
-  bool fullSpan() const
-  {
-    return true;
-  }
-
-private:
-  QString myString;
-  QFont   myFont;
-};
-
-inline bool IsSObjectTable(SALOMEDS::SObject_ptr theSObject){
-  if(!theSObject->_is_nil()) {
-    SALOMEDS::GenericAttribute_var anAttr;
-    if(theSObject->FindAttribute( anAttr, "AttributeTableOfInteger" ))
-      return true;
-    if(theSObject->FindAttribute( anAttr, "AttributeTableOfReal" ))
-      return true;
-  }  
-  return false;
+VisuGUI::VisuGUI():
+  SalomeApp_Module( "VISU" ),
+  myDisplayer( 0 )
+{
 }
 
 
-static VisuGUI MYVISUGUI;
-VisuGUI *visuGUI = &MYVISUGUI;
-
-VISU::VISU_Gen_i* VisuGUI::GetVisuGen(){
-  VISU::VISU_Gen_i::GetVisuGenImpl()->SetCurrentStudy(GetStudyDocument());
-  return VISU::VISU_Gen_i::GetVisuGenImpl();
-}
-
-static int ComputeVisiblePropBounds(VTKViewer_ViewFrame* theViewFrame, float allBounds[6], 
-                                   const char* theActorClassName = "VISU_Actor")
+VisuGUI::~VisuGUI()
 {
-  vtkRenderer *aRen = theViewFrame->getRenderer();
-  vtkActorCollection *anActColl = aRen->GetActors(); 
-  vtkProp    *prop;
-  float      *bounds;
-  int        nothingVisible=1;
-
-  allBounds[0] = allBounds[2] = allBounds[4] = VTK_LARGE_FLOAT;
-  allBounds[1] = allBounds[3] = allBounds[5] = -VTK_LARGE_FLOAT;
-  // loop through all props
-  for (anActColl->InitTraversal(); (prop = anActColl->GetNextProp()); ){
-    // if it's invisible, or has no geometry, we can skip the rest 
-    if ( prop->GetVisibility() && prop->IsA(theActorClassName)){
-      bounds = prop->GetBounds();
-      // make sure we haven't got bogus bounds
-      if ( bounds != NULL &&
-           bounds[0] > -VTK_LARGE_FLOAT && bounds[1] < VTK_LARGE_FLOAT &&
-           bounds[2] > -VTK_LARGE_FLOAT && bounds[3] < VTK_LARGE_FLOAT &&
-           bounds[4] > -VTK_LARGE_FLOAT && bounds[5] < VTK_LARGE_FLOAT )
-        {
-         nothingVisible = 0;
-         if (bounds[0] < allBounds[0]) allBounds[0] = bounds[0]; 
-         if (bounds[1] > allBounds[1]) allBounds[1] = bounds[1]; 
-         if (bounds[2] < allBounds[2]) allBounds[2] = bounds[2]; 
-         if (bounds[3] > allBounds[3]) allBounds[3] = bounds[3]; 
-         if (bounds[4] < allBounds[4]) allBounds[4] = bounds[4]; 
-         if (bounds[5] > allBounds[5]) allBounds[5] = bounds[5]; 
-        }//not bogus
-      }
-    }  
-  return nothingVisible;
 }
 
-VisuGUI::CameraOrient VisuGUI::SetFitAll(VTKViewer_ViewFrame* theViewFrame){ 
-  static float PRECISION = 0.000001;
-  static float DEVIATION = 600;
-  float XYZ_Bnd[6];
-  if(ComputeVisiblePropBounds(theViewFrame,XYZ_Bnd)) return e3D;
+void
+VisuGUI::
+OnImportFromFile()
+{
+  if(MYDEBUG) MESSAGE("VisuGUI::OnImportFromFile()");
+  if ( CheckLock(GetCStudy(GetAppStudy(this)),GetDesktop(this)) )
+    return;
+  
+  SUIT_ResourceMgr* aResourceMgr = GetResourceMgr();
 
-  float absX = XYZ_Bnd[1]-XYZ_Bnd[0];
-  float absY = XYZ_Bnd[3]-XYZ_Bnd[2];
+  // Get file name
+  QStringList aFilter;
+  aFilter.append( tr( "FLT_MED_FILES" ) );
+  aFilter.append( tr( "FLT_ALL_FILES" ) );
   
-  float absZ = XYZ_Bnd[5]-XYZ_Bnd[4];
+  bool toUseBuildProgress = aResourceMgr->booleanValue("VISU", "use_build_progress", false);
+
+  SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg( GetDesktop(this), true, tr("USE_BUILD_PROGRESS") );
+  fd->setCaption( tr( "IMPORT_FROM_FILE" ) );
+  fd->setFilters( aFilter );
+  fd->SetChecked( toUseBuildProgress );
+  fd->exec();
+  QFileInfo aFileInfo( fd->selectedFile() );
+  toUseBuildProgress = fd->IsChecked();
+  delete fd;
   
-  CameraOrient aCameraOrient = e3D;
-  if(absX <= PRECISION) aCameraOrient = eFront;
-  else {if(absY <= PRECISION) aCameraOrient = eLeft;
-  else {if(absZ <= PRECISION) aCameraOrient = eTop;}}
+  // Check the file name
+  if ( !aFileInfo.exists() )
+    return;
   
-    float dev_abs_XY = absX / absY;
-    float dev_abs_YZ = absY / absZ;
-    float dev_abs_XZ = absX / absZ;
-    if(dev_abs_XY >= DEVIATION || 1./dev_abs_YZ >= DEVIATION) aCameraOrient = eLeft;
-    else{if(1./dev_abs_XY >= DEVIATION || 1./dev_abs_XZ >= DEVIATION) aCameraOrient = eFront; 
-    else {if(dev_abs_XZ >= DEVIATION || dev_abs_YZ >= DEVIATION) aCameraOrient = eTop;}}  
-  switch(aCameraOrient){
-  case eFront: theViewFrame->onViewFront();  break;
-  case eLeft:  theViewFrame->onViewLeft();   break;
-  case eTop:   theViewFrame->onViewTop();    break;
-  case e3D:    theViewFrame->onViewReset();  break; 
-  }
-  theViewFrame->getRenderer()->ResetCameraClippingRange();
-  theViewFrame->onViewFitAll();
-  return aCameraOrient;
-}
-QAD_Desktop* VisuGUI::GetDesktop(){
-  return QAD_Application::getDesktop() ;
-}
-
-QAD_Study* VisuGUI::GetActiveStudy(){
-  return GetDesktop()->getActiveStudy() ;
-}
-
-vtkRenderer* VisuGUI::GetRenderer(){
-  if(VTKViewer_ViewFrame* aViewFrame = GetVtkViewFrame())
-    return aViewFrame->getRenderer();
-  return NULL;
-}
-
-VTKViewer_ViewFrame* VisuGUI::GetVtkViewFrame(){
-  QAD_ViewFrame* aViewFrame = GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame();
-  return dynamic_cast<VTKViewer_ViewFrame*>(aViewFrame);
-}
+  if ( !toUseBuildProgress )
+    {
+      bool toBuildFields = aResourceMgr->booleanValue( "VISU", "build_fields", true );
+      bool toBuildMinMax = aResourceMgr->booleanValue( "VISU", "build_min_max", true );
+      bool toBuildGroups = aResourceMgr->booleanValue( "VISU", "build_groups", true );
+      bool toBuildAll = aResourceMgr->booleanValue( "VISU", "full_med_loading", false );
+      bool toBuildAtOnce = aResourceMgr->booleanValue( "VISU", "build_at_once", false );
+      
+      QString anInfo("Importing From File " + aFileInfo.filePath() + "..." ); 
+      application()->putInfo( anInfo );
+
+      QApplication::setOverrideCursor(Qt::waitCursor);
+      VISU::Result_var aResult = GetVisuGen(this)->CreateResult( aFileInfo.filePath() );
+
+      if (CORBA::is_nil(aResult.in())) {
+       SUIT_MessageBox::warn1(GetDesktop(this),
+                              tr("WRN_VISU"),
+                              VisuGUI_BuildProgressDlg::tr("ERR_ERROR_IN_THE_FILE"),
+                              tr("BUT_OK"));
+       QApplication::restoreOverrideCursor();
+      }else{
+       aResult->SetBuildFields( toBuildFields, toBuildMinMax );
+       aResult->SetBuildGroups( toBuildGroups );
+       aResult->Build( toBuildAll, toBuildAtOnce );
 
-static void UpdateViewFrame() {
-  QList<QAD_StudyFrame> aFrameList = VisuGUI::GetActiveStudy()->getStudyFrames();
-
-  for (QAD_StudyFrame* aStudyFrame = aFrameList.first(); aStudyFrame; aStudyFrame = aFrameList.next()) {
-    if (aStudyFrame->getTypeView() == VIEW_VTK) {
-      QAD_ViewFrame* aViewFrame = aStudyFrame->getRightFrame()->getViewFrame();
-      VTKViewer_ViewFrame* aVtkViewFrame = dynamic_cast<VTKViewer_ViewFrame*>(aViewFrame);
-      if (!aVtkViewFrame) continue;
-      VTKViewer_RenderWindowInteractor* anInteractor = aVtkViewFrame->getRWInteractor();
-      if (anInteractor) {
-       anInteractor->SetSelectionProp();
-       anInteractor->SetSelectionTolerance();
-       VTKViewer_InteractorStyleSALOME* aStyle = anInteractor->GetInteractorStyleSALOME();
-       if (aStyle) {
-         aStyle->setPreselectionProp();
-       }
+       UpdateObjBrowser(this);
+       application()->putInfo( anInfo + tr("INF_DONE"));
+       QApplication::restoreOverrideCursor();
       }
     }
-  }
-}
-
-SALOMEDS::Study_var VisuGUI::GetStudyDocument(){
-  return GetActiveStudy()->getStudyDocument();
-}
-
-SALOMEDS::StudyBuilder_var VisuGUI::NewBuilder(){
-  return GetStudyDocument()->NewBuilder();
+  else
+    {
+      VisuGUI_BuildProgressDlg* aBuildProgressDlg = new VisuGUI_BuildProgressDlg( GetDesktop(this) );
+      aBuildProgressDlg->setFileName( aFileInfo.filePath() );
+      aBuildProgressDlg->setGenerator( GetVisuGen(this) );
+      aBuildProgressDlg->show();
+    }
 }
 
+void
+VisuGUI::
+OnImportTableFromFile()
+{
+  if(MYDEBUG) MESSAGE("VisuGUI::OnImportTableFromFile()");
+  if ( CheckLock(GetCStudy(GetAppStudy(this)),GetDesktop(this)) )
+    return;
 
-/**
- * Finds value by given key
- */
-
-VISU::Storable::TRestoringMap VisuGUI::getMapOfValue(SALOMEDS::SObject_var theSObject) {
-  VISU::Storable::TRestoringMap aMap;
-  if(!theSObject->_is_nil()){
-    SALOMEDS::GenericAttribute_var anAttr;
-    if (theSObject->FindAttribute(anAttr, "AttributeComment")) {
-      SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(anAttr);
-      CORBA::String_var aString = aComment->Value();
-      QString strIn(aString.in());
-      VISU::Storable::StrToMap(strIn,aMap);
+  QStringList aFilter;
+  aFilter.append( tr("FLT_TABLE_FILES") );
+  aFilter.append( tr("FLT_ALL_FILES") );
+
+  QFileInfo aFileInfo =
+    SUIT_FileDlg::getFileName(GetDesktop(this),
+                              "",
+                              aFilter,
+                              tr("MEN_IMPORT_TABLE"),
+                              true);
+  if (aFileInfo.exists()) {
+    application()->putInfo( tr("MEN_IMPORT_TABLE") + " " + aFileInfo.filePath() + " ..." );
+
+    CORBA::Object_var anObject = GetVisuGen(this)->ImportTables(aFileInfo.filePath());
+
+    if (CORBA::is_nil(anObject.in())) {
+      SUIT_MessageBox::warn1(GetDesktop(this),
+                             tr("WRN_VISU"),
+                             tr("ERR_ERROR_IN_THE_FILE"),
+                             tr("BUT_OK"));
+    } else {
+      application()->putInfo(aFileInfo.filePath()+tr("INF_DONE"));
+      UpdateObjBrowser(this);
     }
   }
-  return aMap;
 }
 
-QString VisuGUI::getValue(SALOMEDS::SObject_var theSObject, QString theKey) {
-  QString aStr("");
-  VISU::Storable::TRestoringMap aMap = getMapOfValue(theSObject);
-  if(!aMap.empty())
-    aStr = VISU::Storable::FindValue(aMap, theKey.latin1());
-  return aStr;
-}
+void
+VisuGUI::
+OnExportTableToFile()
+{
+  if(MYDEBUG) MESSAGE("VisuGUI::OnExportTableToFile()");
+
+  _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
+
+  LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
+  SALOME_ListIO aListIO;
+  aSelectionMgr->selectedObjects(aListIO);
+
+  if (aListIO.Extent() > 0) {
+    const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
+    if (anIO->hasEntry()) {
+      _PTR(SObject) aSObj = aCStudy->FindObjectID(anIO->getEntry());
+      if (!aSObj) return;
+
+      // find table attribute
+      bool isTOR = true;
+      _PTR(GenericAttribute) anAttr;
+
+      if (!aSObj->FindAttribute(anAttr, "AttributeTableOfReal")) {
+        isTOR = false;
+        if (!aSObj->FindAttribute(anAttr, "AttributeTableOfInteger")) {
+          // if the current SObject is a table title
+          // we take a father contaning the table
+          aSObj = aSObj->GetFather();
+
+          if (aSObj->FindAttribute(anAttr, "AttributeTableOfReal")) {
+            isTOR = true;
+          } else {
+            if (!aSObj->FindAttribute(anAttr, "AttributeTableOfInteger")) {
+              return;
+            }
+          }
+        }
+      }
 
+      // get table title in order to have default name of the file
+      QString aTitle;
+      if (isTOR) {
+        _PTR(AttributeTableOfReal) aTabAttr (anAttr);
+        if (!aTabAttr) return;
+        aTitle = aTabAttr->GetTitle().c_str();
+      } else {
+       _PTR(AttributeTableOfInteger) aTabAttr (anAttr);
+       if (!aTabAttr) return;
+        aTitle = aTabAttr->GetTitle().c_str();
+      }
+      aTitle.simplifyWhiteSpace();
+      aTitle = aTitle.replace(QRegExp(" "), "_").replace(QRegExp("\\*"), "" );
+
+      // get default path for the file
+      SUIT_ResourceMgr* aResourceMgr = GetResourceMgr();
+      QString aDir = aResourceMgr->stringValue("VISU","OutputDir","");
+      if (aDir.isEmpty()) {
+        aDir = aResourceMgr->stringValue("VISU","InputDir","");
+        if (aDir.isEmpty()) {
+          aDir = getenv("CSF_PATHData");
+        }
+      }
+      QString aPath = Qtx::addSlash(aDir) + aTitle;
+
+      // get name for the file
+      QStringList aFilter;
+      aFilter.append("Table Files (*.xls)");
+
+      QFileInfo aFileInfo =
+        SUIT_FileDlg::getFileName(GetDesktop(this),
+                                  aPath,
+                                  aFilter,
+                                  tr("MEN_EXPORT_TABLE"), // "Export Table To File"
+                                  false);
+
+      // export
+      QString aFile = aFileInfo.filePath();
+      if (!aFile.isEmpty()) {
+        application()->putInfo(tr("MEN_EXPORT_TABLE") + " " + aFile + " ...");
+       aDir = Qtx::dir(aFile, true);
+        aResourceMgr->setValue("VISU", "OutputDir", aDir);
 
-CORBA::Object_var GetSelectedObj(Handle(SALOME_InteractiveObject)* pIO = NULL, QAD_Study* theStudy = NULL,
-                                VISU::Storable::TRestoringMap* pMap = NULL)
-{
-  if(theStudy == NULL) theStudy = VisuGUI::GetActiveStudy();
-  SALOME_Selection* aSel = SALOME_Selection::Selection(theStudy->getSelection());
-  if(aSel->IObjectCount() > 0){
-    const Handle(SALOME_InteractiveObject)& anIO = aSel->firstIObject();
-    if(pIO != NULL) *pIO = anIO;
-    if(anIO->hasEntry()){
-      SALOMEDS::Study_var aStudy = theStudy->getStudyDocument();
-      SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(anIO->getEntry());
-      if(!aSObject->_is_nil()){
-       SALOMEDS::GenericAttribute_var anAttr;
-       if (pMap != NULL && aSObject->FindAttribute(anAttr, "AttributeComment")) {
-         SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(anAttr);
-         string aComm = aComment->Value();
-         QString strIn(aComm.c_str());
-         VISU::Storable::StrToMap(strIn,*pMap);
+       try {
+         GetVisuGen(this)->ExportTableToFile(GetSObject(aSObj), aFile.latin1());
+          application()->putInfo(aFile + " " + tr("INF_DONE"));
+       } catch(std::exception& exc) {
+         INFOS(exc.what());
+         SUIT_MessageBox::warn1(GetDesktop(this),
+                                 tr("WRN_VISU"),
+                                tr("ERR_ERROR_DURING_EXPORT") + " " + tr(exc.what()),
+                                tr("BUT_OK"));
+       } catch(...) {
+         INFOS(tr("ERR_ERROR_DURING_EXPORT"));
+         SUIT_MessageBox::warn1(GetDesktop(this),
+                                 tr("WRN_VISU"),
+                                tr("ERR_ERROR_DURING_EXPORT"),
+                                tr("BUT_OK") );
        }
-       return VISU::SObjectToObject(aSObject);
       }
     }
   }
-  return CORBA::Object::_nil();
-}
-
-
-int IsTrihedronDisplayed(){
-  if(VTKViewer_ViewFrame* aVTKViewFrame = VisuGUI::GetVtkViewFrame())
-    return aVTKViewFrame->isTrihedronDisplayed();
-  return 1;
 }
 
+void
+VisuGUI::
+OnImportMedField()
+{
+  _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
+  if (CheckLock(aCStudy,GetDesktop(this)))
+    return;
+  SALOMEDS::Study_var aStudy = GetDSStudy(aCStudy);
 
-void RepaintCurrentView(){
-  if(VTKViewer_ViewFrame* vf = VisuGUI::GetVtkViewFrame()) vf->Repaint();
-}
-
-
-VisuGUI::VisuGUI( const QString& theName, QObject* theParent ): 
-  SALOMEGUI( theName, theParent ) 
-{    
-  mySelectionDlg = 0;
-}
-
-/* ==================================================================================== */
-/* ==================================================================================== */
-/*                                     ONGUI EVENT                                     */
-/* ==================================================================================== */
-/* ==================================================================================== */
-
-static int isStudyLocked(const SALOMEDS::Study_var& theStudy){
-  return theStudy->GetProperties()->IsLocked();
-}
+  LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
+  SALOME_ListIO aListIO;
+  aSelectionMgr->selectedObjects(aListIO);
 
-static int checkLock(const SALOMEDS::Study_var& theStudy) {
-  if (isStudyLocked(theStudy)) {
-    QAD_MessageBox::warn1 ( (QWidget*)QAD_Application::getDesktop(),
-                          QObject::tr("WRN_WARNING"), 
-                          QObject::tr("WRN_STUDY_LOCKED"),
-                          QObject::tr("BUT_OK") );
-    return true;
+  SALOME_ListIteratorOfListIO It (aListIO);
+  QApplication::setOverrideCursor(Qt::waitCursor);
+  for (; It.More(); It.Next()) {
+    Handle(SALOME_InteractiveObject) anIO = It.Value();
+    SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(anIO->getEntry());
+    if (!aSObject->_is_nil()) {
+      CORBA::Object_var anObject = VISU::SObjectToObject(aSObject);
+      if (!CORBA::is_nil(anObject)) {
+        SALOME_MED::MED_var aMED = SALOME_MED::MED::_narrow(anObject);
+        if (!CORBA::is_nil(aMED.in()))
+          GetVisuGen(this)->ImportMed(aSObject);
+        SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow(anObject);
+        if (!CORBA::is_nil(aField.in()))
+          GetVisuGen(this)->ImportMedField(aField);
+      } else {
+        SALOMEDS::SObject_var aSFather = aSObject->GetFather();
+        SALOMEDS::GenericAttribute_var anAttr;
+        aSFather->FindAttribute(anAttr, "AttributeName");
+        SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
+        CORBA::String_var aValue = aName->Value();
+        if (strcmp(aValue.in(), "MEDFIELD") == 0)
+          GetVisuGen(this)->ImportMed(aSObject);
+      }
+    }
   }
-  return false;
+  UpdateObjBrowser(this, true);
+  QApplication::restoreOverrideCursor();
 }
 
-
-
-bool VisuGUI::OnGUIEvent(int theCommandID,  QAD_Desktop* parent)
+void
+CreateCurves( SalomeApp_Module* theModule,
+              VISU::CutLines_i* thePrs,
+              QDialog* theDlg,
+              const bool theCreate = true )
 {
-  try{
-    QString VisuInputDir = getVisuInputDir();
-    QString VisuOutputDir = getVisuOutputDir();
-    
-    SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument(); //Document OCAF de l'etude active
-    SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
-    SALOMEDS::GenericAttribute_var anAttr;
-    SALOMEDS::AttributeName_var    aName;
-    SALOMEDS::AttributeIOR_var     anIOR;
-    
-    switch (theCommandID){
-      /* ======================================================================================== */
-      /* Import Table from file                                                                  */
-      /* ======================================================================================== */
-    case 199:
-      {
-       if(checkLock(aStudy)) break;
-       visuGUI->ImportTablesFromFile();
-       break;
-      }
-
-      /* ======================================================================================== */
-      /* Import Mesh from MED, DAT file                                                                  */
-      /* ======================================================================================== */
-
-    case 111:
-      {
-       visuGUI->CopyAndImportFile();
-       break;
-      }
-    case 112:
-      {
-       visuGUI->ImportFile();
-       break;
-      }
-
-      /* ======================================================================================== */
-      /* Export results and mesh into a file format                                              */
-      /* ======================================================================================== */
-
-    case 122:
-      {
-       //visuGUI->ExportToFile();
-       break;
-      }
-
-     /* ========================================================================== */
-     /* Visualization of Results :                                                 */
-     /* 4011 : Scalar Map                                                          */
-     /* 4012 : Deformed Shape                                                      */
-     /* 4013 : Vectors                                                             */
-     /* 4014 : Iso-Surfaces                                                        */
-     /* 4015 : Cut Planes                                                          */
-     /* 4016 : Stream Lines                                                        */
-     /* ========================================================================== */
-
-    case 4011 :
-      visuGUI->CreateScalarMap();
-      break;
-    case 4012 :
-      visuGUI->CreateDeformedShape();
-      break;
-    case 4013 :
-      visuGUI->CreateVectors();
-      break;
-    case 4014 :
-      visuGUI->CreateIsoSurfaces();
-      break;
-    case 4015 :
-      visuGUI->CreateCutPlanes();
-      break;
-    case 4018 :
-      visuGUI->CreateCutLines();
-      break;
-    case 4016 :
-      visuGUI->CreateStreamLines();
-      break;
-
-    case 4111 :
-      visuGUI->SelectionInfo();
-      break;
-
-      /* ========================================================================================================================= */
-      /* Visualization - Wireframe                                                                                                */
-      /* ========================================================================================================================= */
-
-    case 4211 :
-      ChangeViewer(1);
-      break;
-
-      /* ========================================================================================================================= */
-      /* Visualization - Surface                                                                                                  */
-      /* ========================================================================================================================= */
-
-    case 4212 :
-      ChangeViewer(2);
-      break;
-
-      /* ========================================================================================================================= */
-      /* Visualization - Points                                                                                                           */
-      /* ========================================================================================================================= */
-
-    case 4213 :
-      ChangeViewer(0);
-      break;
-
-      /* ========================================================================================================================= */
-      /* Visualization - Erase                                                                                                    */
-      /* ========================================================================================================================= */
-
-    case 422 :
-      ChangeViewer(-1);
-      break;
-
-      /* ========================================================================================================================= */
-      /* Visualization - Global                                                                                                           */
-      /* ========================================================================================================================= */
-
-      //case 423 :
-                  
-      /* ========================================================================================================================= */
-      /* Visualization - Partial                                                                                                  */
-      /* ========================================================================================================================= */
-
-      //case 424 :
-
-      case 430 :
-       {  
-         //Show dialog that allows to select scale function and corresponding scale factor
-         VisuGUI_NonIsometricDlg* m_NonIsoDlg = new VisuGUI_NonIsometricDlg ( QAD_Application::getDesktop(), "m_NonIsoDlg",
-                                                                             FALSE, Qt::WDestructiveClose );
-         m_NonIsoDlg->show();
-         break;
-       }
-
-      /* ============================ */
-      /*  POP-UP OBJECTS BROWSER      */
-      /* ============================ */
-
-    case 900 : // Rename object
-      visuGUI->Rename();
-      break;
-
-                // ---------------- For Popup in Viewer
-    case 802  : // Erase
-    case 902  : // Erase
-      visuGUI->ErasePrs();
-      break;
-
-    case 803  : // Display only
-    case 903  : // Display only
-      visuGUI->DisplayOnlyPrs();
-      break;
-
-    case 901  : // Display
-      visuGUI->DisplayPrs();
-      break;
-
-    case 8041 : // Object representation : Wireframe
-    case 9041 : // Object representation : Wireframe
-      visuGUI->ChangeRepresentation(VISU::WIREFRAME);
-      break;
-
-    case 8042 : // Object representation : Surface
-    case 9042 : // Object representation : Surface
-      visuGUI->ChangeRepresentation(VISU::SHADED);
-      break;
-
-    case 8043 : // Object representation : Points
-    case 9043 : // Object representation : Points
-      visuGUI->ChangeRepresentation(VISU::POINT);
-      break;
-
-    case 8044 : // Object representation : Shrink/Unshrink
-    case 9044 : // Object representation : Shrink/Unshrink
-      visuGUI->ChangeRepresentation(VISU::SHRINK);
-      break;
-
-    case 8051 : // Change object color
-    case 9051 : // Change object color
-      visuGUI->ChageColor();
-      break;
-
-    case 8052 : // Change object opacity
-    case 9052 : // Change object opacity
-      visuGUI->ChangeOpacity();
-      break;
-
-    case 8053 : // Change object line width
-    case 9053 : // Change object line width
-      visuGUI->ChangeLines();
-      break;
-
-    case 808  : // Sweep IsoSurfaces or Cutplanes
-    case 908  : // Sweep IsoSurfaces or Cutplanes
-      visuGUI->Sweep();
-      break;
-
-/* ======================================================================================== */
-/* Preferences for Scalar Bar                                                               */
-/* ======================================================================================== */
-    case 51:
-      {
-       ChangeScalarBar();
-       break;
-      }
+  if ( !thePrs )
+    return;
+  VisuGUI_CutLinesDlg* aCutDlg = dynamic_cast<VisuGUI_CutLinesDlg*>( theDlg );
+  if ( !aCutDlg )
+    return;
 
-/* ======================================================================================== */
-/* Preferences for Sweeping                                                               */
-/* ======================================================================================== */
-    case 52:
-      {
-       SetSweepingPreferences();
+  _PTR(Study)   aStudy = GetCStudy( GetAppStudy( theModule ) );
+  _PTR(SObject) aSObject = aStudy->FindObjectID( thePrs->GetEntry().latin1() );
+
+  if ( !theCreate && aSObject ) {
+    // Remove old Table
+    _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
+    _PTR(ChildIterator) aIter = aStudy->NewChildIterator(aSObject);
+    for (; aIter->More(); aIter->Next()) {
+      _PTR(SObject) aTblObj = aIter->Value();
+      if ( aTblObj ) {
+        _PTR(GenericAttribute) anAttr;
+        if (aTblObj->FindAttribute( anAttr, "AttributeName" ) ) {
+          aBuilder->RemoveObjectWithChildren( aTblObj ); // We should have only one child
+         UpdateObjBrowser(theModule,true,aTblObj);
+          break;
+        }
       }
-      break;
-
-/* ======================================================================================== */
-/* Preferences for Full loading                                                             */
-/* ======================================================================================== */
-    case 53:
-    case 54:
-      {
-       QMenuData* pp;
-       QMenuItem* item = parent->menuBar()->findItem(theCommandID,&pp);
-       bool check = !pp->isItemChecked(theCommandID);
-       pp->setItemChecked(theCommandID,check);
-       switch(theCommandID){
-       case 53:
-         QAD_CONFIG->addSetting( "Visu:BuildResult", check );
-         break;
-       case 54:
-         QAD_CONFIG->addSetting( "Visu:BuildDefaultPrs3d", check );
-         break;
-       }
-      }
-      break;
+    }
+  }
 
-    case 113: // Load MED using MED component
-      {
-       if (checkLock(GetStudyDocument())) break;
-
-       Engines::Component_var aMedComp = GetDesktop()->getEngine("FactoryServer", "MED");
-       if (CORBA::is_nil(aMedComp)) return false;
-       SALOME_MED::MED_Gen_var aMedGen = SALOME_MED::MED_Gen::_narrow(aMedComp);
-       if (CORBA::is_nil(aMedGen)) return false;
-
-       QStringList filtersList ;       
-       
-       filtersList.append( tr("MED_MEN_IMPORT_MED") );
-       filtersList.append( tr("MED_MEN_ALL_FILES") ) ;
-       QString aFileName = QAD_FileDlg::getFileName(GetDesktop(),
-                                                    "",
-                                            filtersList,
-                                                    tr("MED_MEN_IMPORT"),
-                                                    true);
-       if (!aFileName.isEmpty()) {
-         QApplication::setOverrideCursor( Qt::waitCursor );
-         aMedGen->readStructFileWithFieldType(aFileName.latin1(), GetActiveStudy()->getTitle());
-         GetActiveStudy()->updateObjBrowser();
-         QApplication::restoreOverrideCursor();
-       }
+  if ( aCutDlg->isGenerateTable() ) {
+    GetVisuGen( theModule )->CreateTable( thePrs->GetEntry() );
+    if ( aCutDlg->isGenerateCurves() ) {
+      if ( aSObject ) {
+        _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
+        _PTR(ChildIterator) aIter = aStudy->NewChildIterator(aSObject);
+        for (; aIter->More(); aIter->Next()) {
+          _PTR(SObject) aTblObj = aIter->Value();
+          if ( aTblObj ) {
+            _PTR(GenericAttribute) anAttr;
+            if ( aTblObj->FindAttribute( anAttr, "AttributeName" ) ) {
+              CreatePlot( theModule, aTblObj );
+            }
+          }
+        }
       }
-      break;
-
-    default:
-      QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
-                             tr ("MSG_NOT_IMPLEMENTED"),
-                             tr ("VISU_BUT_OK") );
-      break;
-    } 
-  } catch (const std::bad_alloc& e ) { 
-    INFOS("bad_alloc exception is caught "<<e.what());
-    QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
-                         tr("ERR_NO_MEMORY") + " " + tr(e.what()),
-                         tr("VISU_BUT_OK") );
-    return false;
     }
-  catch (std::exception& e){
-    INFOS(e.what());
-    QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
-                         tr(e.what()),
-                         tr("VISU_BUT_OK") );
-  }catch (const SALOME::SALOME_Exception& S_ex) {
-    INFOS("const SALOME::SALOME_Exception& S_ex");
-    QtCatchCorbaException(S_ex);
-    return false;
   }
-  catch(...) {
-    INFOS(tr("ERR_UNKNOWN_EXCEPTION").latin1());
-    QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
-                         tr("ERR_UNKNOWN_EXCEPTION"),
-                         tr("VISU_BUT_OK") );
-    return false;
-  }
-  return true;
-}
 
-void VisuGUI::SelectionInfo() {
-  mySelectionDlg = new VisuGUI_SelectionDlg();
-  mySelectionDlg->show();
+  if (!theCreate && aSObject) {
+    UpdateObjBrowser(theModule);
+  }
 }
 
+void
+VisuGUI::
+OnCreateMesh()
+{
+  _PTR(Study) aStudy = GetCStudy(GetAppStudy(this));
+  if (CheckLock(aStudy,GetDesktop(this)))
+    return;
 
+  // Get selected SObject
+  Handle(SALOME_InteractiveObject) anIO;
+  CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
+  if (anIO.IsNull() || !anIO->hasEntry())
+    return;
 
+  // create a VTK view window if it does not exist
+  SVTK_ViewWindow* aViewWindow = GetViewWindow<SVTK_Viewer>(this);
 
-/* ********************************************************************************** */
-/* Function ShowTrihedron                                                             */
-/* ********************************************************************************** */
-
-void VisuGUI::ShowTrihedron(bool ShowThd){
-  bool ThdIsVisible = true; 
-  if( ShowThd && !ThdIsVisible)
-    ((VTKViewer_ViewFrame*)visuGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->onViewTrihedron();
-  if( !ShowThd && ThdIsVisible)
-    ((VTKViewer_ViewFrame*)visuGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->onViewTrihedron();
+  // create mesh presentation and display it in aViewWindow
+  CreateMesh(this, anIO, aViewWindow);
 }
 
-/* ********************************************************************************** */
-/* Destructor                                                                        */
-/* Clear all tmp files used in VISU                                                  */
-/* ********************************************************************************** */
+void
+VisuGUI::
+OnCreateManyMesh()
+{
+  _PTR(Study) aStudy = GetCStudy(GetAppStudy(this));
+  if (CheckLock(aStudy,GetDesktop(this)))
+    return;
 
-VisuGUI::~VisuGUI(){
-  if(MYDEBUG) MESSAGE("VisuGUI::~VisuGUI");
-}
-                       
-/* ********************************************************************************** */
-/* Function ChangeViewer                                                             */
-/* Change representation of all actors                                               */
-/* ********************************************************************************** */
-
-void VisuGUI::ChangeViewer(int theType){
-  if(theType < 0 ) 
-    GetActiveStudy()->unHighlightAll();
-  if(vtkRenderer *aRen = GetRenderer()){
-    vtkActor *anActor;
-    vtkActorCollection *anActColl = aRen->GetActors();
-    for(anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL; ){
-      if(anActor->GetVisibility() > 0)
-       if(VISU_Actor* anVISUActor = VISU_Actor::SafeDownCast(anActor)){ 
-         anVISUActor = anVISUActor->GetParent();
-         if(theType >= 0)
-           anVISUActor->SetRepresentation(theType); 
-         else
-           anVISUActor->VisibilityOff();
-       }
-    }
-    RepaintCurrentView();
+  // create a VTK view window if it does not exist
+  SVTK_ViewWindow* aViewWindow = GetViewWindow<SVTK_Viewer>(this);
+
+  // Get selected SObject
+  LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
+  SALOME_ListIO aListIO;
+  aSelectionMgr->selectedObjects(aListIO);
+  SALOME_ListIteratorOfListIO anIter (aListIO);
+  for (; anIter.More(); anIter.Next()) {
+    Handle(SALOME_InteractiveObject) anIO = anIter.Value();
+    if (anIO.IsNull() || !anIO->hasEntry())
+      return;
+
+    // create mesh presentation and display it in aViewWindow
+    CreateMesh(this, anIO, aViewWindow);
   }
 }
 
-// -----------------------------------------------------------------------------------------
-// EVENTS
-// -----------------------------------------------------------------------------------------
-
-bool VisuGUI::OnMousePress (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
+void
+VisuGUI::
+OnCreateScalarMap()
 {
-  return true;
+  CreatePrs3d<VISU::ScalarMap_i,VisuGUI_ScalarBarDlg,1>(this);
 }
 
-// ====================================================================================================================
 
-bool VisuGUI::OnMouseMove (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
+void
+VisuGUI::
+OnCreateDeformedShape()
 {
-  return true;
+  CreatePrs3d<VISU::DeformedShape_i,VisuGUI_DeformedShapeDlg,1>(this);
 }
 
-// ===================================================================================================================
-
-bool VisuGUI::OnKeyPress (QKeyEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
+void
+VisuGUI::
+OnCreateScalarMapOnDeformedShape()
 {
-  if (GetActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_VTK) // true = Viewer OCC
-    return false;
+  CreatePrs3d<VISU::ScalarMapOnDeformedShape_i,VisuGUI_ScalarMapOnDeformedShapeDlg,1>(this);
+}
 
-  if(MYDEBUG) MESSAGE( "VisuGUI::onKeyPress : " << pe->key() )
+void
+VisuGUI::
+OnCreateVectors()
+{
+  CreatePrs3d<VISU::Vectors_i,VisuGUI_VectorsDlg,1>(this);
+}
 
-  switch ( pe->key() )
-    {
-    case Key_Escape :
-      {
-         if(MYDEBUG) MESSAGE("--> Key : Escape")
-         return true;    
-      }
-    default :
-       return true;
-       break;
-   }
- return true;
+void
+VisuGUI::
+OnCreateIsoSurfaces()
+{
+  CreatePrs3d<VISU::IsoSurfaces_i,VisuGUI_IsoSurfacesDlg,1>(this);
 }
 
+void
+VisuGUI::
+OnCreateCutPlanes()
+{
+  CreatePrs3d<VISU::CutPlanes_i,VisuGUI_CutPlanesDlg,0>(this);
+}
 
+void
+VisuGUI::
+OnCreateCutLines()
+{
+  CreatePrs3d<VISU::CutLines_i,VisuGUI_CutLinesDlg,0>(this);
+}
 
-//=====================================================================================
-// Slot-functions for presentations creation
-//=====================================================================================
+void
+VisuGUI::
+OnCreateStreamLines()
+{
+  CreatePrs3d<VISU::StreamLines_i,VisuGUI_StreamLinesDlg,1>(this);
+}
 
-#define CREATEPRESENTATION(FunctionName)  \
- void FunctionName() { \
-   if (checkLock(GetStudyDocument())) return; \
-   SALOMEDS::SObject_var objVisu;  \
-   if (!TestObjectBrowser(objVisu)) return;  \
-   if(!FunctionName(objVisu)) return; \
-   GetActiveStudy()->updateObjBrowser(); \
-   GetDesktop()->putInfo("Ready"); \
-   VTKViewer_ViewFrame* vf = GetVtkViewFrame(); \
-   if (vf) { \
-     /*vf->getRenderer()->ResetCameraClippingRange();*/ \
-     vf->onViewFitAll(); \
-   } \
- } 
+void
+VisuGUI::
+OnCreatePlot3D()
+{
+  CreatePrs3d<VISU::Plot3D_i,VisuGUI_Plot3DDlg,0>(this);
+}
 
+void
+VisuGUI::
+OnCreatePlot2dView()
+{
+  CheckLock(GetCStudy(GetAppStudy(this)),GetDesktop(this));
+  GetVisuGen( this )->CreateContainer();
+  UpdateObjBrowser(this);
+}
 
-CREATEPRESENTATION(VisuGUI::CreateScalarMap);
-CREATEPRESENTATION(VisuGUI::CreateDeformedShape);
-CREATEPRESENTATION(VisuGUI::CreateVectors);
-CREATEPRESENTATION(VisuGUI::CreateIsoSurfaces);
-CREATEPRESENTATION(VisuGUI::CreateCutPlanes);
-CREATEPRESENTATION(VisuGUI::CreateCutLines);
-CREATEPRESENTATION(VisuGUI::CreateStreamLines);
+void
+VisuGUI::
+OnDisplayPrs()
+{
+  if(MYDEBUG) MESSAGE("VisuGUI::OnDisplayPrs");
 
+  LightApp_SelectionMgr* mgr = GetSelectionMgr(this);
+  if (!mgr) return;
 
+  QApplication::setOverrideCursor(Qt::waitCursor);
 
-//=====================================================================================
-// function : SetSettings()
-// purpose  :
-//=====================================================================================
-bool VisuGUI::SetSettings(QAD_Desktop* parent)
-{
-  int anId = 53;
-  QMenuData* pp;
-  QMenuItem* item = parent->menuBar()->findItem(anId,&pp);
-  QString aValue = QAD_CONFIG->getSetting("Visu:BuildResult");
-  
-  if(aValue.isEmpty()? 0 : aValue.toInt()) 
-    pp->setItemChecked(anId, true);
-  
-  anId = 54;
-  item = parent->menuBar()->findItem(anId,&pp);
-  aValue  = QAD_CONFIG->getSetting("Visu:BuildDefaultPrs3d");
-  
-  if(aValue.isEmpty()? 0 : aValue.toInt()) 
-    pp->setItemChecked(anId, true);
-  
-  anId = 50;
-  parent->menuBar()->changeItem(anId,parent->getComponentUserName("VISU"));
+  SVTK_ViewWindow* vw = GetActiveViewWindow<SVTK_ViewWindow>(this);
 
-  ::UpdateViewFrame();
+  SALOME_ListIO aSel, aList;
+  mgr->selectedObjects(aSel);
+  extractContainers(aSel, aList);
 
-  return true;
-}
+  for (SALOME_ListIteratorOfListIO it (aList); it.More(); it.Next()) {
+    Handle(SALOME_InteractiveObject) anIO = it.Value();
+    CORBA::Object_var anObject = GetSelectedObj(GetAppStudy(this), anIO->getEntry());
 
-//=====================================================================================
-// function : DisplayPrs()
-// purpose  :
-//=====================================================================================
-void VisuGUI::DisplayPrs() {
-  if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs");
-  Handle(SALOME_InteractiveObject) anIO;
-  CORBA::Object_var anObject = GetSelectedObj(&anIO);
-  if ( !CORBA::is_nil( anObject ) ) {
-    // is it Prs3d object ?
-    VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject).in());
-    if(aPrsObject){
-      if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Prs3d object");
-      UpdateViewer(aPrsObject);
-      if (VTKViewer_ViewFrame* vf = GetVtkViewFrame()) {
-       vf->getRenderer()->ResetCameraClippingRange();
-       vf->Repaint();
-       vf->highlight(anIO, 1);
+    if (!CORBA::is_nil(anObject)) {
+      // is it Prs3d object ?
+      VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject).in());
+      if (aPrsObject) {
+        if(MYDEBUG) MESSAGE("VisuGUI::OnDisplayPrs : Prs3d object");
+        //UpdateViewer( this, aPrsObject );
+        if (vw) {
+         displayer()->Display(anIO->getEntry());
+         vw->highlight(anIO, 1);
+        }
+        continue;
       }
-      return;
-    }
-    // is it Curve ?
-    VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(anObject).in());
-    if(aCurve){
-      if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Curve object");
-      PlotCurve(aCurve, VISU::eDisplay );
-      return;
-    }
-    // is it Container ?
-    VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(anObject).in());
-    if(aContainer){
-      if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Container object");
-      PlotContainer(aContainer, VISU::eDisplay );
-      return;
-    }
-    // is it Table ?
-    VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(anObject).in());
-    if(aTable){
-      if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Table object");
-      PlotTable(aTable, VISU::eDisplay );
-      return;
-    }
-  }
-}
-
-//=====================================================================================
-// function : DisplayOnlyPrs()
-// purpose  :
-//=====================================================================================
-void VisuGUI::DisplayOnlyPrs() {
-  if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyPrs");
-  CORBA::Object_var anObject = GetSelectedObj();
-  if ( !CORBA::is_nil( anObject ) ) {
-    // is it Prs3d object ?
-    PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
-    if(VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(aServant.in())){
-      if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyPrs : Prs3d object");
-      UpdateViewer(aPrsObject, true);
-      VTKViewer_ViewFrame* vf = GetVtkViewFrame();
-      if (vf) {
-       vf->getRenderer()->ResetCameraClippingRange();
-       vf->Repaint();
+      // is it Curve ?
+      VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(anObject).in());
+      if (aCurve) {
+        if(MYDEBUG) MESSAGE("VisuGUI::OnDisplayPrs : Curve object");
+        //PlotCurve( this, aCurve, VISU::eDisplay );
+       displayer()->Display(anIO->getEntry());
+        continue;
+      }
+      // is it Container ?
+      VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(anObject).in());
+      if (aContainer) {
+        if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Container object");
+        //PlotContainer( this, aContainer, VISU::eDisplay );
+       displayer()->Display(anIO->getEntry());
+        continue;
+      }
+      // is it Table ?
+      VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(anObject).in());
+      if (aTable) {
+        if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Table object");
+        //PlotTable( this, aTable, VISU::eDisplay );
+       displayer()->Display(anIO->getEntry());
+        continue;
       }
-    }else if(VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(aServant.in())){
-      if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyPrs : Curve object");
-      PlotCurve(aCurve, VISU::eDisplayOnly );
-    }else if(VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(aServant.in())){
-      if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyPrs : Container object");
-      PlotContainer(aContainer, VISU::eDisplayOnly );
-    }else if(VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(aServant.in())){
-      if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyPrs : Table object");
-      PlotTable(aTable, VISU::eDisplayOnly );
     }
   }
-}
 
-//=====================================================================================
-// function : ErasePrs()
-// purpose  :
-//=====================================================================================
-static void ErasePrs(CORBA::Object_ptr theObject) {
-  if(MYDEBUG) MESSAGE("ErasePrs");
-  if ( !CORBA::is_nil( theObject ) ) {
-    VISU::Base_var aBase = VISU::Base::_narrow(theObject);
-    if ( CORBA::is_nil( aBase ) ) return;
-    VISU::VISUType aType = aBase->GetType();
-    switch (aType){
-    case VISU::TCURVE:{
-      if(VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aBase).in()))
-       VisuGUI::PlotCurve(aCurve, VISU::eErase );
-      break;
-    }
-    case VISU::TCONTAINER:{
-      if(VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aBase).in()))
-       VisuGUI::PlotContainer(aContainer, VISU::eErase );
-      break;
-    }
-    case VISU::TTABLE:{
-      if(VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aBase).in()))
-       VisuGUI::PlotTable(aTable, VISU::eErase );
-      break;
-    }
-    default:{
-      if(VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(aBase).in())){
-       VisuGUI::ErasePrs(aPrsObject);
-       if (VTKViewer_ViewFrame* vf = VisuGUI::GetVtkViewFrame())
-         vf->Repaint();
-      }
-    }}
+  if (vw) {
+    vw->getRenderer()->ResetCameraClippingRange();
+    vw->Repaint();
   }
-}
 
-void VisuGUI::ErasePrs() {
-  ::ErasePrs(GetSelectedObj());
+  QApplication::restoreOverrideCursor();
 }
 
-
-//=====================================================================================
-// function : DisplayManyPrs()
-// purpose  :
-//=====================================================================================
-void VisuGUI::DisplayManyPrs()
+void
+VisuGUI::
+OnDisplayOnlyPrs()
 {
-  if(MYDEBUG) MESSAGE("VisuGUI::DisplayManyPrs");
-  SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection());
-  SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
-  for ( ; It.More(); It.Next() ) {
-    Handle(SALOME_InteractiveObject)& anIO = It.Value();
-    if ( anIO->hasEntry() ) {
-      SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
-      SALOMEDS::SObject_var aSObject = aStudy->FindObjectID( anIO->getEntry() );
-      VISU::Storable::TRestoringMap pMap;
-      if( !aSObject->_is_nil() ) {
-       CORBA::Object_var aCORBAObject = VISU::SObjectToObject(aSObject);
-       if ( !CORBA::is_nil( aCORBAObject ) ) {
-         // is it Prs3d object ?
-         VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(aCORBAObject).in());
-         if(aPrsObject){
-           if(MYDEBUG) MESSAGE("VisuGUI::DisplayManyPrs : Prs3d object");
-           UpdateViewer(aPrsObject);
-           VTKViewer_ViewFrame* vf = GetVtkViewFrame();
-           if (vf) {
-             vf->getRenderer()->ResetCameraClippingRange();
-             vf->Repaint();
-             vf->highlight(anIO, 1);
-           }
-           continue;
-         }
-         // is it Curve ?
-         VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCORBAObject).in());
-         if(aCurve){
-           if(MYDEBUG) MESSAGE("VisuGUI::DisplayManyPrs: Curve object");
-           PlotCurve(aCurve, VISU::eDisplay );
-           continue;
-         }
-         // is it Container ?
-         VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aCORBAObject).in());
-         if(aContainer){
-           if(MYDEBUG) MESSAGE("VisuGUI::DisplayManyPrs : Container object");
-           PlotContainer(aContainer, VISU::eDisplay );
-           continue;
-         }
-         // is it Table ?
-         VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aCORBAObject).in());
-         if(aTable){
-           if(MYDEBUG) MESSAGE("VisuGUI::DisplayManyPrs : Table object");
-           PlotTable(aTable, VISU::eDisplay );
-           continue;
-         }
-       }
-      }
-    }
-  }
+  OnEraseAll();
+  OnDisplayPrs();
 }
 
-//=====================================================================================
-// function : DisplayOnlyManyPrs()
-// purpose  :
-//=====================================================================================
-void VisuGUI::DisplayOnlyManyPrs() {
-  if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyManyPrs");
-  SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection());
-  SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
-  bool aFirstElem = true;
-  for ( ; It.More(); It.Next() ) {
-    Handle(SALOME_InteractiveObject)& anIO = It.Value();
-    if ( anIO->hasEntry() ) {
-      SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
-      SALOMEDS::SObject_var aSObject = aStudy->FindObjectID( anIO->getEntry() );
-      VISU::Storable::TRestoringMap pMap;
-      if( !aSObject->_is_nil() ) {
-       CORBA::Object_var aCORBAObject = VISU::SObjectToObject(aSObject);
-       if ( !CORBA::is_nil( aCORBAObject ) ) {
-         // is it Prs3d object ?
-         VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(aCORBAObject).in());
-         if(aPrsObject){
-           if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyManyPrs : Prs3d object");
-           UpdateViewer(aPrsObject, aFirstElem);
-           if (aFirstElem) aFirstElem = false;
-           VTKViewer_ViewFrame* vf = GetVtkViewFrame();
-           if (vf) {
-             vf->getRenderer()->ResetCameraClippingRange();
-             vf->Repaint();
-             vf->highlight(anIO, 1);
-           }
-           continue;
-         }
-         // is it Curve ?
-         VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCORBAObject).in());
-         if(aCurve){
-           if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyManyPrs: Curve object");
-           if (aFirstElem) {
-             PlotCurve(aCurve, VISU::eDisplayOnly );
-             aFirstElem = false;
-           }
-           else PlotCurve(aCurve, VISU::eDisplay );
-           continue;
-         }
-         // is it Container ?
-         VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aCORBAObject).in());
-         if(aContainer){
-           if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyManyPrs : Container object");
-           if (aFirstElem) {
-             PlotContainer(aContainer, VISU::eDisplayOnly );
-             aFirstElem = false;
-           }
-           else PlotContainer(aContainer, VISU::eDisplay );
-           continue;
-         }
-         // is it Table ?
-         VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aCORBAObject).in());
-         if(aTable){
-           if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyManyPrs : Table object");
-           if (aFirstElem) {
-             PlotTable(aTable, VISU::eDisplayOnly );
-             aFirstElem = false;
-           }
-           else PlotTable(aTable, VISU::eDisplay );
-           continue;
-         }
-       }
-      }
-    }
-  }
-}
-
-
-//=====================================================================================
-// function : EraseManyPrs()
-// purpose  :
-//=====================================================================================
-void VisuGUI::EraseManyPrs()
+void
+VisuGUI::
+OnErasePrs()
 {
-  if(MYDEBUG) MESSAGE("VisuGUI::EraseManyPrs");
-  SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection());
-  SALOME_ListIO LIO; LIO = Sel->StoredIObjects();
-  SALOME_ListIteratorOfListIO It( LIO );
-  for ( ; It.More(); It.Next() ) {
-    Handle(SALOME_InteractiveObject)& anIO = It.Value();
-    if ( anIO->hasEntry() ) {
-      SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
-      SALOMEDS::SObject_var aSObject = aStudy->FindObjectID( anIO->getEntry() );
-      VISU::Storable::TRestoringMap pMap;
-      if( !aSObject->_is_nil() ) {
-       CORBA::Object_var aCORBAObject = VISU::SObjectToObject(aSObject);
-       if ( !CORBA::is_nil( aCORBAObject ) ) {
-         // is it Prs3d object ?
-         VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(aCORBAObject).in());
-         if(aPrsObject){
-           if(MYDEBUG) MESSAGE("VisuGUI::EraseManyPrs : Prs3d object");
-           ErasePrs(aPrsObject);
-           VTKViewer_ViewFrame* vf = GetVtkViewFrame();
-           if (vf) {
-             vf->Repaint();
-           }
-           continue;
-         }
-         // is it Curve ?
-         VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCORBAObject).in());
-         if(aCurve){
-           if(MYDEBUG) MESSAGE("VisuGUI::EraseManyPrs : Curve object");
-           PlotCurve(aCurve, VISU::eErase );
-           continue;
-         }
-         // is it Container ?
-         VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aCORBAObject).in());
-         if(aContainer){
-           if(MYDEBUG) MESSAGE("VisuGUI::EraseManyPrs : Container object");
-           PlotContainer(aContainer, VISU::eErase );
-           continue;
-         }
-         // is it Table ?
-         VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aCORBAObject).in());
-         if(aTable){
-           if(MYDEBUG) MESSAGE("VisuGUI::EraseManyPrs : Table object");
-           PlotTable(aTable, VISU::eErase );
-           continue;
-         }
-       }
-      }
-    }
-  }
-}
+  if(MYDEBUG) MESSAGE("OnErasePrs");
 
-//=====================================================================================
-// function : RecreateActor()
-// purpose  :
-//=====================================================================================
-void VisuGUI::RecreateActor(VISU::Prs3d_i* thePrs) {
   QApplication::setOverrideCursor(Qt::waitCursor);
-  try{
-    thePrs->Update();
-    //UpdateViewer(thePrs); Avoid unnessary settings of visibility on for thePrs
-    for(int i = 0, nbFrames = GetActiveStudy()->getStudyFramesCount(); i < nbFrames; i++)
-      if(QAD_StudyFrame* aFrame = GetActiveStudy()->getStudyFrame(i)){
-       QAD_ViewFrame* aVFrame = aFrame->getRightFrame()->getViewFrame();
-       if(VTKViewer_ViewFrame* aViewFrame = dynamic_cast<VTKViewer_ViewFrame*>(aVFrame))
-         if(VISU_Actor* anActor = GetActor(thePrs,aViewFrame))
-           thePrs->UpdateActor(anActor);
-      }
-  }catch(std::runtime_error& ex){
-    INFOS(ex.what());
-    QApplication::restoreOverrideCursor();
-    QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"), 
-                           tr ("ERR_CANT_BUILD_PRESENTATION") + " " + tr(ex.what()), 
-                           tr ("VISU_BUT_OK") );
-    for(int i = 0, nbFrames = GetActiveStudy()->getStudyFramesCount(); i < nbFrames; i++)
-      if(QAD_StudyFrame* aFrame = GetActiveStudy()->getStudyFrame(i)){
-       QAD_ViewFrame* aVFrame = aFrame->getRightFrame()->getViewFrame();
-       if(VTKViewer_ViewFrame* aViewFrame = dynamic_cast<VTKViewer_ViewFrame*>(aVFrame)) {
-         if(VISU_Actor* anActor = GetActor(thePrs,aViewFrame)) {
-           aViewFrame->RemoveActor(anActor);
-           anActor->Delete();
-         }
-       }
-      }
-    return;
-  }
-  QApplication::restoreOverrideCursor();
-}
 
+  //SVTK_ViewWindow* vw = GetActiveViewWindow<SVTK_ViewWindow>(this);
+  //if (vw)
+  //  vw->unHighlightAll();
 
-//=====================================================================================
-// function : EditPrs()
-// purpose  :
-//=====================================================================================
-#define EDITPRS(PrsName, DlgName)  \
-    { \
-      PrsName* aPrsObject = dynamic_cast<PrsName*>(aPrs3d); \
-      if (aPrsObject) { \
-       DlgName* aDlg = new DlgName(); \
-        aDlg->initFromPrsObject(aPrsObject); \
-       if ( aDlg->exec() )  { \
-         if(!(aDlg->storeToPrsObject(aPrsObject))){ \
-           delete aDlg; \
-            return; \
-          } \
-         RecreateActor(aPrsObject); \
-         if (VTKViewer_ViewFrame* vf = GetVtkViewFrame()) { \
-           if ( vf->getRenderer()->GetActors()->GetNumberOfItems () > 0 ) { \
-                 vf->getRenderer()->ResetCameraClippingRange(); \
-                vf->Repaint(); \
-             }\
-         } \
-       } \
-       delete aDlg; \
-      } \
-    }
+  SALOME_ListIO aList, aSel;
+  LightApp_SelectionMgr* mgr = GetSelectionMgr(this);
+  mgr->selectedObjects(aSel);
+  extractContainers(aSel, aList);
 
-void VisuGUI::EditPrs() {
-  VISU::Prs3d_i* aPrs3d = GetSelectedPrs3d();
+  for (SALOME_ListIteratorOfListIO it (aList); it.More(); it.Next()) {
+    Handle(SALOME_InteractiveObject) anIO = it.Value();
+    CORBA::Object_var anObject = GetSelectedObj(GetAppStudy(this), anIO->getEntry());
+    //ErasePrs(this, anObject, /*repaint_view_window = */false);
+    ErasePrs(this, anObject, /*repaint_view_window = */true);
+  }
 
-  switch (aPrs3d->GetType()) {
-  case VISU::TMESH: // Mesh 13
-    break;
+  //if (vw)
+  //  vw->Repaint();
 
-  case VISU::TSCALARMAP: // ScalarMap 18
-    EDITPRS(VISU::ScalarMap_i, VisuGUI_ScalarBarDlg);
-    break;
-    
-  case VISU::TDEFORMEDSHAPE: // Deformed Shape 28
-    EDITPRS(VISU::DeformedShape_i, VisuGUI_MagnitudeDlg);
-    break;
-    
-  case VISU::TCUTPLANES: // Cut planes 42
-    //EDITPRS(VISU::CutPlanes_i, VisuGUI_CutPlanesDlg);
-    {
-      VISU::CutPlanes_i* aPrsObject = dynamic_cast<VISU::CutPlanes_i*>(aPrs3d);
-      if (aPrsObject) {
-       VisuGUI_CutPlanesDlg* aDlg = new VisuGUI_CutPlanesDlg(false, false); 
-        aDlg->initFromPrsObject(aPrsObject);
-       aDlg->show();
-       myActiveDialogBox = aDlg;      
-//     if ( aDlg->exec() )  {
-//       if(!(aDlg->storeToPrsObject(aPrsObject))){
-//         delete aDlg;
-//             return;
-//           }
-//       RecreateActor(aPrsObject);
-//       if (VTKViewer_ViewFrame* vf = GetVtkViewFrame()) {
-//         if ( vf->getRenderer()->GetActors()->GetNumberOfItems () > 0 ) {
-//                  vf->getRenderer()->ResetCameraClippingRange();
-//              vf->Repaint();
-//           }
-//       }
-//     }
-//     delete aDlg;
+  QApplication::restoreOverrideCursor();
+}
+
+void
+VisuGUI::
+OnEraseAll()
+{
+  startOperation( myEraseAll );
+  if (SVTK_ViewWindow* vw = GetActiveViewWindow<SVTK_ViewWindow>(this)) {
+    vw->unHighlightAll();
+    if (vtkRenderer *aRen = vw->getRenderer()) {
+      vtkActor *anActor;
+      vtkActorCollection *anActColl = aRen->GetActors();
+      for (anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL; ) {
+        if (anActor->GetVisibility() > 0)
+          if (VISU_Actor* anVISUActor = VISU_Actor::SafeDownCast(anActor)) {
+           RemoveScalarBarPosition(this, vw, anVISUActor->GetPrs3d());
+            anVISUActor->VisibilityOff();
+          }
       }
+      vw->Repaint();
     }
-    break;
+  } else if (SPlot2d_Viewer* aPlot2d = GetPlot2dViewer(this, false)) {
+    aPlot2d->EraseAll();
+  }
+}
 
-  case VISU::TCUTLINES: // Cut planes 42
-    //EDITPRS(VISU::CutLines_i, VisuGUI_CutLinesDlg);
-    {
-      VISU::CutLines_i* aPrsObject = dynamic_cast<VISU::CutLines_i*>(aPrs3d); 
-      if (aPrsObject) { 
-       VisuGUI_CutLinesDlg* aDlg = new VisuGUI_CutLinesDlg(false); 
-        aDlg->initFromPrsObject(aPrsObject); 
-       aDlg->show();
-       myActiveDialogBox = aDlg;
-//     if ( aDlg->exec() )  { 
-//       aDlg->storeToPrsObject(aPrsObject); 
-//       RecreateActor(aPrsObject); 
-//       if (VTKViewer_ViewFrame* vf = GetVtkViewFrame()) { 
-//         if ( vf->getRenderer()->GetActors()->GetNumberOfItems () > 0 ) { 
-//           vf->getRenderer()->ResetCameraClippingRange(); 
-//           vf->Repaint(); 
-//         }
-//       }
-//       // Remove old Table
-//       SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument();
-//       SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(aPrsObject->GetEntry());
-//       if(!aSObject->_is_nil()) {
-//         SALOMEDS::ChildIterator_var aIter = aStudy->NewChildIterator( aSObject );
-//         SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder();
-//         for ( ;aIter->More(); aIter->Next()) {
-//           SALOMEDS::SObject_var aTblObj = aIter->Value();
-//           if (!aTblObj->_is_nil()) {
-//             SALOMEDS::GenericAttribute_var anAttr;
-//             if (aTblObj->FindAttribute(anAttr, "AttributeName")) {
-//               aBuilder->RemoveObjectWithChildren(aIter->Value()); // We should have only one child
-//               break;
-//             }
-//           }
-//         }
-//         if (aDlg->isGenerateTable()) {
-//           GetVisuGen()->CreateTable(aSObject->GetID());
-//           if (aDlg->isGenerateCurves()) {
-//             SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument();
-//             SALOMEDS::ChildIterator_var aIter = aStudy->NewChildIterator( aSObject );
-//             SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder();
-//             for ( ;aIter->More(); aIter->Next()) {
-//               SALOMEDS::SObject_var aTblObj = aIter->Value();
-//               if (!aTblObj->_is_nil()) {
-//                 SALOMEDS::GenericAttribute_var anAttr;
-//                 if (aTblObj->FindAttribute(anAttr, "AttributeName")) {
-//                   CreatePlot(aTblObj);
-//                 }
-//               }
-
-//             }
-//           }
-//         }
-//         GetActiveStudy()->updateObjBrowser();
-//       }
-//     } 
-//     delete aDlg; 
-      } 
-    } 
-    break;
 
-  case VISU::TISOSURFACE: // Iso surfaces
-    EDITPRS(VISU::IsoSurfaces_i, VisuGUI_IsoSurfacesDlg);
-    break;
-  case VISU::TVECTORS: // Vectors 64
-    EDITPRS(VISU::Vectors_i, VisuGUI_VectorsDlg);
-    break;
+void
+VisuGUI::
+OnEditScalarMap()
+{
+  Handle(SALOME_InteractiveObject) anIO;
+  if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, &anIO))
+    EditPrs3d<VISU::ScalarMap_i, VisuGUI_ScalarBarDlg, 1>(this, anIO, aPrs3d);
+}
 
-  case VISU::TSTREAMLINES:
-    EDITPRS(VISU::StreamLines_i, VisuGUI_StreamLinesDlg);
-    break;
-  default: 
-    return;        
-  }
-  
+void
+VisuGUI::
+OnEditDeformedShape()
+{
   Handle(SALOME_InteractiveObject) anIO;
-  CORBA::Object_var anObject = GetSelectedObj(&anIO);
-  if ( !CORBA::is_nil( anObject ) ) 
-    if (VTKViewer_ViewFrame* vf = GetVtkViewFrame()) 
-      vf->highlight(anIO, 1);
+  if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, &anIO))
+    EditPrs3d<VISU::DeformedShape_i, VisuGUI_DeformedShapeDlg, 1>(this, anIO, aPrs3d);
 }
 
+void
+VisuGUI::
+OnEditScalarMapOnDeformedShape()
+{
+  Handle(SALOME_InteractiveObject) anIO;
+  if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, &anIO))
+    EditPrs3d<VISU::ScalarMapOnDeformedShape_i, VisuGUI_ScalarMapOnDeformedShapeDlg, 1>(this, anIO, aPrs3d);
+}
 
-//=====================================================================================
-// function : CreateMesh()
-// purpose  :
-//=====================================================================================
-void VisuGUI::CreateMesh() {
-  SALOME_Selection* Sel = SALOME_Selection::Selection(GetActiveStudy()->getSelection());
-  SALOMEDS::SObject_var aSObject  = GetActiveStudy()->getStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() );
-  
-  if (checkLock(GetStudyDocument())) return;
-
-  SALOMEDS::SObject_var aSObj = aSObject->GetFather();
-  aSObj = aSObj->GetFather();
-  aSObj = aSObj->GetFather();
-  CORBA::Object_var anObject = VISU::SObjectToObject(aSObj);
-  if(CORBA::is_nil(anObject)) {
-    aSObj = aSObj->GetFather();
-    anObject = VISU::SObjectToObject(aSObj);
-  }
-  VISU::Result_var aResult;
-  if (!CORBA::is_nil(anObject)) {
-    aResult = VISU::Result::_narrow(anObject);
-  }
-  if(CORBA::is_nil(aResult)) {
-    QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
-                         tr ("WRN_NO_AVAILABLE_DATA"),
-                         tr ("VISU_BUT_OK"));
-    return;
-  }
-  VISU::Storable::TRestoringMap aMap;
-  SALOMEDS::GenericAttribute_var anAttr;
-  if(aSObject->FindAttribute(anAttr, "AttributeComment")) {
-    SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(anAttr);
-    string aComm = aComment->Value();
-    QString strIn(aComm.c_str());
-    VISU::Storable::StrToMap(strIn,aMap);
-  }
-  bool isExist;
-  string aComment = VISU::Storable::FindValue(aMap,"myComment",&isExist).latin1();
-  if(!isExist) return;
-  CORBA::Object_var aMesh;
-  string aMeshName = VISU::Storable::FindValue(aMap,"myMeshName").latin1();
-#ifdef CHECKTIME
-  Utils_Timer timer;
-  timer.Start();
-#endif
-  VISU::Result_i* pResult = dynamic_cast<VISU::Result_i*>(VISU::GetServant(aResult.in()).in());
-  if(aComment == "ENTITY"){
-    VISU::Entity anEntity = (VISU::Entity)VISU::Storable::FindValue(aMap,"myId").toInt();
-    if(VISU::Mesh_i::IsPossible(pResult,aMeshName.c_str(),anEntity))
-      aMesh = GetVisuGen()->MeshOnEntity(aResult,aMeshName.c_str(),anEntity);
-  }else if(aComment == "FAMILY"){
-    VISU::Entity anEntity = (VISU::Entity)VISU::Storable::FindValue(aMap,"myEntityId").toInt();
-    string aFamilyName = VISU::Storable::FindValue(aMap,"myName").latin1();
-    if(VISU::Mesh_i::IsPossible(pResult,aMeshName.c_str(),anEntity,aFamilyName.c_str()))
-      aMesh = GetVisuGen()->FamilyMeshOnEntity(aResult,aMeshName.c_str(),anEntity,aFamilyName.c_str());
-  }else if(aComment == "GROUP"){
-    string aGroupName = VISU::Storable::FindValue(aMap,"myName").latin1();
-    if(VISU::Mesh_i::IsPossible(pResult,aMeshName.c_str(),aGroupName.c_str()))
-      aMesh = GetVisuGen()->GroupMesh(aResult,aMeshName.c_str(),aGroupName.c_str());
-  }
-#ifdef CHECKTIME
-  timer.Stop();
-  MESSAGE("VisuGUI::CreateMesh() - CREATE MESH");
-  timer.Show();
-#endif
+void
+VisuGUI::
+OnEditCutPlanes()
+{
+  Handle(SALOME_InteractiveObject) anIO;
+  if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, &anIO))
+    EditPrs3d<VISU::CutPlanes_i, VisuGUI_CutPlanesDlg, 0>(this, anIO, aPrs3d);
+}
 
-  QApplication::restoreOverrideCursor();
-  VISU::Mesh_i* pPresent = NULL;
-  if(!CORBA::is_nil(aMesh)) 
-    pPresent = dynamic_cast<VISU::Mesh_i*>(VISU::GetServant(aMesh).in());
-  if (pPresent == NULL) {
-    QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"), 
-                           tr ("ERR_CANT_BUILD_PRESENTATION"), 
-                           tr ("VISU_BUT_OK") ); 
-    return;
-  }
+void
+VisuGUI::
+OnEditCutLines()
+{
+  Handle(SALOME_InteractiveObject) anIO;
+  if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, &anIO))
+    EditPrs3d<VISU::CutLines_i, VisuGUI_CutLinesDlg, 0>(this, anIO, aPrs3d);
+}
 
-  if(VTKViewer_ViewFrame* vf = GetVtkViewFrame()){
-    try{
-      VISU_Actor *anActor = pPresent->CreateActor();
-#ifdef CHECKTIME
-      Utils_Timer timer;
-      timer.Start();
-#endif
-      vf->AddActor(anActor);
-      SetFitAll(vf);
-#ifdef CHECKTIME
-      timer.Stop();
-      MESSAGE("VisuGUI::CreateMesh() - DISPLAY MESH");
-      timer.Show();
-#endif
-      //GetActiveStudy()->updateObjBrowser(); //not necessary
-      GetDesktop()->putInfo("Ready");
-    }catch(std::runtime_error& exc){
-      INFOS(exc.what());
-      QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"), 
-                             tr ("ERR_CANT_CREATE_ACTOR") + " " + tr(exc.what()), 
-                             tr ("VISU_BUT_OK") ); 
-    }
-  }
+void
+VisuGUI::
+OnEditIsoSurfaces()
+{
+  Handle(SALOME_InteractiveObject) anIO;
+  if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, &anIO))
+    EditPrs3d<VISU::IsoSurfaces_i, VisuGUI_IsoSurfacesDlg, 1>(this, anIO, aPrs3d);
 }
 
-//=====================================================================================
-// function : CreateManyMesh()
-// purpose  :
-//=====================================================================================
-void VisuGUI::CreateManyMesh(){
-  if (checkLock(GetStudyDocument())) return;
-
-  SALOME_Selection* Sel = SALOME_Selection::Selection(GetActiveStudy()->getSelection());
-  SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
-  for ( ; It.More(); It.Next() ) {
-    SALOMEDS::SObject_var aSObject  = GetStudyDocument()->FindObjectID(It.Value()->getEntry());
-    SALOMEDS::SObject_var aSObj = aSObject->GetFather();
-    aSObj = aSObj->GetFather();
-    aSObj = aSObj->GetFather();
-    CORBA::Object_var anObject = VISU::SObjectToObject(aSObj);
-    if(CORBA::is_nil(anObject)) {
-      aSObj = aSObj->GetFather();
-      anObject = VISU::SObjectToObject(aSObj);
-      if(CORBA::is_nil(anObject)) return;
-    }
-    VISU::Result_var aResult = VISU::Result::_narrow(anObject);
-    if(CORBA::is_nil(aResult)) return;
-    
-    VISU::Storable::TRestoringMap aMap;
-    SALOMEDS::GenericAttribute_var anAttr;
-    if(aSObject->FindAttribute(anAttr, "AttributeComment")) {
-      SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(anAttr);
-      string aComm = aComment->Value();
-      QString strIn(aComm.c_str());
-      VISU::Storable::StrToMap(strIn,aMap);
-    }
-    bool isExist;
-    string aComment = VISU::Storable::FindValue(aMap,"myComment",&isExist).latin1();
-    if(!isExist) return;
-    CORBA::Object_var aMesh;
-    string aMeshName = VISU::Storable::FindValue(aMap,"myMeshName").latin1();
-    if(aComment == "ENTITY"){
-      VISU::Entity anEntity = (VISU::Entity)VISU::Storable::FindValue(aMap,"myId").toInt();
-      aMesh = GetVisuGen()->MeshOnEntity(aResult,aMeshName.c_str(),anEntity);
-    }else if(aComment == "FAMILY"){
-      VISU::Entity anEntity = (VISU::Entity)VISU::Storable::FindValue(aMap,"myEntityId").toInt();
-      string aFamilyName = VISU::Storable::FindValue(aMap,"myName").latin1();
-      aMesh = GetVisuGen()->FamilyMeshOnEntity(aResult,aMeshName.c_str(),anEntity,aFamilyName.c_str());
-    }else if(aComment == "GROUP"){
-      string aGroupName = VISU::Storable::FindValue(aMap,"myName").latin1();
-      aMesh = GetVisuGen()->GroupMesh(aResult,aMeshName.c_str(),aGroupName.c_str());
-    }
-    QApplication::restoreOverrideCursor();
-    if(CORBA::is_nil(aMesh)) return;
-    
-    VISU::Mesh_i* pPresent = dynamic_cast<VISU::Mesh_i*>(VISU::GetServant(aMesh).in());
-    try{
-      VISU_Actor *anActor = pPresent->CreateActor();
-      if(VTKViewer_ViewFrame* vf = GetVtkViewFrame()){
-       vf->AddActor(anActor);
-       SetFitAll(vf);
-      }
-      GetDesktop()->putInfo("Ready");
-    }catch(std::runtime_error& exc){
-      INFOS(exc.what());
-    }
-  }
+void
+VisuGUI::
+OnEditVectors()
+{
+  Handle(SALOME_InteractiveObject) anIO;
+  if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, &anIO))
+    EditPrs3d<VISU::Vectors_i, VisuGUI_VectorsDlg, 1>(this, anIO, aPrs3d);
 }
 
-//=====================================================================================
-// function : ChangeRepresentation()
-// purpose  :
-//=====================================================================================
-
-static void ShrinkMesh(VISU_Actor *theActor){
-  if(theActor->IsShrunk()) 
-    theActor->UnShrink();
-  else
-    theActor->SetShrink();
+void
+VisuGUI::
+OnEditStreamLines()
+{
+  Handle(SALOME_InteractiveObject) anIO;
+  if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, &anIO))
+    EditPrs3d<VISU::StreamLines_i, VisuGUI_StreamLinesDlg, 1>(this, anIO, aPrs3d);
 }
 
-void VisuGUI::ChangeRepresentation(VISU::PresentationType theType) {
-  if(VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d())
-    if(VISU_Actor* anActor = GetActor(aPrsObject)){
-      switch (theType) {
-      case VISU::SHRINK:
-       ShrinkMesh(anActor);
-       break;
-      default:
-       if(VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrsObject)){
-         aMesh->SetPresentationType(theType);
-         RecreateActor(aMesh);
-       }else
-         anActor->SetRepresentation(theType);
-      }
-      if (VTKViewer_ViewFrame* vf = GetVtkViewFrame()) 
-       vf->Repaint();
-    }
+void
+VisuGUI::
+OnEditPlot3D()
+{
+  Handle(SALOME_InteractiveObject) anIO;
+  if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, &anIO))
+    EditPrs3d<VISU::Plot3D_i, VisuGUI_Plot3DDlg, 0>(this, anIO, aPrs3d);
 }
 
 
-void VisuGUI::MakeSurfaceframe() {
-  ChangeRepresentation(VISU::SURFACEFRAME);
+void
+VisuGUI::
+OnMakeSurfaceframe()
+{
+  ChangeRepresentation(this, VISU::SURFACEFRAME);
 }
 
-void VisuGUI::MakeInsideframe() {
-  ChangeRepresentation(VISU::INSIDEFRAME);
+void
+VisuGUI::
+OnMakeInsideframe()
+{
+  ChangeRepresentation(this, VISU::INSIDEFRAME);
 }
 
-void VisuGUI::MakeWireframe() {
-  ChangeRepresentation(VISU::WIREFRAME);
+void
+VisuGUI::
+OnMakeWireframe()
+{
+  ChangeRepresentation(this, VISU::WIREFRAME);
 }
 
-void VisuGUI::MakeSurface() {
-  ChangeRepresentation(VISU::SHADED);
+void
+VisuGUI::
+OnMakeSurface()
+{
+  ChangeRepresentation(this, VISU::SHADED);
 }
 
-void VisuGUI::MakePoints() {
-  ChangeRepresentation(VISU::POINT);
+void
+VisuGUI::
+OnMakePoints()
+{
+  ChangeRepresentation(this, VISU::POINT);
 }
 
-void VisuGUI::MakeShrink() {
-  ChangeRepresentation(VISU::SHRINK);
+void
+VisuGUI::
+OnMakeShrink()
+{
+  ChangeRepresentation(this, VISU::SHRINK);
 }
 
+void
+VisuGUI::
+OnSetShadingOn()
+{
+  SetShading(this, true);
+}
 
-
-//=====================================================================================
-// functions : Change Propertise
-// purpose  :
-//=====================================================================================
-VISU::Prs3d_i* VisuGUI::GetSelectedPrs3d(Handle(SALOME_InteractiveObject)* theIO) {
-  CORBA::Object_var anObject = GetSelectedObj(theIO);
-  if(CORBA::is_nil(anObject)) return NULL;
-  PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
-  if(!aServant.in()) return NULL;
-  return dynamic_cast<VISU::Prs3d_i*>(aServant.in());
+void
+VisuGUI::
+OnSetShadingOff()
+{
+  SetShading(this, false);
 }
 
-void VisuGUI::ChageColor() {
-  VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d();
-  if(!aPrsObject) return;
+void
+VisuGUI::
+OnChangeColor()
+{
+  Handle(SALOME_InteractiveObject) anIO;
+  CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
+  if (CORBA::is_nil(anObject)) return;
+  PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
+  if (!aServant.in()) return;
 
-  VISU_Actor* anActor = GetActor(aPrsObject);  
-  if (!anActor) return;
-  NewColor(anActor);
-}
+  VISU::Prs3d_i* aPrs3d = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
+  if (!aPrs3d) return;
 
-void VisuGUI::ChangeWireframeColor() {
-  VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d();
-  if(!aPrsObject) return;
+  SVTK_ViewWindow* vw = GetActiveViewWindow<SVTK_ViewWindow>(this);
+  if (!vw) return;
 
-  VISU_MeshAct* anActor = dynamic_cast<VISU_MeshAct*>(GetActor(aPrsObject));
+  VISU_Actor* anActor = GetActor(aPrs3d, vw);
   if (!anActor) return;
-  NewWireframeColor(anActor);
-}
 
+  VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrs3d);
+  VISU::DeformedShape_i* aDeformedShape = dynamic_cast<VISU::DeformedShape_i*>(aPrs3d);
+  SALOMEDS::Color anOldColor, aNewColor;
+  int aRepresent = anActor->GetRepresentation();
+  if (aMesh) {
+    switch (aRepresent) {
+      case VISU::POINT :
+        anOldColor = aMesh->GetNodeColor();
+        break;
+      case VISU::WIREFRAME :
+      case VISU::INSIDEFRAME :
+        anOldColor = aMesh->GetLinkColor();
+        break;
+      case VISU::SHADED :
+      case VISU::SURFACEFRAME :
+        anOldColor = aMesh->GetCellColor();
+        break;
+    }
+  } else if (aDeformedShape) {
+    anOldColor = aDeformedShape->GetColor();
+  } else {
+    return;
+  }
 
-void VisuGUI::ChangeOpacity() {
-  VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d();
-  if(!aPrsObject) return;
-
-  VISU_Actor* anActor = GetActor(aPrsObject);  
-  if (!anActor) return;
-  NewOpacity(anActor);
+  QColor aColor (int(255*anOldColor.R),
+                 int(255*anOldColor.G),
+                 int(255*anOldColor.B));
+  QColor aColorNew = QColorDialog::getColor(aColor, GetDesktop(this));
+  if (aColorNew.isValid()) {
+    aNewColor.R = aColorNew.red()/255.;
+    aNewColor.G = aColorNew.green()/255.;
+    aNewColor.B = aColorNew.blue()/255.;
+    if (aMesh) {
+      switch (aRepresent) {
+        case VISU::POINT :
+          aMesh->SetNodeColor(aNewColor);
+          break;
+        case VISU::WIREFRAME :
+        case VISU::INSIDEFRAME :
+          aMesh->SetLinkColor(aNewColor);
+          break;
+        case VISU::SHADED :
+        case VISU::SURFACEFRAME :
+          aMesh->SetCellColor(aNewColor);
+          break;
+      }
+    } else {
+      aDeformedShape->SetColor(aNewColor);
+    }
+    RecreateActor(this, aPrs3d);
+  }
 }
 
+void
+VisuGUI::
+OnChangeWireframeColor()
+{
+  Handle(SALOME_InteractiveObject) anIO;
+  CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
+  if (CORBA::is_nil(anObject)) return;
+  PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
+  if (!aServant.in()) return;
+
+  VISU::Prs3d_i* aPrs3d = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
+  if (!aPrs3d) return;
 
-void VisuGUI::ChangeLines() {
-  VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d();
-  if(!aPrsObject) return;
+  SVTK_ViewWindow* vw = GetActiveViewWindow<SVTK_ViewWindow>(this);
+  if (!vw) return;
 
-  VISU_Actor* anActor = GetActor(aPrsObject);  
+  VISU_Actor* anActor = GetActor(aPrs3d, vw);
   if (!anActor) return;
-  NewLinewidth(anActor);
-}
-void VisuGUI::PlotTable( VISU::Table_i* table, int theDisplaying )
-{
-  if ( table && GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
-    Plot2d_ViewFrame* aPlot = (Plot2d_ViewFrame*)GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame();
-    if ( theDisplaying == VISU::eDisplayOnly ) 
-      aPlot->EraseAll();
-    QList<Plot2d_Curve> clist;
-    aPlot->getCurves( clist );
-    SALOMEDS::SObject_var TableSO = GetActiveStudy()->getStudyDocument()->FindObjectID( table->GetEntry() );
-    if ( !TableSO->_is_nil() ) {
-      SALOMEDS::ChildIterator_var Iter = GetActiveStudy()->getStudyDocument()->NewChildIterator( TableSO );
-      for ( ; Iter->More(); Iter->Next() ) {
-       CORBA::Object_var childObject = VISU::SObjectToObject( Iter->Value() );
-       if( !CORBA::is_nil( childObject ) ) {
-         CORBA::Object_ptr aCurve = VISU::Curve::_narrow( childObject );
-         if( !CORBA::is_nil( aCurve ) ) {
-           VISU::Curve_i* theCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
-           Plot2d_Curve* plotCurve = 0;
-           for ( int i = 0; i < clist.count(); i++ ) {
-             if ( clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) ) {
-               plotCurve = clist.at( i );
-               break;
-             }
-           }
-           if ( theDisplaying == VISU::eErase ) {
-             if ( plotCurve ) {
-               aPlot->eraseCurve( plotCurve, false );
-               clist.remove( plotCurve );
-             }
-           }
-           else if ( theDisplaying == VISU::eDisplay || theDisplaying == VISU::eDisplayOnly ) {
-             if ( plotCurve ) {
-               plotCurve->setHorTitle( theCurve->GetHorTitle().c_str() );
-               //plotCurve->setVerTitle(  theCurve->GetVerTitle().c_str() );
-               plotCurve->setVerTitle( theCurve->GetName() );
-               plotCurve->setHorUnits( theCurve->GetHorUnits().c_str() );
-               plotCurve->setVerUnits( theCurve->GetVerUnits().c_str() );
-               /* - DATA NOT UPDATED */
-               double* xList = 0;
-               double* yList = 0;
-               int     nbPoints = theCurve->GetData( xList, yList );
-               if ( nbPoints > 0 && xList && yList ) {
-                 plotCurve->setData( xList, yList, nbPoints );
-               }
-               if ( !theCurve->IsAuto() ) {
-                 plotCurve->setLine( (Plot2d_Curve::LineType)theCurve->GetLine(), theCurve->GetLineWidth() );
-                 plotCurve->setMarker( (Plot2d_Curve::MarkerType)theCurve->GetMarker() ); 
-                 SALOMEDS::Color color = theCurve->GetColor();
-                 plotCurve->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
-               }
-               plotCurve->setAutoAssign( theCurve->IsAuto() );
-               aPlot->displayCurve( plotCurve, false );
-             }
-             else {
-               Plot2d_Curve* crv = theCurve->CreatePresentation();
-               if ( crv ) {
-                 aPlot->displayCurve( crv, false );
-                 theCurve->SetLine( (VISU::Curve::LineType)crv->getLine(), crv->getLineWidth() );
-                 theCurve->SetMarker( (VISU::Curve::MarkerType)crv->getMarker());
-                 SALOMEDS::Color newColor;
-                 newColor.R = crv->getColor().red()/255.;
-                 newColor.G = crv->getColor().green()/255.;
-                 newColor.B = crv->getColor().blue()/255.;
-                 theCurve->SetColor( newColor );
-                 crv->setAutoAssign( theCurve->IsAuto() );
-               }
-             }
-           }
-         }
-       }
-      }
-      aPlot->Repaint();
+
+  if (VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrs3d)) {
+    SALOMEDS::Color anOldColor = aMesh->GetLinkColor(), aNewColor;
+    QColor aColor (int(255*anOldColor.R),
+                   int(255*anOldColor.G),
+                   int(255*anOldColor.B));
+    QColor aColorNew = QColorDialog::getColor(aColor, GetDesktop(this));
+    if (aColorNew.isValid()) {
+      aNewColor.R = aColorNew.red()/255.;
+      aNewColor.G = aColorNew.green()/255.;
+      aNewColor.B = aColorNew.blue()/255.;
+      aMesh->SetLinkColor(aNewColor);
+      RecreateActor(this, aMesh);
     }
   }
 }
-void VisuGUI::PlotCurve( VISU::Curve_i* theCurve, int theDisplaying )
+
+void
+VisuGUI::
+OnChangeOpacity()
 {
-  if ( theCurve && GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
-    Plot2d_ViewFrame* aPlot = (Plot2d_ViewFrame*)GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame();
-//  if ( theDisplaying == VISU::eDisplayOnly ) 
-//    aPlot->EraseAll();
-    QList<Plot2d_Curve> clist;
-    aPlot->getCurves( clist );
-    Plot2d_Curve* plotCurve = 0;
-    for ( int i = 0; i < clist.count(); i++ ) {
-      if ( clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) ) {
-       plotCurve = clist.at( i );
-      }
-      else if ( theDisplaying == VISU::eDisplayOnly ) {
-       aPlot->eraseCurve( clist.at( i ) );
-      }
-    }
-    if ( theDisplaying == VISU::eErase ) {
-      if ( plotCurve )
-       aPlot->eraseCurve( plotCurve, false );
-    }
-    else if ( theDisplaying == VISU::eDisplay || theDisplaying == VISU::eDisplayOnly ) {
-      if ( plotCurve ) {
-       plotCurve->setHorTitle( theCurve->GetHorTitle().c_str() );
-       //plotCurve->setVerTitle( ( theCurve->GetVerTitle().c_str() ) );
-       plotCurve->setVerTitle( theCurve->GetName() );
-       plotCurve->setHorUnits( theCurve->GetHorUnits().c_str() );
-       plotCurve->setVerUnits( theCurve->GetVerUnits().c_str() );
-       double* xList = 0;
-       double* yList = 0;
-       int     nbPoints = theCurve->GetData( xList, yList );
-       if ( nbPoints > 0 && xList && yList ) {
-         plotCurve->setData( xList, yList, nbPoints );
-       }
-       if ( !theCurve->IsAuto() ) {
-         plotCurve->setLine( (Plot2d_Curve::LineType)theCurve->GetLine(), theCurve->GetLineWidth() );
-         plotCurve->setMarker( (Plot2d_Curve::MarkerType)theCurve->GetMarker() ); 
-         SALOMEDS::Color color = theCurve->GetColor();
-         plotCurve->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
-       }
-       plotCurve->setAutoAssign( theCurve->IsAuto() );
-       aPlot->displayCurve( plotCurve, false );
-      }
-      else {
-       Plot2d_Curve* crv = theCurve->CreatePresentation();
-       if ( crv ) {
-         aPlot->displayCurve( crv, false );
-         theCurve->SetLine( (VISU::Curve::LineType)crv->getLine(), crv->getLineWidth() );
-         theCurve->SetMarker( (VISU::Curve::MarkerType)crv->getMarker());
-         SALOMEDS::Color newColor;
-         newColor.R = crv->getColor().red()/255.;
-         newColor.G = crv->getColor().green()/255.;
-         newColor.B = crv->getColor().blue()/255.;
-         theCurve->SetColor( newColor );
-         crv->setAutoAssign( theCurve->IsAuto() );
-       }
-      }
-    }
-    aPlot->Repaint();
-  }
+  Handle(SALOME_InteractiveObject) anIO;
+  CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
+  if (CORBA::is_nil(anObject)) return;
+  PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
+  if (!aServant.in()) return;
+
+  VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
+  if (!aPrsObject) return;
+
+  SVTK_ViewWindow* vw = GetActiveViewWindow<SVTK_ViewWindow>(this);
+  if (!vw) return;
+
+  VISU_Actor* anActor = GetActor(aPrsObject, vw);
+  if (!anActor) return;
+
+  VisuGUI_TransparencyDlg* aTransparencyDlg = new VisuGUI_TransparencyDlg( this );
+  aTransparencyDlg->show();
 }
-void VisuGUI::PlotContainer( VISU::Container_i* container, int theDisplaying )
+
+void
+VisuGUI::
+OnChangeLines()
 {
-  if ( container && GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
-    Plot2d_ViewFrame* aPlot = (Plot2d_ViewFrame*)GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame();
-    if ( theDisplaying == VISU::eDisplayOnly ) 
-      aPlot->EraseAll();
-    QList<Plot2d_Curve> clist;
-    aPlot->getCurves( clist );
-    if ( container->GetNbCurves() > 0 ) {
-      int nbCurves = container->GetNbCurves();
-      for ( int k = 1; k <= nbCurves; k++ ) {
-       VISU::Curve_i* theCurve = container->GetCurve( k );
-       if ( theCurve && theCurve->IsValid() ) {
-         Plot2d_Curve* plotCurve = aPlot->getCurveByIO( new SALOME_InteractiveObject( theCurve->GetEntry(), "", "" ) );
-//       for ( int i = 0; i < clist.count(); i++ ) {
-//         if ( clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) ) {
-//           plotCurve = clist.at( i );
-//           break;
-//         }
-//       }
-         if ( theDisplaying == VISU::eErase ) {
-           if ( plotCurve ) {
-             aPlot->eraseCurve( plotCurve, false );
-             clist.remove( plotCurve );
-           }
-         }
-         else if ( theDisplaying == VISU::eDisplay || theDisplaying == VISU::eDisplayOnly ) {
-           if ( plotCurve ) {
-             plotCurve->setHorTitle( theCurve->GetHorTitle().c_str() );
-              //plotCurve->setVerTitle( ( theCurve->GetVerTitle().c_str() ) );
-              plotCurve->setVerTitle( theCurve->GetName() );
-             plotCurve->setHorUnits( theCurve->GetHorUnits().c_str() );
-             plotCurve->setVerUnits( theCurve->GetVerUnits().c_str() );
-             double* xList = 0;
-             double* yList = 0;
-             int     nbPoints = theCurve->GetData( xList, yList );
-             if ( nbPoints > 0 && xList && yList ) {
-               plotCurve->setData( xList, yList, nbPoints );
-             }
-             if ( !theCurve->IsAuto() ) {
-               plotCurve->setLine( (Plot2d_Curve::LineType)theCurve->GetLine(), theCurve->GetLineWidth() );
-               plotCurve->setMarker( (Plot2d_Curve::MarkerType)theCurve->GetMarker() ); 
-               SALOMEDS::Color color = theCurve->GetColor();
-               plotCurve->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
-             }
-             plotCurve->setAutoAssign( theCurve->IsAuto() );
-             aPlot->displayCurve( plotCurve, false );
-           }
-           else {
-             Plot2d_Curve* crv = theCurve->CreatePresentation();
-             if ( crv ) {
-               aPlot->displayCurve( crv, false );
-               theCurve->SetLine( (VISU::Curve::LineType)crv->getLine(), crv->getLineWidth() );
-               theCurve->SetMarker( (VISU::Curve::MarkerType)crv->getMarker());
-               SALOMEDS::Color newColor;
-               newColor.R = crv->getColor().red()/255.;
-               newColor.G = crv->getColor().green()/255.;
-               newColor.B = crv->getColor().blue()/255.;
-               theCurve->SetColor( newColor );
-               crv->setAutoAssign( theCurve->IsAuto() );
-             }
-           }
-         }
-       }
-      }
-    }
-    aPlot->Repaint();
+  Handle(SALOME_InteractiveObject) anIO;
+  CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
+  if (CORBA::is_nil(anObject)) return;
+  PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
+  if (!aServant.in()) return;
+
+  VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
+  if (!aPrsObject) return;
+
+  SVTK_ViewWindow* vw = GetActiveViewWindow<SVTK_ViewWindow>(this);
+  if (!vw) return;
+
+  VISU_Actor* anActor = GetActor(aPrsObject, vw);
+  if (!anActor) return;
+
+  VisuGUI_CursorDlg* CursorDlg =
+    new VisuGUI_CursorDlg (GetDesktop(this), tr("DLG_LINEWIDTH_TITLE"), TRUE);
+
+  CursorDlg->Comment1->setText(tr("DLG_LINEWIDTH_CMT1"));
+  CursorDlg->Comment2->setText(tr("DLG_LINEWIDTH_CMT2"));
+  CursorDlg->SpinBox1->setMinValue(1);
+  CursorDlg->SpinBox1->setMaxValue(10);
+
+  float oldlwid = anActor->GetLineWidth();
+  int intlwid = int(oldlwid);
+  CursorDlg->SpinBox1->setValue(intlwid);
+
+  int ret = CursorDlg->exec();
+  if (ret == 1) {
+    intlwid  = CursorDlg->SpinBox1->value();
+    float newlwid = intlwid;
+    anActor->SetLineWidth(newlwid);
   }
+  delete CursorDlg;
 }
 
-/*!
-  Slot : opens Table view : for Table object or SObject with table attribute selected
-*/
-void VisuGUI::ShowTable() {
-  SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
-  if( Sel->IObjectCount() !=1 )
-    return;
+void
+VisuGUI::
+OnShowTable()
+{
   Handle(SALOME_InteractiveObject) anIO;
-  CORBA::Object_var anObject = GetSelectedObj(&anIO);
-  SALOMEDS::SObject_var SO;
+  CORBA::Object_var anObject = GetSelectedObj( this, &anIO );
+  _PTR(SObject) SO;
   if ( !CORBA::is_nil( anObject ) ) {
-    VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
+    VISU::Base_var aVisuObj = VISU::Base::_narrow( anObject );
     if ( !CORBA::is_nil( aVisuObj ) && aVisuObj->GetType() == VISU::TTABLE ) {
       CORBA::Object_ptr aTable = VISU::Table::_narrow( anObject );
       if( !CORBA::is_nil( aTable ) ) {
-       VISU::Table_i* table = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTable).in());
-       if ( table ) {
-         SO = GetActiveStudy()->getStudyDocument()->FindObjectID( table->GetObjectEntry() );
-       }
+        VISU::Table_i* table = dynamic_cast<VISU::Table_i*>( VISU::GetServant(aTable).in() );
+        if ( table ) {
+          SO = GetCStudy( GetAppStudy( this ) )->FindObjectID( table->GetObjectEntry() );
+        }
       }
-    } 
+    }
   } else {
     // possibly this is Table SObject
-    SO = GetActiveStudy()->getStudyDocument()->FindObjectID( anIO->getEntry() );
+    SO = GetCStudy( GetAppStudy( this ) )->FindObjectID( anIO->getEntry() );
   }
 
-  if(!IsSObjectTable(SO))
+  if( !IsSObjectTable( SO ) )
     return;
 
-  SALOMEGUI_TableDlg* dlg = new SALOMEGUI_TableDlg( QAD_Application::getDesktop(),
-                                                   SO, 
-                                                   false, 
-                                                  //SAL2670 Orientation of show tables
-                                                   SALOMEGUI_TableDlg::ttAuto, 
-                                                   Qt::Vertical );
+  VisuGUI_TableDlg* dlg = new VisuGUI_TableDlg( GetDesktop( this ),
+                                               SO,
+                                               false,
+                                               //SAL2670 Orientation of show tables
+                                               VisuGUI_TableDlg::ttAuto,
+                                               Qt::Vertical );
   dlg->show();
 }
 
+void
+VisuGUI::
+OnCreateTable()
+{
+  Handle(SALOME_InteractiveObject) anIO;
+  CORBA::Object_var anObject = GetSelectedObj( this, &anIO );
+  _PTR(Study) aStudy = GetCStudy( GetAppStudy( this ) );
+  _PTR(SObject) aSObject = aStudy->FindObjectID(anIO->getEntry());
+  VISU::CutLines_var aCutLines = VISU::CutLines::_narrow( anObject );
+  if(!aCutLines->_is_nil() || IsSObjectTable(aSObject)) {
+    GetVisuGen( this )->CreateTable( aSObject->GetID().c_str() );
+    UpdateObjBrowser(this);
+  }
+}
 
-/*!
-  Slot : opens Table view : for Table object or SObject with table attribute selected
-*/
-void VisuGUI::CreateTable() {
-  SALOME_Selection* aSel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
-  if( aSel->IObjectCount() !=1 )
+void
+VisuGUI::
+OnDeleteObjects()
+{
+  _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
+  if (CheckLock(aCStudy,GetDesktop(this)))
     return;
 
-  Handle(SALOME_InteractiveObject) anIO = aSel->firstIObject();
-  if (anIO->hasEntry()){
-    SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument();
-    SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(anIO->getEntry());
-    if(!aSObject->_is_nil()) {
-      CORBA::Object_var anObject = VISU::SObjectToObject(aSObject);
-      VISU::CutLines_var aCutLines = VISU::CutLines::_narrow( anObject );
-      if(!aCutLines->_is_nil() || IsSObjectTable(aSObject)) {
-       GetVisuGen()->CreateTable(aSObject->GetID());
-       GetActiveStudy()->updateObjBrowser();
-      }
-    }
-  }
-}
+  SALOME_ListIO aList;
+  LightApp_SelectionMgr* mgr = GetSelectionMgr(this);
+  mgr->selectedObjects(aList,QString::null,false);
+  int i = 0, nbSelected = aList.Extent();
+  if (nbSelected < 1) return;
 
+  const char* entries [nbSelected];
+  Handle(SALOME_InteractiveObject) anIO;
+  for (SALOME_ListIteratorOfListIO it (aList); it.More(); it.Next()) {
+    anIO = it.Value();
+    if (anIO->hasEntry())
+      entries[i++] = anIO->getEntry();
+  }
+  nbSelected = i;
+  if (nbSelected < 1) return;
 
-/*!
-  Slot : deletes SObject with all subobjects
-*/
-void VisuGUI::DeleteObject() {
-  SALOMEDS::Study_var aStudy = GetStudyDocument();
-  if (checkLock(aStudy)) return;
+  // There is a transaction
+  _PTR(StudyBuilder) aStudyBuilder = aCStudy->NewBuilder();
+  aStudyBuilder->NewCommand();
 
-  SALOME_Selection* aSel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
-  if( aSel->IObjectCount() !=1 )
-    return;
-  Handle(SALOME_InteractiveObject) anIO = aSel->firstIObject();
-  if (anIO->hasEntry()){
-    SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(anIO->getEntry());
-    if(!aSObject->_is_nil()){
-      SALOMEDS::ChildIterator_var aChildIter = aStudy->NewChildIterator(aSObject);
-      for(aChildIter->InitEx(true); aChildIter->More(); aChildIter->Next()){
-       SALOMEDS::SObject_var aChildSObject = aChildIter->Value();
-       CORBA::Object_var aChildObj = VISU::SObjectToObject(aChildSObject);
-       ::ErasePrs(aChildObj);
-      }
-      SALOMEDS::StudyBuilder_var aStudyBuilder = VisuGUI::NewBuilder();
-      // There is a transaction
-      aStudyBuilder->NewCommand();
-      CORBA::Object_var anObj = VISU::SObjectToObject(aSObject);
-      if(!CORBA::is_nil(anObj)){
-       VISU::Base_var aBase = VISU::Base::_narrow(anObj);
-       if(!CORBA::is_nil(aBase)){
-         VISU::VISUType aType = aBase->GetType();
-         switch (aType){
-         case VISU::TRESULT:
-           {
-             SALOMEDS::ChildIterator_var aChildIter = aStudy->NewChildIterator(aSObject);
-             for(aChildIter->InitEx(true); aChildIter->More(); aChildIter->Next()){
-               SALOMEDS::SObject_var aChildSObject = aChildIter->Value();
-               CORBA::Object_var aChildObj = VISU::SObjectToObject(aChildSObject);
-                 if(CORBA::is_nil(aChildObj)) continue;
-                 VISU::Prs3d_var aPrs3d = VISU::Prs3d::_narrow(aChildObj);
-                 if(CORBA::is_nil(aPrs3d)) continue;
-                 VISU::Prs3d_i* pPrs3d = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(aPrs3d).in());
-                 DeletePresentation(pPrs3d);
-             }
-             break;
-           }
-         case VISU::TTABLE:
-           {
-             SALOMEDS::ChildIterator_var aChildIter = aStudy->NewChildIterator(aSObject);
-             for(aChildIter->InitEx(true); aChildIter->More(); aChildIter->Next()){
-               SALOMEDS::SObject_var aChildSObject = aChildIter->Value();
-               CORBA::Object_var aChildObj = VISU::SObjectToObject(aChildSObject);
-                 if(CORBA::is_nil(aChildObj)) continue;
-                 CORBA::Object_ptr aCurve = VISU::Curve::_narrow( aChildObj );
-                 if(CORBA::is_nil(aCurve)) continue;
-                 VISU::Curve_i* pCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
-                 DeletePresentation(pCurve);
-             }
-             break;
-           }
-         }
-       }
-      }
-      aStudyBuilder->RemoveObjectWithChildren(aSObject);
-      aStudyBuilder->CommitCommand();
-      GetActiveStudy()->unHighlightAll();
-      GetActiveStudy()->updateObjBrowser(true);
+  for (i = 0; i < nbSelected; i++) {
+    _PTR(SObject) aSObject = aCStudy->FindObjectID(entries[i]);
+    if (aSObject) {
+      DeleteSObject(this, aCStudy, aSObject);
+      UpdateObjBrowser(this, true, aSObject);
     }
   }
-}
-
 
-/*!
-  Slot : deletes empty container
-*/
-void VisuGUI::CreatePlot2dView() {
-  if (checkLock(GetStudyDocument())) return;
-  GetVisuGen()->CreateContainer();
-  GetActiveStudy()->updateObjBrowser( true );
+  // Finish transaction
+  aStudyBuilder->CommitCommand();
 }
 
+void
+VisuGUI::
+OnPlotData()
+{
+  Handle(SALOME_InteractiveObject) anIO;
+  CORBA::Object_var anObject = GetSelectedObj( this, &anIO );
+  _PTR(SObject) SO;
+  _PTR(GenericAttribute) anAttr;
+  _PTR(AttributeName)    aName;
+  QString SOName;
+  _PTR(Study) aStudy = GetCStudy( GetAppStudy( this ) );
 
-
-/*!
-  Opens dialog box for curves creation. Acts only for selected SObject with table attribute.
-*/
-void VisuGUI::PlotData() {
-  SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
-  if( Sel->IObjectCount() !=1 )
-    return;
-  CORBA::Object_var anObject = GetSelectedObj();
-  SALOMEDS::SObject_var SO;
   if ( !CORBA::is_nil( anObject ) ) {
     VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
     if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TTABLE) {
       // Table (VISU object) is selected
       CORBA::Object_ptr aTbl = VISU::Table::_narrow( anObject );
       if( !CORBA::is_nil( aTbl ) ) {
-       VISU::Table_i* table = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTbl).in());
-       if ( table ) {
-         SALOMEDS::GenericAttribute_var anAttr;
-         SALOMEDS::AttributeName_var    aName;
-         QString SOName;
-         SALOMEDS::SObject_var SO = GetActiveStudy()->getStudyDocument()->FindObjectID( table->GetObjectEntry() );
-         if ( IsSObjectTable(SO) ) {
-           // get name of SObject
-           if ( SO->FindAttribute( anAttr, "AttributeName" ) ) {
-             aName = SALOMEDS::AttributeName::_narrow( anAttr );
-             SOName = aName->Value();
-           }
-           Plot2d_SetupPlot2dDlg* dlg = new Plot2d_SetupPlot2dDlg( SO, QAD_Application::getDesktop() );
-           if ( dlg->exec() == QDialog::Accepted ) {
-             if ( !isStudyLocked( GetActiveStudy()->getStudyDocument() ) ) {
-               // if study is not locked - create new container, create curves
-               // and insert them into container, then plot container if current viewer is of VIEW_PLOT2D type
-               int horIndex;
-               QValueList<int> verIndices;
-               dlg->getCurvesSource( horIndex, verIndices );
-               if ( horIndex >= 0 && verIndices.count() > 0 ) { 
-                 CORBA::Object_var aContainer = GetVisuGen()->CreateContainer();
-                 if( !CORBA::is_nil( aContainer ) ) {
-                   VISU::Container_i* pContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
-                   if ( pContainer ) {
-                     for ( int i = 0; i < verIndices.count(); i++ ) {
-                       CORBA::Object_var aNewCurve = GetVisuGen()->CreateCurve( table->_this(), horIndex+1, verIndices[i]+1 );
-                       if( !CORBA::is_nil( aNewCurve ) ) {
-                         VISU::Curve_i* pCrv = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aNewCurve).in());
-                         if ( pCrv ) {
-                           bool isAuto;
-                           int  marker, line, lineWidth;
-                           QColor color;
-                           if ( dlg->getCurveAttributes( verIndices[i], isAuto, marker, line, lineWidth, color ) && !isAuto ) {
-                             SALOMEDS::Color c; c.R = color.red()/255.; c.G = color.green()/255.; c.B = color.blue()/255.;
-                             pCrv->SetColor( c );
-                             pCrv->SetMarker( ( VISU::Curve::MarkerType )marker );
-                             pCrv->SetLine( ( VISU::Curve::LineType )line, lineWidth );
-                           }
-                           pContainer->AddCurve( pCrv->_this() );
-                         }
-                       }
-                     }
-                     GetActiveStudy()->updateObjBrowser( true );
-                     PlotContainer( pContainer, VISU::eDisplay );
-                   }
-                 }
-               }
-             }
-             else {
-               // if study is locked just get curves info and plot them if current viewer is of VIEW_PLOT2D type
-               Plot2d_CurveContainer container;
-               dlg->getCurves( container );
-               if ( !container.isEmpty() ) {
-                 ((Plot2d_ViewFrame*)(GetActiveStudy()->getActiveStudyFrame()->
-                                      getRightFrame()->getViewFrame()))->displayCurves( container, true );
-                 ((Plot2d_ViewFrame*)(GetActiveStudy()->getActiveStudyFrame()->
-                                      getRightFrame()->getViewFrame()))->setTitle( SOName );
-               }
-             }
-           }
-           delete dlg;
-         }
-       }
+        VISU::Table_i* table = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTbl).in());
+        if ( table ) {
+          _PTR(SObject) SO = aStudy->FindObjectID( table->GetObjectEntry() );
+          if ( IsSObjectTable(SO) ) {
+            // get name of SObject
+            if ( SO->FindAttribute( anAttr, "AttributeName" ) ) {
+              aName = anAttr;
+              SOName = QString( aName->Value().c_str() );
+            }
+            VisuGUI_SetupPlot2dDlg* dlg = new VisuGUI_SetupPlot2dDlg( SO, GetDesktop( this ) );
+            if ( dlg->exec() == QDialog::Accepted ) {
+              if ( !IsStudyLocked( aStudy ) ) {
+                // if study is not locked - create new container, create curves and insert them
+                // into container, then plot container if current viewer is of VIEW_PLOT2D type
+                int horIndex;
+                QValueList<int> verIndices;
+                dlg->getCurvesSource( horIndex, verIndices );
+                if ( horIndex >= 0 && verIndices.count() > 0 ) {
+                  CORBA::Object_var aContainer = GetVisuGen(this)->CreateContainer();
+                  if( !CORBA::is_nil( aContainer ) ) {
+                    VISU::Container_i* pContainer =
+                      dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
+                    if ( pContainer ) {
+                      for ( int i = 0; i < verIndices.count(); i++ ) {
+                        CORBA::Object_var aNewCurve =
+                          GetVisuGen(this)->CreateCurve( table->_this(), horIndex+1, verIndices[i]+1 );
+                        if( !CORBA::is_nil( aNewCurve ) ) {
+                          VISU::Curve_i* pCrv =
+                            dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aNewCurve).in());
+                          if ( pCrv ) {
+                            bool isAuto;
+                            int  marker, line, lineWidth;
+                            QColor color;
+                            if ( dlg->getCurveAttributes(verIndices[i], isAuto, marker,
+                                                         line, lineWidth, color) && !isAuto ) {
+                              SALOMEDS::Color c;
+                              c.R = color.red()  /255.;
+                              c.G = color.green()/255.;
+                              c.B = color.blue() /255.;
+                              pCrv->SetColor( c );
+                              pCrv->SetMarker( ( VISU::Curve::MarkerType )marker );
+                              pCrv->SetLine( ( VISU::Curve::LineType )line, lineWidth );
+                            }
+                            pContainer->AddCurve( pCrv->_this() );
+                          }
+                        }
+                      }
+                      UpdateObjBrowser(this);
+                      PlotContainer( this, pContainer, VISU::eDisplay );
+                    }
+                  }
+                }
+              }
+              else {
+                // if study is locked just get curves info and plot them
+                // if current viewer is of VIEW_PLOT2D type
+                QPtrList<Plot2d_Curve> container;
+                dlg->getCurves( container );
+                if ( !container.isEmpty() ) {
+                  GetPlot2dViewer( this )->getActiveViewFrame()->displayCurves( container, true );
+                  GetPlot2dViewer( this )->getActiveViewFrame()->setTitle( SOName );
+                }
+              }
+            }
+            delete dlg;
+          }
+        }
       }
     }
   }
-  else {
-    // possibly this is Table SObject
-    SALOMEDS::GenericAttribute_var anAttr;
-    SALOMEDS::AttributeName_var    aName;
-    QString SOName;
-      
+  else if ( !anIO.IsNull() ) {
     // check if Table SObject is selected
-    SALOMEDS::SObject_var SO = GetActiveStudy()->getStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() );
+    SO = aStudy->FindObjectID( anIO->getEntry() );
     if ( IsSObjectTable(SO) ) {
       // get name of SObject
       if ( SO->FindAttribute( anAttr, "AttributeName" ) ) {
-       aName = SALOMEDS::AttributeName::_narrow( anAttr );
-       SOName = aName->Value();
+        aName = anAttr;
+        SOName = QString( aName->Value().c_str() );
       }
-      Plot2d_SetupPlot2dDlg* dlg = new Plot2d_SetupPlot2dDlg( SO, QAD_Application::getDesktop() );
+      VisuGUI_SetupPlot2dDlg* dlg = new VisuGUI_SetupPlot2dDlg( SO, GetDesktop( this ) );
       if ( dlg->exec() == QDialog::Accepted ) {
-       if ( !isStudyLocked( GetActiveStudy()->getStudyDocument() ) ) {
-         // if study is not locked - create new table and container objects, create curves
-         // and insert them into container, then plot container if current viewer is of VIEW_PLOT2D type
-         int horIndex;
-         QValueList<int> verIndices;
-         dlg->getCurvesSource( horIndex, verIndices );
-         if ( horIndex >= 0 && verIndices.count() > 0 ) { 
-           CORBA::Object_var aTable = GetVisuGen()->CreateTable( SO->GetID() );
-           CORBA::Object_var aContainer = GetVisuGen()->CreateContainer();
-           if ( !CORBA::is_nil( aTable ) && !CORBA::is_nil( aContainer ) ) {
-             VISU::Table_i*     pTable     = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTable).in());
-             VISU::Container_i* pContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
-           
-             if ( pContainer && pTable ) {
-               for ( int i = 0; i < verIndices.count(); i++ ) {
-                 CORBA::Object_var aNewCurve = GetVisuGen()->CreateCurve( pTable->_this(), horIndex+1, verIndices[i]+1 );
-                 if( !CORBA::is_nil( aNewCurve ) ) {
-                   VISU::Curve_i* pCrv = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aNewCurve).in());
-                   if ( pCrv ) {
-                     bool isAuto;
-                     int  marker, line, lineWidth;
-                     QColor color;
-                     if ( dlg->getCurveAttributes( verIndices[i], isAuto, marker, line, lineWidth, color ) && !isAuto ) {
-                       SALOMEDS::Color c; c.R = color.red()/255.; c.G = color.green()/255.; c.B = color.blue()/255.;
-                       pCrv->SetColor( c );
-                       pCrv->SetMarker( ( VISU::Curve::MarkerType )marker );
-                       pCrv->SetLine( ( VISU::Curve::LineType )line, lineWidth );
-                     }
-                     pContainer->AddCurve( pCrv->_this() );
-                   }
-                 }
-               }
-               GetActiveStudy()->updateObjBrowser( true );
-               PlotContainer( pContainer, VISU::eDisplay );
-             }
-           }
-         }
-       } else {
-         // if study is locked just get curves info and plot them if current viewer is of VIEW_PLOT2D type
-         if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
-           Plot2d_CurveContainer container;
-           dlg->getCurves( container );
-           if ( !container.isEmpty() ) {
-             ((Plot2d_ViewFrame*)(GetActiveStudy()->getActiveStudyFrame()->
-                                  getRightFrame()->getViewFrame()))->displayCurves( container, true );
-             ((Plot2d_ViewFrame*)(GetActiveStudy()->getActiveStudyFrame()->
-                                  getRightFrame()->getViewFrame()))->setTitle( SOName );
-           }
-         }
-       }
+        if ( !IsStudyLocked( aStudy ) ) {
+          // if study is not locked - create new table and container objects, create curves
+          // and insert them into container, then plot container if current viewer is of VIEW_PLOT2D type
+          int horIndex;
+          QValueList<int> verIndices;
+          dlg->getCurvesSource( horIndex, verIndices );
+          if ( horIndex >= 0 && verIndices.count() > 0 ) {
+            CORBA::Object_var aTable = GetVisuGen(this)->CreateTable( SO->GetID().c_str() );
+            CORBA::Object_var aContainer = GetVisuGen(this)->CreateContainer();
+            if ( !CORBA::is_nil( aTable ) && !CORBA::is_nil( aContainer ) ) {
+              VISU::Table_i*     pTable     = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTable).in());
+              VISU::Container_i* pContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
+
+              if ( pContainer && pTable ) {
+                for ( int i = 0; i < verIndices.count(); i++ ) {
+                  CORBA::Object_var aNewCurve = GetVisuGen(this)->CreateCurve
+                    ( pTable->_this(), horIndex+1, verIndices[i]+1 );
+                  if( !CORBA::is_nil( aNewCurve ) ) {
+                    VISU::Curve_i* pCrv = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aNewCurve).in());
+                    if ( pCrv ) {
+                      bool isAuto;
+                      int  marker, line, lineWidth;
+                      QColor color;
+                      if ( dlg->getCurveAttributes(verIndices[i], isAuto, marker,
+                                                   line, lineWidth, color) && !isAuto ) {
+                        SALOMEDS::Color c;
+                        c.R = color.red()/255.;
+                        c.G = color.green()/255.;
+                        c.B = color.blue()/255.;
+                        pCrv->SetColor( c );
+                        pCrv->SetMarker( ( VISU::Curve::MarkerType )marker );
+                        pCrv->SetLine( ( VISU::Curve::LineType )line, lineWidth );
+                      }
+                      pContainer->AddCurve( pCrv->_this() );
+                    }
+                  }
+                }
+                UpdateObjBrowser(this);
+                PlotContainer( this, pContainer, VISU::eDisplay );
+              }
+            }
+          }
+        } else {
+          // if study is locked just get curves info and plot them
+          QPtrList<Plot2d_Curve> container;
+          dlg->getCurves( container );
+          if ( !container.isEmpty() ) {
+            GetPlot2dViewer( this )->getActiveViewFrame()->displayCurves( container, true );
+            GetPlot2dViewer( this )->getActiveViewFrame()->setTitle( SOName );
+          }
+        }
       }
       delete dlg;
-    } 
-  }
-}
-
-
-void VisuGUI::CreatePlot(SALOMEDS::SObject_var theTableSO) {
-  SALOMEDS::GenericAttribute_var anAttr;
-  SALOMEDS::AttributeName_var    aName;
-
-  if ( IsSObjectTable(theTableSO) ) {
-    CORBA::Object_var aTable = VISU::SObjectToObject(theTableSO);
-    CORBA::Object_var aContainer = GetVisuGen()->CreateContainer();
-    if ( !CORBA::is_nil( aTable ) && !CORBA::is_nil( aContainer ) ) {
-      VISU::Table_i*     pTable     = dynamic_cast<VISU::Table_i*>( VISU::GetServant(aTable).in() );
-      VISU::Container_i* pContainer = dynamic_cast<VISU::Container_i*>( VISU::GetServant(aContainer).in() );
-      
-      if ( pContainer && pTable ) {
-       for ( int i = 2; i <= pTable->GetNbRows(); i++ ) {
-         CORBA::Object_var aNewCurve = GetVisuGen()->CreateCurve( pTable->_this(), 1, i );
-         if( !CORBA::is_nil( aNewCurve ) ) {
-           VISU::Curve_i* pCrv = dynamic_cast<VISU::Curve_i*>( VISU::GetServant(aNewCurve).in() );
-           if ( pCrv ) {
-             pContainer->AddCurve( pCrv->_this() );
-           }
-         }
-       }
-       GetActiveStudy()->updateObjBrowser( true );
-       PlotContainer( pContainer, VISU::eDisplay );
-      }
     }
   }
 }
 
-
-/*!
-  Slot : Opens "Setup curve" dialog to set curve properties : for Curve object selected
-*/
-void VisuGUI::CurveProperties() {
-  SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
-  if( Sel->IObjectCount() !=1 )
-    return;
-  CORBA::Object_var anObject = GetSelectedObj();
-  SALOMEDS::SObject_var SO;
+void
+VisuGUI::
+OnCurveProperties()
+{
+  LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
+  SALOME_ListIO aListIO;
+  aSelectionMgr->selectedObjects(aListIO);
+  if (aListIO.Extent() != 1) return;
+
+  SalomeApp_Study* aAppStudy = GetAppStudy(this);
+  const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
+  CORBA::Object_var anObject = GetSelectedObj( aAppStudy, anIO->getEntry() );
   if (CORBA::is_nil( anObject )) return;
 
   VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
@@ -2179,242 +1296,309 @@ void VisuGUI::CurveProperties() {
     // Curve object
     CORBA::Object_ptr aCurve = VISU::Curve::_narrow( anObject );
     if( !CORBA::is_nil( aCurve ) ) {
-      VISU::Curve_i* curve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
-      if ( curve && !isStudyLocked( GetActiveStudy()->getStudyDocument() ) ) {
-       SALOMEGUI_SetupCurveDlg* dlg = new SALOMEGUI_SetupCurveDlg( QAD_Application::getDesktop() );    
-       dlg->setLine( (int)curve->GetLine(), curve->GetLineWidth() );
-       dlg->setMarker( (int)curve->GetMarker() );
-       SALOMEDS::Color color = curve->GetColor();
-       dlg->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
-       if( dlg->exec() == QDialog::Accepted ) {
-         curve->SetLine( (VISU::Curve::LineType)dlg->getLine(), dlg->getLineWidth() );
-         curve->SetMarker( (VISU::Curve::MarkerType)dlg->getMarker());
-         SALOMEDS::Color newColor;
-         newColor.R = dlg->getColor().red()/255.;
-         newColor.G = dlg->getColor().green()/255.;
-         newColor.B = dlg->getColor().blue()/255.;
-         curve->SetColor( newColor );
-         QList<QAD_StudyFrame> sfList = GetActiveStudy()->getStudyFrames();
-         if ( sfList.count() > 0 ) {
-           QListIterator<QAD_StudyFrame> it( sfList );
-           for ( ; it.current(); ++it ) {
-             if ( it.current()->getTypeView() == VIEW_PLOT2D ) {
-               Plot2d_ViewFrame* aPlot = (Plot2d_ViewFrame*)it.current()->getRightFrame()->getViewFrame();
-               Handle(SALOME_InteractiveObject) IO = aPlot->FindIObject( curve->GetEntry() );
-               if ( IO.IsNull() )
-                 continue;
-               Plot2d_Curve* plotCurve = aPlot->getCurveByIO( IO );
-               if ( plotCurve ) {
-                 plotCurve->setLine( (Plot2d_Curve::LineType)dlg->getLine(), dlg->getLineWidth() );
-                 plotCurve->setMarker( (Plot2d_Curve::MarkerType)dlg->getMarker() );
-                 plotCurve->setColor( dlg->getColor() );
-                 aPlot->updateCurve( plotCurve, true );
-               }
-             }
-           }
-         }
-       }
-      } 
+      VISU::Curve_i* aDSCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
+      if ( aDSCurve && (!IsStudyLocked( GetCStudy(aAppStudy) )) ) {
+        Plot2d_SetupCurveDlg aDlg(GetDesktop( this ));
+
+        aDlg.setLine( (int)aDSCurve->GetLine(), aDSCurve->GetLineWidth() );
+        aDlg.setMarker( (int)aDSCurve->GetMarker() );
+        SALOMEDS::Color aColor = aDSCurve->GetColor();
+        aDlg.setColor( QColor( (int)(aColor.R*255.), (int)(aColor.G*255.), (int)(aColor.B*255.) ) );
+        if( aDlg.exec() == QDialog::Accepted ) {
+          aDSCurve->SetLine( (VISU::Curve::LineType)aDlg.getLine(), aDlg.getLineWidth() );
+          aDSCurve->SetMarker( (VISU::Curve::MarkerType)aDlg.getMarker());
+          SALOMEDS::Color newColor;
+          newColor.R = aDlg.getColor().red()/255.;
+          newColor.G = aDlg.getColor().green()/255.;
+          newColor.B = aDlg.getColor().blue()/255.;
+          aDSCurve->SetColor( newColor );
+          PlotCurve(this, aDSCurve, VISU::eDisplay);
+        }
+      }
     }
   }
 }
 
-
-/*!
-  Slot : Clears container contents : for Container object selected
-*/
-void VisuGUI::ClearContainer() {
-  SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
-  if( Sel->IObjectCount() !=1 )
+void
+VisuGUI::
+OnClearContainer()
+{
+  _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
+  if (CheckLock(aCStudy,GetDesktop(this)))
+    return;
+  Handle(SALOME_InteractiveObject) anIO;
+  CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
+  if (anIO.IsNull() || CORBA::is_nil(anObject))
     return;
-
-  CORBA::Object_var anObject = GetSelectedObj();
-  SALOMEDS::SObject_var SO;
-  if (CORBA::is_nil( anObject )) return;
 
   VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
   if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCONTAINER) {
     // Container object
-    CORBA::Object_ptr aCnt = VISU::Container::_narrow( anObject );
-    if( !CORBA::is_nil( aCnt ) ) {
+    CORBA::Object_ptr aCnt = VISU::Container::_narrow(anObject);
+    if (!CORBA::is_nil(aCnt)) {
       VISU::Container_i* container = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aCnt).in());
-      if ( container && container->GetNbCurves() > 0 && !isStudyLocked( GetActiveStudy()->getStudyDocument() ) ) {
-       container->Clear();
-       GetActiveStudy()->updateObjBrowser();
+      if (container && container->GetNbCurves() > 0) {
+        container->Clear();
+        UpdateObjBrowser(this);
       }
     }
   }
 }
 
-/*!
-  Slot : Edit container contents : for Container object selected
-*/
-void VisuGUI::EditContainer() {
-  CORBA::Object_var anObject = GetSelectedObj();
-  if(CORBA::is_nil(anObject)) return;
+void
+VisuGUI::
+OnEditContainer()
+{
+  Handle(SALOME_InteractiveObject) anIO;
+  CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
+  if (CORBA::is_nil(anObject)) return;
+
   PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
-  if(!aServant.in()) return;
+  if (!aServant.in()) return;
   VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(aServant.in());
-  if(!aContainer) return;
-  
-  VisuGUI_EditContainerDlg* aDlg = new VisuGUI_EditContainerDlg();
+  if (!aContainer) return;
+
+  VisuGUI_EditContainerDlg* aDlg = new VisuGUI_EditContainerDlg (this);
   aDlg->initFromPrsObject(aContainer);
   if (aDlg->exec()) {
     aDlg->storeToPrsObject(aContainer);
-    GetActiveStudy()->updateObjBrowser( true );
+    UpdateObjBrowser(this, true);
   }
   delete aDlg;
 }
 
+void
+VisuGUI::
+OnSaveViewParams()
+{
+  _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
+  if (CheckLock(aCStudy,GetDesktop(this)))
+    return;
 
-void VisuGUI::DeletePrs() {
-  SALOMEDS::Study_var aStudy = GetStudyDocument();
-  if (checkLock(aStudy)) return;
-  
-  // There is a transaction
-  SALOMEDS::StudyBuilder_var aStudyBuilder = VisuGUI::NewBuilder();
-  aStudyBuilder->NewCommand();
+  SUIT_ViewManager* aViewMgr = getApp()->activeViewManager();
+  if (aViewMgr->getType() != SVTK_Viewer::Type())
+    return;
 
-  CORBA::Object_var anObject = GetSelectedObj();
-  if ( !CORBA::is_nil( anObject ) ) {
-    // is it Prs3d object ?
-    VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject).in());
-    if(aPrsObject)
-      DeletePresentation(aPrsObject);
-    // is it Curve object ?
-    VISU::Curve_i* aCurveObject = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(anObject).in());
-    if(aCurveObject)
-      DeletePresentation(aCurveObject);
+  LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
+  SALOME_ListIO aListIO;
+  aSelectionMgr->selectedObjects(aListIO);
+  if (aListIO.Extent() > 1)
+    return;
+
+  if (aListIO.Extent() == 0) {
+    VISU::View3D_i::SaveViewParams(aViewMgr, VISU::View3D_i::GenerateViewParamsName().latin1());
+  } else {
+    const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
+    VISU::View3D_i::SaveViewParams(aViewMgr, anIO->getName());
   }
-  aStudyBuilder->CommitCommand();
+  UpdateObjBrowser(this);
 }
 
-
-void VisuGUI::SaveViewParams()
+void
+VisuGUI::
+OnRestoreViewParams()
 {
-  if (checkLock(GetStudyDocument())) return;
-  SALOME_Selection* aSel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
-  QAD_StudyFrame* aStudyFrame = GetActiveStudy()->getActiveStudyFrame();
-  if ( aSel->IObjectCount() > 1 || aStudyFrame->getTypeView() != VIEW_VTK ) 
+  SUIT_ViewManager* aViewMgr = getApp()->activeViewManager();
+  if (aViewMgr->getType() != SVTK_Viewer::Type())
     return;
-  if ( aSel->IObjectCount()  == 0 ) {
-    VISU::View3D_i::SaveViewParams(aStudyFrame,VISU::View3D_i::GenerateViewParamsName().latin1());
-  }else{
-    const Handle(SALOME_InteractiveObject)& anIO = aSel->firstIObject();
-    VISU::View3D_i::SaveViewParams(aStudyFrame,anIO->getName());
-  }
-  GetActiveStudy()->updateObjBrowser( true );
-}
 
+  LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
+  SALOME_ListIO aListIO;
+  aSelectionMgr->selectedObjects(aListIO);
+  if (aListIO.Extent() != 1)
+    return;
+
+  const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
+  //jfa tmp:VISU::View3D_i::RestoreViewParams(aViewMgr, anIO->getName());
+  _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));//jfa tmp
+  _PTR(SObject) aSObj = aCStudy->FindObjectID(anIO->getEntry());//jfa tmp
+  if ( aSObj )
+    VISU::View3D_i::RestoreViewParams(aViewMgr, aSObj->GetName().c_str());//jfa tmp
+}
 
-void VisuGUI::RestoreViewParams()
+void
+VisuGUI::
+OnRename()
 {
-  SALOME_Selection* aSel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
-  QAD_StudyFrame* aStudyFrame = GetActiveStudy()->getActiveStudyFrame();
-  if ( aSel->IObjectCount() > 1 || aStudyFrame->getTypeView() != VIEW_VTK ) 
+  _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
+  if (CheckLock(aCStudy,GetDesktop(this)))
     return;
-  const Handle(SALOME_InteractiveObject)& anIO = aSel->firstIObject();
-  VISU::View3D_i::RestoreViewParams(aStudyFrame,anIO->getName());
-}
 
+  Handle(SALOME_InteractiveObject) anIO;
+  CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
 
-//=====================================================================================
-// function : DeleteViewParams()
-// purpose  :
-//=====================================================================================
-void VisuGUI::DeleteViewParams() {
-  bool isExist;
-  VISU::Storable::TRestoringMap aMap;
-  Handle(SALOME_InteractiveObject) anIO;    
-  CORBA::Object_var anObject = GetSelectedObj(&anIO,GetActiveStudy(),&aMap);
-  VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt();
-  if(isExist && aType == VISU::TVIEW3D){
-    SALOMEDS::Study_var aStudy = GetStudyDocument();
-    SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(anIO->getEntry());
-    aStudy->NewBuilder()->RemoveObject(aSObject);
+  _PTR(SObject) aSObj = aCStudy->FindObjectID(anIO->getEntry());
+  if (!aSObj) return;
 
-    SALOME_Selection* aSel = SALOME_Selection::Selection(GetActiveStudy()->getSelection());
-    aSel->RemoveIObject(anIO, 0);
+  //TEST DU PARENT == VISU
+  _PTR(StudyBuilder) aBuilder = aCStudy->NewBuilder();
+  _PTR(GenericAttribute) anAttr = aBuilder->FindOrCreateAttribute(aSObj, "AttributeName");
+  if (anAttr) {
+    _PTR(AttributeName) aName (anAttr);
+    QString Name = VisuGUI_NameDlg::getName( GetDesktop( this ), aName->Value().c_str() );
+    if (!Name.isEmpty()) {
+      QApplication::setOverrideCursor(Qt::waitCursor);
+
+      // rename specific objects
+      if (!CORBA::is_nil(anObject)) {
+        VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
+        if (!CORBA::is_nil(aVisuObj)) {
+          switch (aVisuObj->GetType()) {
+            case VISU::TCURVE: // Curve object
+            {
+              CORBA::Object_ptr aCurve = VISU::Curve::_narrow(anObject);
+              if (!CORBA::is_nil(aCurve)) {
+                VISU::Curve_i* curve =
+                  dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
+                if (curve)
+                  curve->SetName(Name.latin1());
+              }
+              break;
+            }
+            case VISU::TTABLE: // Table object
+            {
+              CORBA::Object_ptr aTable = VISU::Table::_narrow(anObject);
+              if (!CORBA::is_nil(aTable)) {
+                VISU::Table_i* table =
+                  dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTable).in());
+                if (table)
+                  table->SetName(Name.latin1());
+              }
+              break;
+            }
+            case VISU::TCONTAINER: // Container object
+            {
+              CORBA::Object_ptr aContainer = VISU::Container::_narrow(anObject);
+              if (!CORBA::is_nil(aContainer)) {
+                VISU::Container_i* container =
+                  dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
+                if (container)
+                  container->SetName(Name.latin1());
+              }
+              break;
+            }
+            default:
+            {
+            }
+          }
+        }
+      }
 
-    GetActiveStudy()->updateObjBrowser( true );
-  }
-}
+      // rename the study object
+      aName->SetValue(Name.latin1()); // rename the SObject
+      anIO->setName(Name.latin1()); // rename the InteractiveObject
+      
+      ViewManagerList pvm_list;
+      getApp()->viewManagers( SPlot2d_Viewer::Type(), pvm_list );
+      for( SUIT_ViewManager* mgr = pvm_list.first(); mgr; mgr = pvm_list.next() )
+      {
+       Plot2d_ViewManager* pvm = dynamic_cast<Plot2d_ViewManager*>( mgr );
+       if( pvm )
+       {
+         SPlot2d_Viewer* pv = dynamic_cast<SPlot2d_Viewer*>( pvm->getViewModel() );
+         if( pv )
+           pv->renameAll( anIO, Name.latin1() );
+       }
+      }
 
+      UpdateObjBrowser(this, false);
 
-//=====================================================================================
-// function : Sweep()
-// purpose  :
-//=====================================================================================
-void VisuGUI::Sweep() {
-  VISU::ScalarMap_i* aPrsObject = dynamic_cast<VISU::ScalarMap_i*>(GetSelectedPrs3d());
-  if (!aPrsObject) return;
+      QApplication::restoreOverrideCursor();
+    }
+  }
+}
 
-  VTKViewer_ViewFrame* vf = VisuGUI::GetVtkViewFrame();
-  if(!vf) return;
+void
+VisuGUI::
+OnClippingPlanes()
+{
+  new VisuGUI_ClippingDlg (this, "", false);
+}
 
-  int aTemp=100000;
-  QString aTempoStr = QAD_CONFIG->getSetting("Visu:SweepTempo");
-  if ( !aTempoStr.isEmpty() )
-    aTemp = int(1.E6*(aTempoStr.toFloat()));
+void
+VisuGUI::
+OnSweep()
+{
+  // GetSelectedPrs3d
+  Handle(SALOME_InteractiveObject) anIO;
+  CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
+  if (CORBA::is_nil(anObject)) return;
+  PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
+  if (!aServant.in()) return;
 
-  int aCycles=1;
-  QString aCyclesStr = QAD_CONFIG->getSetting("Visu:SweepCycles");
-  if ( !aCyclesStr.isEmpty() )
-    aCycles = aCyclesStr.toInt();
+  VISU::ScalarMap_i* aPrsObject = dynamic_cast<VISU::ScalarMap_i*>(aServant.in());
+  if (!aPrsObject) return;
 
-  int aSteps=40;
-  QString aStepsStr = QAD_CONFIG->getSetting("Visu:SweepSteps");
-  if ( !aStepsStr.isEmpty() )
-    aSteps = aStepsStr.toInt();
+  SVTK_ViewWindow* vw = GetActiveViewWindow<SVTK_ViewWindow>(this);
+  if (!vw) return;
 
-  VISU_Actor* aActor = GetActor(aPrsObject);
+  VISU_Actor* aActor = GetActor(aPrsObject, vw);
   if (!aActor) return;
-  
+
   if (!aActor->GetVisibility()) {
     aActor->VisibilityOn();
   }
 
-  QApplication::setOverrideCursor( Qt::waitCursor );
-  try{
-    for (int j=0 ; j<aCycles; j++) {
-      for (int i=0 ; i<=aSteps; i++) {
-       float aPercents = float(i)/aSteps;
-       aPrsObject->SetMapScale(aPercents);
-       aPrsObject->UpdateActor(aActor);
-       vf->getRW()->getRenderWindow()->Render();
-       usleep(aTemp);
+  // Get sweep parameters
+  SUIT_ResourceMgr* aResourceMgr = GetResourceMgr();
+
+  double aTempoDbl = aResourceMgr->doubleValue("VISU", "sweeping_time_step", 0.1);
+  int aTemp = int(1.E6 * aTempoDbl);
+
+  int aCycles = aResourceMgr->integerValue("VISU", "sweeping_number_cycles", 1);
+  int aSteps  = aResourceMgr->integerValue("VISU", "sweeping_time_step", 40);
+
+  // Sweep
+  QApplication::setOverrideCursor(Qt::waitCursor);
+  for (int j = 0; j < aCycles; j++) {
+    for (int i = 0; i <= aSteps; i++) {
+      try {
+        float aPercents = float(i)/aSteps;
+        aPrsObject->SetMapScale(aPercents);
+        aPrsObject->UpdateActor(aActor);
+        vw->getRenderWindow()->Render();
+        usleep(aTemp);
+      } catch (std::exception& exc) {
+        INFOS("Follow exception was occured :\n" << exc.what());
+      } catch (...) {
+        INFOS("Unknown exception was occured!");
       }
     }
-  }catch(std::exception& exc){
-    INFOS("Follow exception was occured :\n"<<exc.what());
-  }catch(...){
-    INFOS("Unknown exception was occured!");
   }
   QApplication::restoreOverrideCursor();
 }
 
+void
+VisuGUI::
+OnTimeAnimation()
+{
+  if (!VISU::GetActiveViewWindow<SVTK_ViewWindow>(this))
+    return;
+
+  _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
+  VisuGUI_TimeAnimationDlg* aAnimationDlg =
+    new VisuGUI_TimeAnimationDlg (this, aCStudy);
 
+  LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
+  SALOME_ListIO aListIO;
+  aSelectionMgr->selectedObjects(aListIO);
 
-void VisuGUI::TimeAnimation() {
-  VisuGUI_TimeAnimationDlg* aAnimationDlg = new VisuGUI_TimeAnimationDlg(GetStudyDocument());
-  SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
-  
   bool isDefined = false;
   long aNbTimes = 0;
-  SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
+  SALOME_ListIteratorOfListIO It (aListIO);
   for (; It.More(); It.Next()) {
-    SALOMEDS::SObject_var aSObject  = GetStudyDocument()->FindObjectID( It.Value()->getEntry() ); 
-    if (aSObject->_is_nil()) continue;
+    _PTR(SObject) aSObject = aCStudy->FindObjectID(It.Value()->getEntry());
+    if (!aSObject) continue;
     if (getValue(aSObject, "myComment") == QString("FIELD")) {
       long aNumber = getValue(aSObject, "myNbTimeStamps").toLong();
       if (aNumber > 1) {
-       if (!isDefined) {
-         aNbTimes = aNumber;
-         aAnimationDlg->addField(aSObject);
-         isDefined = true;
-       } else if (aNbTimes == aNumber) {
-         aAnimationDlg->addField(aSObject);
-       }
+        if (!isDefined) {
+          aNbTimes = aNumber;
+          aAnimationDlg->addField(aSObject);
+          isDefined = true;
+        } else if (aNbTimes == aNumber) {
+          aAnimationDlg->addField(aSObject);
+        }
       }
     }
   }
@@ -2422,1731 +1606,1440 @@ void VisuGUI::TimeAnimation() {
   else delete aAnimationDlg;
 }
 
-
-void VisuGUI::ImportMedField() {
-  if (checkLock(GetStudyDocument())) return;
-  SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
-  SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
-  QApplication::setOverrideCursor( Qt::waitCursor );
-  for(;It.More();It.Next()) {
-    Handle(SALOME_InteractiveObject) anIO = It.Value();
-    SALOMEDS::SObject_var aSObject = GetStudyDocument()->FindObjectID(anIO->getEntry());
-    if(!aSObject->_is_nil()){
-      CORBA::Object_var anObject = VISU::SObjectToObject(aSObject);
-      if(!CORBA::is_nil(anObject)){
-       SALOME_MED::MED_var aMED = SALOME_MED::MED::_narrow( anObject );
-       if(!CORBA::is_nil(aMED.in()))
-         GetVisuGen()->ImportMed( aSObject );
-       SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow( anObject );
-       if(!CORBA::is_nil(aField.in()))
-         GetVisuGen()->ImportMedField( aField );
-      }else{
-       SALOMEDS::SObject_var aSFather = aSObject->GetFather();
-       SALOMEDS::GenericAttribute_var anAttr;
-       aSFather->FindAttribute(anAttr, "AttributeName");
-       SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
-       CORBA::String_var aValue = aName->Value();
-       if(strcmp(aValue.in(),"MEDFIELD") == 0)
-         GetVisuGen()->ImportMed(aSObject);
-       //if(strcmp(aValue.in(),"MEDMESH") == 0)
-       //  VisuGUI::myComponent->ImportMed(aSObject);
-      }
-    }
-  }
-  GetActiveStudy()->updateObjBrowser( true );
-  QApplication::restoreOverrideCursor();
-}
-
-//=====================================================================================
-// functions : Rename()
-// purpose  :
-//=====================================================================================
-void VisuGUI::Rename() {
-  if (checkLock(GetStudyDocument())) return;
-  SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
-  if ( Sel->IObjectCount() != 1 )
+//************************************************************************
+void
+VisuGUI::
+OnShowAnimation()
+{
+  if (!VISU::GetActiveViewWindow<SVTK_ViewWindow>(this))
     return;
-  SALOMEDS::SObject_var aSObj = GetStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() );
-  if( aSObj->_is_nil() ) return;
-   
-  VISU::Curve_i* curve = 0;
-  CORBA::Object_var anObject = GetSelectedObj();
-  if ( !CORBA::is_nil( anObject )) {
-    VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
-    if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCURVE) {
-      // Curve object
-      CORBA::Object_ptr aCurve = VISU::Curve::_narrow( anObject );
-      if( !CORBA::is_nil( aCurve ) ) {
-       curve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
-      }
-    }
-  }
 
-  //TEST DU PARENT == VISU
-  SALOMEDS::GenericAttribute_var anAttr;  
-  SALOMEDS::AttributeName_var    aName;
-  if ( aSObj->FindAttribute(anAttr, "AttributeName") ) {
-    aName = SALOMEDS::AttributeName::_narrow( anAttr );
-    QString Name = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), aName->Value() );
-    if ( !Name.isEmpty() ) {
-      QApplication::setOverrideCursor( Qt::waitCursor );
-      if ( curve )
-       curve->SetName( Name.latin1() );
-      GetActiveStudy()->renameIObject( Sel->firstIObject(), Name );
-      QApplication::restoreOverrideCursor();
-      
-      //int TypeMode;  bool InViewer;
-      //VISU_Actor *ActorTmp = ActorSelected(parent,InViewer,&TypeMode);
-      //ActorTmp->setName((Standard_CString)Name.latin1());
-    }
-  }
-}
+  LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
+  SALOME_ListIO aListIO;
+  aSelectionMgr->selectedObjects(aListIO);
 
-//=====================================================================================
-// functions : RenameTable()
-// purpose  :
-//=====================================================================================
-void VisuGUI::RenameTable() {
-  if (checkLock(GetStudyDocument())) return;
-  SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
-  if ( Sel->IObjectCount() != 1 )
+  if (aListIO.Extent() != 1)
     return;
-  SALOMEDS::SObject_var aSObj = GetStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() );
-  if( aSObj->_is_nil() ) return;
-   
-  VISU::Table_i* table = 0;
-  CORBA::Object_var anObject = GetSelectedObj();
-  if ( !CORBA::is_nil( anObject )) {
-    VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
-    if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TTABLE) {
-      // Table object
-      CORBA::Object_ptr aTable = VISU::Table::_narrow( anObject );
-      if( !CORBA::is_nil( aTable ) ) {
-       table = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTable).in());
-      }
-    }
-  }
-
-  //TEST DU PARENT == VISU
-  SALOMEDS::GenericAttribute_var anAttr;  
-  SALOMEDS::AttributeName_var    aName;
-  if ( aSObj->FindAttribute(anAttr, "AttributeName") ) {
-    aName = SALOMEDS::AttributeName::_narrow( anAttr );
-    QString Name = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), aName->Value() );
-    if ( !Name.isEmpty() ) {
-      QApplication::setOverrideCursor( Qt::waitCursor );
-      if ( table )
-       table->SetName( Name.latin1() );
-      GetActiveStudy()->renameIObject( Sel->firstIObject(), Name );
-      QApplication::restoreOverrideCursor();
-      
-      //int TypeMode;  bool InViewer;
-      //VISU_Actor *ActorTmp = ActorSelected(parent,InViewer,&TypeMode);
-      //ActorTmp->setName((Standard_CString)Name.latin1());
-    }
-  }
-}
 
+  const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
 
+  _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
 
-//=====================================================================================
-// functions : RenameContainer()
-// purpose  :
-//=====================================================================================
-void VisuGUI::RenameContainer() {
-  if (checkLock(GetStudyDocument())) return;
-  SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
-  if ( Sel->IObjectCount() != 1 )
-    return;
-  SALOMEDS::SObject_var aSObj = GetStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() );
-  if( aSObj->_is_nil() ) return;
-   
-  VISU::Container_i* container = 0;
-  CORBA::Object_var anObject = GetSelectedObj();
-  if ( !CORBA::is_nil( anObject )) {
-    VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
-    if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCONTAINER) {
-      // Curve object
-      CORBA::Object_ptr aContainer = VISU::Container::_narrow( anObject );
-      if( !CORBA::is_nil( aContainer ) ) {
-       container = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
-      }
-    }
-  }
+  _PTR(SObject) aSObj = aCStudy->FindObjectID(anIO->getEntry());
+  if (!aSObj) return;
 
-  //TEST DU PARENT == VISU
-  SALOMEDS::GenericAttribute_var anAttr;  
-  SALOMEDS::AttributeName_var    aName;
-  if ( aSObj->FindAttribute(anAttr, "AttributeName") ) {
-    aName = SALOMEDS::AttributeName::_narrow( anAttr );
-    QString Name = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), aName->Value() );
-    if ( !Name.isEmpty() ) {
-      QApplication::setOverrideCursor( Qt::waitCursor );
-      if ( container )
-       container->SetName( Name.latin1() );
-      GetActiveStudy()->renameIObject( Sel->firstIObject(), Name );
-      QApplication::restoreOverrideCursor();
-      
-      //int TypeMode;  bool InViewer;
-      //VISU_Actor *ActorTmp = ActorSelected(parent,InViewer,&TypeMode);
-      //ActorTmp->setName((Standard_CString)Name.latin1());
-    }
-  }
+  VISU::Storable::TRestoringMap aMap;
+  _PTR(GenericAttribute) anAttr;
+  if (!aSObj->FindAttribute(anAttr, "AttributeComment")) return;
+
+  _PTR(AttributeComment) aComment (anAttr);
+  string aComm = aComment->Value();
+  QString strIn (aComm.c_str());
+  VISU::Storable::StrToMap(strIn, aMap);
+  bool isExist;
+  VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt();
+  if (aType != VISU::TANIMATION) return;
+
+  VisuGUI_TimeAnimationDlg* aAnimationDlg =
+    new VisuGUI_TimeAnimationDlg(this, aCStudy);
+  aAnimationDlg->restoreFromStudy(aSObj);
+  aAnimationDlg->show();
 }
 
+void
+VisuGUI::
+OnCopyPresentation()
+{
+  _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
+  if (CheckLock(aCStudy,GetDesktop(this)))
+    return;
 
+  Handle(SALOME_InteractiveObject) anIO;
+  CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
+  if (CORBA::is_nil(anObject)) return;
+  PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
+  if (!aServant.in()) return;
 
-//=====================================================================================
-// function : CopyPresentation()
-// purpose  :
-//=====================================================================================
-void VisuGUI::CopyPresentation(){
-  if (checkLock(GetStudyDocument())) return;
-  VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d();
+  VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
   if (!aPrsObject) return;
+
   switch (aPrsObject->GetType()) {
   case VISU::TMESH:
     {
       VISU::Mesh_i* aMeshPrs = dynamic_cast<VISU::Mesh_i*>(aPrsObject);
       VISU::Mesh_i* aSameMesh = new VISU::Mesh_i(aMeshPrs->GetResult());
       aSameMesh->SameAs(aMeshPrs);
-      UpdateViewer(aSameMesh);
-    }    
+    }
     break;
-   case VISU::TSCALARMAP:
+  case VISU::TSCALARMAP:
     {
       VISU::ScalarMap_i* aScalarPrs = dynamic_cast<VISU::ScalarMap_i*>(aPrsObject);
-      VISU::ScalarMap_i* aSameScalar = new VISU::ScalarMap_i(aScalarPrs->GetResult());
+      VISU::ScalarMap_i* aSameScalar = new VISU::ScalarMap_i(aScalarPrs->GetResult(),true);
       aSameScalar->SameAs(aScalarPrs);
-      UpdateViewer(aSameScalar);
-    }    
+    }
     break;
-   case VISU::TDEFORMEDSHAPE:
+  case VISU::TDEFORMEDSHAPE:
     {
       VISU::DeformedShape_i* aDefPrs = dynamic_cast<VISU::DeformedShape_i*>(aPrsObject);
-      VISU::DeformedShape_i* aSameDeformed = new VISU::DeformedShape_i(aDefPrs->GetResult());
+      VISU::DeformedShape_i* aSameDeformed = new VISU::DeformedShape_i(aDefPrs->GetResult(),true);
       aSameDeformed->SameAs(aDefPrs);
-      UpdateViewer(aSameDeformed);
-    }    
+    }
+    break;
+  case VISU::TSCALARMAPONDEFORMEDSHAPE:
+    {
+      VISU::ScalarMapOnDeformedShape_i* aDefPrs =
+        dynamic_cast<VISU::ScalarMapOnDeformedShape_i*>(aPrsObject);
+      VISU::ScalarMapOnDeformedShape_i* aSameScalarMapOnDeformed =
+        new VISU::ScalarMapOnDeformedShape_i(aDefPrs->GetResult(),true);
+      aSameScalarMapOnDeformed->SameAs(aDefPrs);
+    }
     break;
-   case VISU::TCUTPLANES:
+  case VISU::TCUTPLANES:
     {
       VISU::CutPlanes_i* aCutPrs = dynamic_cast<VISU::CutPlanes_i*>(aPrsObject);
-      VISU::CutPlanes_i* aSameCut = new VISU::CutPlanes_i(aCutPrs->GetResult());
+      VISU::CutPlanes_i* aSameCut = new VISU::CutPlanes_i(aCutPrs->GetResult(),true);
       aSameCut->SameAs(aCutPrs);
-      UpdateViewer(aSameCut);
-    }    
+    }
     break;
-    case VISU::TCUTLINES:
+  case VISU::TCUTLINES:
     {
       VISU::CutLines_i* aCutPrs = dynamic_cast<VISU::CutLines_i*>(aPrsObject);
-      VISU::CutLines_i* aSameCut = new VISU::CutLines_i(aCutPrs->GetResult());
+      VISU::CutLines_i* aSameCut = new VISU::CutLines_i(aCutPrs->GetResult(),true);
       aSameCut->SameAs(aCutPrs);
-      UpdateViewer(aSameCut);
-    }    
+    }
     break;
   case VISU::TISOSURFACE:
     {
       VISU::IsoSurfaces_i* aIsoPrs = dynamic_cast<VISU::IsoSurfaces_i*>(aPrsObject);
-      VISU::IsoSurfaces_i* aSameIso = new VISU::IsoSurfaces_i(aIsoPrs->GetResult());
+      VISU::IsoSurfaces_i* aSameIso = new VISU::IsoSurfaces_i(aIsoPrs->GetResult(),true);
       aSameIso->SameAs(aIsoPrs);
-      UpdateViewer(aSameIso);
-    }    
+    }
     break;
-   case VISU::TSTREAMLINES:
+  case VISU::TSTREAMLINES:
     {
       VISU::StreamLines_i* aLinesPrs = dynamic_cast<VISU::StreamLines_i*>(aPrsObject);
-      VISU::StreamLines_i* aSameLines = new VISU::StreamLines_i(aLinesPrs->GetResult());
+      VISU::StreamLines_i* aSameLines = new VISU::StreamLines_i(aLinesPrs->GetResult(),true);
       aSameLines->SameAs(aLinesPrs);
-      UpdateViewer(aSameLines);
-    }    
+    }
     break;
-   case VISU::TVECTORS:
+  case VISU::TVECTORS:
     {
       VISU::Vectors_i* aVectorsPrs = dynamic_cast<VISU::Vectors_i*>(aPrsObject);
-      VISU::Vectors_i* aSameVectors = new VISU::Vectors_i(aVectorsPrs->GetResult());
+      VISU::Vectors_i* aSameVectors = new VISU::Vectors_i(aVectorsPrs->GetResult(),true);
       aSameVectors->SameAs(aVectorsPrs);
-      UpdateViewer(aSameVectors);
-    }    
+    }
+    break;
+  case VISU::TPLOT3D:
+    {
+      VISU::Plot3D_i* aPlot3DPrs = dynamic_cast<VISU::Plot3D_i*>(aPrsObject);
+      VISU::Plot3D_i* aSamePlot3D = new VISU::Plot3D_i(aPlot3DPrs->GetResult());
+      aSamePlot3D->SameAs(aPlot3DPrs);
+    }
     break;
- }
-  GetActiveStudy()->updateObjBrowser();
 }
+  UpdateObjBrowser(this);
 }
 
-
-
-//=====================================================================================
-// function : DefinePopup()
-// purpose  :
-//=====================================================================================
-void VisuGUI::DefinePopup( QString & theContext, QString & theParent, QString & theObject )
+void
+VisuGUI::
+OnSelectionInfo()
 {
-  theObject = "";
-  theContext = "";
+  if (GetActiveViewWindow<SVTK_ViewWindow>(this))
+    (new VisuGUI_SelectionDlg(this))->show();
+  else
+    SUIT_MessageBox::warn1(GetDesktop(this),
+                           tr("WRN_VISU"),
+                           tr("ERR_ACTIVATE_VIEW3D"),
+                           tr("BUT_OK") );
 }
 
-
-//=====================================================================================
-// function : checkHomoSelection()
-// purpose  : 
-//=====================================================================================
-enum { homoNone=0, homoCurves, homoPresentations, homoPresentable, homoAnimatable, homoOther };
-int VisuGUI::checkHomoSelection()
+void
+VisuGUI::
+OnMergeScalarBars()
 {
-  int selMode = homoNone;
-  SALOME_Selection* Sel = SALOME_Selection::Selection(GetActiveStudy()->getSelection());
-  SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
-  for ( ; It.More(); It.Next() ) {
-    int selNext = homoOther;
+  LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
+  SALOME_ListIO aListIO;
+  aSelectionMgr->selectedObjects(aListIO);
+
+  SALOME_ListIteratorOfListIO It (aListIO);
+
+  // first find the bounds
+  double aMin, aMax; bool first = true;
+  for (; It.More(); It.Next()) {
     Handle(SALOME_InteractiveObject)& anIO = It.Value();
-    if ( anIO->hasEntry() ) {
-      SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument();
-      SALOMEDS::SObject_var aSObject = aStudy->FindObjectID( anIO->getEntry() );
-      VISU::Storable::TRestoringMap pMap;
-      if( !aSObject->_is_nil() ) {
-       CORBA::Object_var aCORBAObject = VISU::SObjectToObject(aSObject);
-       if ( !CORBA::is_nil( aCORBAObject ) ) {
-         VISU::Base_var aVisuObj = VISU::Base::_narrow( aCORBAObject );
-         if ( !CORBA::is_nil( aVisuObj ) ) {
-           VISU::VISUType aType = aVisuObj->GetType();
-           switch( aType ) {
-           case VISU::TTABLE:
-           case VISU::TCURVE:
-           case VISU::TCONTAINER:
-             selNext = homoCurves; break;
-           case VISU::TMESH:
-           case VISU::TSCALARMAP:
-           case VISU::TISOSURFACE:
-           case VISU::TDEFORMEDSHAPE:
-           case VISU::TCUTPLANES:
-           case VISU::TCUTLINES:
-           case VISU::TVECTORS:
-           case VISU::TSTREAMLINES:
-             selNext = homoPresentations; break;
-           case VISU::TFIELD:
-             if (getValue(aSObject, "myNbTimeStamps").toLong() > 1) {
-               selNext = homoAnimatable; break;
-             }
-             selNext = homoOther; break;
-           default:
-             selNext = homoOther;
-           }
-         }
-       }
-       else {
-         SALOMEDS::GenericAttribute_var anAttr;
-         if ( aSObject->FindAttribute( anAttr, "AttributeComment") ) {
-           SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow( anAttr );
-           string aComm = aComment->Value();
-           QString strIn( aComm.c_str() );
-           VISU::Storable::StrToMap( strIn, pMap );
-           bool isExist;
-           VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(pMap,"myType",&isExist).toInt();
-           if( isExist ) {
-             switch ( aType ) {
-             case VISU::TENTITY:
-             case VISU::TFAMILY:
-             case VISU::TGROUP: 
-               selNext = homoPresentable; break;
-             case VISU::TFIELD:
-               if (getValue(aSObject, "myNbTimeStamps").toLong() > 1) {
-                 selNext = homoAnimatable; break;
-               }
-               selNext = homoOther; break;
-             default:
-               selNext = homoOther;
-             }
-           }
-         }
-       }
+    std::vector<VISU::Prs3d_i*> aPrsList = GetPrs3dList(this, anIO);
+    if (!aPrsList.empty()) {
+      for (int i = 0, n = aPrsList.size(); i < n; i++) {
+        VISU::Prs3d_i* aPrsObject = aPrsList[i];
+        if (aPrsObject) {
+          VISU::ScalarMap_i* aScalar = dynamic_cast<VISU::ScalarMap_i*>(aPrsObject);
+          if (aScalar) {
+            if (first) {
+              first = false;
+              aMin = aScalar->GetMin(); aMax = aScalar->GetMax();
+            } else {
+              if (aScalar->GetMin() < aMin) aMin = aScalar->GetMin();
+              if (aScalar->GetMax() > aMax) aMax = aScalar->GetMax();
+            }
+          }
+        }
       }
     }
-    if ( selMode == homoNone ) 
-      selMode = selNext;
-    else {
-      if ( selMode != selNext )
-       return homoNone;
-    }
   }
-  return selMode;
-}
 
-//=====================================================================================
-// function : GetNbChildren() [ static ]
-// purpose  : get number of children
-//=====================================================================================
-int GetNbChildren( SALOMEDS::SObject_var SO, bool refToo )
-{
-  if ( SO->_is_nil() )
-    return 0;
-  int cnt = 0;
-  SALOMEDS::ChildIterator_var Iter = SO->GetStudy()->NewChildIterator( SO );
-  for ( ; Iter->More(); Iter->Next() ) {
-    SALOMEDS::SObject_var refSO;
-    if ( !Iter->Value()->ReferencedObject( refSO ) || refToo )
-      cnt++;
+  // set the computed range to every selected ScalarMap
+  bool update = false;
+  for (It.Initialize(aListIO); It.More(); It.Next() ) {
+    Handle(SALOME_InteractiveObject)& anIO = It.Value();
+    std::vector<VISU::Prs3d_i*> aPrsList = GetPrs3dList(this, anIO);
+    if (!aPrsList.empty()) {
+      for (int i = 0, n = aPrsList.size(); i < n; i++) {
+        VISU::Prs3d_i* aPrsObject = aPrsList[i];
+        if(aPrsObject){
+          VISU::ScalarMap_i* aScalar = dynamic_cast<VISU::ScalarMap_i*>(aPrsObject);
+          if (aScalar) {
+            aScalar->SetRange(aMin, aMax);
+            RecreateActor(this, aScalar);
+            update = true;
+          }
+        }
+      }
+    }
+  }
+  if (update) {
+    if (SVTK_ViewWindow* vw = GetActiveViewWindow<SVTK_ViewWindow>(this)) {
+      vw->getRenderer()->ResetCameraClippingRange();
+      vw->Repaint();
+    }
   }
-  return cnt;
 }
 
-//=====================================================================================
-// function : CustomPopup()
-// purpose  :
-//=====================================================================================
-bool VisuGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* thePopup, const QString & theContext,
-                         const QString & theParent, const QString & theObject)
+void
+VisuGUI::
+OnFreeScalarBars()
 {
-  QAD_ResourceMgr* rmgr = parent->createResourceManager();
+  LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
+  SALOME_ListIO aListIO;
+  aSelectionMgr->selectedObjects(aListIO);
 
-  bool aIsLocked = isStudyLocked( GetActiveStudy()->getStudyDocument() );
-  
-  bool isVTKViewer = (GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK);
-  SALOME_Selection* aSelection = SALOME_Selection::Selection(GetActiveStudy()->getSelection());
-  QString aParentComponent     = ((SALOMEGUI_Desktop*)parent)->getComponentFromSelection();
-  int nbSel = aSelection->IObjectCount();
-
-  thePopup->clear();
+  SALOME_ListIteratorOfListIO It (aListIO);
 
-  if ( nbSel == 0 ) {
-    if ( theParent == "Viewer" && isVTKViewer && !aIsLocked)
-      thePopup->insertItem( "Save view parameters", visuGUI, SLOT( SaveViewParams() ) );
-    return false;
-  }
-  if( nbSel > 1 ) {
-    int selMode = checkHomoSelection();
-    if(MYDEBUG) MESSAGE("VisuGUI::CustomPopup: multiple selection : selMode = "<<selMode );
-    if ( selMode == homoCurves ) {
-      if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
-       thePopup->insertItem( "Display", visuGUI, SLOT( DisplayManyPrs() ) );
-       thePopup->insertItem( "Erase", visuGUI, SLOT( EraseManyPrs () ) );
-       thePopup->insertItem( "Display Only", visuGUI, SLOT( DisplayOnlyManyPrs() ) );
-      }
-    }
-    else if ( selMode == homoPresentations ) {
-      if (isVTKViewer) {
-       thePopup->insertItem( "Display", visuGUI, SLOT( DisplayManyPrs() ) );
-       thePopup->insertItem( "Erase", visuGUI, SLOT( EraseManyPrs () ) );
+  // restore the source range for every ScalarMap
+  bool update = false;
+  for (; It.More(); It.Next()) {
+    Handle(SALOME_InteractiveObject)& anIO = It.Value();
+    std::vector<VISU::Prs3d_i*> aPrsList = GetPrs3dList(this, anIO);
+    if (!aPrsList.empty()) {
+      for (int i = 0, n = aPrsList.size(); i < n; i++) {
+        VISU::Prs3d_i* aPrsObject = aPrsList[i];
+        if (aPrsObject) {
+          VISU::ScalarMap_i* aScalar = dynamic_cast<VISU::ScalarMap_i*>(aPrsObject);
+          if (aScalar) {
+            aScalar->SetSourceRange();
+            RecreateActor(this, aScalar);
+            update = true;
+          }
+        }
       }
     }
-    else if ( selMode == homoPresentable ) {
-      if (!aIsLocked) thePopup->insertItem("Create Presentations", visuGUI, SLOT(CreateManyMesh()));    
-    }
-    else if ( selMode == homoAnimatable ) {
-      thePopup->insertItem( "Animation...", visuGUI, SLOT( TimeAnimation() ) );
+  }
+  if (update) {
+    if (SVTK_ViewWindow* vw = GetActiveViewWindow<SVTK_ViewWindow>(this)) {
+      vw->getRenderer()->ResetCameraClippingRange();
+      vw->Repaint();
     }
-    return true;
   }
-  VISU::Storable::TRestoringMap aMap;
-  Handle(SALOME_InteractiveObject) anIO;
-  CORBA::Object_var anObject = GetSelectedObj(&anIO,GetActiveStudy(),&aMap);
-  if (!CORBA::is_nil(anObject)) {
-    SALOMEDS::SObject_var aSObject = GetStudyDocument()->FindObjectID(anIO->getEntry());
-    VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
-    if (!CORBA::is_nil(aVisuObj)) {
-      VISU::VISUType aType = aVisuObj->GetType();
-      if(MYDEBUG) MESSAGE("VisuGUI::CustomPopup - VISU object :: "<<aType);
-      switch (aType) {
-      case VISU::TVISUGEN:
-       thePopup->insertItem("Import MED", visuGUI, SLOT(ImportFile()));
-       thePopup->insertItem("Import TABLE", visuGUI, SLOT(ImportTablesFromFile()));
-       thePopup->insertItem("Create Plot2d View", visuGUI, SLOT(CreatePlot2dView()));
-       break;
-
-      case VISU::TRESULT:
-       if (!aIsLocked) thePopup->insertItem("Delete", visuGUI, SLOT(DeleteObject()));
-       break;
-       
-      case VISU::TTABLE:
-       if (!aIsLocked) thePopup->insertItem( "Rename...", visuGUI, SLOT( RenameTable() ) );
-       thePopup->insertItem( "Show Table",    visuGUI, SLOT( ShowTable() ) );
-       if (!aIsLocked) thePopup->insertItem( "Create Curves", visuGUI, SLOT( PlotData() ) );
-       thePopup->insertItem( "Export Table", visuGUI, SLOT( ExportTableToFile() ) );
-       thePopup->insertSeparator();
-       if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
-         if ( GetNbChildren( aSObject, false ) > 0 ) {
-           thePopup->insertItem( "Erase",        visuGUI, SLOT( ErasePrs () ) );
-           thePopup->insertItem( "Display",      visuGUI, SLOT( DisplayPrs() ) );
-           thePopup->insertItem( "Display Only", visuGUI, SLOT( DisplayOnlyPrs() ) );
-         }
-       }
-       thePopup->insertItem( "Delete", visuGUI, SLOT( DeleteObject() ) );
-       break;
-      case VISU::TCURVE:
-       if ( !aIsLocked ) {
-         thePopup->insertItem( "Properties", visuGUI, SLOT( CurveProperties() ) );
-         thePopup->insertItem( "Rename...", visuGUI, SLOT(Rename()));
-       }
-       if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
-         if ( GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame()->isVisible( anIO ) ) 
-           thePopup->insertItem( "Erase", visuGUI, SLOT( ErasePrs () ) );
-         else 
-           thePopup->insertItem( "Display", visuGUI, SLOT( DisplayPrs() ) );
-         thePopup->insertItem( "Display Only", visuGUI, SLOT( DisplayOnlyPrs() ) );
-       }
-       if ( !aIsLocked ) thePopup->insertItem("Delete", visuGUI, SLOT(DeletePrs()));
-       break;
-
-      case VISU::TCONTAINER:
-//     if( !CORBA::is_nil( anObject ) ) {
-//       CORBA::Object_ptr aCnt = VISU::Container::_narrow( anObject );
-//       if( !CORBA::is_nil( aCnt ) ) {
-//         VISU::Container_i* container = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aCnt).in());
-//         if ( container ) {
-//           if ( !aIsLocked ) {
-//             thePopup->insertItem( "Edit...", visuGUI, SLOT( EditContainer() ) );
-//             thePopup->insertItem( "Rename...", visuGUI, SLOT( RenameContainer() ) );
-//             if (container->GetNbCurves() > 0)
-//               thePopup->insertItem( "Clear", visuGUI, SLOT( ClearContainer() ) );
-//           }
-//           if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
-//             thePopup->insertSeparator();
-//             thePopup->insertItem( "Display", visuGUI, SLOT( DisplayPrs() ) );
-//             thePopup->insertItem( "Erase", visuGUI, SLOT( ErasePrs () ) );
-//             thePopup->insertItem( "Display Only", visuGUI, SLOT( DisplayOnlyPrs() ) );
-//           }
-//         }
-//       }
-//     }
-       if ( !aIsLocked ) {
-         thePopup->insertItem( "Edit...", visuGUI, SLOT( EditContainer() ) );
-         thePopup->insertItem( "Rename...", visuGUI, SLOT( RenameContainer() ) );
-         thePopup->insertItem( "Clear", visuGUI, SLOT( ClearContainer() ) );
-       }
-       if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
-         thePopup->insertSeparator();
-         thePopup->insertItem( "Display", visuGUI, SLOT( DisplayPrs() ) );
-         thePopup->insertItem( "Erase", visuGUI, SLOT( ErasePrs () ) );
-         thePopup->insertItem( "Display Only", visuGUI, SLOT( DisplayOnlyPrs() ) );
-       }
-       if ( !aIsLocked ) thePopup->insertItem( "Delete", visuGUI, SLOT( DeleteObject() ) );
-       break;
+}
 
-      default: // Presentation
-       {
-         VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject).in());
-         if (aPrsObject) {
-           if (isVTKViewer) {
-             // Add Presentation menu
-             if (VISU_Actor* anVISUActor = visuGUI->GetActor(aPrsObject)){
-               QPopupMenu* aPresMenu = new QPopupMenu(GetDesktop());
-               int aRepresent = anVISUActor->GetRepresentation();
-               switch(aRepresent){
-               case VISU::POINT :
-                 aPresMenu->insertItem("Wireframe", visuGUI, SLOT(MakeWireframe()));
-                 aPresMenu->insertItem("Surface", visuGUI, SLOT(MakeSurface()));
-                 if (aType == VISU::TMESH || aType == VISU::TSCALARMAP || aType == VISU::TDEFORMEDSHAPE)
-                   aPresMenu->insertItem("Insideframe", visuGUI, SLOT(MakeInsideframe()));
-                 if (aType == VISU::TMESH)  
-                   aPresMenu->insertItem("Surfaceframe", visuGUI, SLOT(MakeSurfaceframe()));
-                 break;
-               case VISU::WIREFRAME :
-                 aPresMenu->insertItem("Points", visuGUI, SLOT(MakePoints()));
-                 aPresMenu->insertItem("Surface", visuGUI, SLOT(MakeSurface()));
-                 if (aType == VISU::TMESH || aType == VISU::TSCALARMAP || aType == VISU::TDEFORMEDSHAPE)
-                   aPresMenu->insertItem("Insideframe", visuGUI, SLOT(MakeInsideframe()));
-                 if (aType == VISU::TMESH)
-                   aPresMenu->insertItem("Surfaceframe", visuGUI, SLOT(MakeSurfaceframe()));
-                 break;
-               case VISU::SHADED :
-                 aPresMenu->insertItem("Points", visuGUI, SLOT(MakePoints()));
-                 aPresMenu->insertItem("Wireframe", visuGUI, SLOT(MakeWireframe()));
-                 if (aType == VISU::TMESH || aType == VISU::TSCALARMAP || aType == VISU::TDEFORMEDSHAPE)
-                   aPresMenu->insertItem("Insideframe", visuGUI, SLOT(MakeInsideframe()));
-                 if (aType == VISU::TMESH)
-                   aPresMenu->insertItem("Surfaceframe", visuGUI, SLOT(MakeSurfaceframe()));
-                 break;
-               case VISU::INSIDEFRAME :
-                 aPresMenu->insertItem("Points", visuGUI, SLOT(MakePoints()));
-                 aPresMenu->insertItem("Surface", visuGUI, SLOT(MakeSurface()));
-                 aPresMenu->insertItem("Wireframe", visuGUI, SLOT(MakeWireframe()));
-                 if (aType == VISU::TMESH)
-                   aPresMenu->insertItem("Surfaceframe", visuGUI, SLOT(MakeSurfaceframe()));
-                 break;
-               case VISU::SURFACEFRAME :
-                 aPresMenu->insertItem("Points", visuGUI, SLOT(MakePoints()));
-                 aPresMenu->insertItem("Surface", visuGUI, SLOT(MakeSurface()));
-                 aPresMenu->insertItem("Wireframe", visuGUI, SLOT(MakeWireframe()));
-                 aPresMenu->insertItem("Insideframe", visuGUI, SLOT(MakeInsideframe()));
-                 break;
-               }
-               if(anVISUActor->IsShrunkable())
-                 if(aType != VISU::TVECTORS && aType != VISU::TSTREAMLINES){
-                   if (anVISUActor->IsShrunk())
-                     aPresMenu->insertItem("Unshrink", visuGUI, SLOT(MakeShrink()));
-                   else
-                     aPresMenu->insertItem("Shrink", visuGUI, SLOT(MakeShrink()));
-                 }
-               thePopup->insertItem("Representation", aPresMenu);
-
-               // Add Properties
-               QPopupMenu* aPropMenu = new QPopupMenu(GetDesktop());
-               if(aType == VISU::TMESH){
-                 if(aRepresent == VISU::SURFACEFRAME){
-                   aPropMenu->insertItem("Cell Color", visuGUI, SLOT(ChageColor()));
-                   aPropMenu->insertItem("Edge Color", visuGUI, SLOT(ChangeWireframeColor()));
-                 }else
-                   aPropMenu->insertItem("Color", visuGUI, SLOT(ChageColor()));
-               }else if(aType == VISU::TDEFORMEDSHAPE)
-                 aPropMenu->insertItem("Color", visuGUI, SLOT(ChageColor()));
-
-               if (aType != VISU::TVECTORS && aType != VISU::TSTREAMLINES)
-                 aPropMenu->insertItem("Opacity", visuGUI, SLOT(ChangeOpacity()));
-               if (aType != VISU::TVECTORS){
-                 aPropMenu->insertItem("Line width", visuGUI, SLOT(ChangeLines()));
-                 thePopup->insertItem("Properties", aPropMenu);                  
-               }
-               thePopup->insertSeparator();
-             }
-           }
-           if ( !aIsLocked ) thePopup->insertItem("Rename...", visuGUI, SLOT(Rename()));
-           if (aType != VISU::TMESH) {
-             //if (aType != VISU::TSCALARMAP)
-             if ( !aIsLocked ) thePopup->insertItem("Edit...", visuGUI, SLOT(EditPrs()));
-             
-             if (aType == VISU::TCUTLINES) {
-               // Check: Does it has living children (tables)
-               SALOMEDS::ChildIterator_var aIter = 
-                 GetActiveStudy()->getStudyDocument()->NewChildIterator( aSObject );
-               bool isPresent = false;
-               for ( ;aIter->More(); aIter->Next()) {
-                 SALOMEDS::SObject_var aTblObj = aIter->Value();
-                 isPresent = !aTblObj->_is_nil();
-                 if (isPresent) {
-                   SALOMEDS::GenericAttribute_var    anAttr;
-                   isPresent = aTblObj->FindAttribute(anAttr, "AttributeName");
-                   if (isPresent) break; // We have at least a one child
-                 }
-               }
-               if ((!isPresent) && (!aIsLocked) )
-                 thePopup->insertItem( "Create Table", visuGUI, SLOT( CreateTable() ) );
-             }
-             thePopup->insertItem("Sweep", visuGUI, SLOT(Sweep()));
-             
-           }
-           if (isVTKViewer) {
-             if ( theParent == "Viewer" && 
-                  ( aType == VISU::TMESH      || 
-                    aType == VISU::TSCALARMAP || 
-                    aType == VISU::TDEFORMEDSHAPE ) ) {
-               thePopup->insertSeparator();
-               thePopup->insertItem("Selection info...",   visuGUI, SLOT(SelectionInfo()));
-             }
-             thePopup->insertSeparator();
-             
-             if (visuGUI->IsDisplayed(aPrsObject) ){
-               thePopup->insertItem("Erase", visuGUI, SLOT(ErasePrs()));
-             }
-             else
-               thePopup->insertItem("Display", visuGUI, SLOT(DisplayPrs()));
-             
-             thePopup->insertItem("Display Only", visuGUI, SLOT(DisplayOnlyPrs()));
-           }
-           thePopup->insertItem("Delete", visuGUI, SLOT(DeletePrs()));
-           if ((aType != VISU::TMESH) && (!aIsLocked)) {
-             thePopup->insertSeparator();
-             thePopup->insertItem("Same As", visuGUI, SLOT(CopyPresentation()));
-           }
-         }
-       }
-      }
-      return false;
-    }
-    
-    else {
-      // possibly this is the MED field/mesh and support objects
-      SALOME_MED::MED_ptr aMED = SALOME_MED::MED::_narrow( anObject );
-      if(!CORBA::is_nil(aMED))
-       thePopup->insertItem( "Import Structure", visuGUI, SLOT( ImportMedField() ) );
-      SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow( anObject );
-      if(!CORBA::is_nil(aField))
-        thePopup->insertItem( "Import TimeStamp", visuGUI, SLOT( ImportMedField() ) );
-      if ( aParentComponent != parent->getActiveComponent() )  {
-        //insert pre-defined Display/Erase items
-       if ( thePopup->count() > 0 ) {
-         thePopup->insertSeparator();
-       }
-       thePopup->insertItem (tr ("MEN_APP_DISPLAY"),      GetActiveStudy()->getApp(), SLOT(onDisplay(int)), 0, QAD_Display_Popup_ID);
-       thePopup->insertItem (tr ("MEN_APP_DISPLAY_ONLY"), GetActiveStudy()->getApp(), SLOT(onDisplay(int)), 0, QAD_DisplayOnly_Popup_ID);
-       thePopup->insertItem (tr ("MEN_APP_ERASE"),        GetActiveStudy()->getApp(), SLOT(onErase()),      0, QAD_Erase_Popup_ID);
-      }
-      return false;
-    }
-  }else{
-    SALOMEDS::SObject_var aSObject = GetStudyDocument()->FindObjectID(anIO->getEntry());
-    if(!aSObject->_is_nil()){
-      bool isExist;
-      VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt();
-      if(isExist){
-       switch (aType) {
-       case VISU::TENTITY:
-       case VISU::TFAMILY:
-       case VISU::TGROUP: 
-         if ( !aIsLocked )thePopup->insertItem("Create Presentation", visuGUI, SLOT(CreateMesh()));    
-         break;
-       case VISU::TVIEW3D: 
-         if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK )
-           thePopup->insertItem( "Restore view parameters", visuGUI, SLOT( RestoreViewParams() ) );
-         if ( !aIsLocked ) {
-           if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { 
-             // Available only for VTK viewer
-             thePopup->insertItem( "Save view parameters", visuGUI, SLOT( SaveViewParams() ) );
-           }
-           thePopup->insertItem( "Rename...", visuGUI, SLOT( Rename() ) );
-           thePopup->insertItem("Delete", visuGUI, SLOT(DeleteViewParams()));
-         }
-         break;
-       case VISU::TFIELD:
-         if ((getValue(aSObject, "myNbTimeStamps").toLong() > 1) && isVTKViewer)
-           thePopup->insertItem( "Animation...", visuGUI, SLOT( TimeAnimation() ) );
-         break;
-       case VISU::TTIMESTAMP: {
-         int aNunComponent = VISU::Storable::FindValue(aMap,"myNumComponent",&isExist).toInt();
-         thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_SCALAR_MAP") ), 
-                              "Scalar Map...", visuGUI, SLOT(CreateScalarMap()));
-         thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_ISO_SURFACES") ),
-                              "Iso Surfaces...", visuGUI, SLOT(CreateIsoSurfaces()));
-         thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_CUT_PLANES") ),
-                              "Cut Planes...", visuGUI, SLOT(CreateCutPlanes()));
-         thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_CUT_LINES") ),
-                              "Cut Lines...", visuGUI, SLOT(CreateCutLines()));
-         if(aNunComponent > 1){
-           thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_DEFORMED_SHAPE") ),
-                                "Deformed Shape...", visuGUI, SLOT(CreateDeformedShape()));
-           thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_VECTORS") ),
-                                "Vectors...", visuGUI, SLOT(CreateVectors()));
-           thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_STREAM_LINES") ),
-                                "Stream lines...", visuGUI, SLOT(CreateStreamLines()));
-         }
-         break;
-       }
-       }
-       return false;
-      }else{
+void
+VisuGUI::
+OnTranslatePrs()
+{
+  if(MYDEBUG) MESSAGE("VisuGUI::OnTranslatePrs");
+  VisuGUI_OffsetDlg* aDlg = new VisuGUI_OffsetDlg (this);
 
-       if(IsSObjectTable(aSObject)){
-         thePopup->insertItem( "Show Table",    visuGUI, SLOT(ShowTable()));
-         thePopup->insertItem( "Create Curves", visuGUI, SLOT(PlotData()));
-         thePopup->insertItem( "Export Table", visuGUI, SLOT( ExportTableToFile() ) );
-         thePopup->insertSeparator();
-         thePopup->insertItem( "Delete", visuGUI, SLOT( DeleteObject() ) );
-         return false;
-       }
+  _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
 
-       CORBA::Long aTag = 1;
-       SALOMEDS::SObject_var aSubObject;
-       if(aSObject->FindSubObject(aTag,aSubObject) && IsSObjectTable(aSubObject)) {
-         thePopup->insertItem( "Delete", visuGUI, SLOT( DeleteObject() ) );
-         return false;
-       }
+  LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
+  SALOME_ListIO aListIO;
+  aSelectionMgr->selectedObjects(aListIO);
 
-       aSObject = aSObject->GetFather();
-       if(aSObject->_is_nil()) return false;
-       SALOMEDS::GenericAttribute_var anAttr;
-       aSObject->FindAttribute(anAttr, "AttributeName");
-       SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
-       if(aName->_is_nil()) return false;
-       CORBA::String_var aValue = aName->Value();
-       //if(strcmp(aValue.in(),"MEDMESH") == 0)
-       //  thePopup->insertItem( "Import MED", visuGUI, SLOT( ImportMedField() ) );
-       if(strcmp(aValue.in(),"MEDFIELD") == 0)
-         thePopup->insertItem( "Import Field", visuGUI, SLOT( ImportMedField() ) );
-       if ( aParentComponent != parent->getActiveComponent() )  {
-         //insert pre-defined Display/Erase items
-         if ( thePopup->count() > 0 ) {
-           thePopup->insertSeparator();
-         }
-         thePopup->insertItem (tr ("MEN_APP_DISPLAY"),      GetActiveStudy()->getApp(), SLOT(onDisplay(int)), 0, QAD_Display_Popup_ID);
-         thePopup->insertItem (tr ("MEN_APP_DISPLAY_ONLY"), GetActiveStudy()->getApp(), SLOT(onDisplay(int)), 0, QAD_DisplayOnly_Popup_ID);
-         thePopup->insertItem (tr ("MEN_APP_ERASE"),        GetActiveStudy()->getApp(), SLOT(onErase()),      0, QAD_Erase_Popup_ID);
-       }
-       return false;
+  SALOME_ListIteratorOfListIO It (aListIO);
+  for (; It.More(); It.Next()) {
+    Handle(SALOME_InteractiveObject)& anIO = It.Value();
+    if (anIO->hasEntry()) {
+      _PTR(SObject) aSObject = aCStudy->FindObjectID(anIO->getEntry());
+      if (aSObject) {
+        CORBA::Object_var aCORBAObject = VISU::ClientSObjectToObject(aSObject);
+        if (!CORBA::is_nil(aCORBAObject)) {
+          PortableServer::ServantBase_var aServant = VISU::GetServant(aCORBAObject);
+          if (VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(aServant.in())) {
+            aDlg->addPresentation(aPrsObject);
+          }
+        }
       }
     }
   }
-  return false;
+  if (aDlg->getPrsCount() > 0)
+    aDlg->show();
+  else
+    delete aDlg;
 }
 
-//===========================================================================
-// BuildPresentation
-//===========================================================================
-void VisuGUI::BuildPresentation( const Handle(SALOME_InteractiveObject)& theIO,
-                                 QAD_ViewFrame* )
+void
+VisuGUI::
+OnArrangeActors()
 {
-  BEGIN_OF("VisuGUI::BuildPresentation");
-
-  if (theIO.IsNull()) {
-    if(MYDEBUG) MESSAGE("VisuGUI::BuildPresentation(): null SALOME_InteractiveObject passed");
-    return;
+  SVTK_ViewWindow* vw = GetActiveViewWindow<SVTK_ViewWindow>(this);
+  if (vw) {
+    ArrangeDlg* aDlg = new ArrangeDlg (GetDesktop(this), vw);
+    aDlg->exec();
+    delete aDlg;
   }
+}
 
-  SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument();
-  SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
 
-  if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_VTK &&
-       GetActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_PLOT2D) return;
+void
+VisuGUI::
+initialize( CAM_Application* theApp )
+{
+  SalomeApp_Module::initialize( theApp );
 
-  SALOMEDS::SObject_var aSObj = aStudy -> FindObjectID ( theIO->getEntry() );
-  SCRUTE(aSObj);
-  if (aSObj -> _is_nil() ) {
-    if(MYDEBUG) MESSAGE("No SObject for interacative object is found");
-    return;
-  }
-  
-  CORBA::Object_var anObject = VISU::SObjectToObject(aSObj);
-  if(!CORBA::is_nil(anObject)) {
-    VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject).in());
-    if ( aPrsObject ) {
-      VISU_Actor *SelectedActor = visuGUI->GetActor(aPrsObject);
-      if(!SelectedActor) {
-       try{
-         SelectedActor = aPrsObject -> CreateActor();
-         if(VTKViewer_ViewFrame* vf = GetVtkViewFrame())
-           vf->AddActor(SelectedActor);
-       }catch(std::runtime_error& exc){
-         INFOS(exc.what());
-         throw exc; 
-       }
-      }
-    }
-    VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(anObject).in());
-    if ( aTable ) {
-      // table object 
-      PlotTable(aTable, VISU::eDisplay );
-    }
-    VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(anObject).in());
-    if ( aContainer ) {
-      // container object
-      PlotContainer(aContainer, VISU::eDisplay );
-    }
-    VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(anObject).in());
-    if ( aCurve ) {
-      // curve object 
-      PlotCurve(aCurve, VISU::eDisplay );
-    }
-  }else
-    if(MYDEBUG) MESSAGE("CORBA::is_nil(anObject) = true");
-  END_OF("VisuGUI::BuildPresentation");
+  createActions();
+  createMenus();
+  createToolBars();
+  createPopupMenus();
 }
 
-
-//===========================================================================
-// SupportedViewType
-//===========================================================================
-void VisuGUI::SupportedViewType(int* buffer, int bufferSize)
+void
+VisuGUI::
+createActions()
 {
-  if (!buffer || !bufferSize) return;
-  buffer[0] = (int)VIEW_VTK;
-  if (--bufferSize) buffer[1] = (int)VIEW_PLOT2D;
-} 
+  QPixmap aPixmap;
+  QWidget* aParent = application()->desktop();
+  SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
+
+  // Create actions
+  createAction( VISU_IMPORT_FROM_FILE, "", QIconSet(),
+                tr("MEN_IMPORT_FROM_FILE"), "", (CTRL + Key_I), aParent, false,
+                this, SLOT(OnImportFromFile()));
+
+  createAction( VISU_IMPORT_TABLE, "", QIconSet(),
+                tr("MEN_IMPORT_TABLE"), "", 0, aParent, false,
+                this, SLOT(OnImportTableFromFile()));
+
+  aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_SCALAR_MAP"));
+  createAction( VISU_SCALAR_MAP, tr("MEN_SCALAR_MAP"), QIconSet(aPixmap),
+                tr("MEN_SCALAR_MAP"), "", 0, aParent, false,
+                this, SLOT(OnCreateScalarMap()));
+
+  aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_DEFORMED_SHAPE"));
+  createAction( VISU_DEFORMED_SHAPE, tr("MEN_DEFORMED_SHAPE"), QIconSet(aPixmap),
+                tr("MEN_DEFORMED_SHAPE"), "", 0, aParent, false,
+                this, SLOT(OnCreateDeformedShape()));
+
+  aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_SCALAR_MAP_ON_DEFORMED_SHAPE"));
+  createAction( VISU_SCALAR_MAP_ON_DEFORMED_SHAPE, tr("MEN_SCALAR_MAP_ON_DEFORMED_SHAPE"), QIconSet(aPixmap),
+                tr("MEN_SCALAR_MAP_ON_DEFORMED_SHAPE"), "", 0, aParent, false,
+                this, SLOT(OnCreateScalarMapOnDeformedShape()));
+
+  aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_VECTORS"));
+  createAction( VISU_VECTORS, tr("MEN_VECTORS"), QIconSet(aPixmap),
+                tr("MEN_VECTORS"), "", 0, aParent, false,
+                this, SLOT(OnCreateVectors()));
+
+  aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_ISO_SURFACES"));
+  createAction( VISU_ISO_SURFACES, tr("MEN_ISO_SURFACES"), QIconSet(aPixmap),
+                tr("MEN_ISO_SURFACES"), "", 0, aParent, false,
+                this, SLOT(OnCreateIsoSurfaces()));
+
+  aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_CUT_PLANES"));
+  createAction( VISU_CUT_PLANES, tr("MEN_CUT_PLANES"), QIconSet(aPixmap),
+                tr("MEN_CUT_PLANES"), "", 0, aParent, false,
+                this, SLOT(OnCreateCutPlanes()));
+
+  aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_STREAM_LINES"));
+  createAction( VISU_STREAM_LINES, tr("MEN_STREAM_LINES"), QIconSet(aPixmap),
+                tr("MEN_STREAM_LINES"), "", 0, aParent, false,
+                this, SLOT(OnCreateStreamLines()));
+
+  aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_CUT_LINES"));
+  createAction( VISU_CUT_LINES, tr("MEN_CUT_LINES"), QIconSet(aPixmap),
+                tr("MEN_CUT_LINES"), "", 0, aParent, false,
+                this, SLOT(OnCreateCutLines()));
+
+  aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_PLOT_3D"));
+  createAction( VISU_PLOT_3D, tr("MEN_PLOT_3D"), QIconSet(aPixmap),
+                tr("MEN_PLOT_3D"), "", 0, aParent, false,
+                this, SLOT(OnCreatePlot3D()));
+
+  aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_PLOT2D"));
+  createAction( VISU_PLOT2D, tr("MEN_CREATE_PLOT2D"), QIconSet(aPixmap),
+                tr("MEN_CREATE_PLOT2D"), "", 0, aParent, false,
+                this, SLOT(OnCreatePlot2dView()));
+
+  createAction( VISU_DELETE_OBJS, tr("MEN_DELETE_OBJS"), QIconSet(),
+                tr("MEN_DELETE_OBJS"), "", 0, aParent, false,
+                this, SLOT(OnDeleteObjects()));
+
+  createAction( VISU_SHOW_TABLE, tr("MEN_SHOW_TABLE"), QIconSet(),
+                tr("MEN_SHOW_TABLE"), "", 0, aParent, false,
+                this, SLOT(OnShowTable()));
+
+  createAction( VISU_CREATE_CURVES, tr("MEN_CREATE_CURVES"), QIconSet(),
+                tr("MEN_CREATE_CURVES"), "", 0, aParent, false,
+                this, SLOT(OnPlotData()));
+
+  createAction( VISU_EXPORT_TABLE, tr("MEN_EXPORT_TABLE"), QIconSet(),
+                tr("MEN_EXPORT_TABLE"), "", 0, aParent, false,
+                this, SLOT(OnExportTableToFile()));
+
+  createAction( VISU_IMPORT_MED_STRUCTURE, tr("MEN_IMPORT_MED_STRUCTURE"), QIconSet(),
+                tr("MEN_IMPORT_MED_STRUCTURE"), "", 0, aParent, false,
+                this, SLOT(OnImportMedField()));
+
+  createAction( VISU_IMPORT_MED_TIMESTAMP, tr("MEN_IMPORT_MED_TIMESTAMP"), QIconSet(),
+                tr("MEN_IMPORT_MED_TIMESTAMP"), "", 0, aParent, false,
+                this, SLOT(OnImportMedField()));
+
+  createAction( VISU_IMPORT_MED_FIELD, tr("MEN_IMPORT_MED_FIELD"), QIconSet(),
+                tr("MEN_IMPORT_MED_FIELD"), "", 0, aParent, false,
+                this, SLOT(OnImportMedField()));
+
+  createAction( VISU_CREATE_PRS, tr("MEN_CREATE_PRS"), QIconSet(),
+                tr("MEN_CREATE_PRS"), "", 0, aParent, false,
+                this, SLOT(OnCreateMesh()));
+
+  createAction( VISU_CREATE_MANY_PRS, tr("MEN_CREATE_MANY_PRS"), QIconSet(),
+                tr("MEN_CREATE_MANY_PRS"), "", 0, aParent, false,
+                this, SLOT(OnCreateManyMesh()));
+
+  createAction( VISU_TRANSLATE_PRS, tr("MEN_TRANSLATE_PRS"), QIconSet(),
+                tr("MEN_TRANSLATE_PRS"), "", 0, aParent, false,
+                this, SLOT(OnTranslatePrs()));
+
+  createAction( VISU_MERGE_SCALAR_BARS, tr("MEN_MERGE_SCALAR_BARS"), QIconSet(),
+                tr("MEN_MERGE_SCALAR_BARS"), "", 0, aParent, false,
+                this, SLOT(OnMergeScalarBars()));
+
+  createAction( VISU_FREE_SCALAR_BARS, tr("MEN_FREE_SCALAR_BARS"), QIconSet(),
+                tr("MEN_FREE_SCALAR_BARS"), "", 0, aParent, false,
+                this, SLOT(OnFreeScalarBars()));
+
+  createAction( VISU_ERASE, tr("MEN_ERASE"), QIconSet(),
+                tr("MEN_ERASE"), "", 0, aParent, false,
+                this, SLOT(OnErasePrs()));
+
+  createAction( VISU_DISPLAY, tr("MEN_DISPLAY"), QIconSet(),
+                tr("MEN_DISPLAY"), "", 0, aParent, false,
+                this, SLOT(OnDisplayPrs()));
+
+  createAction( VISU_DISPLAY_ONLY, tr("MEN_DISPLAY_ONLY"), QIconSet(),
+                tr("MEN_DISPLAY_ONLY"), "", 0, aParent, false,
+                this, SLOT(OnDisplayOnlyPrs()));
+
+  createAction( VISU_COPY_PRS, tr("MEN_COPY_PRS"), QIconSet(),
+                tr("MEN_COPY_PRS"), "", 0, aParent, false,
+                this, SLOT(OnCopyPresentation()));
+
+  createAction( VISU_CURVE_PROPS, tr("MEN_CURVE_PROPS"), QIconSet(),
+                tr("MEN_CURVE_PROPS"), "", 0, aParent, false,
+                this, SLOT(OnCurveProperties()));
+
+  createAction( VISU_RENAME, tr("MEN_RENAME"), QIconSet(), tr("MEN_RENAME"), "", 0, aParent, false,
+                this, SLOT(OnRename()));
+
+  createAction( VISU_EDIT_CONTAINER, tr("MEN_EDIT_CONTAINER"), QIconSet(),
+                tr("MEN_EDIT_CONTAINER"), "", 0, aParent, false,
+                this, SLOT(OnEditContainer()));
+
+  createAction( VISU_CLEAR_CONTAINER, tr("MEN_CLEAR_CONTAINER"), QIconSet(),
+                tr("MEN_CLEAR_CONTAINER"), "", 0, aParent, false,
+                this, SLOT(OnClearContainer()));
+
+  createAction( VISU_SAVE_VIEW_PARAMS, tr("MEN_SAVE_VIEWPARAMS"), QIconSet(),
+                tr("MEN_SAVE_VIEWPARAMS"), "", 0, aParent, false,
+                this, SLOT(OnSaveViewParams()));
+  createAction( VISU_SAVE_VIEW_PARAMS_1, tr("MEN_SAVE_VIEWPARAMS"), QIconSet(),
+                tr("MEN_SAVE_VIEWPARAMS"), "", 0, aParent, false,
+                this, SLOT(OnSaveViewParams()));
+
+  createAction( VISU_RESTORE_VIEW_PARAMS, tr("MEN_RESTORE_VIEWPARAMS"), QIconSet(),
+                tr("MEN_RESTORE_VIEWPARAMS"), "", 0, aParent, false,
+                this, SLOT(OnRestoreViewParams()));
+
+  //createAction( VISU_DELETE_VIEW_PARAMS, tr("MEN_DELETE_VIEWPARAMS"), QIconSet(),
+  //              tr("MEN_DELETE_VIEWPARAMS"), "", 0, aParent, false,
+  //              this, SLOT(OnDeleteObjects()));
+
+  createAction( VISU_ARRANGE_ACTORS, tr("MEN_ARRANGE_ACTORS"), QIconSet(),
+                tr("MEN_ARRANGE_ACTORS"), "", 0, aParent, false,
+                this, SLOT(OnArrangeActors()));
+
+  aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_POINTS"));
+  createAction( VISU_POINTS, tr("MEN_POINTS"), QIconSet(aPixmap),
+                tr("MEN_POINTS"), "", 0, aParent, false,
+                this, SLOT(OnMakePoints()));
+
+  aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_WIREFRAME"));
+  createAction( VISU_WIREFRAME, tr("MEN_WIREFRAME"), QIconSet(aPixmap),
+                tr("MEN_WIREFRAME"), "", 0, aParent, false,
+                this, SLOT(OnMakeWireframe()));
+
+  aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_SURFACE"));
+  createAction( VISU_SURFACE, tr("MEN_SURFACE"), QIconSet(aPixmap),
+                tr("MEN_SURFACE"), "", 0, aParent, false,
+                this, SLOT(OnMakeSurface()));
+
+  createAction( VISU_INSIDEFRAME, tr("MEN_INSIDEFRAME"), QIconSet(),
+                tr("MEN_INSIDEFRAME"), "", 0, aParent, false,
+                this, SLOT(OnMakeInsideframe()));
+
+  createAction( VISU_SURFACEFRAME, tr("MEN_SURFACEFRAME"), QIconSet(),
+                tr("MEN_SURFACEFRAME"), "", 0, aParent, false,
+                this, SLOT(OnMakeSurfaceframe()));
+
+  createAction( VISU_SHRINK, tr("MEN_SHRINK"), QIconSet(),
+                tr("MEN_SHRINK"), "", 0, aParent, false,
+                this, SLOT(OnMakeShrink()));
+
+  createAction( VISU_UNSHRINK, tr("MEN_UNSHRINK"), QIconSet(),
+                tr("MEN_UNSHRINK"), "", 0, aParent, false,
+                this, SLOT(OnMakeShrink()));
+  
+  createAction( VISU_SHADING, tr("MEN_SHADING"), QIconSet(),
+                tr("MEN_SHADING"), "", 0, aParent, false,
+                this, SLOT(OnSetShadingOn()));
+  
+  createAction( VISU_NOSHADING, tr("MEN_NOSHADING"), QIconSet(),
+                tr("MEN_NOSHADING"), "", 0, aParent, false,
+                this, SLOT(OnSetShadingOff()));
 
-extern "C"
-{
-  Standard_EXPORT SALOMEGUI* GetComponentGUI() {
-    if ( !visuGUI )
-      visuGUI = new VisuGUI( "" );
-    return visuGUI;
-  }
-}
+  createAction( VISU_CELL_COLOR, tr("MEN_CELL_COLOR"), QIconSet(),
+                tr("MEN_CELL_COLOR"), "", 0, aParent, false,
+                this, SLOT(OnChangeColor()));
 
+  createAction( VISU_COLOR, tr("MEN_COLOR"), QIconSet(),
+                tr("MEN_COLOR"), "", 0, aParent, false,
+                this, SLOT(OnChangeColor()));
 
-//////////////////////////////////////////////////////////////////////////////////
-////////////////               CHANGE ACTOR COLOR         ////////////////////////
-//////////////////////////////////////////////////////////////////////////////////
-///////////////// /////////////////////////////////////////////////////////////////
-// change actor color
-// In : Name of Actor
-//
-//
+  createAction( VISU_EDGE_COLOR, tr("MEN_EDGE_COLOR"), QIconSet(),
+                tr("MEN_EDGE_COLOR"), "", 0, aParent, false,
+                this, SLOT(OnChangeWireframeColor()));
 
-void VisuGUI::NewColor(VISU_Actor *theActor){
-  if(VISU::Prs3d_i* aPrs3d = theActor->GetPrs3d()){
-    VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrs3d);
-    VISU::DeformedShape_i* aDeformedShape = dynamic_cast<VISU::DeformedShape_i*>(aPrs3d);
-    SALOMEDS::Color anOldColor, aNewColor;
-    int aRepresent = theActor->GetRepresentation();
-    if(aMesh)
-      switch(aRepresent){
-      case VISU::POINT :
-       anOldColor = aMesh->GetNodeColor();
-       break;
-      case VISU::WIREFRAME :
-      case VISU::INSIDEFRAME :
-       anOldColor = aMesh->GetLinkColor();
-       break;
-      case VISU::SHADED :
-      case VISU::SURFACEFRAME :
-       anOldColor = aMesh->GetCellColor();
-       break;
-      }
-    else if(aDeformedShape)
-      anOldColor = aDeformedShape->GetColor();
-    else
-      return;
-    QColor aColor = QColor(int(255*anOldColor.R),int(255*anOldColor.G),int(255*anOldColor.B));
-    QColor aColorNew = QColorDialog::getColor(aColor, GetDesktop());
-    if(aColorNew.isValid()){
-      aNewColor.R = aColorNew.red()/255.;
-      aNewColor.G = aColorNew.green()/255.;
-      aNewColor.B = aColorNew.blue()/255.;
-      if(aMesh)
-       switch(aRepresent){
-       case VISU::POINT :
-         aMesh->SetNodeColor(aNewColor);
-         break;
-       case VISU::WIREFRAME :
-       case VISU::INSIDEFRAME :
-         aMesh->SetLinkColor(aNewColor);
-         break;
-       case VISU::SHADED :
-       case VISU::SURFACEFRAME :
-         aMesh->SetCellColor(aNewColor);
-         break;
-       }
-      else
-       aDeformedShape->SetColor(aNewColor);
-      RecreateActor(aPrs3d);
-    }
-  }
-}
+  createAction( VISU_OPACITY, tr("MEN_OPACITY"), QIconSet(),
+                tr("MEN_OPACITY"), "", 0, aParent, false,
+                this, SLOT(OnChangeOpacity()));
 
-void VisuGUI::NewWireframeColor(VISU_MeshAct *theActor){
-  if(VISU::Prs3d_i* aPrs3d = theActor->GetPrs3d()){
-    if(VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrs3d)){
-      SALOMEDS::Color anOldColor = aMesh->GetLinkColor(), aNewColor;
-      QColor aColor = QColor(int(255*anOldColor.R),int(255*anOldColor.G),int(255*anOldColor.B));
-      QColor aColorNew = QColorDialog::getColor(aColor, GetDesktop());
-      if(aColorNew.isValid()){
-       aNewColor.R = aColorNew.red()/255.;
-       aNewColor.G = aColorNew.green()/255.;
-       aNewColor.B = aColorNew.blue()/255.;
-       aMesh->SetLinkColor(aNewColor);
-       VisuGUI::RecreateActor(aMesh);
-      }
-    }
-  }
-}
+  createAction( VISU_LINE_WIDTH, tr("MEN_LINE_WIDTH"), QIconSet(),
+                tr("MEN_LINE_WIDTH"), "", 0, aParent, false,
+                this, SLOT(OnChangeLines()));
 
-//////////////////////////////////////////////////////////////////////////////////
-////////////////               CHANGE ACTOR OPACITY       ////////////////////////
-//////////////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////////////
-// change actor opacity
-// In : Name of Actor
-//
-// Use CursorDlg to select a value between 0 and 100
-//
 
-void VisuGUI::NewOpacity(VISU_Actor *Actor)
-{
-  
-  VisuGUI_CursorDlg* CursorDlg = new VisuGUI_CursorDlg(QAD_Application::getDesktop(), tr("Opacity"), TRUE );
-  
-  float oldopac,newopac;
-  int intopac;
-  CursorDlg->Comment1->setText( tr( "Set value between") );
-  CursorDlg->Comment2->setText( tr( "0 (transparent) and 100 (opaque)" ) );
-  oldopac=Actor->GetOpacity();
-  intopac=int(oldopac*100.+0.5);
-  CursorDlg->SpinBox1->setMinValue(0);
-  CursorDlg->SpinBox1->setMaxValue(100);
-  CursorDlg->SpinBox1->setValue(intopac);
-  
-  int ret = CursorDlg->exec();
-  if (ret == 1)
-    {
-      intopac  = CursorDlg->SpinBox1->value() ;
-      newopac = intopac/100.;
-      Actor->SetOpacity(newopac);
-    }
-  delete CursorDlg;
-}
+  createAction( VISU_EDIT_SCALARMAP, tr("MEN_EDIT_PRS"), QIconSet(),
+                tr("MEN_EDIT_PRS"), "", 0, aParent, false,
+                this, SLOT(OnEditScalarMap()));
 
-//////////////////////////////////////////////////////////////////////////////////
-////////////////               CHANGE ACTOR LINEWIDTH     ////////////////////////
-//////////////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////////////
-// change actor linewidth
-// In : Name of Actor
-//
-// Use CursorDlg to select a value between 0 and 10
-//
+  createAction( VISU_EDIT_DEFORMEDSHAPE, tr("MEN_EDIT_PRS"), QIconSet(),
+                tr("MEN_EDIT_PRS"), "", 0, aParent, false,
+                this, SLOT(OnEditDeformedShape()));
 
-void VisuGUI::NewLinewidth(VISU_Actor *Actor)
-{
+  createAction( VISU_EDIT_CUTPLANES, tr("MEN_EDIT_PRS"), QIconSet(),
+                tr("MEN_EDIT_PRS"), "", 0, aParent, false,
+                this, SLOT(OnEditCutPlanes()));
 
-  VisuGUI_CursorDlg* CursorDlg = new VisuGUI_CursorDlg(QAD_Application::getDesktop(), tr("Line Width"), TRUE );
-  
-  float oldlwid,newlwid;
-  int intlwid;
-  CursorDlg->Comment1->setText("Set value between");
-  CursorDlg->Comment2->setText("1 (thin) and 10 (thick)");
-  oldlwid=Actor->GetLineWidth();
-  intlwid=int(oldlwid);
-  CursorDlg->SpinBox1->setMinValue(1);
-  CursorDlg->SpinBox1->setMaxValue(10);
-  CursorDlg->SpinBox1->setValue(intlwid);
-  
-  int ret = CursorDlg->exec();
-  if (ret == 1) {
-    intlwid  = CursorDlg->SpinBox1->value() ;
-    newlwid = intlwid;
-    Actor->SetLineWidth(newlwid);
-  }
-  delete CursorDlg;
-}
+  createAction( VISU_EDIT_CUTLINES, tr("MEN_EDIT_PRS"), QIconSet(),
+                tr("MEN_EDIT_PRS"), "", 0, aParent, false,
+                this, SLOT(OnEditCutLines()));
 
-/* ======================================================================================== */
-/* Setting parameters for Scalar Bar                                                        */
-/* ======================================================================================== */
-void VisuGUI::ChangeScalarBar()
-{
-  VisuGUI_ScalarBarDlg* Scbar = new VisuGUI_ScalarBarDlg(TRUE);
-  Scbar->initFromResources();
-  int ret = Scbar->exec();
-  if ( ret )  {
-    Scbar->storeToResources();
-  }
-  delete Scbar;
-}
+  createAction( VISU_EDIT_ISOSURFACE, tr("MEN_EDIT_PRS"), QIconSet(),
+                tr("MEN_EDIT_PRS"), "", 0, aParent, false,
+                this, SLOT(OnEditIsoSurfaces()));
 
-/* ======================================================================================== */
-/* Setting parameters for Sweeping                                                        */
-/* ======================================================================================== */
-void VisuGUI::SetSweepingPreferences()
-{
-       float tempo=0.2;
-       int cycles=1;
-       int steps=20;
+  createAction( VISU_EDIT_VECTORS, tr("MEN_EDIT_PRS"), QIconSet(),
+                tr("MEN_EDIT_PRS"), "", 0, aParent, false,
+                this, SLOT(OnEditVectors()));
 
-       QString Tempo = QAD_CONFIG->getSetting("Visu:SweepTempo");
-       if ( !Tempo.isEmpty() )
-               tempo = Tempo.toFloat();
+  createAction( VISU_EDIT_STREAMLINES, tr("MEN_EDIT_PRS"), QIconSet(),
+                tr("MEN_EDIT_PRS"), "", 0, aParent, false,
+                this, SLOT(OnEditStreamLines()));
 
-       QString Cycles = QAD_CONFIG->getSetting("Visu:SweepCycles");
-       if ( !Cycles.isEmpty() )
-               cycles = Cycles.toInt();
+  createAction( VISU_EDIT_PLOT3D, tr("MEN_EDIT_PRS"), QIconSet(),
+                tr("MEN_EDIT_PRS"), "", 0, aParent, false,
+                this, SLOT(OnEditPlot3D()));
 
-       QString Steps = QAD_CONFIG->getSetting("Visu:SweepSteps");
-       if ( !Steps.isEmpty() )
-               steps = Steps.toInt();
+  createAction( VISU_EDIT_SCALARMAPONDEFORMEDSHAPE, tr("MEN_EDIT_PRS"), QIconSet(),
+                tr("MEN_EDIT_PRS"), "", 0, aParent, false,
+                this, SLOT(OnEditScalarMapOnDeformedShape()));
 
-       VisuGUI_SweepPrefDlg* Sweep = new VisuGUI_SweepPrefDlg(QAD_Application::getDesktop(), 0, TRUE, 0);
 
-       Sweep->setTimeStep( tempo );
-       Sweep->setNbCycles( cycles );
-       Sweep->setNbSteps ( steps );
+  createAction( VISU_CREATE_TABLE, tr("MEN_CREATE_TABLE"), QIconSet(),
+                tr("MEN_CREATE_TABLE"), "", 0, aParent, false,
+                this, SLOT(OnCreateTable()));
 
-       if ( Sweep->exec() )
-       {
-               tempo  = Sweep->getTimeStep();
-               cycles = Sweep->getNbCycles();
-               steps  = Sweep->getNbSteps();
+  aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_SWEEP"));
+  createAction( VISU_SWEEP, tr("MEN_SWEEP"), QIconSet(aPixmap),
+                tr("MEN_SWEEP"), "", 0, aParent, false,
+                this, SLOT(OnSweep()));
 
-               QAD_CONFIG->addSetting("Visu:SweepTempo",  tempo);
-               QAD_CONFIG->addSetting("Visu:SweepCycles", cycles);
-               QAD_CONFIG->addSetting("Visu:SweepSteps",  steps);
-       }
-       delete Sweep;
-}
+  createAction( VISU_CLIPPING, tr("MEN_CLIPPING"), QIconSet(),
+                tr("MEN_CLIPPING"), "", 0, aParent, false,
+                this, SLOT(OnClippingPlanes()));
 
-/* ======================================================================================== */
-/* Returns Visu input files directory (default is CSF_PATHData)                             */
-/* ======================================================================================== */
-QString VisuGUI::getVisuInputDir()
-{
-       QString Tmp = QAD_CONFIG->getSetting("Visu:InputDir");
-       if ( Tmp.isEmpty() )
-               Tmp =  QAD_Tools::addSlash(getenv("CSF_PATHData"));
-       Tmp = QAD_Tools::addSlash(Tmp);
-       return (Tmp);
-}
+  createAction( VISU_SELECTION_INFO, tr("MEN_SELECTION_INFO"), QIconSet(),
+                tr("MEN_SELECTION_INFO"), "", 0, aParent, false,
+                this, SLOT(OnSelectionInfo()));
 
-/* ======================================================================================== */
-/* Returns Visu output files directory (default is InputDir)                                */
-/* ======================================================================================== */
-QString VisuGUI::getVisuOutputDir()
-{
-       QString Tmp = QAD_CONFIG->getSetting("Visu:OutputDir");
-       if ( Tmp.isEmpty() )
-       {
-               QString Tmp2 = QAD_CONFIG->getSetting("Visu:InputDir");
-               if ( Tmp2.isEmpty() )
-                       Tmp =  QAD_Tools::addSlash(getenv("CSF_PATHData"));
-               else
-                       Tmp = Tmp2;
-       }
-       Tmp = QAD_Tools::addSlash(Tmp);
-       return (Tmp);
-}
+  aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_TIMEANIMATION"));
+  createAction( VISU_ANIMATION, tr("MEN_ANIMATION"), QIconSet(aPixmap),
+                tr("MEN_ANIMATION"), "", 0, aParent, false,
+                this, SLOT(OnTimeAnimation()));
 
+  aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_ERASE_ALL"));
+  createAction( VISU_ERASE_ALL, tr("MEN_ERASE_ALL"), QIconSet(aPixmap),
+                tr("MEN_ERASE_ALL"), "", 0, aParent, false,
+                this, SLOT(OnEraseAll()));
 
-/* ======================================================================================== */
-/* Global Method for Scalar Map                                                  */
-/* ======================================================================================== */
-VISU::Result_i* VisuGUI::CreatePresent(SALOMEDS::SObject_var theField, VISU::Result_var& theResult){
-  if(MYDEBUG) MESSAGE("VisuGUI::CreatePresent");
-  SALOMEDS::SObject_var aSObj = theField->GetFather(); 
-  if (CORBA::is_nil(aSObj)) return NULL;
-  aSObj = aSObj->GetFather(); if (CORBA::is_nil(aSObj)) return NULL;
-  aSObj = aSObj->GetFather(); if (CORBA::is_nil(aSObj)) return NULL;
-  aSObj = aSObj->GetFather(); if (CORBA::is_nil(aSObj)) return NULL;
-  CORBA::Object_var anObject = VISU::SObjectToObject(aSObj);
-  if(CORBA::is_nil(anObject)) return NULL;
-  theResult = VISU::Result::_narrow(anObject);
-  VISU::Result_i* pResult = dynamic_cast<VISU::Result_i*>(VISU::GetServant(anObject).in());
-  if(pResult == NULL)
-    QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
-                         tr ("WRN_NO_AVAILABLE_DATA"),
-                         tr ("VISU_BUT_OK"));
-  return pResult;
-}
+  aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_GLOBAL_SELECTION"));
+  createAction( VISU_GLOBAL_SELECTION, tr("MEN_GLOBAL_SELECTION"), QIconSet(aPixmap),
+                tr("MEN_GLOBAL_SELECTION"), "", 0, aParent, false,
+                this);
 
-#define CREATEPRS(PRSTYPE, FNAME, FCREATE) \
-PRSTYPE* FNAME(SALOMEDS::SObject_var theField, \
-              const char* theMeshName, VISU::Entity theEntity, \
-              const char* theFieldName, int theTimeId) {\
-  VISU::Result_var aResult; \
-  VISU::Result_i* pResult = CreatePresent(theField,aResult); \
-  if(pResult != NULL){ \
-    QApplication::setOverrideCursor( Qt::waitCursor ); \
-    CORBA::Object_var anObject =  \
-      GetVisuGen()->FCREATE(aResult,theMeshName,theEntity,theFieldName,theTimeId); \
-    QApplication::restoreOverrideCursor(); \
-    if(!CORBA::is_nil(anObject))  \
-      return dynamic_cast<PRSTYPE*>(VISU::GetServant(anObject).in()); \
-  } \
-  QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"), \
-                         tr ("ERR_CANT_BUILD_PRESENTATION"), \
-                         tr ("VISU_BUT_OK") ); \
-  return NULL; \
-} 
-
-CREATEPRS(VISU::ScalarMap_i, VisuGUI::CreateScalarMapPrs, ScalarMapOnField);
-CREATEPRS(VISU::DeformedShape_i, VisuGUI::CreateDeformedShapePrs, DeformedShapeOnField);
-CREATEPRS(VISU::Vectors_i, VisuGUI::CreateVectorsPrs, VectorsOnField);
-CREATEPRS(VISU::IsoSurfaces_i, VisuGUI::CreateIsoSurfacesPrs, IsoSurfacesOnField);
-CREATEPRS(VISU::CutPlanes_i, VisuGUI::CreateCutPlanesPrs, CutPlanesOnField);
-CREATEPRS(VISU::CutLines_i, VisuGUI::CreateCutLinesPrs, CutLinesOnField);
-CREATEPRS(VISU::StreamLines_i, VisuGUI::CreateStreamLinesPrs, StreamLinesOnField);
-
-
-#define BUILDPRS(TYPE, FCREATE, FNAME, DLGNAME) \
-bool FNAME(SALOMEDS::SObject_var theField) { \
-  VISU::Storable::TRestoringMap aMap = getMapOfValue(theField); \
-  bool isExist; \
-  QString aType = VISU::Storable::FindValue(aMap,"myType",&isExist); \
-  if(!isExist || aType.toInt() != VISU::TTIMESTAMP ) return false; \
-  QString aMeshName = VISU::Storable::FindValue(aMap,"myMeshName",&isExist).latin1(); \
-  QString anEntity = VISU::Storable::FindValue(aMap,"myEntityId",&isExist).latin1(); \
-  QString aFieldName = VISU::Storable::FindValue(aMap,"myFieldName",&isExist).latin1(); \
-  QString aTimeStampId = VISU::Storable::FindValue(aMap,"myTimeStampId",&isExist).latin1(); \
-  Utils_Timer timer; \
-  if(MYCHECKTIME) timer.Start(); \
-  TYPE* pPresent = FCREATE(theField,aMeshName,(VISU::Entity)anEntity.toInt(),aFieldName,aTimeStampId.toInt()); \
-  if(MYCHECKTIME) { \
-    timer.Stop(); \
-    MESSAGE("BUILDPRS(TYPE, FCREATE, FNAME, DLGNAME) - CREATE PRSOBJECT"); \
-    timer.Show(); \
-  } \
-  if (pPresent) { \
-    QString aValue = QAD_CONFIG->getSetting("Visu:BuildDefaultPrs3d"); \
-    if(aValue.isEmpty() || (!aValue.isEmpty() && !aValue.toInt())){ \
-      DLGNAME* aDlg = new DLGNAME(); \
-      aDlg->initFromPrsObject(pPresent); \
-      if (aDlg->exec() && (aDlg->storeToPrsObject(pPresent))) { \
-        delete aDlg; \
-      } else { \
-        DeletePresentation(pPresent); \
-        delete aDlg; \
-        return false; \
-      } \
-    } \
-     try { \
-       CreateActor(pPresent); \
-     }catch (...) {\
-       return false;} \
-    return true; \
-  } \
-  return false; \
-}
+  aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_PARTIAL_SELECTION"));
+  createAction( VISU_PARTIAL_SELECTION, tr("MEN_PARTIAL_SELECTION"), QIconSet(aPixmap),
+                tr("MEN_PARTIAL_SELECTION"), "", 0, aParent, false,
+                this);
 
-BUILDPRS(VISU::ScalarMap_i, CreateScalarMapPrs, VisuGUI::CreateScalarMap, VisuGUI_ScalarBarDlg);
-BUILDPRS(VISU::DeformedShape_i, CreateDeformedShapePrs, VisuGUI::CreateDeformedShape, VisuGUI_MagnitudeDlg);
-BUILDPRS(VISU::Vectors_i, CreateVectorsPrs, VisuGUI::CreateVectors, VisuGUI_VectorsDlg);
-BUILDPRS(VISU::IsoSurfaces_i, CreateIsoSurfacesPrs, VisuGUI::CreateIsoSurfaces, VisuGUI_IsoSurfacesDlg);
-//BUILDPRS(VISU::CutPlanes_i, CreateCutPlanesPrs, VisuGUI::CreateCutPlanes, VisuGUI_CutPlanesDlg);
-//BUILDPRS(VISU::CutLines_i, CreateCutLinesPrs, VisuGUI::CreateCutLines, VisuGUI_CutLinesDlg);
-BUILDPRS(VISU::StreamLines_i, CreateStreamLinesPrs, VisuGUI::CreateStreamLines, VisuGUI_StreamLinesDlg);
-
-
-bool VisuGUI::CreateCutPlanes(SALOMEDS::SObject_var theField) { 
-  try {
-  VISU::Storable::TRestoringMap aMap = getMapOfValue(theField); 
-  bool isExist; 
-  QString aType = VISU::Storable::FindValue(aMap,"myType",&isExist); 
-  if(!isExist || aType.toInt() != VISU::TTIMESTAMP ) return false; 
-  QString aMeshName = VISU::Storable::FindValue(aMap,"myMeshName",&isExist).latin1(); 
-  QString anEntity = VISU::Storable::FindValue(aMap,"myEntityId",&isExist).latin1();
-  QString aFieldName = VISU::Storable::FindValue(aMap,"myFieldName",&isExist).latin1(); 
-  QString aTimeStampId = VISU::Storable::FindValue(aMap,"myTimeStampId",&isExist).latin1();
-  Utils_Timer timer;
-  if(MYCHECKTIME) timer.Start();
-  VISU::CutPlanes_i* pPresent = 
-    CreateCutPlanesPrs(theField,aMeshName,(VISU::Entity)anEntity.toInt(),aFieldName,aTimeStampId.toInt());
-  if(MYCHECKTIME) {
-    timer.Stop();
-    MESSAGE("BUILDPRS(TYPE, FCREATE, FNAME, DLGNAME) - CREATE PRSOBJECT");
-    timer.Show();
-  }
-  if (pPresent) {
-    QString aValue = QAD_CONFIG->getSetting("Visu:BuildDefaultPrs3d");
-    if(aValue.isEmpty() || (!aValue.isEmpty() && !aValue.toInt())){
-      VisuGUI_CutPlanesDlg* aDlg = new VisuGUI_CutPlanesDlg(true, false);
-      aDlg->initFromPrsObject(pPresent);
-      aDlg->show();
-      myActiveDialogBox = aDlg;      
-//       if (aDlg->exec() && (aDlg->storeToPrsObject(pPresent))) {
-//         delete aDlg;
-//       } else {
-//         DeletePresentation(pPresent);
-//         delete aDlg;
-//         return false;
-//       }
-//     }
-//     CreateActor(pPresent);
-      return true;
-    }
-  }
-}catch (...){return false;}
-  return false;
+  createAction( VISU_SHOW_ANIMATION, tr("MEN_SHOW_ANIMATION"), QIconSet(),
+                tr("MEN_SHOW_ANIMATION"), "", 0, aParent, false,
+                this, SLOT(OnShowAnimation()));
 }
 
-bool VisuGUI::CreateCutLines(SALOMEDS::SObject_var theField) { 
-try {
-  VISU::Storable::TRestoringMap aMap = getMapOfValue(theField); 
-  bool isExist; 
-  QString aType = VISU::Storable::FindValue(aMap,"myType",&isExist); 
-  if(!isExist || aType.toInt() != VISU::TTIMESTAMP ) return false; 
-  QString aMeshName = VISU::Storable::FindValue(aMap,"myMeshName",&isExist).latin1(); 
-  QString anEntity = VISU::Storable::FindValue(aMap,"myEntityId",&isExist).latin1(); 
-  QString aFieldName = VISU::Storable::FindValue(aMap,"myFieldName",&isExist).latin1(); 
-  QString aTimeStampId = VISU::Storable::FindValue(aMap,"myTimeStampId",&isExist).latin1(); 
-  Utils_Timer timer; 
-  if(MYCHECKTIME) timer.Start(); 
-  VISU::CutLines_i* pPresent = CreateCutLinesPrs(theField,aMeshName,
-                                    (VISU::Entity)anEntity.toInt(),
-                                    aFieldName,aTimeStampId.toInt()); 
-  if(MYCHECKTIME) { 
-    timer.Stop(); 
-    MESSAGE("BUILDPRS(VISU::CutLines_i, CreateCutLinesPrs, VisuGUI::CreateCutLines, VisuGUI_CutLinesDlg) - CREATE PRSOBJECT");
-    timer.Show(); 
-  } 
-  if (pPresent) { 
-    QString aValue = QAD_CONFIG->getSetting("Visu:BuildDefaultPrs3d"); 
-    if(aValue.isEmpty() || (!aValue.isEmpty() && !aValue.toInt())){ 
-      VisuGUI_CutLinesDlg* aDlg = new VisuGUI_CutLinesDlg(true); 
-      aDlg->initFromPrsObject(pPresent); 
-      aDlg->show();
-      myActiveDialogBox = aDlg;
-      return true;
-//       if (aDlg->exec()) { 
-//         aDlg->storeToPrsObject(pPresent);
-//     if (aDlg->isGenerateTable()) {
-//       GetVisuGen()->CreateTable(pPresent->GetEntry());
-//       if (aDlg->isGenerateCurves()) {
-//         SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument();
-//         SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(pPresent->GetEntry());
-//         if(!aSObject->_is_nil()) {
-//           SALOMEDS::ChildIterator_var aIter = aStudy->NewChildIterator( aSObject );
-//           SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder();
-//           for ( ;aIter->More(); aIter->Next()) {
-//             SALOMEDS::SObject_var aTblObj = aIter->Value();
-//             if (!aTblObj->_is_nil()) {
-//               SALOMEDS::GenericAttribute_var anAttr;
-//               if (aTblObj->FindAttribute(anAttr, "AttributeName")) {
-//                 CreatePlot(aTblObj);
-//               }
-//             }
-//           }
-//         }
-//       }
-//       GetActiveStudy()->updateObjBrowser();  
-//     }
-//       } else { 
-//         DeletePresentation(pPresent); 
-//         delete aDlg; 
-//         return false; 
-//       } 
-//       delete aDlg; 
-//     } 
-//     CreateActor(pPresent); 
-//     return true; 
-    } 
-  }
-}catch (...){return false; }
-  return false; 
-}
+void
+VisuGUI::
+createMenus()
+{
+  // Add actions to menus
+  int aMenuId;
+  aMenuId = createMenu( tr( "MEN_DESK_FILE" ), -1 );
+  createMenu( separator(), aMenuId, -1, 10 );
+  
+  int anImportId = createMenu( tr( "MEN_IMPORT" ), aMenuId, -1, 10 );
+  createMenu( VISU_IMPORT_FROM_FILE, anImportId ); // import from file
+  createMenu( VISU_IMPORT_TABLE, anImportId ); // import table
+
+  aMenuId = createMenu( tr( "MEN_VISUALIZATION" ), -1, -1, 30 );
+  createMenu( VISU_SCALAR_MAP, aMenuId, 10 ); // scalar map
+  createMenu( VISU_DEFORMED_SHAPE, aMenuId, 10 ); // deformed shape
+  createMenu( VISU_VECTORS, aMenuId, 10 ); // vectors
+  createMenu( VISU_ISO_SURFACES, aMenuId, 10 ); // iso surfaces
+  createMenu( VISU_CUT_PLANES, aMenuId, 10 ); // cut planes
+  createMenu( VISU_CUT_LINES, aMenuId, 10 ); // cut lines
+  createMenu( VISU_STREAM_LINES, aMenuId, 10 ); // stream lines
+  createMenu( VISU_PLOT_3D, aMenuId, 10 ); // Plot3d
+  createMenu( VISU_SCALAR_MAP_ON_DEFORMED_SHAPE, aMenuId, 10 ); // scalar map on deformed shape
+
+  aMenuId = createMenu( tr( "MEN_SELECTION" ), -1, -1, 30 );
+  createMenu( VISU_SELECTION_INFO, aMenuId, 10 ); // selection info
+
+  aMenuId = createMenu( tr( "MEN_REPRESENTATION" ), -1, -1, 30 );
+  int parentId =
+    createMenu( tr( "MEN_DISPLAY_SELECTION" ), aMenuId, 10 ); // display selection
+  createMenu( VISU_POINTS, parentId, 10 ); //   points
+  createMenu( VISU_WIREFRAME, parentId, 10 ); //   wireframe
+  createMenu( VISU_SURFACE, parentId, 10 ); //   surface
+  createMenu( VISU_ERASE_ALL, aMenuId, 10 ); // erase all
+  createMenu( VISU_GLOBAL_SELECTION, aMenuId, 10 ); // global selection
+  createMenu( VISU_PARTIAL_SELECTION, aMenuId, 10 ); // partial selection
+}
+
+void
+VisuGUI::
+createToolBars()
+{
+  int aToolId = createTool(tr("TOOL_VISUALISATION"));
+  createTool( VISU_SCALAR_MAP, aToolId );
+  createTool( VISU_DEFORMED_SHAPE, aToolId );
+  createTool( VISU_VECTORS, aToolId );
+  createTool( VISU_ISO_SURFACES, aToolId );
+  createTool( VISU_CUT_PLANES, aToolId );
+  createTool( VISU_CUT_LINES, aToolId );
+  createTool( VISU_STREAM_LINES, aToolId );
+  createTool( VISU_PLOT_3D, aToolId );
+  createTool( VISU_SCALAR_MAP_ON_DEFORMED_SHAPE, aToolId );
+
+  aToolId = createTool(tr("TOOL_REPRESENTATION"));
+  createTool( VISU_POINTS, aToolId );
+  createTool( VISU_WIREFRAME, aToolId );
+  createTool( VISU_SURFACE, aToolId );
+  createTool( VISU_ERASE_ALL, aToolId );
+  createTool( VISU_GLOBAL_SELECTION, aToolId );
+  createTool( VISU_PARTIAL_SELECTION, aToolId );
+}
+
+void
+VisuGUI::
+createPopupMenus()
+{
+  // Prepare popup menus
+  QtxPopupMgr* mgr = popupMgr();
+
+  // VISU root commands
+  mgr->insert( action( VISU_IMPORT_FROM_FILE ), -1, -1, -1 ); // import MED file
+  mgr->insert( action( VISU_IMPORT_TABLE ), -1, -1, -1 ); // import tables from file
+  mgr->insert( action( VISU_PLOT2D ), -1, -1, -1 ); // create Plot2d View
+
+  //mgr->insert( action( VISU_IMPORT_MED ), -1, -1, -1 ); // import MED structure from MED module
+
+  // create
+  mgr->insert( action( VISU_SCALAR_MAP ), -1, -1, -1 ); // scalar bar
+  mgr->insert( action( VISU_ISO_SURFACES ), -1, -1, -1 ); // iso surface
+  mgr->insert( action( VISU_CUT_PLANES ), -1, -1, -1 ); // cut planes
+  mgr->insert( action( VISU_CUT_LINES ), -1, -1, -1 ); // cut lines
+  mgr->insert( action( VISU_DEFORMED_SHAPE ), -1, -1, -1 ); // deformed shape
+  mgr->insert( action( VISU_VECTORS ), -1, -1, -1 ); // vectors
+  mgr->insert( action( VISU_STREAM_LINES ), -1, -1, -1 ); // stream lines
+  mgr->insert( action( VISU_PLOT_3D ), -1, -1, -1 ); // Plot3d
+  mgr->insert( action( VISU_SCALAR_MAP_ON_DEFORMED_SHAPE ), -1, -1, -1 ); // scalar map on deformed shape
+
+  mgr->insert( action( VISU_CREATE_PRS ), -1, -1, -1 ); // create presentation
+  mgr->insert( action( VISU_CREATE_MANY_PRS ), -1, -1, -1 ); // create presentations
+
+  mgr->insert( action( VISU_CREATE_TABLE ), -1, -1, -1 ); // create table
+
+  // edit
+  mgr->insert( action( VISU_EDIT_SCALARMAP ), -1, -1, -1 );
+  mgr->insert( action( VISU_EDIT_DEFORMEDSHAPE ), -1, -1, -1 );
+  mgr->insert( action( VISU_EDIT_CUTPLANES ), -1, -1, -1 );
+  mgr->insert( action( VISU_EDIT_CUTLINES ), -1, -1, -1 );
+  mgr->insert( action( VISU_EDIT_ISOSURFACE ), -1, -1, -1 );
+  mgr->insert( action( VISU_EDIT_VECTORS ), -1, -1, -1 );
+  mgr->insert( action( VISU_EDIT_STREAMLINES ), -1, -1, -1 );
+  mgr->insert( action( VISU_EDIT_PLOT3D ), -1, -1, -1 );
+  mgr->insert( action( VISU_EDIT_SCALARMAPONDEFORMEDSHAPE ), -1, -1, -1 );
+  mgr->insert( action( VISU_EDIT_CONTAINER ), -1, -1, -1 );
+
+  // rename
+  mgr->insert( action( VISU_RENAME ), -1, -1, -1 );
+
+  // copy
+  mgr->insert( action( VISU_COPY_PRS ), -1, -1, -1 );
+
+  // delete
+  mgr->insert( action( VISU_CLEAR_CONTAINER ), -1, -1, -1 );
+
+  // table commands
+  //mgr->insert( action( VISU_SHOW_TABLE ), -1, -1, -1 ); // show table
+  //mgr->insert( action( VISU_CREATE_CURVES ), -1, -1, -1 ); // create curves
+  //mgr->insert( action( VISU_EXPORT_TABLE ), -1, -1, -1 ); // export table
+
+  mgr->insert( separator(), -1, -1, -1 );
+
+  mgr->insert( action( VISU_ERASE ), -1, -1, -1 ); // erase
+  mgr->insert( action( VISU_DISPLAY ), -1, -1, -1 ); // display
+  mgr->insert( action( VISU_DISPLAY_ONLY ), -1, -1, -1 ); // display only
+
+  // "Representation" submenu
+  int parentId = mgr->insert( tr( "MEN_REPRESENTATION" ), -1, -1 );
+  mgr->insert( action( VISU_POINTS )      , parentId, -1, -1 ); // points
+  mgr->insert( action( VISU_WIREFRAME )   , parentId, -1, -1 ); // wireframe
+  mgr->insert( action( VISU_SURFACE )     , parentId, -1, -1 ); // surface
+  mgr->insert( action( VISU_INSIDEFRAME ) , parentId, -1, -1 ); // insideframe
+  mgr->insert( action( VISU_SURFACEFRAME ), parentId, -1, -1 ); // surfaceframe
+  mgr->insert( action( VISU_SHRINK )      , parentId, -1, -1 ); // shrink
+  mgr->insert( action( VISU_UNSHRINK )    , parentId, -1, -1 ); // unshrink
+  mgr->insert( separator(), parentId, -1, -1 );
+  mgr->insert( action( VISU_SHADING )     , parentId, -1, -1 ); // shading
+  mgr->insert( action( VISU_NOSHADING )   , parentId, -1, -1 ); // noshading
+
+  // "Properties" submenu
+  parentId = mgr->insert( tr( "MEN_PROPERTIES" ), -1, -1 );
+  mgr->insert( action( VISU_CELL_COLOR ), parentId, -1, -1 ); // cell color
+  mgr->insert( action( VISU_EDGE_COLOR ), parentId, -1, -1 ); // edge color
+  mgr->insert( action( VISU_COLOR )     , parentId, -1, -1 ); // color
+  mgr->insert( action( VISU_OPACITY )   , parentId, -1, -1 ); // opacity
+  mgr->insert( action( VISU_LINE_WIDTH ), parentId, -1, -1 ); // line width
+
+  mgr->insert( separator(), -1, -1, -1 );
+
+  // Other presentations management
+  mgr->insert( action( VISU_TRANSLATE_PRS ), -1, -1, -1 );
+  mgr->insert( action( VISU_CLIPPING ), -1, -1, -1 );
+
+  mgr->insert( action( VISU_MERGE_SCALAR_BARS ), -1, -1, -1 );
+  mgr->insert( action( VISU_FREE_SCALAR_BARS ), -1, -1, -1 );
+
+  mgr->insert( action( VISU_SWEEP ), -1, -1, -1 );
+  mgr->insert( action( VISU_ANIMATION ), -1, -1, -1 );
+
+  mgr->insert( separator(), -1, -1, -1 );
+
+  // view parameters commands
+  mgr->insert( action( VISU_SAVE_VIEW_PARAMS ), -1, -1, -1 ); // save view params
+  mgr->insert( action( VISU_SAVE_VIEW_PARAMS_1 ), -1, -1, -1 ); // save view params
+  mgr->insert( action( VISU_RESTORE_VIEW_PARAMS ), -1, -1, -1 ); // restore view params
+  //mgr->insert( action( VISU_DELETE_VIEW_PARAMS ), -1, -1, -1 ); // delete view params
+
+  mgr->insert( action( VISU_ARRANGE_ACTORS ), -1, -1, -1 ); // arrange actors
+
+  mgr->insert( action( VISU_CURVE_PROPS ), -1, -1, -1 ); // curve properties
+
+  mgr->insert( action( VISU_SELECTION_INFO ), -1, -1, -1 ); // Selection info
+
+  // Rules
+
+  QString aPrsAll ("'VISU::TSCALARMAP' 'VISU::TISOSURFACE' 'VISU::TDEFORMEDSHAPE' 'VISU::TCUTPLANES' "
+                   "'VISU::TCUTLINES' 'VISU::TVECTORS' 'VISU::TSTREAMLINES' 'VISU::TPLOT3D' 'VISU::TSCALARMAPONDEFORMEDSHAPE'");
+
+  // VISU root commands
+  QString aRule = "client='ObjectBrowser' and selcount=1 and type='VISU::TVISUGEN'";
+  mgr->setRule( action( VISU_IMPORT_FROM_FILE ), aRule, true );
+  mgr->setRule( action( VISU_IMPORT_TABLE ), aRule, true );
+  mgr->setRule( action( VISU_PLOT2D ), aRule, true );
+
+  // timestamp commands
+  aRule = "client='ObjectBrowser' and selcount=1 and type='VISU::TTIMESTAMP'";
+  mgr->setRule( action( VISU_SCALAR_MAP ), aRule, true );
+  mgr->setRule( action( VISU_ISO_SURFACES ), aRule, true );
+  mgr->setRule( action( VISU_CUT_PLANES ), aRule, true );
+  mgr->setRule( action( VISU_CUT_LINES ), aRule, true );
+  mgr->setRule( action( VISU_PLOT_3D ), aRule, true );
+  aRule += " and nbComponents>1";
+  mgr->setRule( action( VISU_DEFORMED_SHAPE ), aRule, true );
+  mgr->setRule( action( VISU_VECTORS ), aRule, true );
+  mgr->setRule( action( VISU_STREAM_LINES ), aRule, true );
+  mgr->setRule( action( VISU_SCALAR_MAP_ON_DEFORMED_SHAPE ), aRule, true );
+
+  // display/erase commands
+  QString andInvisible = " and (((not isVisible) and isActiveView) or (not isActiveView))";
+  QString aTableOrCont = "(type='VISU::TTABLE' and nbChildren>0) or type='VISU::TCONTAINER'";
+  QString orCurveVisible   = "or (type='VISU::TCURVE' and isVisible)";
+  QString orCurveInvisible = "or (type='VISU::TCURVE'" + andInvisible + ")";
+  QString aPrsVisible   = "(($type in {'VISU::TMESH' " + aPrsAll + "}) and isVisible)";
+  QString aPrsInvisible = "(($type in {'VISU::TMESH' " + aPrsAll + "})" + andInvisible + ")";
+  QString aComponent = "( selcount=1 and canBeDisplayed and isComponent )";
+
+  QString anEraseRule = "( selcount>0 and ({true} in $canBeDisplayed) and (" + aPrsVisible +
+    " or (client='ObjectBrowser' and (" + aTableOrCont + orCurveVisible + "))) ) or " + aComponent;
+
+  QString aDisplayRule = "( selcount>0 and ({true} in $canBeDisplayed) and (" + aPrsInvisible +
+    " or (client='ObjectBrowser' and (" + aTableOrCont + orCurveInvisible + "))) ) or" + aComponent;
+
+  QString aDOnlyRule = "( selcount>0 and ({true} in $canBeDisplayed) and (($type in {'VISU::TMESH' " + aPrsAll + "})"
+    " or (client='ObjectBrowser' and ((type='VISU::TTABLE' and nbChildren>0) or"
+    " ($type in {'VISU::TCURVE' 'VISU::TCONTAINER'})))) ) or" + aComponent;
+
+  mgr->setRule( action( VISU_ERASE ), anEraseRule, true );
+  mgr->setRule( action( VISU_DISPLAY ), aDisplayRule, true );
+  mgr->setRule( action( VISU_DISPLAY_ONLY ), aDOnlyRule, true );
+
+  aRule = "selcount>0 and $type in {'VISU::TMESH' " + aPrsAll + "}";
+  mgr->setRule( action( VISU_TRANSLATE_PRS ), aRule, true );
+
+  aRule = "selcount>1 and $type in {'VISU::TMESH' " + aPrsAll + "}";
+  mgr->setRule( action( VISU_MERGE_SCALAR_BARS ), aRule, true );
+  mgr->setRule( action( VISU_FREE_SCALAR_BARS ), aRule, true );
+
+  // view parameters
+  aRule = "selcount=1 and type='VISU::TVIEW3D' and activeView='VTKViewer'";
+  mgr->setRule( action( VISU_SAVE_VIEW_PARAMS_1 ), aRule, true );
+  mgr->setRule( action( VISU_SAVE_VIEW_PARAMS ), "client='VTKViewer' and selcount=0 and activeView='VTKViewer'", true );
+  mgr->setRule( action( VISU_RESTORE_VIEW_PARAMS ), "selcount=1 and type='VISU::TVIEW3D' and activeView='VTKViewer'", true );
+  //mgr->setRule( action( VISU_DELETE_VIEW_PARAMS ), "selcount=1 and type='VISU::TVIEW3D'", true );
+
+  mgr->setRule( action( VISU_ARRANGE_ACTORS ), "client='VTKViewer' and selcount=0", true );
+
+  // 3D presentations commands
+  QString aPrsType    = " and $type in {'VISU::TMESH' " + aPrsAll + "}";
+  QString aInsideType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TDEFORMEDSHAPE'}";
+  QString aSurfType   = " and $type in {'VISU::TMESH'}";
+  QString aShrinkType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TISOSURFACE' "
+                        "'VISU::TDEFORMEDSHAPE' 'VISU::TCUTPLANES' 'VISU::TCUTLINES' 'VISU::TPLOT3D' 'VISU::TSCALARMAPONDEFORMEDSHAPE'}";
+  QString aLineType   = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TISOSURFACE' 'VISU::TDEFORMEDSHAPE' "
+                        "'VISU::TCUTPLANES' 'VISU::TCUTLINES' 'VISU::TSTREAMLINES' 'VISU::TPLOT3D' 'VISU::TSCALARMAPONDEFORMEDSHAPE' }";
+
+  aRule = "selcount=1";
+  mgr->setRule( action( VISU_CLIPPING ), aRule + aPrsType, true );
+
+  // "Representation" submenu
+  QString aNotPoints = " and $representation in {'VISU::WIREFRAME' 'VISU::SHADED' 'VISU::INSIDEFRAME' 'VISU::SURFACEFRAME'}";
+  QString aNotWirefr = " and $representation in {'VISU::POINT' 'VISU::SHADED' 'VISU::INSIDEFRAME' 'VISU::SURFACEFRAME'}";
+  QString aNotSurfac = " and $representation in {'VISU::POINT' 'VISU::WIREFRAME' 'VISU::INSIDEFRAME' 'VISU::SURFACEFRAME'}";
+  QString aNotInside = " and $representation in {'VISU::POINT' 'VISU::WIREFRAME' 'VISU::SHADED' 'VISU::SURFACEFRAME'}";
+  QString aNotSurffr = " and $representation in {'VISU::POINT' 'VISU::WIREFRAME' 'VISU::SHADED' 'VISU::INSIDEFRAME'}";
+
+  mgr->setRule( action( VISU_POINTS )      , aRule + aPrsType + aNotPoints, true );
+  mgr->setRule( action( VISU_WIREFRAME )   , aRule + aPrsType + aNotWirefr, true );
+  mgr->setRule( action( VISU_SURFACE )     , aRule + aPrsType + aNotSurfac, true );
+  mgr->setRule( action( VISU_INSIDEFRAME ) , aRule + aInsideType + aNotInside, true );
+  mgr->setRule( action( VISU_SURFACEFRAME ), aRule + aSurfType + aNotSurffr, true );
+
+  mgr->setRule( action( VISU_SHRINK )  , aRule + aShrinkType + " and isShrunk=0", true );
+  mgr->setRule( action( VISU_UNSHRINK ), aRule + aShrinkType + " and isShrunk=1", true );
+
+  mgr->setRule( action( VISU_SHADING )  , aRule + " and isScalarMapAct=1 and isShading=0", true );
+  mgr->setRule( action( VISU_NOSHADING ), aRule + " and isScalarMapAct=1 and isShading=1", true );
+
+  // "Properties" submenu
+  mgr->setRule( action( VISU_CELL_COLOR ), aRule + " and type='VISU::TMESH' and representation='VISU::SURFACEFRAME'", true );
+  mgr->setRule( action( VISU_EDGE_COLOR ), aRule + " and type='VISU::TMESH' and representation='VISU::SURFACEFRAME'", true );
+  mgr->setRule( action( VISU_COLOR ), aRule + " and ((type='VISU::TMESH'"
+               " and $representation in {'VISU::POINT' 'VISU::WIREFRAME' 'VISU::SHADED' 'VISU::INSIDEFRAME'}) "
+               "or (type='VISU::TDEFORMEDSHAPE' and hasActor=1))", true );
+  mgr->setRule( action( VISU_OPACITY ), aRule + aShrinkType + " and hasActor=1", true );
+  mgr->setRule( action( VISU_LINE_WIDTH ), aRule + aLineType + " and hasActor=1", true );
+
+  // rename command
+  QString aCurveAll = "'VISU::TTABLE' 'VISU::TCURVE' 'VISU::TCONTAINER'";
+
+  aRule = "selcount=1 and ($type in {'VISU::TVIEW3D' 'VISU::TMESH' " + aCurveAll + " " + aPrsAll + "})";
+  mgr->setRule( action( VISU_RENAME ), aRule, true );
+
+  // copy presentation command
+  aRule = "selcount=1 and ($type in {" + aPrsAll + "})";
+  mgr->setRule( action( VISU_COPY_PRS ), aRule, true );
+
+  // curve commands
+  aRule = "selcount=1 and type='VISU::TCURVE'";
+  mgr->setRule( action( VISU_CURVE_PROPS ), aRule, true );
+
+  // curve container commands
+  aRule = "client='ObjectBrowser' and selcount=1 and type='VISU::TCONTAINER'";
+  mgr->setRule( action( VISU_EDIT_CONTAINER ), aRule, true );
+  mgr->setRule( action( VISU_CLEAR_CONTAINER ), aRule, true );
+
+  mgr->setRule( action( VISU_EDIT_SCALARMAP ),
+               "selcount=1 and type='VISU::TSCALARMAP'", true );
+  mgr->setRule( action( VISU_EDIT_DEFORMEDSHAPE ),
+               "selcount=1 and type='VISU::TDEFORMEDSHAPE'", true );
+  mgr->setRule( action( VISU_EDIT_SCALARMAPONDEFORMEDSHAPE ),
+               "selcount=1 and type='VISU::TSCALARMAPONDEFORMEDSHAPE'", true );
+  mgr->setRule( action( VISU_EDIT_CUTPLANES ),
+               "selcount=1 and type='VISU::TCUTPLANES'", true );
+  mgr->setRule( action( VISU_EDIT_CUTLINES ),
+               "selcount=1 and type='VISU::TCUTLINES'", true );
+  mgr->setRule( action( VISU_EDIT_ISOSURFACE ),
+               "selcount=1 and type='VISU::TISOSURFACE'", true );
+  mgr->setRule( action( VISU_EDIT_VECTORS ),
+               "selcount=1 and type='VISU::TVECTORS'", true );
+  mgr->setRule( action( VISU_EDIT_STREAMLINES ),
+               "selcount=1 and type='VISU::TSTREAMLINES'", true );
+  mgr->setRule( action( VISU_EDIT_PLOT3D ),
+               "selcount=1 and type='VISU::TPLOT3D'", true );
+
+  aRule = "selcount=1 and type='VISU::TCUTLINES' and nbNamedChildren=0";
+  mgr->setRule( action( VISU_CREATE_TABLE ), aRule, true );
+
+  aRule = "selcount=1 and ($type in {" + aPrsAll + "})";
+  mgr->setRule( action( VISU_SWEEP ), aRule, true );
+
+  // "Selection info" popup item
+  aRule = "client='VTKViewer' and selcount=1" + aInsideType;
+  mgr->setRule( action( VISU_SELECTION_INFO ), aRule, true );
+
+  aRule = "client='ObjectBrowser' and selcount>0";
+  aRule += " and $type in {'VISU::TFIELD'}";
+  aRule += " and nbTimeStamps>1";
+  aRule += " and activeView in {'VTKViewer' 'VVTK'}";
+  mgr->setRule( action( VISU_ANIMATION ), aRule, true );
+
+  aRule = "client='ObjectBrowser' and $type in {'VISU::TENTITY' 'VISU::TFAMILY' 'VISU::TGROUP'}";
+  mgr->setRule( action( VISU_CREATE_PRS ), aRule + " and selcount=1", true );
+  mgr->setRule( action( VISU_CREATE_MANY_PRS ), aRule + " and selcount>1", true );
+
+  //aRule = "client='ObjectBrowser' and type='MEDFIELD'";
+  //mgr->setRule( action( VISU_IMPORT_MED ), aRule, true );
+}
+
+//***************************************************************************
+void VisuGUI::contextMenuPopup( const QString& theClient, QPopupMenu* theMenu, QString& theTitle )
+{
+  SalomeApp_Module::contextMenuPopup(theClient, theMenu, theTitle);
 
+  OB_Browser* ob = getApp()->objectBrowser();
+  bool isOBClient = (ob && theClient == ob->popupClientType());
 
+  LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
+  SALOME_ListIO aListIO;
+  aSelectionMgr->selectedObjects(aListIO);
 
-/* ======================================================================================== */
-/* Global Method to import tables from file */
-/* ======================================================================================== */
-void VisuGUI::ImportTablesFromFile(){
-  if (checkLock(GetActiveStudy()->getStudyDocument())) return;
-  QStringList flt;
-  flt.append( "Files (*.xls *.txt *.tab)" );
-  flt.append( "All Files (*.*)" );
-  QString aDir = getVisuInputDir();
-  QFileInfo aFileInfo = QAD_FileDlg::getFileName(QAD_Application::getDesktop(),
-                                          aDir,flt,tr("Import From File"),true);
-  
-  if(aFileInfo.exists()){
-    QAD_Application::getDesktop()->putInfo( "Importing From File " + aFileInfo.filePath() + "..." );
-    aDir = QAD_Tools::getDirFromPath(aFileInfo.filePath());
-    QAD_CONFIG->addSetting("Visu:InputDir",aDir);
-    QAD_WaitCursor wc;
-
-    CORBA::Object_var anObject;
-#ifdef CHECKTIME
-    Utils_Timer timer;
-    timer.Start();
-#endif
-   
-    anObject=GetVisuGen()->ImportTables(aFileInfo.filePath());
-    
-#ifdef CHECKTIME
-    timer.Stop();
-    MESSAGE("VisuGUI::ImportTablesFromFile() - IMPORT FILE");
-    timer.Show();
-#endif
-    
-    if(CORBA::is_nil(anObject)) {
-      wc.stop();
-      QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
-                             tr ("ERR_ERROR_IN_THE_FILE"),
-                             tr ("VISU_BUT_OK") );
-      wc.start();
-    }
-    else {
-      QAD_Application::getDesktop()->putInfo(aFileInfo.filePath()+" imported.");
-    }
-    GetActiveStudy()->updateObjBrowser(); //update Object browser
-  }
-} 
+  if (aListIO.Extent() < 1) return;
 
-void VisuGUI::ExportTableToFile() 
-{
-  QAD_Study *aQADStudy = VisuGUI::GetActiveStudy();
-  SALOME_Selection* aSel = SALOME_Selection::Selection (  aQADStudy -> getSelection() );
+  _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
 
-  if( aSel->IObjectCount() > 0 ) {
-    const Handle(SALOME_InteractiveObject)& anIO = aSel->firstIObject();
-    if(anIO->hasEntry()){
-      SALOMEDS::Study_var aStudy = aQADStudy->getStudyDocument();
-      SALOMEDS::SObject_var aSObj = aStudy -> FindObjectID(anIO->getEntry());
-      if(CORBA::is_nil(aSObj))  return; 
+  // Check if "Merge Scalar Range" can be applied
+  int nbPrs = 0;
+  SALOME_ListIteratorOfListIO It (aListIO);
+  for (; It.More(); It.Next()) {
+    Handle(SALOME_InteractiveObject)& anIO = It.Value();
 
-      QString aTitle;
-      SALOMEDS::GenericAttribute_var anAttr;
-
-      if (!aSObj->FindAttribute(anAttr, "AttributeTableOfReal") && 
-         !aSObj->FindAttribute(anAttr, "AttributeTableOfInteger")) {
-       aSObj = aSObj->GetFather(); //if the current SObject is a table title
-                                   // we take a father contaning the table 
-       if (!CORBA::is_nil(aSObj)) {
-         if (!aSObj->FindAttribute(anAttr, "AttributeTableOfReal") && 
-             !aSObj->FindAttribute(anAttr, "AttributeTableOfInteger"))
-           return;
-       }
-       else return;
+    if (!anIO.IsNull() && anIO->hasEntry()) {
+      _PTR(SObject) aSObject = aCStudy->FindObjectID(anIO->getEntry());
+      if ( !aSObject )
+       continue;
+      CORBA::Object_var aCORBAObject = VISU::ClientSObjectToObject(aSObject);
+      if (CORBA::is_nil(aCORBAObject)) {
+        _PTR(GenericAttribute) anAttr;
+        if (aSObject->FindAttribute(anAttr, "AttributeComment")) {
+          _PTR(AttributeComment) aComment (anAttr);
+          string aComm = aComment->Value();
+          QString strIn (aComm.c_str());
+          VISU::Storable::TRestoringMap pMap;
+          VISU::Storable::StrToMap(strIn, pMap);
+          bool isExist;
+          VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(pMap,"myType",&isExist).toInt();
+          if (isExist && aType == VISU::TTIMESTAMP) {
+            _PTR(ChildIterator) anIter = aCStudy->NewChildIterator(aSObject);
+            _PTR(SObject) aPrs;
+            for (; anIter->More(); anIter->Next()) {
+              aPrs = anIter->Value();
+              if (!aPrs) continue;
+              std::vector<VISU::Prs3d_i*> aSubList = GetPrs3dList(this, aPrs);
+              nbPrs += aSubList.size();
+            }
+          }
+        }
       }
-      if (CORBA::is_nil(anAttr)) return;
-
-      SALOMEDS::AttributeTableOfReal_var aTabAttr = SALOMEDS::AttributeTableOfReal::_narrow(anAttr);
-      if (!CORBA::is_nil(aTabAttr)) 
-       aTitle  = aTabAttr->GetTitle(); //get table title in order to have default name of the file 
-      else {
-       SALOMEDS::AttributeTableOfInteger_var aTabAttr = SALOMEDS::AttributeTableOfInteger::_narrow(anAttr);
-       if (!CORBA::is_nil(aTabAttr))
-         aTitle  = aTabAttr->GetTitle(); //get table title in order to have default name of the file 
-       else return;
-      }
-      aTitle.simplifyWhiteSpace();
-      QStringList flt;
-      flt.append("Table Files (*.xls)");
-      
-      QAD_FileDlg *aDlg = new QAD_FileDlg(QAD_Application::getDesktop(), false, true, true);
-      aDlg -> setCaption("Export Table To File");
-      aDlg -> setDir( getVisuOutputDir() );
-      aDlg -> setFilters(flt);
-      aDlg -> setSelection(aTitle.replace(QRegExp(" "), "_"));
-      aDlg -> exec();
-      QString aFile = aDlg -> selectedFile();
-      delete aDlg;
-
-      if(!aFile.isEmpty()){
-       QAD_Application::getDesktop()->putInfo( "Exporting To File " + aFile + "..." );
-       QString aDir = QAD_Tools::getDirFromPath(aFile);
-       QAD_CONFIG->addSetting("Visu:OutputDir",aDir);
-       
-       try {
-         GetVisuGen() -> ExportTableToFile(aSObj, aFile.latin1());
-         QAD_Application::getDesktop()->putInfo(aFile+" exported.");
-       } catch(std::exception& ex) {
-         INFOS(ex.what());
-         QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
-                                tr ("ERR_ERROR_DURING_EXPORT") + " " + tr(ex.what()),
-                                tr ("VISU_BUT_OK") );
-       } catch(...) {
-         INFOS(tr ("ERR_ERROR_DURING_EXPORT"));
-         QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
-                                tr ("ERR_ERROR_DURING_EXPORT"),
-                                tr ("VISU_BUT_OK") );
-       } 
-      } 
     }
   }
-}
-/* ======================================================================================== */
-/* Global Method to import mesh results in MED and DAT format                               */
-/* ======================================================================================== */
-void VisuGUI::ImportFile(){
-  VisuGUI::ImportFromFile(&VISU::VISU_Gen_i::ImportFile);
-}
-void VisuGUI::CopyAndImportFile(){
-  VisuGUI::ImportFromFile(&VISU::VISU_Gen_i::CopyAndImportFile);
-}
-void VisuGUI::ImportFromFile(TImportFun theImportFun){
-  if (checkLock(GetActiveStudy()->getStudyDocument())) return;
-  QStringList flt;
-  //flt.append( "Exportable Files (*.med *.dat)" );
-  //flt.append( "Dat Files (*.dat)" );
-  flt.append( "Med Files (*.med)" );
-  flt.append( tr("MED_MEN_ALL_FILES") );
-  QString aDir = getVisuInputDir();
-  QFileInfo aFileInfo = VisuGUI_FileDlg::getFileName(QAD_Application::getDesktop(),
-                                                    aDir,flt,tr("Import From File"),true);
-  
-  if(aFileInfo.exists()){
-    QAD_Application::getDesktop()->putInfo( "Importing From File " + aFileInfo.filePath() + "..." );
-    aDir = QAD_Tools::getDirFromPath(aFileInfo.filePath());
-    QAD_CONFIG->addSetting("Visu:InputDir",aDir);
-    QAD_WaitCursor wc;
-    
-    VISU::Result_var aResult;
-    
-#ifdef CHECKTIME
-    Utils_Timer timer;
-    timer.Start();
-#endif
-    QString IsBuild = QAD_CONFIG->getSetting("Visu:BuildResult");
-    bool isBuild = (IsBuild.isEmpty()? 0 : IsBuild.toInt());
-    if (VisuGUI_FileDlg::IsBuild){
-      aResult = GetVisuGen()->ImportFile(aFileInfo.filePath());
-      if(!CORBA::is_nil(aResult.in())) 
-       if(VISU::Result_i* pResult = dynamic_cast<VISU::Result_i*>(GetServant(aResult).in())){
-         if(!pResult->IsPossible())
-           QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
-                                   tr ("ERR_CANT_BUILD_PRESENTATION"),
-                                   tr ("VISU_BUT_OK") );
-         else
-           aResult->BuildAll();  
-       }
-    }else{
-      QAD_CONFIG->addSetting( "Visu:BuildResult", false );
-      //aResult=(GetVisuGen()->*theImportFun)(aFileInfo.filePath()); APO: 18/12/03 - fix crash on Linux RedHat 7.1
-      aResult=GetVisuGen()->ImportFile(aFileInfo.filePath());     // APO: 18/12/03 - fix crash on Linux RedHat 7.1
-      QAD_CONFIG->addSetting( "Visu:BuildResult", isBuild );
-    }
-#ifdef CHECKTIME
-    timer.Stop();
-    MESSAGE("VisuGUI::ImportFromFile() - IMPORT FILE");
-    timer.Show();
-#endif
 
-    if(CORBA::is_nil(aResult.in())) {
-      wc.stop();
-      QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
-                            tr ("ERR_ERROR_IN_THE_FILE"),
-                            tr ("VISU_BUT_OK") );
-      wc.start();
-    }
-    else {
-      QAD_Application::getDesktop()->putInfo(aFileInfo.filePath()+" imported.");
-    }
-    GetActiveStudy()->updateObjBrowser(); //update Object browser
+  if (nbPrs > 1) {
+    theMenu->insertSeparator();
+    action( VISU_MERGE_SCALAR_BARS )->addTo(theMenu);
+    action( VISU_FREE_SCALAR_BARS  )->addTo(theMenu);
   }
-}
 
-void VisuGUI::ExportToFile(){
-  CORBA::Object_var anObject = GetSelectedObj();
-  if(CORBA::is_nil(anObject)) return;
-  VISU::Base_i* aBase = dynamic_cast<VISU::Base_i*>(VISU::GetServant(anObject).in());
-  if(aBase != NULL && aBase->GetType() == VISU::TRESULT){
-    QStringList flt;
-    flt.append( "Dat Files (*.dat)" );
-    flt.append( "Med Files (*.med)" );
-    QString aDir = getVisuOutputDir();
-    QString aFile = QAD_FileDlg::getFileName(QAD_Application::getDesktop(),
-                                            aDir,flt,tr("Export To File"),false);
-    if(!aFile.isEmpty()){
-      QAD_Application::getDesktop()->putInfo( "Exporting To File " + aFile + "..." );
-      aDir = QAD_Tools::getDirFromPath(aFile);
-      QAD_CONFIG->addSetting("Visu:OutputDir",aDir);
-      if(dynamic_cast<VISU::Result_i*>(aBase)){
-       try{
-         //APO - aResult->GetInput()->ToFile(aFile.latin1());
-         QAD_Application::getDesktop()->putInfo(aFile+" exported.");
-       }catch(std::exception& ex) {
-         INFOS(ex.what());
-         QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
-                                tr ("ERR_ERROR_DURING_EXPORT") + " " +tr(ex.what()),
-                                tr ("VISU_BUT_OK") );
-       } 
-       catch(...){
-         INFOS(tr ("ERR_ERROR_DURING_EXPORT").latin1());
-         QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
-                                tr ("ERR_ERROR_DURING_EXPORT"),
-                                tr ("VISU_BUT_OK") );
-       } 
-      }
-    }
-  }else
-    QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
-                         tr ("WRN_NO_AVAILABLE_DATA"),
-                         tr ("VISU_BUT_OK"));
-}
+  theMenu->insertSeparator();
 
-/* ======================================================================================== */
-/* Test and Read Object Browser before display                                             */
-/* ======================================================================================== */
-bool VisuGUI::TestObjectBrowser(SALOMEDS::SObject_var& objVisu ){
-  if(MYDEBUG) MESSAGE("VisuGUI::TestObjectBrowser");
-  Handle(SALOME_InteractiveObject) anIO;    
-  CORBA::Object_var anObject = GetSelectedObj(&anIO);
-  if(!anIO.IsNull() && anIO->hasEntry()){
-    objVisu = GetStudyDocument()->FindObjectID(anIO->getEntry());
-    QString aValue = getValue(objVisu,"myType");
-    if((VISU::VISUType)aValue.toInt() == VISU::TTIMESTAMP) return true;
+  // Check if some (nb > 0) removable objects selected
+  if (isOBClient && IsRemovableSelected(this)) {
+    action( VISU_DELETE_OBJS )->addTo(theMenu);
   }
-  QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
-                       tr("WRN_NO_AVAILABLE_DATA"),
-                       tr("VISU_BUT_OK") );
-  return false;
-}
 
-/**
- * Returns Actor of presentation if it exists
- */
-VISU_Actor* VisuGUI::GetActor(VISU::Prs3d_i* thePrs, VTKViewer_ViewFrame* theViewFrame){
-  VTKViewer_ViewFrame* vf = theViewFrame? theViewFrame: GetVtkViewFrame();
-  if (!vf) return NULL;
-  vtkActor *anActor;
-  vtkActorCollection *anActColl = vf->getRenderer()->GetActors();
-  for(anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL;)
-    if(VISU_Actor* anVISUActor = dynamic_cast<VISU_Actor*>(anActor))
-      if(thePrs == anVISUActor->GetPrs3d())
-       return anVISUActor->GetParent();
-  return NULL;
-}
+  // Check if some curves selected (for bug PAL10611)
+  bool isCurves = false;
+  SALOME_ListIteratorOfListIO It1 (aListIO);
+  for (; It1.More() && !isCurves; It1.Next()) {
+    Handle(SALOME_InteractiveObject)& anIO = It1.Value();
 
-/** 
- * Displays only actor of given presentation
- * Creates it if it is abcent
- */
-VISU_Actor* VisuGUI::UpdateViewer(VISU::Prs3d_i* thePrs, bool theDispOnly){
-  VTKViewer_ViewFrame* vf = GetVtkViewFrame();
-  if (!vf) return NULL;
-
-  vtkRenderer *aRen = vf->getRenderer();
-  vtkActorCollection *anActColl = aRen->GetActors();
-
-  vtkActor *anActor;
-  VISU_Actor* anVISUActor = NULL;
-  VISU_Actor* aResActor = NULL;
-  for(anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL; ){
-    if(!SALOME_Actor::SafeDownCast(anActor))
-      continue;
-    if(anActor->IsA("VISU_Actor")){ 
-      anVISUActor = VISU_Actor::SafeDownCast(anActor);
-      VISU::Prs3d_i* aPrs = anVISUActor->GetPrs3d();      
-      if(aPrs == NULL) continue;
-      if (thePrs == aPrs) {
-       aResActor = anVISUActor->GetParent();
-       thePrs->UpdateActor(aResActor);
-       aResActor->VisibilityOn();
-        
-      } else if (theDispOnly) {
-       anVISUActor->GetParent()->VisibilityOff();
-      } else {
+    if (!anIO.IsNull() && anIO->hasEntry()) {
+      _PTR(SObject) aSObject = aCStudy->FindObjectID(anIO->getEntry());
+      if ( !aSObject )
+       continue;
+      _PTR(GenericAttribute) anAttr;
+      if (aSObject->FindAttribute(anAttr, "AttributeComment")) {
+        _PTR(AttributeComment) aComment (anAttr);
+        string aComm = aComment->Value();
+        QString strIn (aComm.c_str());
+        VISU::Storable::TRestoringMap pMap;
+        VISU::Storable::StrToMap(strIn, pMap);
+        bool isExist;
+        VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(pMap,"myType",&isExist).toInt();
+        if (isExist && aType == VISU::TCURVE) {
+          isCurves = true;
+        }
       }
-    } else if (theDispOnly && anActor->GetVisibility()) {
-      anActor->VisibilityOff();
-    } else {
-    } 
+    }
   }
-  if (aResActor) return aResActor;
-  try{
-    anVISUActor = thePrs->CreateActor();
-    vf->AddActor(anVISUActor);
-  } catch ( std::runtime_error& exc ){
-    INFOS(exc.what());
-    QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
-                          tr("ERR_CANT_VISUALIZE_OBJECT") + " " + tr(exc.what()),
-                          tr ("VISU_BUT_OK") );
-    anVISUActor = NULL;
+  if (isCurves) {
+    action( myDisplay     )->removeFrom(theMenu);
+    action( myErase       )->removeFrom(theMenu);
+    action( myDisplayOnly )->removeFrom(theMenu);
+    action( myEraseAll    )->removeFrom(theMenu);
   }
-  return anVISUActor;
-}
 
+  // Check single selection
+  if (aListIO.Extent() != 1) return;
 
-/** 
- * Returns TRUE if Presentation is displayed                                              
- */
-bool VisuGUI::IsDisplayed(VISU::Prs3d_i* thePrs) {
-  VISU_Actor* anVISUActor = GetActor(thePrs);
-  return (anVISUActor)? anVISUActor->GetVisibility() : false;
-}
+  Handle(SALOME_InteractiveObject) anIO;
+  VISU::Storable::TRestoringMap aMap;
+  CORBA::Object_var anObject = GetSelectedObj( this, &anIO, &aMap);
 
-/** 
- * Erases Presentation
- */
-void VisuGUI::ErasePrs(VISU::Prs3d_i* thePrs) {
-  GetActiveStudy()->unHighlightAll();
-  VISU_Actor* anVISUActor = GetActor(thePrs);
-  if (anVISUActor) {
-    anVISUActor->VisibilityOff();
-  }
-}
+  _PTR(SObject) SO = aCStudy->FindObjectID(anIO->getEntry());
+  if ( !SO )
+    return;
+  bool isExist;
+  VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt();
 
-/**
- * Deletes given presentation from Data structure
- */
-void VisuGUI::DeletePresentation(VISU::Prs3d_i* thePrs) {
-  if(checkLock(GetStudyDocument()) || !thePrs) return;
-  GetActiveStudy()->unHighlightAll();
-  for(int i = 0, nbFrames = GetActiveStudy()->getStudyFramesCount(); i < nbFrames; i++)
-    if(QAD_StudyFrame* aFrame = GetActiveStudy()->getStudyFrame(i)){
-      QAD_ViewFrame* aVFrame = aFrame->getRightFrame()->getViewFrame();
-      if(VTKViewer_ViewFrame* aViewFrame = dynamic_cast<VTKViewer_ViewFrame*>(aVFrame)){
-       if(VISU_Actor* anActor = GetActor(thePrs,aViewFrame)){
-         aViewFrame->RemoveActor(anActor);
-         anActor->Delete();
-       }
-       aViewFrame->unHighlightAll();
+  if (aType == VISU::TANIMATION) {
+    action( VISU_SHOW_ANIMATION )->addTo(theMenu);
+
+  } else if (isOBClient) {
+    if (IsSObjectTable(SO)) {
+      action( VISU_SHOW_TABLE )->addTo(theMenu);
+      action( VISU_CREATE_CURVES )->addTo(theMenu);
+      action( VISU_EXPORT_TABLE )->addTo(theMenu);
+      theMenu->insertSeparator();
+    } else {
+      if (!CORBA::is_nil(anObject)) {
+        SALOME_MED::MED_var aMED = SALOME_MED::MED::_narrow(anObject);
+        if (!CORBA::is_nil(aMED.in())) {
+          action( VISU_IMPORT_MED_STRUCTURE )->addTo(theMenu);
+        }
+
+        SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow(anObject); // "Import Structure"
+        if (!CORBA::is_nil(aField)) {
+          action( VISU_IMPORT_MED_TIMESTAMP )->addTo(theMenu); // "Import TimeStamp"
+        }
+      } else {
+        _PTR(SObject) aSFather = SO->GetFather();
+        if (aSFather) {
+          _PTR(GenericAttribute) anAttr;
+          aSFather->FindAttribute(anAttr, "AttributeName");
+          if (anAttr) {
+            _PTR(AttributeName) aName (anAttr);
+            std::string aValue = aName->Value();
+            if (strcmp(aValue.c_str(), "MEDFIELD") == 0) {
+              action( VISU_IMPORT_MED_FIELD )->addTo(theMenu); // "Import Field"
+            }
+          }
+        }
       }
     }
-  thePrs->RemoveFromStudy(); 
-  GetActiveStudy()->updateObjBrowser(); //update Object browser
+  }
 }
 
-/**
- * Deletes given curve presentation from Data structure
- */
-void VisuGUI::DeletePresentation(VISU::Curve_i* theCurve) {
-  if(checkLock(GetStudyDocument()) || !theCurve) return;
-  GetActiveStudy()->unHighlightAll();
-  for(int i = 0, nbFrames = GetActiveStudy()->getStudyFramesCount(); i < nbFrames; i++)
-    if(QAD_StudyFrame* aFrame = GetActiveStudy()->getStudyFrame(i)){
-      QAD_ViewFrame* aVFrame = aFrame->getRightFrame()->getViewFrame();
-      if(Plot2d_ViewFrame* aViewFrame = dynamic_cast<Plot2d_ViewFrame*>(aVFrame)){
-       QList<Plot2d_Curve> clist;
-       aViewFrame->getCurves( clist );
-       for ( int i = 0; i < clist.count(); i++ ) {
-         if ( clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) )
-           aViewFrame->eraseCurve( clist.at( i ) );
-       }
-       aViewFrame->Repaint();
-       aViewFrame->unHighlightAll();
-      }
-    }
-  theCurve->RemoveFromStudy(); 
-  GetActiveStudy()->updateObjBrowser(); //update Object browser
+
+//***************************************************************************
+void
+VisuGUI::
+windows( QMap<int, int>& theMap ) const
+{
+  theMap.clear();
+  theMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
+  theMap.insert( SalomeApp_Application::WT_PyConsole, Qt::DockBottom );
 }
 
-/**
- * Creates new actor of presentation
- */
-void VisuGUI::CreateActor(VISU::Prs3d_i* thePrs) {
-  if (GetActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_VTK) return;
-  if (!thePrs) return;
-  QApplication::setOverrideCursor( Qt::waitCursor );
-  if(VTKViewer_ViewFrame* vf = GetVtkViewFrame()){
-#ifdef CHECKTIME
-    Utils_Timer timer;
-    timer.Start();
-#endif
-    try{
-      MESSAGE("Available memory : "<<VISU_PipeLine::GetAvailableMemory());
-      VISU_Actor* aActor = thePrs->CreateActor();
-      vf->AddActor(aActor);
-    }catch(std::runtime_error& exc) {
-      INFOS("std::runtime_error "<<exc.what());
-      INFOS("Available memory : "<<VISU_PipeLine::GetAvailableMemory());
-      QApplication::restoreOverrideCursor();
-      QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
-                               tr ("WRN_CANT_VISUALIZE_PRS") + " " + tr(exc.what()),
-                               tr ("VISU_BUT_OK") );
-      throw exc;
-    } catch (...) {
-      MESSAGE(" Unknown exception");
-      QApplication::restoreOverrideCursor();
-      INFOS("Unknown exception is caught in VisuGUI::CreateActor");
-      INFOS("Available memory : "<<VISU_PipeLine::GetAvailableMemory());
-      QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
-                            tr ("WRN_CANT_VISUALIZE_PRS") + " " + tr("ERR_UNKNOWN_EXCEPTION"),
-                            tr ("VISU_BUT_OK") );
-      throw ;
-    }
-#ifdef CHECKTIME
-    timer.Stop();
-    MESSAGE("VisuGUI::CreateActor(VISU::Prs3d_i* thePrs) - DISPLAY ACTOR");
-    timer.Show();
-#endif
+
+void
+VisuGUI::
+viewManagers( QStringList& theList ) const
+{
+  theList.clear();
+  // append SVTK viewer only if there is neither SVTK nor VVTK is open
+  QPtrList<SUIT_ViewManager> lst;
+  getApp()->viewManagers( SVTK_Viewer::Type(), lst );
+  if ( !lst.count() ) {
+    lst.clear();
+    getApp()->viewManagers( VVTK_Viewer::Type(), lst );
+    if ( !lst.count() )
+      theList.append( SVTK_Viewer::Type() );
   }
-  QApplication::restoreOverrideCursor();
 }
 
 
+QString
+VisuGUI::
+engineIOR() const
+{
+  CORBA::String_var anIOR = GetVisuGen(this)->GetID();
+  return QString(anIOR.in());
+}
 
-/* ======================================================================================== */
-/* Functions to State of VisuGUI and Dialog Box                                                    */
-/* ======================================================================================== */
 
-void VisuGUI::SetState(int aState )
-{  
-       this->myState = aState ;  
-       return ; 
+bool
+VisuGUI::
+activateModule( SUIT_Study* theStudy )
+{
+  SalomeApp_Module::activateModule( theStudy );
+  studyActivated();
+  setMenuShown( true );
+  setToolShown( true );
+  return true;
 }
 
 
-void VisuGUI::ResetState()
-{  
-       this->myState = -1 ;  
-       return ; 
+bool
+VisuGUI::
+deactivateModule( SUIT_Study* theStudy )
+{
+  setMenuShown( false );
+  setToolShown( false );
+
+  SalomeApp_Module::deactivateModule( theStudy );
+  return true;
 }
 
-void VisuGUI::EmitSignalDeactivateDialog()
+LightApp_Selection*
+VisuGUI::
+createSelection() const
 {
-       emit this->SignalDeactivateActiveDialog() ;
-       return ;
+  return new VisuGUI_Selection( (SalomeApp_Module*)this );
 }
 
-void VisuGUI::EmitSignalCloseAllDialogs()
+//******************************************************************
+void VisuGUI::studyActivated()
 {
-        emit this->SignalCloseAllDialogs() ;
-        return ;
+  GetVisuGen(this)->SetCurrentStudy(GetDSStudy(GetCStudy(GetAppStudy(this))));
+}
+
+/*
+extern "C" {
+  CAM_Module*
+  createModule()
+  {
+    return new VisuGUI();
+  }
 }
+*/
 
-QDialog* VisuGUI::GetActiveDialogBox()
+void VisuGUI::createPreferences()
+{
+  // TAB: "Scalar Bar"
+  int sbarTab = addPreference( tr( "VISU_SCALAR_BAR" ) );
+
+  int rangeGr = addPreference( tr( "VISU_SCALAR_RANGE" ), sbarTab );
+  setPreferenceProperty( rangeGr, "columns", 1 );
+
+  int mode = addPreference( tr( "VISU_SCALAR_MODE" ), rangeGr, LightApp_Preferences::Selector, "VISU", "scalar_bar_mode" );
+  QStringList modes;
+  modes.append( tr( "VISU_MODULUS" ) );
+  modes.append( tr( "VISU_COMPONENT" ) + tr("1") );
+  modes.append( tr( "VISU_COMPONENT" ) + tr("2") );
+  modes.append( tr( "VISU_COMPONENT" ) + tr("3") );
+  QValueList<QVariant> indices;
+  indices.append( 0 );
+  indices.append( 1 );
+  indices.append( 2 );
+  indices.append( 3 );
+  setPreferenceProperty( mode, "strings", modes );
+  setPreferenceProperty( mode, "indexes", indices );
+
+  addPreference( tr( "VISU_LOGARITHMIC_SCALING" ), rangeGr, LightApp_Preferences::Bool, "VISU", "scalar_bar_logarithmic" );
+
+  int rangetype = addPreference( tr( "VISU_RANGE_TO_USE" ), rangeGr, LightApp_Preferences::Selector, "VISU", "scalar_range_type" );
+  QStringList types;
+  types.append( tr( "VISU_FIELD_RANGE" ) );
+  types.append( tr( "VISU_IMPOSED_RANGE" ) );
+  indices.clear();
+  indices.append( 0 );
+  indices.append( 1 );
+  setPreferenceProperty( rangetype, "strings", types );
+  setPreferenceProperty( rangetype, "indexes", indices );
+
+  int imposedGr = addPreference( tr( "VISU_MINMAX_IMPOSED_RANGE" ), sbarTab );
+
+  int min = addPreference( tr( "VISU_MIN" ), imposedGr, LightApp_Preferences::DblSpin, "VISU", "scalar_range_min" );
+  int max = addPreference( tr( "VISU_MAX" ), imposedGr, LightApp_Preferences::DblSpin, "VISU", "scalar_range_max" );
+  setPreferenceProperty( min, "step", 0.1 );
+  setPreferenceProperty( max, "step", 0.1 );
+
+  // group: "Font"
+  int fontGr = addPreference( tr( "VISU_FONT" ), sbarTab );
+  int tfont = addPreference( tr( "VISU_TITLE" ), fontGr,
+                             LightApp_Preferences::Font, "VISU", "scalar_bar_title_font" );
+  addPreference( tr( "VISU_TITLE" ), fontGr,
+                 LightApp_Preferences::Color, "VISU", "scalar_bar_title_color" );
+  int lfont = addPreference( tr( "VISU_LABELS" ), fontGr,
+                             LightApp_Preferences::Font, "VISU", "scalar_bar_label_font" );
+  addPreference( tr( "VISU_LABELS" ), fontGr,
+                 LightApp_Preferences::Color, "VISU", "scalar_bar_label_color" );
+
+  QStringList fam;
+  fam.append( tr( "VISU_FONT_ARIAL" ) );
+  fam.append( tr( "VISU_FONT_COURIER" ) );
+  fam.append( tr( "VISU_FONT_TIMES" ) );
+  int wflag = ( QtxListResourceEdit::FontItem::All &
+                ( ~( QtxListResourceEdit::FontItem::Size |
+                     QtxListResourceEdit::FontItem::UserSize ) ) );
+
+  setPreferenceProperty( tfont, "families", fam );
+  setPreferenceProperty( tfont, "system", false );
+  setPreferenceProperty( tfont, "widget_flags", wflag );
+  setPreferenceProperty( lfont, "families", fam );
+  setPreferenceProperty( lfont, "system", false );
+  setPreferenceProperty( lfont, "widget_flags", wflag );
+
+  // group: "Colors & Labels"
+  int colorsLabelsGr = addPreference( tr( "VISU_COLORS_AND_LABELS" ), sbarTab );
+
+  int numcol = addPreference( tr( "VISU_NB_COLORS" ), colorsLabelsGr,
+                              LightApp_Preferences::IntSpin, "VISU", "scalar_bar_num_colors" );
+  setPreferenceProperty( numcol, "min", 2 );
+  setPreferenceProperty( numcol, "max", 256 );
+
+  int numlab = addPreference( tr( "VISU_NB_LABELS" ), colorsLabelsGr,
+                              LightApp_Preferences::IntSpin, "VISU", "scalar_bar_num_labels" );
+  setPreferenceProperty( numlab, "min", 2 );
+  setPreferenceProperty( numlab, "max", 65 );
+
+  // group: "Orientation"
+  int orientGr = addPreference( tr( "VISU_ORIENTATION" ), sbarTab );
+  int orient = addPreference( tr( "VISU_ORIENTATION" ), orientGr,
+                              LightApp_Preferences::Selector, "VISU", "scalar_bar_orientation" );
+  QStringList orients;
+  orients.append( tr( "VISU_VERTICAL" ) );
+  orients.append( tr( "VISU_HORIZONTAL" ) );
+  indices.clear();
+  indices.append( 0 );
+  indices.append( 1 );
+  setPreferenceProperty( orient, "strings", orients );
+  setPreferenceProperty( orient, "indexes", indices );
+
+  // group: "Origin & Size Vertical"
+  int posVSizeGr = addPreference( tr( "VISU_ORIGIN_AND_SIZE" ) + " " + tr( "VISU_VERTICAL" ), sbarTab );
+  int xv = addPreference( tr( "VISU_X" ), posVSizeGr,
+                          LightApp_Preferences::DblSpin, "VISU", "scalar_bar_vertical_x" );
+  int yv = addPreference( tr( "VISU_Y" ), posVSizeGr,
+                          LightApp_Preferences::DblSpin, "VISU", "scalar_bar_vertical_y" );
+  int wv = addPreference( tr( "VISU_WIDTH" ), posVSizeGr,
+                          LightApp_Preferences::DblSpin, "VISU", "scalar_bar_vertical_width" );
+  int hv = addPreference( tr( "VISU_HEIGHT" ), posVSizeGr,
+                          LightApp_Preferences::DblSpin, "VISU", "scalar_bar_vertical_height" );
+  setPreferenceProperty( xv, "step", 0.1 );
+  setPreferenceProperty( yv, "step", 0.1 );
+  setPreferenceProperty( wv, "step", 0.1 );
+  setPreferenceProperty( hv, "step", 0.1 );
+  setPreferenceProperty( xv, "min", 0.0 );
+  setPreferenceProperty( yv, "min", 0.0 );
+  setPreferenceProperty( wv, "min", 0.0 );
+  setPreferenceProperty( hv, "min", 0.0 );
+  setPreferenceProperty( xv, "max", 1.0 );
+  setPreferenceProperty( yv, "max", 1.0 );
+  setPreferenceProperty( wv, "max", 1.0 );
+  setPreferenceProperty( hv, "max", 1.0 );
+
+  // group: "Origin & Size Horizontal"
+  int posHSizeGr = addPreference( tr( "VISU_ORIGIN_AND_SIZE" ) + " " + tr( "VISU_HORIZONTAL" ), sbarTab );
+  int xh = addPreference( tr( "VISU_X" ), posHSizeGr,
+                          LightApp_Preferences::DblSpin, "VISU", "scalar_bar_horizontal_x" );
+  int yh = addPreference( tr( "VISU_Y" ), posHSizeGr,
+                          LightApp_Preferences::DblSpin, "VISU", "scalar_bar_horizontal_y" );
+  int wh = addPreference( tr( "VISU_WIDTH" ), posHSizeGr,
+                          LightApp_Preferences::DblSpin, "VISU", "scalar_bar_horizontal_width" );
+  int hh = addPreference( tr( "VISU_HEIGHT" ), posHSizeGr,
+                          LightApp_Preferences::DblSpin, "VISU", "scalar_bar_horizontal_height" );
+  setPreferenceProperty( xh, "step", 0.1 );
+  setPreferenceProperty( yh, "step", 0.1 );
+  setPreferenceProperty( wh, "step", 0.1 );
+  setPreferenceProperty( hh, "step", 0.1 );
+  setPreferenceProperty( xh, "min", 0.0 );
+  setPreferenceProperty( yh, "min", 0.0 );
+  setPreferenceProperty( wh, "min", 0.0 );
+  setPreferenceProperty( hh, "min", 0.0 );
+  setPreferenceProperty( xh, "max", 1.0 );
+  setPreferenceProperty( yh, "max", 1.0 );
+  setPreferenceProperty( wh, "max", 1.0 );
+  setPreferenceProperty( hh, "max", 1.0 );
+
+  // group: "Scalar bars default position"
+  int scalarBarGr = addPreference( tr( "Scalar bars default position" ), sbarTab );
+  addPreference( tr( "Arrange Scalar Bars" ), scalarBarGr, LightApp_Preferences::Bool, "VISU", "scalar_bars_default_position" );
+
+  int srangeTab = addPreference( tr( "Sweep, MED import" ) );
+
+  // group: "Sweeping preferences"
+  int sweepGr = addPreference( tr( "VISU_SWEEPING_PREF" ), srangeTab );
+  setPreferenceProperty( sweepGr, "columns", 1 );
+
+  int timestep   = addPreference( tr( "VISU_TIME_STEP" ), sweepGr,
+                                  LightApp_Preferences::DblSpin, "VISU", "sweeping_time_step" );
+  int nbcycles   = addPreference( tr( "VISU_NB_CYCLES" ), sweepGr,
+                                  LightApp_Preferences::IntSpin, "VISU", "sweeping_number_cycles" );
+  int nbsteps    = addPreference( tr( "VISU_NB_STEPS" ),  sweepGr,
+                                  LightApp_Preferences::IntSpin, "VISU", "sweeping_number_steps" );
+  setPreferenceProperty( timestep, "min",  0.1 );
+  setPreferenceProperty( timestep, "step", 0.1 );
+  setPreferenceProperty( timestep, "max",  1000 );
+  setPreferenceProperty( nbcycles, "max",  100  );
+  setPreferenceProperty( nbsteps,  "max",  200  );
+
+  // group: "MED files import"
+  int importGr = addPreference( tr( "MED files import" ), srangeTab );
+  setPreferenceProperty( importGr, "columns", 1 );
+  addPreference( tr( "Use build progress" ), importGr, LightApp_Preferences::Bool, "VISU", "use_build_progress" );
+  addPreference( tr( "Full MED loading" ), importGr, LightApp_Preferences::Bool, "VISU", "full_med_loading" );
+  addPreference( tr( "Build at once" ), importGr, LightApp_Preferences::Bool, "VISU", "build_at_once" );
+  addPreference( tr( "Build fields" ), importGr, LightApp_Preferences::Bool, "VISU", "build_fields" );
+  addPreference( tr( "Build min/max" ), importGr, LightApp_Preferences::Bool, "VISU", "build_min_max" );
+  addPreference( tr( "Build groups" ), importGr, LightApp_Preferences::Bool, "VISU", "build_groups" );
+  addPreference( tr( "Close dialog at finish" ), importGr, LightApp_Preferences::Bool, "VISU", "close_at_finish" );
+
+  // group: "Representation properties"
+  int representGr = addPreference( tr( "VISU_PREF_REPRESENT_PROPS" ), srangeTab );
+  addPreference( tr( "VISU_PREF_SHADING" ), representGr,
+                 LightApp_Preferences::Bool, "VISU", "represent_shading" );
+}
+
+void VisuGUI::preferencesChanged( const QString& a, const QString& b)
 {
-       return this->myActiveDialogBox ;
+  if (a != QString("VISU")) return;
+  if (b == QString("scalar_bar_orientation")) return;
+  SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
+  float sbX1,sbY1,sbW,sbH;
+  float aTol = 1.00000009999999;
+  std::string aWarning;
+  if(b == QString("scalar_bar_vertical_x") || b == QString("scalar_bar_vertical_width")){
+    sbX1 = aResourceMgr->doubleValue("VISU", "scalar_bar_vertical_x", sbX1);
+    sbW = aResourceMgr->doubleValue("VISU", "scalar_bar_vertical_width", sbW);
+    if(sbX1+sbW > aTol){
+      aWarning = "Origin and Size Vertical: X+Width > 1\n";
+      sbX1=0.01;
+      sbW=0.05;
+      aResourceMgr->setValue("VISU", "scalar_bar_vertical_x", sbX1);
+      aResourceMgr->setValue("VISU", "scalar_bar_vertical_width", sbW);
+    }
+  }
+  else if(b == QString("scalar_bar_vertical_y") || b == QString("scalar_bar_vertical_height")){
+    sbY1 = aResourceMgr->doubleValue("VISU", "scalar_bar_vertical_y", sbY1);
+    sbH = aResourceMgr->doubleValue("VISU", "scalar_bar_vertical_height",sbH);
+    if(sbY1+sbH > aTol){
+      aWarning = "Origin and Size Vertical: Y+Height > 1\n";
+      sbY1=0.01;
+      sbH=0.5;
+      aResourceMgr->setValue("VISU", "scalar_bar_vertical_y", sbY1);
+      aResourceMgr->setValue("VISU", "scalar_bar_vertical_height",sbH);
+    }
+  }
+  else if(b ==  QString("scalar_bar_horizontal_x") || b ==  QString("scalar_bar_horizontal_width")){
+    sbX1 = aResourceMgr->doubleValue("VISU", "scalar_bar_horizontal_x", sbX1);
+    sbW = aResourceMgr->doubleValue("VISU", "scalar_bar_horizontal_width", sbW);
+    if(sbX1+sbW > aTol){
+      aWarning = "Origin and Size Horizontal: X+Width > 1\n";
+      sbX1=0.2;
+      sbW=0.6;
+      aResourceMgr->setValue("VISU", "scalar_bar_horizontal_x", sbX1);
+      aResourceMgr->setValue("VISU", "scalar_bar_horizontal_width", sbW);
+    }
+  }
+  else if(b ==  QString("scalar_bar_horizontal_y") || b ==  QString("scalar_bar_horizontal_height")){
+    sbY1 = aResourceMgr->doubleValue("VISU", "scalar_bar_horizontal_y", sbY1);
+    sbH = aResourceMgr->doubleValue("VISU", "scalar_bar_horizontal_height",sbH);
+    if(sbY1+sbH > aTol){
+      aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
+      sbY1=0.01;
+      sbH=0.12;
+      aResourceMgr->setValue("VISU", "scalar_bar_horizontal_y", sbY1);
+      aResourceMgr->setValue("VISU", "scalar_bar_horizontal_height",sbH);
+    }
+  }
+  if (aWarning.size() != 0){
+    aWarning += "The default values are applied instead.";
+    SUIT_MessageBox::warn1(GetDesktop(this),
+                          tr("ERR_SCALARBAR_PARAMS"),
+                          tr(aWarning.c_str()),
+                          tr("BUT_OK") );
+  }
+}
+
+SUIT_ViewManager*
+VisuGUI
+::getViewManager(const QString& theType,
+                const bool theIsCreate)
+{
+  return getApp()->getViewManager(theType,theIsCreate);
 }
 
-void VisuGUI::SetActiveDialogBox(QDialog* aDlg)
+TViewToPrs3d 
+VisuGUI
+::getScalarBarsMap()
+{
+  return myScalarBarsMap;
+}
+LightApp_Displayer* VisuGUI::displayer()
 {
-       this->myActiveDialogBox = (QDialog*)aDlg ;
-       return ;
+  if( !myDisplayer )
+    myDisplayer = new VisuGUI_Displayer( getApp() );
+    
+  return myDisplayer;
 }