Salome HOME
Edit curve properties functionality
[modules/visu.git] / src / VISUGUI / VisuGUI.cxx
index 104eb6f32f4bc2162108b26965b843565690fbca..f6ff55f60226c2a9243bd94dd04d64e00bdd0355 100644 (file)
@@ -1,23 +1,23 @@
 //  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
 //
 //
 //
 //  Module : VISU
 //  $Header$
 
-using namespace std;
-#include "VisuGUI.h"
-#include "VisuGUI_PhaseDlg.h"
-#include "VisuGUI_MagnitudeDlg.h"
-#include "VisuGUI_PhaseMagnitudeDlg.h"
-#include "VisuGUI_PartialScaDlg.h"
-#include "VisuGUI_CursorDlg.h"
-#include "VisuGUI_ScalarBarDlg.h"
-#include "VisuGUI_SweepPrefDlg.h"
-#include "VisuGUI_CutPlanesDlg.h"
-#include "VisuGUI_CutLinesDlg.h"
-#include "VisuGUI_VectorsDlg.h"
-#include "VisuGUI_IsoSurfacesDlg.h"
-#include "VisuGUI_StreamLinesDlg.h"
-#include "VisuGUI_TimeAnimation.h"
+#include <exception>
+#include <typeinfo>
+#include <vector>
 
-#include "VisuGUI_Selection.h"
-#include "VisuGUI_VisuAsDlg.h"
-#include "VisuGUI_SelVectCompDlg.h"
-#include "VisuGUI_NonIsometricDlg.h"
+#include <qptrlist.h>
+#include <qptrvector.h>
+#include <qcolordialog.h>
 
+#include <vtkRenderer.h>
+#include <vtkRenderWindow.h>
+#include <vtkActorCollection.h>
+
+#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_RenderWindow.h"
+#include "SVTK_ViewWindow.h"
+#include "SVTK_ViewModel.h"
+#include "SVTK_Functor.h"
+
+#include "SPlot2d_ViewModel.h"
+#include "SPlot2d_SetupPlot2dDlg.h"
+#include "Plot2d_SetupCurveDlg.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_SelectionMgr.h"
+#include "SalomeApp_Selection.h"
+
+#include "VISUConfig.hh"
 #include "VISU_Gen_i.hh"
-#include "VISU_Result_i.hh"
-#include "VISU_Extractor.hxx"
+#include "VISU_Mesh_i.hh"
 #include "VISU_Table_i.hh"
+#include "VISU_Result_i.hh"
+#include "VISU_View_i.hh"
 #include "VISU_ViewManager_i.hh"
-#include "VISU_LookupTable.hxx"
-#include "VISU_ScalarBarActor.hxx"
 
-#include "SALOMEGUI_ImportOperation.h"
-#include "SALOMEGUI_QtCatchCorbaException.hxx"
-#include "utilities.h"
+#include "VISU_Actor.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 "Plot2d_SetupPlot2dDlg.h"
-#include "Plot2d_ViewFrame.h"
-#include "VTKViewer_ViewFrame.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>
-
-//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 "VisuGUI.h"
+#include "VisuGUI_Tools.h"
+#include "VisuGUI_PopupTools.h"
+#include "VisuGUI_NameDlg.h"
+#include "VisuGUI_FileDlg.h"
+#include "VisuGUI_CursorDlg.h"
+#include "VisuGUI_Selection.h"
+#include "VisuGUI_TimeAnimation.h"
+#include "VisuGUI_EditContainerDlg.h"
+#include "VisuGUI_NonIsometricDlg.h"
 
-#include <med.h>
-#include CORBA_CLIENT_HEADER(Med_Gen)
+#include "VISU_ScalarMap_i.hh"
+#include "VisuGUI_ScalarBarDlg.h"
 
-#include <vtkActor.h>
-#include <vtkDataSetMapper.h>
+#include "VISU_DeformedShape_i.hh"
+#include "VisuGUI_DeformedShapeDlg.h"
 
-// Open CASCADE Include
-#include <TCollection_AsciiString.hxx>
+#include "VISU_IsoSurfaces_i.hh"
+#include "VisuGUI_IsoSurfacesDlg.h"
 
-//#define CHECKTIME 
-#ifdef CHECKTIME
-static int MYCHECKTIME = 1;
-#else
-static int MYCHECKTIME = 0;
-#endif
-#include <Utils_Timer.hxx>
+#include "VISU_CutPlanes_i.hh"
+#include "VisuGUI_CutPlanesDlg.h"
 
-#ifdef DEBUG
-static int MYDEBUG = 0;
-static int MYDEBUGWITHFILES = 0;
-#else
-static int MYDEBUG = 0;
-static int MYDEBUGWITHFILES = 0;
-#endif
+#include "VISU_CutLines_i.hh"
+#include "VisuGUI_CutLinesDlg.h"
 
-class CustomItem : public QCustomMenuItem{
-public:
-  CustomItem( const QString& s, const QFont& f )
-    : string( s ), font( f ){};
-  ~CustomItem(){}
-  
-  void paint( QPainter* p, const QColorGroup& /*cg*/, bool /*act*/, bool /*enabled*/, int x, int y, int w, int h )
-  {
-    p->setFont ( font );
-    p->drawText( x, y, w, h, AlignHCenter | AlignVCenter | ShowPrefix | DontClip, string );
-  }
-  
-  QSize sizeHint()
-  {
-    return QFontMetrics( font ).size( AlignHCenter | AlignVCenter | ShowPrefix | DontClip,  string );
-  }
-private:
-  QString string;
-  QFont font;
-};
+#include "VISU_StreamLines_i.hh"
+#include "VisuGUI_StreamLinesDlg.h"
 
-static VisuGUI MYVISUGUI;
-static VisuGUI *visuGUI = &MYVISUGUI;
+#include "VISU_Vectors_i.hh"
+#include "VisuGUI_VectorsDlg.h"
 
-VISU::VISU_Gen_i* VisuGUI::GetVisuGen(){
-  VISU::VISU_Gen_i::GetVisuGenImpl()->SetCurrentStudy(GetStudyDocument());
-  return VISU::VISU_Gen_i::GetVisuGenImpl();
-}
+#include "VisuGUI_TableDlg.h"
 
-QAD_Desktop* VisuGUI::GetDesktop(){
-  return QAD_Application::getDesktop() ;
-}
+#include "SALOMEconfig.h"
+#include CORBA_SERVER_HEADER(MED_Gen)
 
-QAD_Study* VisuGUI::GetActiveStudy(){
-  return GetDesktop()->getActiveStudy() ;
-}
+#include "utilities.h"
 
-vtkRenderer* VisuGUI::GetRenderer(){
-  if(VTKViewer_ViewFrame* aViewFrame = GetVtkViewFrame())
-    return aViewFrame->getRenderer();
-  return NULL;
-}
+#include "VisuGUI_ActionsDef.h"
 
-VTKViewer_ViewFrame* VisuGUI::GetVtkViewFrame(){
-  QAD_ViewFrame* aViewFrame = GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame();
-  return dynamic_cast<VTKViewer_ViewFrame*>(aViewFrame);
-}
+using namespace VISU;
 
-SALOMEDS::Study_var VisuGUI::GetStudyDocument(){
-  return GetActiveStudy()->getStudyDocument();
-}
+#ifdef _DEBUG_
+static int MYDEBUG = 1;
+#else
+static int MYDEBUG = 0;
+#endif
 
-SALOMEDS::StudyBuilder_var VisuGUI::NewBuilder(){
-  return GetStudyDocument()->NewBuilder();
+//////////////////////////////////////////////////
+// Class: VisuGUI
+//////////////////////////////////////////////////
+
+VisuGUI::VisuGUI():
+  SalomeApp_Module( "VISU" )
+{
 }
 
 
-/**
- * Finds value by given key
- */
+VisuGUI::~VisuGUI()
+{
+}
 
-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);
-    }
-  }
-  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;
-}
-
-
-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);
+
+void
+VisuGUI::
+OnImportFromFile()
+{
+  if(MYDEBUG) MESSAGE("VisuGUI::OnImportFromFile()");
+  CheckLock(GetCStudy(GetAppStudy(this)));
+  SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
+
+  QStringList aFilter;
+  aFilter.append( tr("FLT_MED_FILES") );
+  aFilter.append( tr("FLT_ALL_FILES") );
+
+  QFileInfo aFileInfo =
+    SUIT_FileDlg::getFileName(GetDesktop(this),
+                             "",
+                             aFilter,
+                             tr("MEN_IMPORT_FROM_FILE"),
+                             true);
+  if(aFileInfo.exists()){
+    application()->putInfo( "Importing From File " + aFileInfo.filePath() + "..." );
+
+    VISU::Result_var aResult;
+    bool anIsBuild = aResourceMgr->booleanValue("Visu:BuildResult",false);
+    if(VisuGUI_FileDlg::IsBuild){
+      aResult = GetVisuGen(this)->ImportFile(aFileInfo.filePath());
+      if(!CORBA::is_nil(aResult.in()))
+       if(Result_i* aRes = dynamic_cast<Result_i*>(GetServant(aResult).in())){
+         if(!aRes->IsPossible())
+           SUIT_MessageBox::warn1(GetDesktop(this),
+                                  tr("WRN_VISU"),
+                                  tr("ERR_CANT_BUILD_PRESENTATION"),
+                                  tr("BUT_OK") );
+         else
+           aRes->BuildAll();
        }
-       return VISU::SObjectToObject(aSObject);
-      }
+    }else{
+      aResourceMgr->setValue("Visu:BuildResult",false);
+      aResult = GetVisuGen(this)->ImportFile(aFileInfo.filePath());
+      aResourceMgr->setValue("Visu:BuildResult",anIsBuild);
+    }
+
+    if(CORBA::is_nil(aResult.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();
     }
   }
-  return CORBA::Object::_nil();
 }
 
 
-int IsTrihedronDisplayed(){
-  if(VTKViewer_ViewFrame* aVTKViewFrame = VisuGUI::GetVtkViewFrame())
-    return aVTKViewFrame->isTrihedronDisplayed();
-  return 1;
+void
+VisuGUI::
+OnExploreMEDFile()
+{
+  if(MYDEBUG) MESSAGE("VisuGUI::OnExploreMEDFile()");
+  _PTR(Study) aStudy = GetCStudy(GetAppStudy(this));
+  CheckLock(aStudy);
+
+  SALOME_MED::MED_Gen_var aGen = GetMEDEngine();
+
+  QStringList aFilter;
+  aFilter.append( tr("FLT_MED_FILES") );
+  aFilter.append( tr("FLT_ALL_FILES") );
+
+  QFileInfo aFileInfo =
+    SUIT_FileDlg::getFileName(GetDesktop(this),
+                             "",
+                             aFilter,
+                             tr("MEN_EXPLORE_MED_FILE"),
+                             true);
+  if(aFileInfo.exists()){
+    application()->putInfo( tr("MEN_EXPLORE_MED_FILE") + " " + aFileInfo.filePath() + "..." );
+    std::string aStudyName = aStudy->Name();
+    aGen->readStructFileWithFieldType(aFileInfo.filePath(),aStudyName.c_str());
+    application()->putInfo(aFileInfo.filePath()+tr("INF_DONE"));
+    updateObjBrowser();
+  }
 }
 
 
-void RepaintCurrentView(){
-  if(VTKViewer_ViewFrame* vf = VisuGUI::GetVtkViewFrame()) vf->Repaint();
+void
+VisuGUI::
+OnImportTableFromFile()
+{
+  if(MYDEBUG) MESSAGE("VisuGUI::OnImportTableFromFile()");
+  CheckLock(GetCStudy(GetAppStudy(this)));
+
+  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();
+    }
+  }
 }
 
-/**
- * Returns selected sclalar mode or -1 if it was cancelled
- */
-int GetScalarMode(VISU::Result_i* theResult, const char* theFieldName){
-  int aScalarMode = 0;
-//  const VISU::TField* aField = theResult->GetInput()->GetField(theFieldName);
-//  if(aField->myNbComp > 1){
-//    VisuGUI_SelVectCompDlg* SelCompDlg = new VisuGUI_SelVectCompDlg(QAD_Application::getDesktop(), 0, TRUE, 0);
-//    if(SelCompDlg->exec()){
-//     aScalarMode = SelCompDlg->whatIsChecked();
-//    } else {
-//     aScalarMode = -1;
-//    }
-//    delete SelCompDlg;
-//  }
-  return aScalarMode;
-}  
-
+void
+VisuGUI::
+OnExportTableToFile()
+{
+  if(MYDEBUG) MESSAGE("VisuGUI::OnExportTableToFile()");
+}
 
-VisuGUI::VisuGUI(){}
+void 
+CreateCurves( SalomeApp_Module* theModule,
+             VISU::CutLines_i* thePrs,
+             QDialog* theDlg,
+             const bool theCreate = true )
+{
+  if ( !thePrs )
+    return;
+  VisuGUI_CutLinesDlg* aCutDlg = dynamic_cast<VisuGUI_CutLinesDlg*>( theDlg );
+  if ( !aCutDlg )
+    return;
 
+  _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();
+    for ( _PTR(ChildIterator) aIter = aStudy->NewChildIterator( aSObject ); aIter->More(); aIter->Next() ) {
+      _PTR(SObject) aTblObj = aIter->Value();
+      if ( aTblObj ) {
+       _PTR(GenericAttribute) anAttr;
+       if (aTblObj->FindAttribute( anAttr, "AttributeName" ) ) {
+         aBuilder->RemoveObjectWithChildren( aIter->Value() ); // We should have only one child
+         break;
+       }
+      }
+    }
+  }
 
-VisuGUI* VisuGUI::GetOrCreateVisuGUI( QAD_Desktop* desktop ){
-  if(!visuGUI){
-    static VisuGUI VISUGUI;
-    visuGUI = &VISUGUI;
+  if ( aCutDlg->isGenerateTable() ) {
+    GetVisuGen( theModule )->CreateTable( thePrs->GetEntry() );
+    if ( aCutDlg->isGenerateCurves() ) {
+      if( aSObject ) {
+       _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
+       for ( _PTR(ChildIterator) aIter = aStudy->NewChildIterator( aSObject ); aIter->More(); aIter->Next() ) {
+         _PTR(SObject) aTblObj = aIter->Value();
+         if ( aTblObj ) {
+           _PTR(GenericAttribute) anAttr;
+           if ( aTblObj->FindAttribute( anAttr, "AttributeName" ) ) {
+             CreatePlot( theModule, aTblObj );
+           }
+         }
+       }
+      }
+    }
   }
-  return visuGUI;
 }
 
-/* ********************************************************************************* */
-/* Function to return VisuGUI object                                                */
-/* ********************************************************************************* */
-VisuGUI* VisuGUI::GetVisuGUI( )
+template<class TPrs3d_i>
+TPrs3d_i*
+CreatePrs3d(SalomeApp_Module* theModule,
+           SALOMEDS::SObject_var theTimeStamp,
+           const char* theMeshName,
+           VISU::Entity theEntity,
+           const char* theFieldName,
+           int theTimeId)
 {
-       return VisuGUI::GetOrCreateVisuGUI(QAD_Application::getDesktop());
+  VISU::Result_var aResult;
+  if(CheckResult(theModule,theTimeStamp,aResult)){
+    QApplication::setOverrideCursor(Qt::waitCursor);
+    typedef typename TPrs3d_i::TInterface TPrs3d;
+    typename TPrs3d::_var_type aPrs3d =
+      GetVisuGen(theModule)->template Prs3dOnField<TPrs3d_i>
+      (aResult,theMeshName,theEntity,theFieldName,theTimeId);
+    QApplication::restoreOverrideCursor();
+    if(!CORBA::is_nil(aPrs3d.in()))
+      return dynamic_cast<TPrs3d_i*>(VISU::GetServant(aPrs3d.in()).in());
+  }
+  SUIT_MessageBox::warn1(GetDesktop(theModule),
+                        QObject::tr("WRN_VISU"),
+                        QObject::tr("ERR_CANT_BUILD_PRESENTATION"),
+                        QObject::tr("BUT_OK") );
+  return NULL;
 }
 
-/* ==================================================================================== */
-/* ==================================================================================== */
-/*                                     ONGUI EVENT                                     */
-/* ==================================================================================== */
-/* ==================================================================================== */
-
-static int isStudyLocked(const SALOMEDS::Study_var& theStudy){
-  return theStudy->GetProperties()->IsLocked();
-}
 
-static int checkLock(const SALOMEDS::Study_var& theStudy) {
-  if (isStudyLocked(theStudy)) {
-    QAD_MessageBox::warn1 ( (QWidget*)QAD_Application::getDesktop(),
-                          QObject::tr("WARNING"), 
-                          QObject::tr("WRN_STUDY_LOCKED"),
-                          QObject::tr("BUT_OK") );
+template<class TPrs3d_i, class TDlg, int IsDlgModal>
+bool
+CreatePrs3d(SalomeApp_Module* theModule,
+           SALOMEDS::SObject_var theTimeStamp,
+           const Handle(SALOME_InteractiveObject)& theIO)
+{
+  using namespace VISU;
+  Storable::TRestoringMap aMap = getMapOfValue(theTimeStamp);
+  bool isExist;
+  QString aType = Storable::FindValue(aMap,"myType",&isExist);
+  if(!isExist || aType.toInt() != TTIMESTAMP )
+    return false;
+  QString aMeshName = Storable::FindValue(aMap,"myMeshName",&isExist).latin1();
+  QString anEntity = Storable::FindValue(aMap,"myEntityId",&isExist).latin1();
+  QString aFieldName = Storable::FindValue(aMap,"myFieldName",&isExist).latin1();
+  QString aTimeStampId = Storable::FindValue(aMap,"myTimeStampId",&isExist).latin1();
+  QApplication::setOverrideCursor(Qt::waitCursor);
+  TPrs3d_i* aPrs3d =
+    CreatePrs3d<TPrs3d_i>(theModule,
+                         theTimeStamp,
+                         aMeshName.latin1(),
+                         (Entity)anEntity.toInt(),
+                         aFieldName.latin1(),
+                         aTimeStampId.toInt());
+  QApplication::restoreOverrideCursor();
+  if(aPrs3d){
+    SUIT_ResourceMgr* aResourceMgr = GetResourceMgr();
+    int aValue = aResourceMgr->integerValue("Visu:BuildDefaultPrs3d",0);
+    if(!aValue){
+      if(TDlg* aDlg = new TDlg(GetDesktop(theModule))){ // dialog box in creation mode
+       aDlg->initFromPrsObject(aPrs3d);
+       if(IsDlgModal)
+         if(aDlg->exec() && (aDlg->storeToPrsObject(aPrs3d))) {
+           // Optionally, create table and curves for cut lines
+           QApplication::setOverrideCursor(Qt::waitCursor);
+           CreateCurves( theModule, dynamic_cast<VISU::CutLines_i*>( aPrs3d ), aDlg, true ); // in creation mode
+           QApplication::restoreOverrideCursor();
+           delete aDlg;
+         } else {
+           DeletePrs3d(theModule,aPrs3d,theIO);
+           delete aDlg;
+           return false;
+         }
+       else{
+         aDlg->show();
+         return true;
+       }
+      }
+    }
+    PublishInView(theModule,aPrs3d);
     return true;
   }
   return false;
 }
 
 
-
-bool VisuGUI::OnGUIEvent(int theCommandID,  QAD_Desktop* parent)
+template<class TPrs3d_i, class TDlg, int IsDlgModal>
+void
+CreatePrs3d(SalomeApp_Module* theModule)
 {
-  try{
-  VisuGUI::GetOrCreateVisuGUI(parent);
-  QString VisuInputDir = getVisuInputDir();
-  QString VisuOutputDir = getVisuOutputDir();
-  vtkRenderer *theRenderer = GetRenderer();
+  if(CheckLock(GetCStudy(GetAppStudy(theModule))))
+    return;
 
-  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;
+  SALOMEDS::SObject_var aTimeStampSObj;
+  Handle(SALOME_InteractiveObject) anIO;
+  if(!CheckTimeStamp(theModule,aTimeStampSObj,&anIO))
+    return;
 
-  switch (theCommandID)
-    {
-       /* ======================================================================================== */
-       /* Define Selection Mode                                                                  */
-       /* ======================================================================================== */
-    case 101:
-    case 102:
-    case 103:
-    case 104:
-      {
-       QApplication::setOverrideCursor( Qt::waitCursor );
-       int mode  = theCommandID - 100; // Point, Edge, Cell, Actor     
-       parent->SetSelectionMode( mode );
-       QApplication::restoreOverrideCursor();
-      }
-      break;
-      
-      /* ======================================================================================== */
-      /* Import Table from file                                                                  */
-      /* ======================================================================================== */
-
-    case 199:
-      {
-       if(checkLock(aStudy)) break;
-       visuGUI->ImportTablesFromFile();
-       break;
-      }
+  if(!CreatePrs3d<TPrs3d_i,TDlg,IsDlgModal>(theModule,aTimeStampSObj,anIO))
+    return;
 
-      /* ======================================================================================== */
-      /* Import Mesh from MED, DAT file                                                                  */
-      /* ======================================================================================== */
+  theModule->application()->putInfo(QObject::tr("INF_DONE"));
+  theModule->updateObjBrowser();
 
-    case 112:
-      {
-       visuGUI->ImportFromFile();
-       break;
-      }
+  if(SVTK_ViewWindow* aView = GetViewWindow(theModule))
+    aView->onFitAll();
+}
 
-      /* ======================================================================================== */
-      /* Export results and mesh into a file format                                              */
-      /* ======================================================================================== */
+void VisuGUI::CreateMesh (const Handle(SALOME_InteractiveObject)& theIO)
+{
+  _PTR(Study) aStudy = GetCStudy(GetAppStudy(this));
+  //if (CheckLock(aStudy))
+  //  return;
 
-    case 122:
-      {
-       //visuGUI->ExportToFile();
-       break;
-      }
+  SALOMEDS::SObject_var aResultSObj =
+    GetDSStudy(aStudy)->FindObjectID(theIO->getEntry());
 
-     /* ========================================================================== */
-     /* 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;
+  // Get VISU::Result
+  VISU::Result_var aResult;
+  VISU::Result_i* pResult = CheckResult(this, aResultSObj, aResult);
+  if (pResult == NULL)
+    return;
 
-      /* ======================================================================================================================= */
-      /* View Scalar Animation (Animation/scalar)                                                                               */
-      /* With Phase                                                                                                             */
-      /* ======================================================================================================================= */
+  Storable::TRestoringMap aMap = getMapOfValue(aResultSObj);
+  bool isExist;
+  string aComment = Storable::FindValue(aMap,"myComment",&isExist).latin1();
+  if (!isExist)
+    return;
 
-      //case 4021 :
-      //case 4022 :
-      //case 4023 :
+  CORBA::Object_var aMesh;
+  string aMeshName = Storable::FindValue(aMap,"myMeshName").latin1();
+#ifdef CHECKTIME
+  Utils_Timer timer;
+  timer.Start();
+#endif
+  if (aComment == "ENTITY") {
+    VISU::Entity anEntity = (VISU::Entity)Storable::FindValue(aMap,"myId").toInt();
+    if (VISU::Mesh_i::IsPossible(pResult,aMeshName.c_str(),anEntity))
+      aMesh = GetVisuGen(this)->MeshOnEntity(aResult,aMeshName.c_str(),anEntity);
+  } else if (aComment == "FAMILY") {
+    VISU::Entity anEntity = (VISU::Entity)Storable::FindValue(aMap,"myEntityId").toInt();
+    string aFamilyName = Storable::FindValue(aMap,"myName").latin1();
+    if (VISU::Mesh_i::IsPossible(pResult,aMeshName.c_str(),anEntity,aFamilyName.c_str()))
+      aMesh = GetVisuGen(this)->FamilyMeshOnEntity(aResult,aMeshName.c_str(),anEntity,aFamilyName.c_str());
+  } else if (aComment == "GROUP") {
+    string aGroupName = Storable::FindValue(aMap,"myName").latin1();
+    if (VISU::Mesh_i::IsPossible(pResult,aMeshName.c_str(),aGroupName.c_str()))
+      aMesh = GetVisuGen(this)->GroupMesh(aResult,aMeshName.c_str(),aGroupName.c_str());
+  }
+#ifdef CHECKTIME
+  timer.Stop();
+  MESSAGE("VisuGUI::CreateMesh() - CREATE MESH");
+  timer.Show();
+#endif
 
-      /* ========================================================================================================================= */
-      /* Selection - Cell  by number                                                                                              */
-      /* ========================================================================================================================= */
+  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) {
+    SUIT_MessageBox::warn1 (GetDesktop(this),
+                            tr("VISU_WARNING"),
+                           tr("ERR_CANT_BUILD_PRESENTATION"),
+                           tr("BUT_OK"));
+    return;
+  }
 
-    case 4111 :
-      visuGUI->SelectCell();
-      break;
+  if (SVTK_ViewWindow* aView = GetViewWindow(this)){
+    try {
+#ifdef CHECKTIME
+      Utils_Timer timer;
+      timer.Start();
+#endif
+      PublishInView(this, pPresent);
+      aView->onFitAll();
+#ifdef CHECKTIME
+      timer.Stop();
+      MESSAGE("VisuGUI::CreateMesh() - DISPLAY MESH");
+      timer.Show();
+#endif
+      application()->putInfo(QObject::tr("INF_DONE"));
+    } catch (std::runtime_error& exc) {
+      INFOS(exc.what());
+      SUIT_MessageBox::warn1 (GetDesktop(this),
+                              tr("VISU_WARNING"),
+                              tr("ERR_CANT_CREATE_ACTOR") + " " + tr(exc.what()),
+                              tr("BUT_OK"));
+    }
+  }
+}
 
-      /* ========================================================================================================================= */
-      /* Selection - Cell - information attribute                                                                                 */
-      /* ========================================================================================================================= */
+void
+VisuGUI::
+OnCreateMesh()
+{
+  _PTR(Study) aStudy = GetCStudy(GetAppStudy(this));
+  if (CheckLock(aStudy))
+    return;
 
-    case 4112 :
-      visuGUI->InfoOnCell();
-      break;
+  // Get selected SObject
+  SALOMEDS::SObject_var aResultSObj;
+  Handle(SALOME_InteractiveObject) anIO;
+  CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
+  if (anIO.IsNull() || !anIO->hasEntry())
+    return;
 
-      /* ========================================================================================================================= */
-      /* Selection - Point - information number                                                                                           */
-      /* ========================================================================================================================= */
+  CreateMesh(anIO);
+}
 
-    case 4121 :
-      visuGUI->SelectPoint();
-      break;
+void
+VisuGUI::
+OnCreateManyMesh()
+{
+  _PTR(Study) aStudy = GetCStudy(GetAppStudy(this));
+  if (CheckLock(aStudy))
+    return;
 
-      /* ========================================================================================================================= */
-      /* Selection - Point - information attribute                                                                                */
-      /* ========================================================================================================================= */
+  // Get selected SObject
+  SalomeApp_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;
 
-    case 4122 :
-      visuGUI->InfoOnPoint();
-      break;
+    CreateMesh(anIO);
+  }
+}
 
-      /* ========================================================================================================================= */
-      /* Selection - Shape                                                                                                        */
-      /* ========================================================================================================================= */
+void
+VisuGUI::
+OnCreateScalarMap()
+{
+  CreatePrs3d<VISU::ScalarMap_i,VisuGUI_ScalarBarDlg,1>(this);
+}
 
-      //case 413 :
 
-      /* ========================================================================================================================= */
-      /* Visualization - Wireframe                                                                                                */
-      /* ========================================================================================================================= */
+void
+VisuGUI::
+OnCreateDeformedShape()
+{
+  CreatePrs3d<VISU::DeformedShape_i,VisuGUI_DeformedShapeDlg,1>(this);
+}
 
-    case 4211 :
-      ChangeViewer(1);
-      break;
+void
+VisuGUI::
+OnCreateVectors()
+{
+  CreatePrs3d<VISU::Vectors_i,VisuGUI_VectorsDlg,1>(this);
+}
 
-      /* ========================================================================================================================= */
-      /* Visualization - Surface                                                                                                  */
-      /* ========================================================================================================================= */
+void
+VisuGUI::
+OnCreateIsoSurfaces()
+{
+  CreatePrs3d<VISU::IsoSurfaces_i,VisuGUI_IsoSurfacesDlg,1>(this);
+}
 
-    case 4212 :
-      ChangeViewer(2);
-      break;
+void
+VisuGUI::
+OnCreateCutPlanes()
+{
+  CreatePrs3d<VISU::CutPlanes_i,VisuGUI_CutPlanesDlg,1>(this);
+}
 
-      /* ========================================================================================================================= */
-      /* Visualization - Points                                                                                                           */
-      /* ========================================================================================================================= */
+void
+VisuGUI::
+OnCreateCutLines()
+{
+  CreatePrs3d<VISU::CutLines_i,VisuGUI_CutLinesDlg,1>(this);
+}
 
-    case 4213 :
-      ChangeViewer(0);
-      break;
+void
+VisuGUI::
+OnCreateStreamLines()
+{
+  CreatePrs3d<VISU::StreamLines_i,VisuGUI_StreamLinesDlg,1>(this);
+}
 
-      /* ========================================================================================================================= */
-      /* Visualization - Erase                                                                                                    */
-      /* ========================================================================================================================= */
+void
+VisuGUI::
+OnCreatePlot2dView()
+{
+  CheckLock(GetCStudy(GetAppStudy(this)));
+  GetVisuGen( this )->CreateContainer();
+  updateObjBrowser();
+}
 
-    case 422 :
-      ChangeViewer(-1);
-      break;
+void
+VisuGUI::
+OnDisplayPrs()
+{
+  if(MYDEBUG) MESSAGE("VisuGUI::OnDisplayPrs");
 
-      /* ========================================================================================================================= */
-      /* 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;
+  QApplication::setOverrideCursor(Qt::waitCursor);
+  SALOME_ListIO aList;
+  SalomeApp_SelectionMgr* mgr = GetSelectionMgr(this);
+  mgr->selectedObjects(aList);
+  
+  Handle(SALOME_InteractiveObject) anIO;
+  for ( SALOME_ListIteratorOfListIO it( aList ); it.More(); it.Next() ) {
+    anIO = it.Value();
+    CORBA::Object_var anObject = GetSelectedObj( GetAppStudy(this), anIO->getEntry() );
+    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 (SVTK_ViewWindow* vw = GetViewWindow( this )) {
+         vw->highlight(anIO, 1);
+       }
+       continue;
+      }
+      // 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 );
+       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 );
+       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 );
+       continue;
+      }
+    }
+  }
+  if (SVTK_ViewWindow* vw = GetViewWindow( this )) {
+    vw->getRenderer()->ResetCameraClippingRange();
+    vw->Repaint();
+  }
+  QApplication::restoreOverrideCursor();
+}
 
-                // ---------------- For Popup in Viewer
-    case 802  : // Erase
-    case 902  : // Erase
-      visuGUI->ErasePrs();
-      break;
+void
+VisuGUI::
+OnDisplayOnlyPrs()
+{
+  OnEraseAll();
+  OnDisplayPrs();
+}
 
-    case 803  : // Display only
-    case 903  : // Display only
-      visuGUI->DisplayOnlyPrs();
+void VisuGUI::ErasePrs (CORBA::Object_ptr theObject, bool theUpdate)
+{
+  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()))
+       PlotCurve(this, aCurve, VISU::eErase );
       break;
-
-    case 901  : // Display
-      visuGUI->DisplayPrs();
+    }
+    case VISU::TCONTAINER:{
+      if(VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aBase).in()))
+       PlotContainer(this, aContainer, VISU::eErase );
       break;
-
-    case 8041 : // Object representation : Wireframe
-    case 9041 : // Object representation : Wireframe
-      visuGUI->ChangeRepresentation(WIREFRAME);
+    }
+    case VISU::TTABLE:{
+      if(VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aBase).in()))
+       PlotTable(this, aTable, VISU::eErase );
       break;
+    }
+    default:{
+      if(VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(aBase).in())){
+       ErasePrs3d( this, aPrsObject );
+       if (theUpdate) {
+         if (SVTK_ViewWindow* vw = GetViewWindow( this ))
+           vw->Repaint();
+       }
+      }
+    }
+    } // switch (aType)
+  }
+}
 
-    case 8042 : // Object representation : Surface
-    case 9042 : // Object representation : Surface
-      visuGUI->ChangeRepresentation(SURFACE);
-      break;
+void
+VisuGUI::
+OnErasePrs()
+{
+  if(MYDEBUG) MESSAGE("OnErasePrs");
 
-    case 8043 : // Object representation : Points
-    case 9043 : // Object representation : Points
-      visuGUI->ChangeRepresentation(POINTS);
-      break;
+  QApplication::setOverrideCursor(Qt::waitCursor);
+  SALOME_ListIO aList;
+  SalomeApp_SelectionMgr* mgr = GetSelectionMgr(this);
+  mgr->selectedObjects(aList);
 
-    case 8044 : // Object representation : Shrink/Unshrink
-    case 9044 : // Object representation : Shrink/Unshrink
-      visuGUI->ChangeRepresentation(SHRINK);
-      break;
+  Handle(SALOME_InteractiveObject) anIO;
+  for ( SALOME_ListIteratorOfListIO it( aList ); it.More(); it.Next() ) {
+    anIO = it.Value();
+    CORBA::Object_var anObject = GetSelectedObj( GetAppStudy(this), anIO->getEntry() );
+    ErasePrs(anObject, false);
+  }
+  if (SVTK_ViewWindow* vw = GetViewWindow( this ))
+    vw->Repaint();
+  QApplication::restoreOverrideCursor();
+}
 
-    case 8051 : // Change object color
-    case 9051 : // Change object color
-      visuGUI->ChageColor();
-      break;
+template<class TPrs3d_i, class TDlg>
+void
+EditPrs3d (SalomeApp_Module* theModule, VISU::Prs3d_i* thePrs3d)
+{
+  TPrs3d_i* aPrsObject = dynamic_cast<TPrs3d_i*>(thePrs3d);
+  if (aPrsObject) {
+    //TDlg* aDlg = new TDlg (GetDesktop(theModule), false, true);
+    TDlg* aDlg = new TDlg (GetDesktop(theModule));
+    aDlg->initFromPrsObject(aPrsObject);
+    if (aDlg->exec()) {
+      if (!(aDlg->storeToPrsObject(aPrsObject))) {
+       delete aDlg;
+        return;
+      }
+      RecreateActor(theModule, aPrsObject);
+      if (SVTK_ViewWindow* vw = GetViewWindow(theModule)) {
+       //if (vw->getRenderer()->GetActors()->GetNumberOfItems() > 0) {
+          vw->getRenderer()->ResetCameraClippingRange();
+          vw->Repaint();
+       //}
+      }
+    }
+    delete aDlg;
+  }
+}
 
-    case 8052 : // Change object opacity
-    case 9052 : // Change object opacity
-      visuGUI->ChangeOpacity();
-      break;
+void
+VisuGUI::
+OnEditPrs()
+{
+  if (CheckLock(GetCStudy(GetAppStudy(this))))
+    return;
 
-    case 8053 : // Change object line width
-    case 9053 : // Change object line width
-      visuGUI->ChangeLines();
-      break;
+  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;
 
-    case 808  : // Sweep IsoSurfaces or Cutplanes
-    case 908  : // Sweep IsoSurfaces or Cutplanes
-      visuGUI->Sweep();
-      break;
+  VISU::Prs3d_i* aPrs3d = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
+  if (!aPrs3d) return;
 
-/* ======================================================================================== */
-/* Preferences for Scalar Bar                                                               */
-/* ======================================================================================== */
-    case 51:
-      {
-       ChangeScalarBar();
-       break;
-      }
-
-/* ======================================================================================== */
-/* Preferences for Sweeping                                                               */
-/* ======================================================================================== */
-    case 52:
-      {
-       SetSweepingPreferences();
+  switch (aPrs3d->GetType()) {
+  case VISU::TMESH:
+    break;
+  case VISU::TSCALARMAP:
+    EditPrs3d<VISU::ScalarMap_i, VisuGUI_ScalarBarDlg>(this, aPrs3d);
+    break;
+  case VISU::TDEFORMEDSHAPE:
+    EditPrs3d<VISU::DeformedShape_i, VisuGUI_DeformedShapeDlg>(this, aPrs3d);
+    break;
+  case VISU::TCUTPLANES:
+    EditPrs3d<VISU::CutPlanes_i, VisuGUI_CutPlanesDlg>(this, aPrs3d);
+    /*{
+      VISU::CutPlanes_i* aPrsObject = dynamic_cast<VISU::CutPlanes_i*>(aPrs3d);
+      if (aPrsObject) {
+       VisuGUI_CutPlanesDlg* aDlg =
+          new VisuGUI_CutPlanesDlg (GetDesktop(this), false, false);
+        aDlg->initFromPrsObject(aPrsObject);
+       aDlg->show();
       }
-      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;
-       Engines::Med_Gen_var aMedGen = Engines::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();
-       }
+    }*/
+    break;
+  case VISU::TCUTLINES:
+    EditPrs3d<VISU::CutLines_i, VisuGUI_CutLinesDlg>(this, aPrs3d);
+    /*{
+      VISU::CutLines_i* aPrsObject = dynamic_cast<VISU::CutLines_i*>(aPrs3d);
+      if (aPrsObject) {
+       VisuGUI_CutLinesDlg* aDlg =
+          new VisuGUI_CutLinesDlg (GetDesktop(this), false, false);
+        aDlg->initFromPrsObject(aPrsObject);
+       aDlg->show();
       }
-      break;
-
-    default:
-      QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
-                             tr ("MSG_NOT_IMPLEMENTED"),
-                             tr ("VISU_BUT_OK") );
-      break;
-    } 
-  }catch (const SALOME::SALOME_Exception& S_ex) {
-    QtCatchCorbaException(S_ex);
-    return false;
-  }
-  catch(...) {
-    QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
-                         tr("ERR_UNKNOWN_EXCEPTION"),
-                         tr("VISU_BUT_OK") );
-    return false;
+    }*/
+    break;
+  case VISU::TISOSURFACE:
+    EditPrs3d<VISU::IsoSurfaces_i, VisuGUI_IsoSurfacesDlg>(this, aPrs3d);
+    break;
+  case VISU::TVECTORS:
+    EditPrs3d<VISU::Vectors_i, VisuGUI_VectorsDlg>(this, aPrs3d);
+    break;
+  case VISU::TSTREAMLINES:
+    EditPrs3d<VISU::StreamLines_i, VisuGUI_StreamLinesDlg>(this, aPrs3d);
+    break;
+  default:
+    return;
   }
-  return true;
-}
-
 
-/* ********************************************************************************* */
-/* Function to find Actor in Viewer                                                 */
-/* ********************************************************************************* */
+  if (SVTK_ViewWindow* vw = GetViewWindow())
+    vw->highlight(anIO, 1);
+}
 
+void
+VisuGUI::
+OnDeletePrs()
+{
+  _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
+  if (CheckLock(aCStudy))
+    return;
+  SALOMEDS::Study_var aStudy = GetDSStudy(aCStudy);
 
-VISU_Actor *VisuGUI::GetActor(int* theSelectionType){
-  VISU::Prs3d_i* aPrs3d = GetSelectedPrs3d();
-  if (!aPrs3d) return NULL;
+  Handle(SALOME_InteractiveObject) anIO;
+  CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
+  if (anIO.IsNull())
+    return;
 
-  VTKViewer_ViewFrame* vf = VisuGUI::GetVtkViewFrame();
-  if(!vf) return NULL;
+  // There is a transaction
+  SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
+  aStudyBuilder->NewCommand();
 
-  if(theSelectionType){
-    QAD_Study *aStudy = QAD_Application::getDesktop()->getActiveStudy();
-    SALOME_Selection *aSel = SALOME_Selection::Selection(aStudy->getSelection());
-    *theSelectionType = aSel->SelectionMode();
+  // is it Prs3d object ?
+  VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject).in());
+  if (aPrsObject) {
+    DeletePrs3d(this, aPrsObject, anIO);
   }
 
-  return GetActor(aPrs3d,vf);
-}
-
-/* ********************************************************************************** */
-/* 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();
-}
-
-/* ********************************************************************************** */
-/* Destructor                                                                        */
-/* Clear all tmp files used in VISU                                                  */
-/* ********************************************************************************** */
-
-VisuGUI::~VisuGUI(){
-  MESSAGE("VisuGUI::~VisuGUI");
-}
-                       
-/* ********************************************************************************** */
-/* Function ChangeViewer                                                             */
-/* Change representation of all actors                                               */
-/* ********************************************************************************** */
-
-void VisuGUI::ChangeViewer(int theType){
-  VTKViewer_ViewFrame* vf = GetVtkViewFrame();
-  if (!vf) return;
-
-  vtkActor *anActor;
-  vtkRenderer *aRen = vf->getRenderer();
-  vtkActorCollection *anActColl = aRen->GetActors();
-  for(anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL; ){
-    if(anActor->IsA("VISU_Actor")){ 
-      VISU_Actor* anVISUActor = VISU_Actor::SafeDownCast(anActor);
-      if(anVISUActor->GetVisibility() > 0)
-       if(theType > 0)
-         anVISUActor->SetRepresentation(theType); 
-       else if(theType == -1)
-         anVISUActor->VisibilityOff();
-       else
-         anVISUActor->VisibilityOn();
-    }
+  // is it Curve object ?
+  VISU::Curve_i* aCurveObject = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(anObject).in());
+  if (aCurveObject) {
+    //jfa tmp:DeleteCurve(this, aCurveObject, anIO);
   }
-}
 
-
-// -----------------------------------------------------------------------------------------
-// EVENTS
-// -----------------------------------------------------------------------------------------
-
-bool VisuGUI::OnMousePress (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
-{
-  VisuGUI::GetOrCreateVisuGUI(parent);
-  return true;
-}
-
-// ====================================================================================================================
-
-bool VisuGUI::OnMouseMove (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
-{
-  VisuGUI::GetOrCreateVisuGUI(parent);
-  return true;
+  aStudyBuilder->CommitCommand();
 }
 
-// ===================================================================================================================
 
-bool VisuGUI::OnKeyPress (QKeyEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
+void
+VisuGUI::
+OnEraseAll()
 {
-  VisuGUI::GetOrCreateVisuGUI(parent);
-  if (GetActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_VTK) // true = Viewer OCC
-    return false;
-
-  MESSAGE ( "VisuGUI::onKeyPress : " << pe->key() )
-
-  switch ( pe->key() )
-    {
-    case Key_Escape :
-      {
-         MESSAGE("--> Key : Escape")
-         return true;    
+  if (SVTK_ViewWindow* vw = GetViewWindow()) {
+    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)) {
+           anVISUActor = anVISUActor->GetParent();
+           anVISUActor->VisibilityOff();
+         }
       }
-    default :
-       return true;
-       break;
-   }
- return true;
+      vw->Repaint();
+    }
+  } else if (SPlot2d_Viewer* aPlot2d = GetPlot2dViewer(this, false)) {
+    aPlot2d->EraseAll();
+  }
 }
 
-
-
-//=====================================================================================
-// Slot-functions for presentations creation
-//=====================================================================================
-
-
-#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(); \
-   } \
- } 
-
-
-CREATEPRESENTATION(VisuGUI::CreateScalarMap);
-CREATEPRESENTATION(VisuGUI::CreateDeformedShape);
-CREATEPRESENTATION(VisuGUI::CreateVectors);
-CREATEPRESENTATION(VisuGUI::CreateIsoSurfaces);
-CREATEPRESENTATION(VisuGUI::CreateCutPlanes);
-CREATEPRESENTATION(VisuGUI::CreateCutLines);
-CREATEPRESENTATION(VisuGUI::CreateStreamLines);
-
-
-
-
-//=====================================================================================
-// function : setSettings()
-// purpose  :
-//=====================================================================================
-bool VisuGUI::setSettings(QAD_Desktop* parent)
+void VisuGUI::ChangeRepresentation (VISU::PresentationType theType)
 {
-  VisuGUI::GetOrCreateVisuGUI(parent);
-  return true;
-}
+  SVTK_ViewWindow* vw = GetViewWindow();
+  if (!vw) return;
 
-//=====================================================================================
-// function : DisplayPrs()
-// purpose  :
-//=====================================================================================
-void VisuGUI::DisplayPrs() {
-  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));
-    if(aPrsObject){
-      MESSAGE("VisuGUI::DisplayPrs : Prs3d object");
-      UpdateViewer(aPrsObject);
-      if (VTKViewer_ViewFrame* vf = GetVtkViewFrame()) {
-       vf->getRenderer()->ResetCameraClippingRange();
-       vf->Repaint();
-       vf->highlight(anIO, 1);
+  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) {
+    if (VISU_Actor* anActor = GetActor(aPrs3d, vw)) {
+      switch (theType) {
+      case VISU::SHRINK:
+        if (anActor->IsShrunk())
+          anActor->UnShrink();
+        else
+          anActor->SetShrink();
+       break;
+      default:
+       if (VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrs3d)) {
+         aMesh->SetPresentationType(theType);
+         RecreateActor(this, aMesh);
+       } else {
+         anActor->SetRepresentation(theType);
+        }
       }
-      return;
-    }
-    // is it Curve ?
-    VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(anObject));
-    if(aCurve){
-      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));
-    if(aContainer){
-      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));
-    if(aTable){
-      MESSAGE("VisuGUI::DisplayPrs : Table object");
-      PlotTable(aTable, VISU::eDisplay );
-      return;
+      vw->Repaint();
     }
   }
 }
 
-//=====================================================================================
-// function : DisplayOnlyPrs()
-// purpose  :
-//=====================================================================================
-void VisuGUI::DisplayOnlyPrs() {
-  MESSAGE("VisuGUI::DisplayOnlyPrs");
-  CORBA::Object_var anObject = GetSelectedObj();
-  if ( !CORBA::is_nil( anObject ) ) {
-    // is it Prs3d object ?
-    PortableServer::Servant aServant = VISU::GetServant(anObject);
-    if(VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(aServant)){
-      MESSAGE("VisuGUI::DisplayOnlyPrs : Prs3d object");
-      UpdateViewer(aPrsObject, true);
-      VTKViewer_ViewFrame* vf = GetVtkViewFrame();
-      if (vf) {
-       vf->getRenderer()->ResetCameraClippingRange();
-       vf->Repaint();
-      }
-    }else if(VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(aServant)){
-      MESSAGE("VisuGUI::DisplayOnlyPrs : Curve object");
-      PlotCurve(aCurve, VISU::eDisplayOnly );
-    }else if(VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(aServant)){
-      MESSAGE("VisuGUI::DisplayOnlyPrs : Container object");
-      PlotContainer(aContainer, VISU::eDisplayOnly );
-    }else if(VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(aServant)){
-      MESSAGE("VisuGUI::DisplayOnlyPrs : Table object");
-      PlotTable(aTable, VISU::eDisplayOnly );
-    }
-  }
+void
+VisuGUI::
+OnMakeSurfaceframe()
+{
+  ChangeRepresentation(VISU::SURFACEFRAME);
 }
 
-//=====================================================================================
-// function : ErasePrs()
-// purpose  :
-//=====================================================================================
-void VisuGUI::ErasePrs() {
-  MESSAGE("VisuGUI::ErasePrs");
-  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));
-    if(aPrsObject){
-      MESSAGE("VisuGUI::ErasePrs : Prs3d object");
-      ErasePrs(aPrsObject);
-      VTKViewer_ViewFrame* vf = GetVtkViewFrame();
-      if (vf) {
-       vf->Repaint();
-      }
-    }
-    // is it Curve ?
-    VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(anObject));
-    if(aCurve){
-      MESSAGE("VisuGUI::ErasePrs : Curve object");
-      PlotCurve(aCurve, VISU::eErase );
-    }
-    // is it Container ?
-    VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(anObject));
-    if(aContainer){
-      MESSAGE("VisuGUI::ErasePrs : Container object");
-      PlotContainer(aContainer, VISU::eErase );
-    }
-    // is it Table ?
-    VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(anObject));
-    if(aTable){
-      MESSAGE("VisuGUI::ErasePrs : Table object");
-      PlotTable(aTable, VISU::eErase );
-    }
-  }
+void
+VisuGUI::
+OnMakeInsideframe()
+{
+  ChangeRepresentation(VISU::INSIDEFRAME);
 }
 
-//=====================================================================================
-// function : DisplayManyPrs()
-// purpose  :
-//=====================================================================================
-void VisuGUI::DisplayManyPrs()
-{
-  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));
-         if(aPrsObject){
-           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));
-         if(aCurve){
-           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));
-         if(aContainer){
-           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));
-         if(aTable){
-           MESSAGE("VisuGUI::DisplayManyPrs : Table object");
-           PlotTable(aTable, VISU::eDisplay );
-           continue;
-         }
-       }
-      }
-    }
-  }
+void
+VisuGUI::
+OnMakeWireframe()
+{
+  ChangeRepresentation(VISU::WIREFRAME);
 }
 
-//=====================================================================================
-// function : EraseManyPrs()
-// purpose  :
-//=====================================================================================
-void VisuGUI::EraseManyPrs()
-{
-  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));
-         if(aPrsObject){
-           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));
-         if(aCurve){
-           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));
-         if(aContainer){
-           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));
-         if(aTable){
-           MESSAGE("VisuGUI::EraseManyPrs : Table object");
-           PlotTable(aTable, VISU::eErase );
-           continue;
-         }
-       }
-      }
-    }
-  }
+void
+VisuGUI::
+OnMakeSurface()
+{
+  ChangeRepresentation(VISU::SHADED);
 }
 
-//=====================================================================================
-// function : RecreateActor()
-// purpose  :
-//=====================================================================================
-void VisuGUI::RecreateActor(VISU::Prs3d_i* thePrs) {
-  QApplication::setOverrideCursor(Qt::waitCursor);
-  thePrs->Update();
-  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);
-    }
-  QApplication::restoreOverrideCursor();
+void
+VisuGUI::
+OnMakePoints()
+{
+  ChangeRepresentation(VISU::POINT);
 }
 
-
-//=====================================================================================
-// 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() )  { \
-         aDlg->storeToPrsObject(aPrsObject); \
-         RecreateActor(aPrsObject); \
-         /*RepaintCurrentView();*/ \
-         VTKViewer_ViewFrame* vf = GetVtkViewFrame(); \
-         if (vf) { \
-           if ( vf->getRenderer()->GetActors()->GetNumberOfItems () > 0 ) { \
-                 vf->getRenderer()->ResetCameraClippingRange(); \
-                vf->onViewFitAll(); \
-                vf->Repaint(); \
-             }\
-         } \
-       } \
-       delete aDlg; \
-      } \
-    }
-
-
-void VisuGUI::EditPrs() {
-  VISU::Prs3d_i* aPrs3d = GetSelectedPrs3d();
-
-  switch (aPrs3d->GetType()) {
-  case VISU::TMESH: // Mesh 13
-    break;
-
-  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);
-    break;
-
-  case VISU::TCUTLINES: // Cut planes 42
-    EDITPRS(VISU::CutLines_i, VisuGUI_CutLinesDlg);
-    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;
-
-  case VISU::TSTREAMLINES:
-    EDITPRS(VISU::StreamLines_i, VisuGUI_StreamLinesDlg);
-  }
+void
+VisuGUI::
+OnMakeShrink()
+{
+  ChangeRepresentation(VISU::SHRINK);
 }
 
+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;
 
-//=====================================================================================
-// function : EditScalarBar()
-// purpose  :
-//=====================================================================================
-void VisuGUI::EditScalarBar() {
-  VISU::Prs3d_i* aPrs3d = GetSelectedPrs3d();
-  VISU::ScalarMap_i* aPrsObject = dynamic_cast<VISU::ScalarMap_i*>(aPrs3d);
-  if (aPrsObject) {
-    VisuGUI_ScalarBarDlg* aDlg = new VisuGUI_ScalarBarDlg(false);
-    aDlg->initFromPrsObject(aPrsObject);
-    if ( aDlg->exec() )  {
-      aDlg->storeToPrsObject(aPrsObject);
-      RecreateActor(aPrsObject);
-      
-      VTKViewer_ViewFrame* vf = GetVtkViewFrame();
-      if (vf)
-       vf->Repaint();
-      
-      if (aDlg->isToSave())
-       aDlg->storeToResources();
-    }
-    delete aDlg;
-  }
-  
-}
-
+  VISU::Prs3d_i* aPrs3d = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
+  if (!aPrs3d) return;
 
-//=====================================================================================
-// 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;
-  }
+  SVTK_ViewWindow* vw = GetViewWindow();
+  if (!vw) 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
-  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());
-  }
-#ifdef CHECKTIME
-  timer.Stop();
-  MESSAGE("VisuGUI::CreateMesh() - CREATE MESH");
-  timer.Show();
-#endif
+  VISU_Actor* anActor = GetActor(aPrs3d, vw);
+  if (!anActor) return;
 
-  QApplication::restoreOverrideCursor();
-  VISU::Mesh_i* pPresent = NULL;
-  if(!CORBA::is_nil(aMesh)) 
-    pPresent = dynamic_cast<VISU::Mesh_i*>(VISU::GetServant(aMesh));
-  if (pPresent == NULL) {
-    QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"), 
-                           tr ("ERR_CANT_BUILD_PRESENTATION"), 
-                           tr ("VISU_BUT_OK") ); 
+  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;
   }
 
-  if(VTKViewer_ViewFrame* vf = GetVtkViewFrame()){
-    VISU_Actor *anActor = pPresent->CreateActor();
-    if (! anActor ) {
-      QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"), 
-                             tr ("ERR_CANT_CREATE_ACTOR"), 
-                             tr ("VISU_BUT_OK") ); 
-      return;
+  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);
     }
-#ifdef CHECKTIME
-    Utils_Timer timer;
-    timer.Start();
-#endif
-    vf->AddActor(anActor);
-    vf->getRenderer()->ResetCameraClippingRange();
-    vf->onViewFitAll();
-#ifdef CHECKTIME
-    timer.Stop();
-    MESSAGE("VisuGUI::CreateMesh() - DISPLAY MESH");
-    timer.Show();
-#endif
+    RecreateActor(this, aPrs3d);
   }
-  //GetActiveStudy()->updateObjBrowser(); //not necessary
-  GetDesktop()->putInfo("Ready");
 }
 
-//=====================================================================================
-// function : CreateManyMesh()
-// purpose  :
-//=====================================================================================
-void VisuGUI::CreateManyMesh()
+void
+VisuGUI::
+OnChangeWireframeColor()
 {
-  if (checkLock(GetStudyDocument())) 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;
 
-  SALOME_Selection* Sel = SALOME_Selection::Selection(GetActiveStudy()->getSelection());
-  SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
-  for ( ; It.More(); It.Next() ) {
-  SALOMEDS::SObject_var aSObject  = GetActiveStudy()->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));
-  VISU_Actor *anActor = pPresent->CreateActor();
-  if (! anActor ) return;
-  if(VTKViewer_ViewFrame* vf = GetVtkViewFrame()){
-    vf->AddActor(anActor);
-    vf->getRenderer()->ResetCameraClippingRange();
-    vf->onViewFitAll();
-  }
-  }
-  GetDesktop()->putInfo("Ready");
-}
+  VISU::Prs3d_i* aPrs3d = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
+  if (!aPrs3d) return;
 
-//=====================================================================================
-// function : ChangeRepresentation()
-// purpose  :
-//=====================================================================================
+  SVTK_ViewWindow* vw = GetViewWindow();
+  if (!vw) return;
 
-static void ShrinkMesh(VISU_Actor *theActor){
-  if(theActor->isShrunk()) 
-    theActor->unShrink();
-  else
-    theActor->setShrink(0.8);
-}
+  VISU_Actor* anActor = GetActor(aPrs3d, vw);
+  if (!anActor) return;
 
-void VisuGUI::ChangeRepresentation(RepresentType theType) {
-  if(VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d()){
-    if(VISU_Actor* anActor = GetActor(aPrsObject)){
-      switch (theType) {
-      case POINTS:
-      case WIREFRAME:
-      case SURFACE:
-       anActor->SetRepresentation(theType);
-       break;
-      case SHRINK:
-       ShrinkMesh(anActor);
-       break;
-      }
-      if (VTKViewer_ViewFrame* vf = GetVtkViewFrame()) 
-       vf->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::MakeWireframe() {
-  ChangeRepresentation(WIREFRAME);
-}
-
-
-void VisuGUI::MakeSurface() {
-  ChangeRepresentation(SURFACE);
-}
+void
+VisuGUI::
+OnChangeOpacity()
+{
+  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;
 
-void VisuGUI::MakePoints() {
-  ChangeRepresentation(POINTS);
-}
+  SVTK_ViewWindow* vw = GetViewWindow();
+  if (!vw) return;
 
+  VISU_Actor* anActor = GetActor(aPrsObject, vw);
+  if (!anActor) return;
 
-void VisuGUI::MakeShrink() {
-  ChangeRepresentation(SHRINK);
-}
+  VisuGUI_CursorDlg* CursorDlg =
+    new VisuGUI_CursorDlg (GetDesktop(this), tr("DLG_OPACITY_TITLE"), TRUE);
 
+  CursorDlg->Comment1->setText(tr("DLG_OPACITY_CMT1"));
+  CursorDlg->Comment2->setText(tr("DLG_OPACITY_CMT2"));
+  CursorDlg->SpinBox1->setMinValue(0);
+  CursorDlg->SpinBox1->setMaxValue(100);
 
+  float oldopac = anActor->GetOpacity();
+  int intopac = int(oldopac*100. + 0.5);
+  CursorDlg->SpinBox1->setValue(intopac);
 
-//=====================================================================================
-// 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;
-  return dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject));
+  int ret = CursorDlg->exec();
+  if (ret == 1) {
+    intopac = CursorDlg->SpinBox1->value();
+    float newopac = intopac/100.;
+    anActor->SetOpacity(newopac);
+  }
+  delete CursorDlg;
 }
 
-void VisuGUI::ChageColor() {
-  VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d();
-  if(!aPrsObject) return;
+void
+VisuGUI::
+OnChangeLines()
+{
+  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* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
+  if (!aPrsObject) return;
 
-void VisuGUI::ChangeOutlineColor() {
-  VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d();
-  if(!aPrsObject) return;
+  SVTK_ViewWindow* vw = GetViewWindow();
+  if (!vw) return;
 
-  VISUMesh_Actor* anActor = dynamic_cast<VISUMesh_Actor*>(GetActor(aPrsObject));
+  VISU_Actor* anActor = GetActor(aPrsObject, vw);
   if (!anActor) return;
-  NewOutlineColor(anActor);
-}
 
+  VisuGUI_CursorDlg* CursorDlg =
+    new VisuGUI_CursorDlg (GetDesktop(this), tr("DLG_LINEWIDTH_TITLE"), TRUE);
 
-void VisuGUI::ChangeOpacity() {
-  VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d();
-  if(!aPrsObject) return;
-
-  VISU_Actor* anActor = GetActor(aPrsObject);  
-  if (!anActor) return;
-  NewOpacity(anActor);
-}
-
+  CursorDlg->Comment1->setText("DLG_LINEWIDTH_CMT1");
+  CursorDlg->Comment2->setText("DLG_LINEWIDTH_CMT2");
+  CursorDlg->SpinBox1->setMinValue(1);
+  CursorDlg->SpinBox1->setMaxValue(10);
 
-void VisuGUI::ChangeLines() {
-  VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d();
-  if(!aPrsObject) return;
+  float oldlwid = anActor->GetLineWidth();
+  int intlwid = int(oldlwid);
+  CursorDlg->SpinBox1->setValue(intlwid);
 
-  VISU_Actor* anActor = GetActor(aPrsObject);  
-  if (!anActor) return;
-  NewLinewidth(anActor);
-}
-void VisuGUI::PlotTable( VISU::Table_i* table, int theDisplaying )
-{
-  VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() );
-  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 ) );
-           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( strdup( theCurve->GetHorTitle().c_str() ) );
-               //plotCurve->setVerTitle( strdup( theCurve->GetVerTitle().c_str() ) );
-               plotCurve->setVerTitle( strdup( theCurve->GetName() ) );
-               plotCurve->setHorUnits( strdup( theCurve->GetHorUnits().c_str() ) );
-               plotCurve->setVerUnits( strdup( theCurve->GetVerUnits().c_str() ) );
-               /* - DATA NOT UPDATED */
-               if ( !plotCurve->isAutoAssign() ) {
-                 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 );
-               }
-             }
-           }
-         }
-       }
-      }
-      aPlot->Repaint();
-    }
-  }
-}
-void VisuGUI::PlotCurve( VISU::Curve_i* theCurve, int theDisplaying )
-{
-  VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() );
-  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( strdup( theCurve->GetHorTitle().c_str() ) );
-       //plotCurve->setVerTitle( strdup( theCurve->GetVerTitle().c_str() ) );
-       plotCurve->setVerTitle( strdup( theCurve->GetName() ) );
-       plotCurve->setHorUnits( strdup( theCurve->GetHorUnits().c_str() ) );
-       plotCurve->setVerUnits( strdup( theCurve->GetVerUnits().c_str() ) );
-       /* DATA NOT UPDATED */
-       if ( !plotCurve->isAutoAssign() ) {
-         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 );
-       }
-      }
-    }
-    aPlot->Repaint();
-  }
-}
-void VisuGUI::PlotContainer( VISU::Container_i* container, int theDisplaying )
-{
-  VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() );
-  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( strdup(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( strdup( theCurve->GetHorTitle().c_str() ) );
-              //plotCurve->setVerTitle( strdup( theCurve->GetVerTitle().c_str() ) );
-              plotCurve->setVerTitle( strdup( theCurve->GetName() ) );
-             plotCurve->setHorUnits( strdup( theCurve->GetHorUnits().c_str() ) );
-             plotCurve->setVerUnits( strdup( theCurve->GetVerUnits().c_str() ) );
-             /* - DATA NOT UPDATED */
-             if ( !plotCurve->isAutoAssign() ) {
-               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 );
-             }
-           }
-         }
-       }
-      }
-    }
-    aPlot->Repaint();
+  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() {
-  VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() );
-  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 ) );
+       VISU::Table_i* table = dynamic_cast<VISU::Table_i*>( VISU::GetServant(aTable).in() );
        if ( table ) {
-         SO = GetActiveStudy()->getStudyDocument()->FindObjectID( table->GetObjectEntry() );
+         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() );
   }
-  SALOMEDS::GenericAttribute_var anAttr;
-  if ( SO->_is_nil() || ( !SO->FindAttribute( anAttr, "AttributeTableOfInteger" ) 
-                      && !SO->FindAttribute( anAttr, "AttributeTableOfReal" ) ) ) 
+
+  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();
 }
 
-/*!
-  Slot : opens Table view : for Table object or SObject with table attribute selected
-*/
-void VisuGUI::CreateTable() {
-  VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() );
-  SALOME_Selection* aSel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
-  if( aSel->IObjectCount() !=1 )
+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();
+  }
+}
+
+void
+VisuGUI::
+OnDeleteObject()
+{
+  _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
+  if (CheckLock(aCStudy))
+    return;
+  SALOMEDS::Study_var aStudy = GetDSStudy(aCStudy);
+
+  Handle(SALOME_InteractiveObject) anIO;
+  CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
+  if (anIO.IsNull() || !anIO->hasEntry())
     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 );
-      SALOMEDS::GenericAttribute_var anAttr;
-      if(!aCutLines->_is_nil() ||
-        aSObject->FindAttribute( anAttr, "AttributeTableOfInteger") ||
-        aSObject->FindAttribute( anAttr, "AttributeTableOfReal" ) ){
-       GetVisuGen()->CreateTable(aSObject->GetID());
-       GetActiveStudy()->updateObjBrowser();
+  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 = aStudy->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());
+              DeletePrs3d(this, pPrs3d, NULL);
+           }
+           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());
+              //jfa tmp:DeleteCurve(this, pCurve, NULL);
+            }
+            break;
+          }
+        }
       }
     }
+    aStudyBuilder->RemoveObjectWithChildren(aSObject);
+    aStudyBuilder->CommitCommand();
+    //jfa tmp:GetActiveStudy()->unHighlightAll();
+    updateObjBrowser(true);
   }
 }
 
-/*!
-  Opens dialog box for curves creation. Acts only for selected SObject with table attribute.
-*/
-void VisuGUI::PlotData() {
-  VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() );
-  SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
-  if( Sel->IObjectCount() !=1 )
-    return;
-  CORBA::Object_var anObject = GetSelectedObj();
-  SALOMEDS::SObject_var SO;
+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 ) );
+
   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 ) );
+       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 ( !SO->_is_nil() && ( SO->FindAttribute( anAttr, "AttributeTableOfInteger" ) ||
-                                  SO->FindAttribute( anAttr, "AttributeTableOfReal" ) ) ) {
+         _PTR(SObject) SO = aStudy->FindObjectID( table->GetObjectEntry() );
+         if ( IsSObjectTable(SO) ) {
            // get name of SObject
            if ( SO->FindAttribute( anAttr, "AttributeName" ) ) {
-             aName = SALOMEDS::AttributeName::_narrow( anAttr );
-             SOName = strdup( aName->Value() );
+             aName = anAttr;
+             SOName = QString( aName->Value().c_str() );
            }
-           Plot2d_SetupPlot2dDlg* dlg = new Plot2d_SetupPlot2dDlg( SO, QAD_Application::getDesktop() );
+           SPlot2d_SetupPlot2dDlg* dlg = new SPlot2d_SetupPlot2dDlg( SO, GetDesktop( this ) );
            if ( dlg->exec() == QDialog::Accepted ) {
-             if ( !isStudyLocked( GetActiveStudy()->getStudyDocument() ) ) {
+             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()->CreateContainer();
+               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 ) );
+                   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 );
+                       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 ) );
+                         VISU::Curve_i* pCrv = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aNewCurve).in());
                          if ( pCrv ) {
                            bool isAuto;
                            int  marker, line, lineWidth;
@@ -1708,21 +1316,19 @@ void VisuGUI::PlotData() {
                          }
                        }
                      }
-                     GetActiveStudy()->updateObjBrowser( true );
-                     PlotContainer( pContainer, VISU::eDisplay );
+                     updateObjBrowser();
+                     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
-               Plot2d_CurveContainer container;
+               QPtrList<Plot2d_Curve> container;
                dlg->getCurves( container );
                if ( !container.isEmpty() ) {
-                 ((Plot2d_ViewFrame*)(GetActiveStudy()->getActiveStudyFrame()->
-                                      getRightFrame()->getViewFrame()))->displayCurves( container, true );
-                 ((Plot2d_ViewFrame*)(GetActiveStudy()->getActiveStudyFrame()->
-                                      getRightFrame()->getViewFrame()))->setTitle( SOName );
+                 GetPlot2dViewer( this )->getActiveViewFrame()->displayCurves( container, true );
+                 GetPlot2dViewer( this )->getActiveViewFrame()->setTitle( SOName );
                }
              }
            }
@@ -1732,41 +1338,35 @@ void VisuGUI::PlotData() {
       }
     }
   }
-  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() );
-    if ( !SO->_is_nil() && ( SO->FindAttribute( anAttr, "AttributeTableOfInteger" ) ||
-                            SO->FindAttribute( anAttr, "AttributeTableOfReal" ) ) ) {
+    SO = aStudy->FindObjectID( anIO->getEntry() );
+    if ( IsSObjectTable(SO) ) {
       // get name of SObject
       if ( SO->FindAttribute( anAttr, "AttributeName" ) ) {
-       aName = SALOMEDS::AttributeName::_narrow( anAttr );
-       SOName = strdup( aName->Value() );
+       aName = anAttr;
+       SOName = QString( aName->Value().c_str() );
       }
-      Plot2d_SetupPlot2dDlg* dlg = new Plot2d_SetupPlot2dDlg( SO, QAD_Application::getDesktop() );
+      SPlot2d_SetupPlot2dDlg* dlg = new SPlot2d_SetupPlot2dDlg( SO, GetDesktop( this ) );
       if ( dlg->exec() == QDialog::Accepted ) {
-       if ( !isStudyLocked( GetActiveStudy()->getStudyDocument() ) ) {
+       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()->CreateTable( SO->GetID() );
-           CORBA::Object_var aContainer = GetVisuGen()->CreateContainer();
+         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 ) );
-             VISU::Container_i* pContainer = dynamic_cast<VISU::Container_i*>( VISU::GetServant( 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 );
+                 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 ) );
+                   VISU::Curve_i* pCrv = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aNewCurve).in());
                    if ( pCrv ) {
                      bool isAuto;
                      int  marker, line, lineWidth;
@@ -1781,1664 +1381,998 @@ void VisuGUI::PlotData() {
                    }
                  }
                }
-               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 );
-           }
-         }
-       }
-      }
-      delete dlg;
-    }
-  }
-}
-/*!
-  Slot : Opens "Setup curve" dialog to set curve properties : for Curve object selected
-*/
-void VisuGUI::CurveProperties() {
-  VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() );
-  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 )) return;
-
-  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 ) ) {
-      VISU::Curve_i* curve = dynamic_cast<VISU::Curve_i*>( VISU::GetServant( aCurve ) );
-      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 );
-               }
-             }
-           }
-         }
-       }
-      } 
-    }
-  }
-}
-
-
-/*!
-  Slot : Clears container contents : for Container object selected
-*/
-void VisuGUI::ClearContainer() {
-  VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() );
-  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 )) 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 ) ) {
-      VISU::Container_i* container = dynamic_cast<VISU::Container_i*>( VISU::GetServant( aCnt ) );
-      if ( container && container->GetNbCurves() > 0 && !isStudyLocked( GetActiveStudy()->getStudyDocument() ) ) {
-       container->Clear();
-       GetActiveStudy()->updateObjBrowser();
-      }
-    }
-  }
-}
-
-
-void VisuGUI::DeletePrs() {
-  DeletePresentation(GetSelectedPrs3d());
-}
-
-
-void VisuGUI::SaveViewParams()
-{
-  if (checkLock(GetStudyDocument())) return;
-  VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() );
-  SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
-  if ( Sel->IObjectCount() > 1 || GetActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_VTK ) 
-    return;
-  VISU::ViewManager_var aVM = GetVisuGen()->GetViewManager();
-  if(!CORBA::is_nil(aVM.in())){
-    VISU::View_var aView = aVM->GetCurrentView();
-    if(!CORBA::is_nil(aView.in())){
-      VISU::View3D_var aView3D = VISU::View3D::_narrow(aView);
-      if(CORBA::is_nil(aView3D.in())) return;
-      if ( Sel->IObjectCount()  == 0 ) {
-       // Save view parameters by new name
-       aView3D->SaveViewParams( 0 );
-       GetActiveStudy()->updateObjBrowser( true );
-      }else{
-       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){
-         aView3D->SaveViewParams( anIO->getName() );
-         GetActiveStudy()->updateObjBrowser( true );
-       }
-      }
-    }
-  }
-}
-
-
-void VisuGUI::RestoreViewParams()
-{
-  VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() );
-  SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
-  if ( Sel->IObjectCount() > 1 || GetActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_VTK ) 
-    return;
-  VISU::ViewManager_var aVM = GetVisuGen()->GetViewManager();
-  if(!CORBA::is_nil(aVM.in())){
-    VISU::View_var aView = aVM->GetCurrentView();
-    if(!CORBA::is_nil(aView.in())){
-      VISU::View3D_var aView3D = VISU::View3D::_narrow(aView);
-      if(CORBA::is_nil(aView3D.in())) return;
-      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)
-       aView3D->RestoreViewParams( anIO->getName() );
-    }
-  }
-}
-
-//=====================================================================================
-// 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);
-
-    SALOME_Selection* aSel = SALOME_Selection::Selection(GetActiveStudy()->getSelection());
-    aSel->RemoveIObject(anIO, 0);
-
-    GetActiveStudy()->updateObjBrowser( true );
-  }
-}
-
-
-//=====================================================================================
-// function : Sweep()
-// purpose  :
-//=====================================================================================
-void VisuGUI::Sweep() {
-  VISU::ScalarMap_i* aPrsObject = dynamic_cast<VISU::ScalarMap_i*>(GetSelectedPrs3d());
-  if (!aPrsObject) return;
-
-  VTKViewer_ViewFrame* vf = VisuGUI::GetVtkViewFrame();
-  if(!vf) return;
-
-  int aTemp=100000;
-  QString aTempoStr = QAD_CONFIG->getSetting("Visu:SweepTempo");
-  if ( !aTempoStr.isEmpty() )
-    aTemp = int(1.E6*(aTempoStr.toFloat()));
-
-  int aCycles=1;
-  QString aCyclesStr = QAD_CONFIG->getSetting("Visu:SweepCycles");
-  if ( !aCyclesStr.isEmpty() )
-    aCycles = aCyclesStr.toInt();
-
-  int aSteps=40;
-  QString aStepsStr = QAD_CONFIG->getSetting("Visu:SweepSteps");
-  if ( !aStepsStr.isEmpty() )
-    aSteps = aStepsStr.toInt();
-
-  VISU_Actor* aActor = GetActor(aPrsObject);
-  if (!aActor) return;
-  
-  if (!aActor->GetVisibility()) {
-    aActor->VisibilityOn();
-  }
-
-  QApplication::setOverrideCursor( Qt::waitCursor );
-  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);
-    }
-  }
-  QApplication::restoreOverrideCursor();
-}
-
-
-
-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());
-  for (; It.More(); It.Next()) {
-    SALOMEDS::SObject_var aSObject  = GetStudyDocument()->FindObjectID( It.Value()->getEntry() ); 
-    if (aSObject->_is_nil()) 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) aAnimationDlg->show();
-  else delete aAnimationDlg;
-}
-
-
-void VisuGUI::ImportMedField() {
-  if (checkLock(GetStudyDocument())) return;
-  VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() );
-  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();
-}
-/*
-void VisuGUI::ImportMedMesh() {
-  VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() );
-  SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
-  if ( Sel->IObjectCount() != 1 )
-    return;
-  string aComment;
-  Handle(SALOME_InteractiveObject) anIO;    
-  CORBA::Object_var anObject = GetSelectedObj( aComment,anIO, GetActiveStudy());
-  if ( !CORBA::is_nil( anObject ) ) {
-    SALOME_MED::MESH_ptr aMesh = SALOME_MED::MESH::_narrow( anObject );
-    if( !CORBA::is_nil( aMesh ) ) {
-      GetVisuGen->ImportMedMesh( aMesh );
-      GetActiveStudy()->updateObjBrowser( true );
-    }
-    SALOME_MED::SUPPORT_ptr aSupport = SALOME_MED::SUPPORT::_narrow( anObject );
-    if( !CORBA::is_nil( aSupport ) ) {
-      GetVisuGen->ImportMedSupport( aSupport );
-      GetActiveStudy()->updateObjBrowser( true );
-    }
-  }
-}
-*/
-//=====================================================================================
-// functions : Rename()
-// purpose  :
-//=====================================================================================
-void VisuGUI::Rename() {
-  if (checkLock(GetStudyDocument())) return;
-  VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() );
-  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::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 ) );
-      }
-    }
-  }
-
-  //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());
-    }
-  }
-}
-
-
-//=====================================================================================
-// function : CopyPresentation()
-// purpose  :
-//=====================================================================================
-void VisuGUI::CopyPresentation(){
-  if (checkLock(GetStudyDocument())) return;
-  VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d();
-  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:
-    {
-      VISU::ScalarMap_i* aScalarPrs = dynamic_cast<VISU::ScalarMap_i*>(aPrsObject);
-      VISU::ScalarMap_i* aSameScalar = new VISU::ScalarMap_i(aScalarPrs->GetResult());
-      aSameScalar->SameAs(aScalarPrs);
-      UpdateViewer(aSameScalar);
-    }    
-    break;
-   case VISU::TDEFORMEDSHAPE:
-    {
-      VISU::DeformedShape_i* aDefPrs = dynamic_cast<VISU::DeformedShape_i*>(aPrsObject);
-      VISU::DeformedShape_i* aSameDeformed = new VISU::DeformedShape_i(aDefPrs->GetResult());
-      aSameDeformed->SameAs(aDefPrs);
-      UpdateViewer(aSameDeformed);
-    }    
-    break;
-   case VISU::TCUTPLANES:
-    {
-      VISU::CutPlanes_i* aCutPrs = dynamic_cast<VISU::CutPlanes_i*>(aPrsObject);
-      VISU::CutPlanes_i* aSameCut = new VISU::CutPlanes_i(aCutPrs->GetResult());
-      aSameCut->SameAs(aCutPrs);
-      UpdateViewer(aSameCut);
-    }    
-    break;
-    case VISU::TCUTLINES:
-    {
-      VISU::CutLines_i* aCutPrs = dynamic_cast<VISU::CutLines_i*>(aPrsObject);
-      VISU::CutLines_i* aSameCut = new VISU::CutLines_i(aCutPrs->GetResult());
-      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());
-      aSameIso->SameAs(aIsoPrs);
-      UpdateViewer(aSameIso);
-    }    
-    break;
-   case VISU::TSTREAMLINES:
-    {
-      VISU::StreamLines_i* aLinesPrs = dynamic_cast<VISU::StreamLines_i*>(aPrsObject);
-      VISU::StreamLines_i* aSameLines = new VISU::StreamLines_i(aLinesPrs->GetResult());
-      aSameLines->SameAs(aLinesPrs);
-      UpdateViewer(aSameLines);
-    }    
-    break;
-   case VISU::TVECTORS:
-    {
-      VISU::Vectors_i* aVectorsPrs = dynamic_cast<VISU::Vectors_i*>(aPrsObject);
-      VISU::Vectors_i* aSameVectors = new VISU::Vectors_i(aVectorsPrs->GetResult());
-      aSameVectors->SameAs(aVectorsPrs);
-      UpdateViewer(aSameVectors);
-    }    
-    break;
- }
-  GetActiveStudy()->updateObjBrowser();
-}
-
-//=====================================================================================
-// function : InfoOnPoint() [ slot ] 
-// purpose  :
-//=====================================================================================
-void VisuGUI::InfoOnPoint(){
-  SALOME_Selection *aSel = SALOME_Selection::Selection(GetActiveStudy()->getSelection());
-  int aTypeMode = aSel->SelectionMode();
-  if ( aTypeMode == SelectionPoint ){
-    if(VISU::Prs3d_i* aPrs3d = GetSelectedPrs3d()){
-      vtkDataSet* aDataSet = aPrs3d->GetMapper()->GetInput();
-      VisuGUI_Selection::PickingPoint( GetActiveStudy(), aDataSet);
-    }
-  }else
-    QAD_MessageBox::warn1( GetDesktop(), 
-                          tr ("WARNING"),
-                          tr ("ERR_WRONG_SELECTION_MODE"),
-                          tr ("VISU_BUT_OK") );
-}
-
-//=====================================================================================
-// function : InfoOnCell() [ slot ] 
-// purpose  :
-//=====================================================================================
-void VisuGUI::InfoOnCell(){
-  SALOME_Selection *aSel = SALOME_Selection::Selection(GetActiveStudy()->getSelection());
-  int aTypeMode = aSel->SelectionMode();
-  if( aTypeMode == SelectionCell){
-    if(VISU::Prs3d_i* aPrs3d = GetSelectedPrs3d()){
-      vtkDataSet* aDataSet = aPrs3d->GetMapper()->GetInput();
-      VisuGUI_Selection::PickingCell( GetActiveStudy(), aDataSet);
-    }
-  }else
-    QAD_MessageBox::warn1( GetDesktop(), 
-                          tr ("WARNING"),
-                          tr ("ERR_WRONG_SELECTION_MODE"),
-                          tr ("VISU_BUT_OK") );
-}
-
-//=====================================================================================
-// function : SelectPoint() [ slot ] 
-// purpose  :
-//=====================================================================================
-void VisuGUI::SelectPoint(){
-  SALOME_Selection *aSel = SALOME_Selection::Selection(GetActiveStudy()->getSelection());
-  if ( aSel->SelectionMode() != SelectionPoint ) {
-    QAD_MessageBox::warn1( GetDesktop(), 
-                          tr ("WARNING"),
-                          tr ("ERR_WRONG_SELECTION_MODE"),
-                          tr ("VISU_BUT_OK") );
-    return;
-  }
-  Handle(SALOME_InteractiveObject) anIO;
-  if(VISU::Prs3d_i* aPrs3d = GetSelectedPrs3d(&anIO)){
-    bool ok = FALSE;
-    int anId = SALOMEGUI_SetValueDlg::getInteger( tr("Point selection"),
-                                                tr("Point number:" ), 
-                                                0,
-                                                &ok, 
-                                                GetDesktop());
-    vtkDataSet *aDataSet = aPrs3d->GetMapper()->GetInput();
-    int aMaxId = aDataSet->GetNumberOfPoints();
-    if (ok && 0 < anId && anId <= aMaxId )
-      VisuGUI_Selection::Highlight( GetActiveStudy(), anIO, anId );
-  }
-}
-
-//=====================================================================================
-// function : SelectCell() [ slot ] 
-// purpose  :
-//=====================================================================================
-void VisuGUI::SelectCell(){
-  SALOME_Selection *aSel = SALOME_Selection::Selection(GetActiveStudy()->getSelection());
-  if ( aSel->SelectionMode() != SelectionCell) {
-    QAD_MessageBox::warn1( GetDesktop(), 
-                          tr ("WARNING"),
-                          tr ("ERR_WRONG_SELECTION_MODE"),
-                          tr ("VISU_BUT_OK") );
-    return;
-  }
-  Handle(SALOME_InteractiveObject) anIO;
-  if(VISU::Prs3d_i* aPrs3d = GetSelectedPrs3d(&anIO)){
-    bool ok = FALSE;
-    int anId = SALOMEGUI_SetValueDlg::getInteger( tr("Cell selection"),
-                                                tr("Cell number:" ), 
-                                                0,
-                                                &ok, 
-                                                GetDesktop());
-    vtkDataSet *aDataSet = aPrs3d->GetMapper()->GetInput();
-    int aMaxId = aDataSet->GetNumberOfCells();
-    if (ok && 0 < anId && anId <= aMaxId )
-      VisuGUI_Selection::Highlight( GetActiveStudy(), anIO, anId );
-  }
-}
-
-//=====================================================================================
-// function : DefinePopup()
-// purpose  :
-//=====================================================================================
-void VisuGUI::DefinePopup( QString & theContext, QString & theParent, QString & theObject )
-{
-  VisuGUI::GetOrCreateVisuGUI(QAD_Application::getDesktop());
-  theObject = "";
-  theContext = "";
-}
-
-
-//=====================================================================================
-// function : checkHomoSelection()
-// purpose  : 
-//=====================================================================================
-enum { homoNone=0, homoCurves, homoPresentations, homoPresentable, homoAnimatable, homoOther };
-int VisuGUI::checkHomoSelection()
-{
-  int selMode = homoNone;
-  SALOME_Selection* Sel = SALOME_Selection::Selection(GetActiveStudy()->getSelection());
-  SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
-  for ( ; It.More(); It.Next() ) {
-    int selNext = homoOther;
-    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;
-             }
-           }
-         }
-       }
-      }
-    }
-    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++;
-  }
-  return cnt;
-}
-
-//=====================================================================================
-// function : CustomPopup()
-// purpose  :
-//=====================================================================================
-bool VisuGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* thePopup, const QString & theContext,
-                         const QString & theParent, const QString & theObject)
-{
-  int isViewer = (theParent.compare("ObjectBrowser") != 0), initId = isViewer? 800: 900;
-  VisuGUI::GetOrCreateVisuGUI(parent);
-  QAD_ResourceMgr* rmgr = parent->createResourceManager();
-
-  bool isVTKViewer = (GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK);
-  thePopup->clear();
-
-  SALOME_Selection* Sel = SALOME_Selection::Selection(GetActiveStudy()->getSelection());
-  if ( Sel->IObjectCount() == 0 ) {
-    if ( theParent == "Viewer" && isVTKViewer)
-      // Available only for VTK viewer
-      thePopup->insertItem( "Save view parameters", visuGUI, SLOT( SaveViewParams() ) );
-    return false;
-  }
-
-  if( Sel->IObjectCount() > 1 ) {
-    int selMode = checkHomoSelection();
-    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 () ) );
-      }
-    }
-    else if ( selMode == homoPresentations ) {
-      if (isVTKViewer) {
-       thePopup->insertItem( "Display", visuGUI, SLOT( DisplayManyPrs() ) );
-       thePopup->insertItem( "Erase", visuGUI, SLOT( EraseManyPrs () ) );
-      }
-    }
-    else if ( selMode == homoPresentable ) {
-      thePopup->insertItem("Create Presentations", visuGUI, SLOT(CreateManyMesh()));    
-    }
-    else if ( selMode == homoAnimatable ) {
-      thePopup->insertItem( "Animation...", visuGUI, SLOT( TimeAnimation() ) );
-    }
-    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();
-      MESSAGE("VisuGUI::CustomPopup - VISU object :: "<<aType);
-      switch (aType) {
-      case VISU::TVISUGEN:
-       thePopup->insertItem("Import From File", visuGUI, SLOT(ImportFromFile()));
-       break;
-
-      case VISU::TRESULT:
-       //thePopup->insertItem("Create Mesh", visuGUI, SLOT(CreateMesh()));    
-       //thePopup->insertItem("Export To File", visuGUI, SLOT(ExportToFile()));    
-       //thePopup->insertItem("Delete", visuGUI, SLOT(DeletePrs()));
-       break;
-       
-      case VISU::TTABLE:
-       thePopup->insertItem( "Show Table",    visuGUI, SLOT( ShowTable() ) );
-       thePopup->insertItem( "Create Curves", visuGUI, SLOT( PlotData() ) );
-       if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
-         if ( GetNbChildren( aSObject, false ) > 0 ) {
-           thePopup->insertItem( "Display",      visuGUI, SLOT( DisplayPrs() ) );
-           thePopup->insertItem( "Erase",        visuGUI, SLOT( ErasePrs () ) );
-           thePopup->insertItem( "Display Only", visuGUI, SLOT( DisplayOnlyPrs() ) );
-         }
-       }
-       break;
-      case VISU::TCURVE:
-       if ( !isStudyLocked( GetActiveStudy()->getStudyDocument() ) ) {
-         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() ) );
-       }
-       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 ) );
-           if ( container && container->GetNbCurves() > 0 ) {
-             if ( !isStudyLocked( GetActiveStudy()->getStudyDocument() ) ) 
-               thePopup->insertItem( "Clear", visuGUI, SLOT( ClearContainer() ) );
-             if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
-               thePopup->insertItem( "Display", visuGUI, SLOT( DisplayPrs() ) );
-               thePopup->insertItem( "Erase", visuGUI, SLOT( ErasePrs () ) );
-               thePopup->insertItem( "Display Only", visuGUI, SLOT( DisplayOnlyPrs() ) );
-             }
-           }
-         }
-       }
-       break;
-
-      default: // Presentation
-       {
-         VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject));
-         if (aPrsObject) {
-           VISU_Actor* anVISUActor = visuGUI->GetActor(aPrsObject);
-           if (isVTKViewer) {
-             // Add Presentation menu
-             if ((aType != VISU::TSTREAMLINES) && anVISUActor) {
-               QPopupMenu* aPresMenu = new QPopupMenu(GetDesktop());
-               int aRepresent = anVISUActor->GetRepresentation();
-               switch(aRepresent){
-               case 0: //POINTS
-                 aPresMenu->insertItem("Wireframe", visuGUI, SLOT(MakeWireframe()));
-                 aPresMenu->insertItem("Surface", visuGUI, SLOT(MakeSurface()));
-                 break;
-               case 1: //WIREFRAME
-                 aPresMenu->insertItem("Surface", visuGUI, SLOT(MakeSurface()));
-                 aPresMenu->insertItem("Points", visuGUI, SLOT(MakePoints()));
-                 break;
-               case 2: //SURFACE
-                 aPresMenu->insertItem("Wireframe", visuGUI, SLOT(MakeWireframe()));
-                 aPresMenu->insertItem("Points", visuGUI, SLOT(MakePoints()));
-                 break;
-               }
-               if (anVISUActor->GetShrinkable()) {
-                 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) || 
-                 (aType ==  VISU::TDEFORMEDSHAPE) || 
-                 (aType == VISU::TVECTORS) ||
-                 (aType == VISU::TSTREAMLINES))
-               aPropMenu->insertItem("Color", visuGUI, SLOT(ChageColor()));
-             if (aType == VISU::TMESH)
-               aPropMenu->insertItem("Outline Color", visuGUI, SLOT(ChangeOutlineColor()));
-             
-             if ((aType != VISU::TVECTORS) && (aType != VISU::TSTREAMLINES))
-               aPropMenu->insertItem("Opacity", visuGUI, SLOT(ChangeOpacity()));
-             aPropMenu->insertItem("Line width", visuGUI, SLOT(ChangeLines()));
-             thePopup->insertItem("Properties", aPropMenu);              
-             
-             thePopup->insertSeparator();
-           }
-           thePopup->insertItem("Rename...", visuGUI, SLOT(Rename()));
-           if (aType != VISU::TMESH) {
-             if (aType != VISU::TSCALARMAP)
-               thePopup->insertItem("Edit...", visuGUI, SLOT(EditPrs()));
-             thePopup->insertItem("Edit Scalar Bar...", visuGUI, SLOT(EditScalarBar()));
-             
-             if ((aType != VISU::TVECTORS) && (aType != VISU::TSTREAMLINES) 
-                  && (aType != VISU::TCUTLINES) && isVTKViewer)
-               thePopup->insertItem("Sweep", visuGUI, SLOT(Sweep()));
-             
-             if (aType == VISU::TCUTLINES)
-               thePopup->insertItem( "Create Table", visuGUI, SLOT( CreateTable() ) ); 
-           }
-           if (isVTKViewer) {
-             if ( theParent == "Viewer" && 
-                  ( aType == VISU::TMESH      || 
-                    aType == VISU::TSCALARMAP || 
-                    aType == VISU::TDEFORMEDSHAPE ) ) {
-               thePopup->insertSeparator();
-               if ( Sel->SelectionMode() == SelectionPoint ) {
-                 thePopup->insertItem("Results at Point", visuGUI, SLOT(InfoOnPoint()));
-                 thePopup->insertItem("Select a Point",   visuGUI, SLOT(SelectPoint()));
-               }
-               else if ( Sel->SelectionMode() == SelectionCell) {
-                 thePopup->insertItem("Results on Cell", visuGUI, SLOT(InfoOnCell()));
-                 thePopup->insertItem("Select a Cell",  visuGUI, SLOT(SelectCell()));
-               }
+               updateObjBrowser();
+               PlotContainer( this, pContainer, VISU::eDisplay );
              }
-             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()));
-           }
-           if (aType != VISU::TMESH) {
-             thePopup->insertItem("Delete", visuGUI, SLOT(DeletePrs()));
-             thePopup->insertSeparator();
-             thePopup->insertItem("Same As", visuGUI, SLOT(CopyPresentation()));
            }
          }
-       }
-      }
-      return false;
-    }
-    else {
-      // possibly this is the MED field/mesh and suppot 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() ) );
-      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: 
-         thePopup->insertItem("Create Presentation", visuGUI, SLOT(CreateMesh()));    
-         break;
-       case VISU::TVIEW3D: 
-         if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { 
-           // Available only for VTK viewer
-           thePopup->insertItem( "Save view parameters", visuGUI, SLOT( SaveViewParams() ) );
-           thePopup->insertItem( "Restore view parameters", visuGUI, SLOT( RestoreViewParams() ) );
-         }
-         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( "VisuGUI", tr("ICON_SCALAR_MAP") ), 
-                              "Scalar Map...", visuGUI, SLOT(CreateScalarMap()));
-         thePopup->insertItem(rmgr->loadPixmap( "VisuGUI", tr("ICON_ISO_SURFACES") ),
-                              "Iso Surfaces...", visuGUI, SLOT(CreateIsoSurfaces()));
-         thePopup->insertItem(rmgr->loadPixmap( "VisuGUI", tr("ICON_CUT_PLANES") ),
-                              "Cut Planes...", visuGUI, SLOT(CreateCutPlanes()));
-         thePopup->insertItem(rmgr->loadPixmap( "VisuGUI", tr("ICON_CUT_LINES") ),
-                              "Cut Lines...", visuGUI, SLOT(CreateCutLines()));
-         if(aNunComponent > 1){
-           thePopup->insertItem(rmgr->loadPixmap( "VisuGUI", tr("ICON_DEFORMED_SHAPE") ),
-                                "Deformed Shape...", visuGUI, SLOT(CreateDeformedShape()));
-           thePopup->insertItem(rmgr->loadPixmap( "VisuGUI", tr("ICON_VECTORS") ),
-                                "Vectors...", visuGUI, SLOT(CreateVectors()));
-           thePopup->insertItem(rmgr->loadPixmap( "VisuGUI", tr("ICON_STREAM_LINES") ),
-                                "Stream lines...", visuGUI, SLOT(CreateStreamLines()));
+       } 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 );
          }
-         break;
-       }
        }
-       return false;
-      }else{
-       SALOMEDS::GenericAttribute_var anAttr;
-       if(aSObject->FindAttribute( anAttr, "AttributeTableOfInteger" ) || 
-          aSObject->FindAttribute( anAttr, "AttributeTableOfReal" )){
-         thePopup->insertItem( "Show Table",    visuGUI, SLOT(ShowTable()));
-         thePopup->insertItem( "Create Curves", visuGUI, SLOT(PlotData()));
-         return false;
-       }
-       aSObject = aSObject->GetFather();
-       aSObject->FindAttribute(anAttr, "AttributeName");
-       SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
-       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() ) );
-       return false;
       }
+      delete dlg;
     }
   }
 }
 
-//===========================================================================
-// BuildPresentation
-//===========================================================================
-void VisuGUI::BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
+void
+VisuGUI::
+OnCurveProperties()
 {
-  BEGIN_OF("VisuGUI::BuildPresentation");
+  SalomeApp_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;
 
-  if (theIO.IsNull()) {
-    MESSAGE("VisuGUI::BuildPresentation(): null SALOME_InteractiveObject passed");
-    return;
+  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 ) ) {
+      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);
+       }
+      }
+    }
   }
+}
 
-   /* Create or retrieve an object VisuGUI */
-
-  VisuGUI::GetOrCreateVisuGUI(QAD_Application::getDesktop());
-
-  SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument();
-  SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
-
-  if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_VTK ) return;
-
-  vtkRenderer *Renderer = GetRenderer();
-
-  SALOMEDS::SObject_var aSObj = aStudy -> FindObjectID ( theIO->getEntry() );
-  SCRUTE(aSObj);
-  if (aSObj -> _is_nil() ) {
-    MESSAGE("No SObject for interacative object is found");
+void
+VisuGUI::
+OnClearContainer()
+{
+  _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
+  if (CheckLock(aCStudy))
     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));
-    if ( !aPrsObject ) {
-      MESSAGE("The object is not VISU::Prs3d_i");
-      return;
-    }
-    VISU_Actor *SelectedActor = visuGUI->GetActor(aPrsObject);
-    if ( ! SelectedActor )
-      SelectedActor = aPrsObject -> CreateActor();
-    SCRUTE(SelectedActor);
-    if  ( SelectedActor == NULL )   {  
-      MESSAGE("VisuGUI::BuildPresentation(): actor doesn't exist in Render");
-      return;
+  SALOMEDS::Study_var aStudy = GetDSStudy(aCStudy);
+  Handle(SALOME_InteractiveObject) anIO;
+  CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
+  if (anIO.IsNull() || 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)) {
+      VISU::Container_i* container = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aCnt).in());
+      if (container && container->GetNbCurves() > 0) {
+       container->Clear();
+       updateObjBrowser();
+      }
     }
-    VTKViewer_ViewFrame* vf = GetVtkViewFrame();
-    vf->AddActor(SelectedActor);
   }
-    else {
-      MESSAGE("CORBA::is_nil(anObject) = true");
-    }
-  END_OF("VisuGUI::BuildPresentation");
-
 }
 
-extern "C"
+void
+VisuGUI::
+OnEditContainer()
 {
-  bool OnGUIEvent(int theCommandID, QAD_Desktop* parent)
-  {
-    //MESSAGE("VisuGUI::OnGUIEvent "<< theCommandID);
-    return VisuGUI::OnGUIEvent(theCommandID, parent);
-  }
+  Handle(SALOME_InteractiveObject) anIO;
+  CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
+  if (CORBA::is_nil(anObject)) return;
 
-  bool OnKeyPress (QKeyEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
-  {
-    MESSAGE("VisuGUI::OnKeyPress ");
-    return VisuGUI::OnKeyPress (pe, parent, studyFrame);
-  }
+  PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
+  if (!aServant.in()) return;
+  VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(aServant.in());
+  if (!aContainer) return;
 
-  bool OnMousePress (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
-  {
-    //MESSAGE("VisuGUI::OnMousePress ");
-    return VisuGUI::OnMousePress (pe, parent, studyFrame);
+  VisuGUI_EditContainerDlg* aDlg = new VisuGUI_EditContainerDlg (GetDesktop(this));
+  aDlg->initFromPrsObject(aContainer);
+  if (aDlg->exec()) {
+    aDlg->storeToPrsObject(aContainer);
+    updateObjBrowser(true);
   }
+  delete aDlg;
+}
 
-  bool OnMouseMove (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
-  {
-    //MESSAGE("VisuGUI::OnMouseMove ");
-    return VisuGUI::OnMouseMove (pe, parent, studyFrame);
-  }
+void
+VisuGUI::
+OnSaveViewParams()
+{
+  _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
+  if (CheckLock(aCStudy))
+    return;
+  SALOMEDS::Study_var aStudy = GetDSStudy(aCStudy);
 
-  bool SetSettings ( QAD_Desktop* parent )
-  {
-    return VisuGUI::setSettings( parent );
-  }
+  SUIT_ViewManager* aViewMgr = getApp()->activeViewManager();
+  if (aViewMgr->getType() != SVTK_Viewer::Type())
+    return;
 
-  bool customPopup ( QAD_Desktop* parent, QPopupMenu* popup, const QString & theContext,
-                    const QString & theParent, const QString & theObject )
-  {
-    return VisuGUI::CustomPopup( parent, popup, theContext, theParent, theObject );
-  }
+  SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
+  SALOME_ListIO aListIO;
+  aSelectionMgr->selectedObjects(aListIO);
+  if (aListIO.Extent() > 1)
+    return;
 
-  void definePopup ( QString & theContext, QString & theParent, QString & theObject )
-  {
-    VisuGUI::DefinePopup( theContext, theParent, theObject );
+  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());
   }
+  updateObjBrowser();
+}
 
-  bool activeStudyChanged ( QAD_Desktop* parent )
-  {
-    //VisuGUI::activeStudyChanged( parent );
-  }
-    void buildPresentation ( const Handle(SALOME_InteractiveObject)& theIO )
-  {
-    VisuGUI::BuildPresentation(theIO);
-  }
+void
+VisuGUI::
+OnRestoreViewParams()
+{
+  SUIT_ViewManager* aViewMgr = getApp()->activeViewManager();
+  if (aViewMgr->getType() != SVTK_Viewer::Type())
+    return;
 
-  void supportedViewType(int* buffer, int bufferSize)
-  {
-    if (!buffer || !bufferSize) return;
-    buffer[0] = (int)VIEW_VTK;
-    if (--bufferSize) buffer[1] = (int)VIEW_PLOT2D;
-  }  
+  SalomeApp_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
+  VISU::View3D_i::RestoreViewParams(aViewMgr, aSObj->GetName().c_str());//jfa tmp
 }
 
-//////////////////////////////////////////////////////////////////////////////////
-////////////////               CHANGE ACTOR COLOR         ////////////////////////
-//////////////////////////////////////////////////////////////////////////////////
-///////////////// /////////////////////////////////////////////////////////////////
-// change actor color
-// In : Name of Actor
-//
-//
+void
+VisuGUI::
+OnDeleteViewParams()
+{
+  _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
+  if (CheckLock(aCStudy))
+    return;
+  SALOMEDS::Study_var aStudy = GetDSStudy(aCStudy);
 
-void VisuGUI::NewColor(VISU_Actor *theActor){
-  if(VISU::Prs3d_i* aPrs3d = theActor->getPrs3d()){
-    SALOMEDS::Color anOldColor = aPrs3d->GetColor(), 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.;
-      aPrs3d->SetColor(aNewColor);
-      aPrs3d->Update();
-      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(aPrs3d,aViewFrame))
-             aPrs3d->UpdateActor(anActor);
-       }
+  Handle(SALOME_InteractiveObject) anIO;
+  CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
+  _PTR(SObject) aSObject = aCStudy->FindObjectID(anIO->getEntry());
+  if (!aSObject) return;
+
+  VISU::VISUType aType = (VISU::VISUType)getValue(aSObject, "myType").toInt();
+  if (aType == VISU::TVIEW3D) {
+    SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
+    SALOME_ListIO aListIO, aNewListIO;
+    aSelectionMgr->selectedObjects(aListIO);
+    for (SALOME_ListIteratorOfListIO it (aListIO); it.More(); it.Next()) {
+      if (it.Value()->getEntry() != anIO->getEntry()) {
+        aNewListIO.Append(it.Value());
+      }
     }
-  }
-}
+    aSelectionMgr->setSelectedObjects(aNewListIO);
 
-void VisuGUI::NewOutlineColor(VISUMesh_Actor *theActor){
-  if(VISU::Mesh_i* aPrs3d = dynamic_cast<VISU::Mesh_i*>(theActor->getPrs3d())){
-    SALOMEDS::Color anOldColor = aPrs3d->GetColor(), 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.;
-      aPrs3d->SetLinkColor(aNewColor);
-      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(aPrs3d,aViewFrame))
-             aPrs3d->UpdateActor(anActor);
-       }
-    }
+    aCStudy->NewBuilder()->RemoveObject(aSObject);
+
+    updateObjBrowser();
   }
 }
 
-//////////////////////////////////////////////////////////////////////////////////
-////////////////               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)
+void
+VisuGUI::
+OnRename()
 {
-  
-  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->GetProperty()->GetOpacity();
-  intopac=int(oldopac*100.);
-  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->GetProperty()->SetOpacity(newopac);
-    }
-  delete CursorDlg;
-}
+  _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
+  if (CheckLock(aCStudy))
+    return;
 
-//////////////////////////////////////////////////////////////////////////////////
-////////////////               CHANGE ACTOR LINEWIDTH     ////////////////////////
-//////////////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////////////
-// change actor linewidth
-// In : Name of Actor
-//
-// Use CursorDlg to select a value between 0 and 10
-//
+  Handle(SALOME_InteractiveObject) anIO;
+  CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
 
-void VisuGUI::NewLinewidth(VISU_Actor *Actor)
-{
+  _PTR(SObject) aSObj = aCStudy->FindObjectID(anIO->getEntry());
+  if (!aSObj) return;
 
-  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;
-}
+  //TEST DU PARENT == VISU
+  _PTR(GenericAttribute) anAttr;
+  if (aSObj->FindAttribute(anAttr, "AttributeName")) {
+    _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:
+            {
+            }
+          }
+        }
+      }
 
-/* ======================================================================================== */
-/* 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();
+      // rename the study object
+      //getApp()->activeStudy()->renameIObject(anIO, Name);
+      aName->SetValue(Name.latin1()); // rename the SObject
+      anIO->setName(Name.latin1()); // rename the InteractiveObject
+      updateObjBrowser(false);
+
+      QApplication::restoreOverrideCursor();
+    }
   }
-  delete Scbar;
 }
 
-/* ======================================================================================== */
-/* Setting parameters for Sweeping                                                        */
-/* ======================================================================================== */
-void VisuGUI::SetSweepingPreferences()
+void
+VisuGUI::
+OnSweep()
 {
-       float tempo=0.2;
-       int cycles=1;
-       int steps=20;
+  // 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;
+
+  VISU::ScalarMap_i* aPrsObject = dynamic_cast<VISU::ScalarMap_i*>(aServant.in());
+  if (!aPrsObject) return;
+
+  SVTK_ViewWindow* vw = GetViewWindow();
+  if (!vw) return;
+
+  VISU_Actor* aActor = GetActor(aPrsObject, vw);
+  if (!aActor) return;
+
+  if (!aActor->GetVisibility()) {
+    aActor->VisibilityOn();
+  }
 
-       QString Tempo = QAD_CONFIG->getSetting("Visu:SweepTempo");
-       if ( !Tempo.isEmpty() )
-               tempo = Tempo.toFloat();
+  // Get sweep parameters
+  SUIT_ResourceMgr* aResourceMgr = GetResourceMgr();
 
-       QString Cycles = QAD_CONFIG->getSetting("Visu:SweepCycles");
-       if ( !Cycles.isEmpty() )
-               cycles = Cycles.toInt();
+  double aTempoDbl = aResourceMgr->doubleValue("Visu:SweepTempo", 0.1);
+  int aTemp = int(1.E6 * aTempoDbl);
 
-       QString Steps = QAD_CONFIG->getSetting("Visu:SweepSteps");
-       if ( !Steps.isEmpty() )
-               steps = Steps.toInt();
+  int aCycles = aResourceMgr->integerValue("Visu:SweepCycles", 1);
+  int aSteps  = aResourceMgr->integerValue("Visu:SweepSteps", 40);
 
-       VisuGUI_SweepPrefDlg* Sweep = new VisuGUI_SweepPrefDlg(QAD_Application::getDesktop(), 0, TRUE, 0);
+  // Sweep
+  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);
+       vw->getRenderWindow()->getRenderWindow()->Render();
+       usleep(aTemp);
+      }
+    }
+  } catch (std::exception& exc) {
+    INFOS("Follow exception was occured :\n" << exc.what());
+  } catch (...) {
+    INFOS("Unknown exception was occured!");
+  }
+  QApplication::restoreOverrideCursor();
+}
 
-       Sweep->setTimeStep( tempo );
-       Sweep->setNbCycles( cycles );
-       Sweep->setNbSteps ( steps );
+void
+VisuGUI::
+OnTimeAnimation()
+{
+  _PTR(Study) aStudyDS = GetCStudy(GetAppStudy(this));
+  VisuGUI_TimeAnimationDlg* aAnimationDlg =
+    new VisuGUI_TimeAnimationDlg(GetDesktop(this), aStudyDS);
 
-       if ( Sweep->exec() )
-       {
-               tempo  = Sweep->getTimeStep();
-               cycles = Sweep->getNbCycles();
-               steps  = Sweep->getNbSteps();
+  SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
+  SALOME_ListIO aListIO;
+  aSelectionMgr->selectedObjects(aListIO);
 
-               QAD_CONFIG->addSetting("Visu:SweepTempo",  tempo);
-               QAD_CONFIG->addSetting("Visu:SweepCycles", cycles);
-               QAD_CONFIG->addSetting("Visu:SweepSteps",  steps);
-       }
-       delete Sweep;
-}
-
-/* ======================================================================================== */
-/* 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);
-}
-
-/* ======================================================================================== */
-/* 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;
+  bool isDefined = false;
+  long aNbTimes = 0;
+  SALOME_ListIteratorOfListIO It (aListIO);
+  for (; It.More(); It.Next()) {
+    _PTR(SObject) aSObject = aStudyDS->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);
        }
-       Tmp = QAD_Tools::addSlash(Tmp);
-       return (Tmp);
-}
-
-
-/* ======================================================================================== */
-/* Global Method for Scalar Map                                                  */
-/* ======================================================================================== */
-VISU::Result_i* VisuGUI::CreatePresent(SALOMEDS::SObject_var theField, VISU::Result_var& theResult){
-  if(MYDEBUG) MESSAGE("VisuGUI::CreatePresent");
-  VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() );
-  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));
-  if(pResult == NULL)
-    QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
-                         tr ("WRN_NO_AVAILABLE_DATA"),
-                         tr ("VISU_BUT_OK"));
-  return pResult;
-}
-
-#define CREATEPRS(PRSTYPE, FNAME, FCREATE) \
-PRSTYPE* FNAME(SALOMEDS::SObject_var theField, \
-              const char* theMeshName, VISU::Entity theEntity, \
-              const char* theFieldName, double theTimeId) {\
-  VISU::Result_var aResult; \
-  VISU::Result_i* pResult = CreatePresent(theField,aResult); \
-  if(pResult != NULL){ \
-    if(PRSTYPE::IsPossible(pResult,theMeshName,(VISU::Entity)theEntity,theFieldName,theTimeId)){ \
-      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)); \
-    } \
-  } \
-  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.toDouble()); \
-  if(MYCHECKTIME) { \
-    timer.Stop(); \
-    MESSAGE("BUILDPRS(TYPE, FCREATE, FNAME, DLGNAME) - CREATE PRSOBJECT"); \
-    timer.Show(); \
-  } \
-  if (pPresent) { \
-    DLGNAME* aDlg = new DLGNAME(); \
-    aDlg->initFromPrsObject(pPresent); \
-    if (aDlg->exec()) { \
-      aDlg->storeToPrsObject(pPresent); \
-    } else { \
-      DeletePresentation(pPresent); \
-      delete aDlg; \
-      return false; \
-    } \
-    delete aDlg; \
-    CreateActor(pPresent); \
-    return true; \
-  } \
-  return false; \
-}
-
-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);
-
-
-
-/* ======================================================================================== */
-/* Global Method to import tables from file */
-/* ======================================================================================== */
-void VisuGUI::ImportTablesFromFile(){
-  QStringList flt;
-  flt.append( "Files (*.xls *.txt *.tab)" );
-  flt.append( "All Files (*.*)" );
-  QString aDir = getVisuInputDir();
-  QString aFile = QAD_FileDlg::getFileName(QAD_Application::getDesktop(),
-                                          aDir,flt,tr("Import From File"),true);
-  if(!aFile.isEmpty()){
-    QAD_Application::getDesktop()->putInfo( "Importing From File " + aFile + "..." );
-    aDir = QAD_Tools::getDirFromPath(aFile);
-    QAD_CONFIG->addSetting("Visu:InputDir",aDir);
-    QApplication::setOverrideCursor( Qt::waitCursor );
-    QAD_PyInterp* myPyInterp = GetActiveStudy()->get_PyInterp();
-    myPyInterp->run("import VisuGUI");
-    myPyInterp->run("reload(VisuGUI)");
-    myPyInterp->run("VisuGUI.AddTablesInStudyFromFile('"+aFile+"')");
-    //     VISU::Result_var aResult = myComponent->ImportFile(aFile.latin1());
-    //     if(aResult->_is_nil())
-    //       QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
-    //                               tr ("There is an error in imported file"),
-    //                               tr ("VISU_BUT_OK") );
-    //     else
-    // QAD_Application::getDesktop()->putInfo(aFile+" imported.");
-    GetActiveStudy()->updateObjBrowser(); //update Object browser
-    QApplication::restoreOverrideCursor();
+      }
+    }
   }
+  if (isDefined) aAnimationDlg->show();
+  else delete aAnimationDlg;
 }
 
-/* ======================================================================================== */
-/* Global Method to import mesh results in MED and DAT format                               */
-/* ======================================================================================== */
-void VisuGUI::ImportFromFile(){
-  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( "Dat Files (*.xls)" );
-  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;
+void
+VisuGUI::
+OnCopyPresentation()
+{
+  _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
+  if (CheckLock(aCStudy))
+    return;
 
-    CORBA::Object_var anObject;
-#ifdef CHECKTIME
-    Utils_Timer timer;
-    timer.Start();
-#endif
-    if(aFileInfo.extension(false) == "med")
-       anObject = GetVisuGen()->ImportFile(aFileInfo.filePath());
-    else if(aFileInfo.extension(false) == "xls")
-       anObject = GetVisuGen()->ImportTables(aFileInfo.filePath());
-#ifdef CHECKTIME
-    timer.Stop();
-    MESSAGE("VisuGUI::ImportFromFile() - IMPORT FILE");
-    timer.Show();
-#endif
+  //VISU::Prs3d_i* aPrsObject = 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;
+
+  VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
+  if (!aPrsObject) return;
 
-    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();
+  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(this, aSameMesh);
+    }
+    break;
+  case VISU::TSCALARMAP:
+    {
+      VISU::ScalarMap_i* aScalarPrs = dynamic_cast<VISU::ScalarMap_i*>(aPrsObject);
+      VISU::ScalarMap_i* aSameScalar = new VISU::ScalarMap_i(aScalarPrs->GetResult(),true);
+      aSameScalar->SameAs(aScalarPrs);
+      UpdateViewer(this, aSameScalar);
+    }
+    break;
+  case VISU::TDEFORMEDSHAPE:
+    {
+      VISU::DeformedShape_i* aDefPrs = dynamic_cast<VISU::DeformedShape_i*>(aPrsObject);
+      VISU::DeformedShape_i* aSameDeformed = new VISU::DeformedShape_i(aDefPrs->GetResult(),true);
+      aSameDeformed->SameAs(aDefPrs);
+      UpdateViewer(this, aSameDeformed);
+    }
+    break;
+  case VISU::TCUTPLANES:
+    {
+      VISU::CutPlanes_i* aCutPrs = dynamic_cast<VISU::CutPlanes_i*>(aPrsObject);
+      VISU::CutPlanes_i* aSameCut = new VISU::CutPlanes_i(aCutPrs->GetResult(),true);
+      aSameCut->SameAs(aCutPrs);
+      UpdateViewer(this, aSameCut);
+    }
+    break;
+  case VISU::TCUTLINES:
+    {
+      VISU::CutLines_i* aCutPrs = dynamic_cast<VISU::CutLines_i*>(aPrsObject);
+      VISU::CutLines_i* aSameCut = new VISU::CutLines_i(aCutPrs->GetResult(),true);
+      aSameCut->SameAs(aCutPrs);
+      UpdateViewer(this, 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(),true);
+      aSameIso->SameAs(aIsoPrs);
+      UpdateViewer(this, aSameIso);
     }
-    else {
-      QAD_Application::getDesktop()->putInfo(aFileInfo.filePath()+" imported.");
+    break;
+  case VISU::TSTREAMLINES:
+    {
+      VISU::StreamLines_i* aLinesPrs = dynamic_cast<VISU::StreamLines_i*>(aPrsObject);
+      VISU::StreamLines_i* aSameLines = new VISU::StreamLines_i(aLinesPrs->GetResult(),true);
+      aSameLines->SameAs(aLinesPrs);
+      UpdateViewer(this, aSameLines);
+    }
+    break;
+  case VISU::TVECTORS:
+    {
+      VISU::Vectors_i* aVectorsPrs = dynamic_cast<VISU::Vectors_i*>(aPrsObject);
+      VISU::Vectors_i* aSameVectors = new VISU::Vectors_i(aVectorsPrs->GetResult(),true);
+      aSameVectors->SameAs(aVectorsPrs);
+      UpdateViewer(this, aSameVectors);
     }
-    GetActiveStudy()->updateObjBrowser(); //update Object browser
+    break;
   }
+  updateObjBrowser();
 }
 
-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));
-  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(VISU::Result_i* aResult = dynamic_cast<VISU::Result_i*>(aBase)){
-       try{
-         //APO - aResult->GetInput()->ToFile(aFile.latin1());
-         QAD_Application::getDesktop()->putInfo(aFile+" exported.");
-       }catch(...){
-         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"));
-}
-
-/* ======================================================================================== */
-/* 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->hasEntry()){
-    objVisu = GetStudyDocument()->FindObjectID(anIO->getEntry());
-    QString aValue = getValue(objVisu,"myType");
-    if((VISU::VISUType)aValue.toInt() == VISU::TTIMESTAMP) return true;
-  }
-  QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
-                       tr("WRN_NO_AVAILABLE_DATA"),
-                       tr("VISU_BUT_OK") );
-  return false;
+void
+VisuGUI::
+OnSelectionInfo()
+{
+  (new VisuGUI_SelectionDlg(GetDesktop(this)))->show();
 }
 
-/**
- * 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;
+void
+VisuGUI::
+OnScaling()
+{
+  VisuGUI_NonIsometricDlg* m_NonIsoDlg =
+    new VisuGUI_NonIsometricDlg (GetDesktop(this), "m_NonIsoDlg",
+                                 false, Qt::WDestructiveClose);
+  m_NonIsoDlg->show();
 }
 
-/** 
- * 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;
-  VISU::Prs3d_i* aSrcAddr = thePrs;
-  for(anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL; ){
-    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->VisibilityOff();
-      }
-    } 
-  }
-  if (aResActor) return aResActor;
-  anVISUActor = thePrs->CreateActor();
-  MESSAGE("UpdateViewer - thePrs->CreateActor() = "<<anVISUActor);
-  if ( anVISUActor ) {
-    vf->AddActor(anVISUActor);
-  } else 
-    QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
-                           tr ("ERR_CANT_VISUALIZE_OBJECT"),
-                           tr ("VISU_BUT_OK") );
-  return anVISUActor;
-}
-
-
-/** 
- * Returns TRUE if Presentation is displayed                                              
- */
-bool VisuGUI::IsDisplayed(VISU::Prs3d_i* thePrs) {
-  VISU_Actor* anVISUActor = GetActor(thePrs);
-  return (anVISUActor)? anVISUActor->GetVisibility() : false;
-}
-
-/** 
- * Erases Presentation
- */
-void VisuGUI::ErasePrs(VISU::Prs3d_i* thePrs) {
-  GetActiveStudy()->unHighlightAll();
-  VISU_Actor* anVISUActor = GetActor(thePrs);
-  if (anVISUActor) {
-    anVISUActor->VisibilityOff();
-  }
+void
+VisuGUI::
+initialize( CAM_Application* theApp )
+{
+  SalomeApp_Module::initialize( theApp );
+
+  createActions();
+  createMenus();
+  createToolBars();
+  createPopupMenus();
 }
 
-/**
- * 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();
-       }
-    }
-  thePrs->Destroy();
-  GetActiveStudy()->updateObjBrowser(); //update Object browser
-}
-
-/**
- * Creates new actor of presentation
- */
-void VisuGUI::CreateActor(VISU::Prs3d_i* thePrs) {
- if (!thePrs) return;
-  QApplication::setOverrideCursor( Qt::waitCursor );
-  VTKViewer_ViewFrame* vf = GetVtkViewFrame();
-  if (vf) {
-#ifdef CHECKTIME
-  Utils_Timer timer;
-  timer.Start();
-#endif
-    VISU_Actor* aActor = thePrs->CreateActor();
-    if ( ! aActor ) {
-      QApplication::restoreOverrideCursor();
-      QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
-                            tr ("WRN_CANT_VISUALIZE_PRS"),
-                            tr ("VISU_BUT_OK") );
-      return;
-    }
-    vf->AddActor(aActor);
-#ifdef CHECKTIME
-  timer.Stop();
-  MESSAGE("VisuGUI::CreateActor(VISU::Prs3d_i* thePrs) - DISPLAY ACTOR");
-  timer.Show();
-#endif
-  }
-  QApplication::restoreOverrideCursor();
+void
+VisuGUI::
+createActions()
+{
+  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_EXPLORE_MED, "", QIconSet(), tr("MEN_EXPLORE_MED_FILE"), "", (CTRL + Key_M), aParent, false,
+               this, SLOT(OnExploreMEDFile()));
+  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_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(""));
+  createAction( VISU_PLOT2D, tr("MEN_CREATE_PLOT2D"), QIconSet(aPixmap), tr("MEN_CREATE_PLOT2D"), "", 0, aParent, false,
+               this, SLOT(OnCreatePlot2dView()));
+
+  aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
+  createAction( VISU_DELETE, tr("MEN_DELETE_OBJ"), QIconSet(aPixmap), tr("MEN_DELETE_OBJ"), "", 0, aParent, false,
+               this, SLOT(OnDeleteObject()));
+
+  //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
+  //createAction( 4022, tr("MEN_RENAME_TABLE"), QIconSet(aPixmap), tr("MEN_RENAME_TABLE"), "", 0, aParent, false,
+               //this, SLOT(OnRenameTable()));
+
+  aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
+  createAction( VISU_SHOW_TABLE, tr("MEN_SHOW_TABLE"), QIconSet(aPixmap), tr("MEN_SHOW_TABLE"), "", 0, aParent, false,
+               this, SLOT(OnShowTable()));
+
+  aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
+  createAction( VISU_CREATE_CURVES, tr("MEN_CREATE_CURVES"), QIconSet(aPixmap), tr("MEN_CREATE_CURVES"), "", 0, aParent, false,
+               this, SLOT(OnPlotData()));
+
+  aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
+  createAction( VISU_EXPORT_TABLE, tr("MEN_EXPORT_TABLE"), QIconSet(aPixmap), tr("MEN_EXPORT_TABLE"), "", 0, aParent, false,
+               this, SLOT(OnExportTableToFile()));
+
+  aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
+  createAction( VISU_CREATE_PRS, tr("MEN_CREATE_PRS"), QIconSet(aPixmap), tr("MEN_CREATE_PRS"), "", 0, aParent, false,
+               this, SLOT(OnCreateMesh()));
+
+  aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
+  createAction( VISU_CREATE_MANY_PRS, tr("MEN_CREATE_MANY_PRS"), QIconSet(aPixmap), tr("MEN_CREATE_MANY_PRS"), "", 0, aParent, false,
+               this, SLOT(OnCreateManyMesh()));
+
+  aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
+  createAction( VISU_ERASE, tr("MEN_ERASE"), QIconSet(aPixmap), tr("MEN_ERASE"), "", 0, aParent, false,
+               this, SLOT(OnErasePrs()));
+
+  aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
+  createAction( VISU_DISPLAY, tr("MEN_DISPLAY"), QIconSet(aPixmap), tr("MEN_DISPLAY"), "", 0, aParent, false,
+               this, SLOT(OnDisplayPrs()));
+
+  aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
+  createAction( VISU_DISPLAY_ONLY, tr("MEN_DISPLAY_ONLY"), QIconSet(aPixmap), tr("MEN_DISPLAY_ONLY"), "", 0, aParent, false,
+               this, SLOT(OnDisplayOnlyPrs()));
+
+  aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
+  createAction( VISU_DELETE_PRS, tr("MEN_DELETE_PRS"), QIconSet(aPixmap), tr("MEN_DELETE_PRS"), "", 0, aParent, false,
+               this, SLOT(OnDeletePrs()));
+
+  aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
+  createAction( VISU_COPY_PRS, tr("MEN_COPY_PRS"), QIconSet(aPixmap), tr("MEN_COPY_PRS"), "", 0, aParent, false,
+               this, SLOT(OnCopyPresentation()));
+
+  aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
+  createAction( VISU_CURVE_PROPS, tr("MEN_CURVE_PROPS"), QIconSet(aPixmap), tr("MEN_CURVE_PROPS"), "", 0, aParent, false,
+               this, SLOT(OnCurveProperties()));
+
+  aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
+  createAction( VISU_RENAME, tr("MEN_RENAME"), QIconSet(aPixmap), tr("MEN_RENAME"), "", 0, aParent, false,
+               this, SLOT(OnRename()));
+
+  aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
+  createAction( VISU_EDIT_CONTAINER, tr("MEN_EDIT_CONTAINER"), QIconSet(aPixmap), tr("MEN_EDIT_CONTAINER"), "", 0, aParent, false,
+               this, SLOT(OnEditContainer()));
+
+  //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
+  //createAction( 4043, tr("MEN_RENAME_CONTAINER"), QIconSet(aPixmap), tr("MEN_RENAME_CONTAINER"), "", 0, aParent, false,
+               //this, SLOT(OnRenameContainer()));
+
+  aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
+  createAction( VISU_CLEAR_CONTAINER, tr("MEN_CLEAR_CONTAINER"), QIconSet(aPixmap), tr("MEN_CLEAR_CONTAINER"), "", 0, aParent, false,
+               this, SLOT(OnClearContainer()));
+
+  aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
+  createAction( VISU_VIEW_PARAMS, tr("MEN_SAVE_VIEWPARAMS"), QIconSet(aPixmap),
+                tr("MEN_SAVE_VIEWPARAMS"), "", 0, aParent, false,
+               this, SLOT(OnSaveViewParams()));
+
+  aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
+  createAction( VISU_RESTORE_VIEW_PARAMS, tr("MEN_RESTORE_VIEWPARAMS"), QIconSet(aPixmap),
+                tr("MEN_RESTORE_VIEWPARAMS"), "", 0, aParent, false,
+               this, SLOT(OnRestoreViewParams()));
+
+  aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
+  createAction( VISU_DELETE_VIEW_PARAMS, tr("MEN_DELETE_VIEWPARAMS"), QIconSet(aPixmap),
+                tr("MEN_DELETE_VIEWPARAMS"), "", 0, aParent, false,
+               this, SLOT(OnDeleteViewParams()));
+
+  aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
+  createAction( VISU_POINTS, tr("MEN_POINTS"), QIconSet(aPixmap), tr("MEN_POINTS"), "", 0, aParent, false,
+               this, SLOT(OnMakePoints()));
+
+  aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
+  createAction( VISU_WIREFRAME, tr("MEN_WIREFRAME"), QIconSet(aPixmap), tr("MEN_WIREFRAME"), "", 0, aParent, false,
+               this, SLOT(OnMakeWireframe()));
+
+  aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
+  createAction( VISU_SURFACE, tr("MEN_SURFACE"), QIconSet(aPixmap), tr("MEN_SURFACE"), "", 0, aParent, false,
+               this, SLOT(OnMakeSurface()));
+
+  aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
+  createAction( VISU_INSIDEFRAME, tr("MEN_INSIDEFRAME"), QIconSet(aPixmap), tr("MEN_INSIDEFRAME"), "", 0, aParent, false,
+               this, SLOT(OnMakeInsideframe()));
+
+  aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
+  createAction( VISU_SURFACEFRAME, tr("MEN_SURFACEFRAME"), QIconSet(aPixmap), tr("MEN_SURFACEFRAME"), "", 0, aParent, false,
+               this, SLOT(OnMakeSurfaceframe()));
+
+  aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
+  createAction( VISU_SHRINK, tr("MEN_SHRINK"), QIconSet(aPixmap), tr("MEN_SHRINK"), "", 0, aParent, false,
+               this, SLOT(OnMakeShrink()));
+
+  aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
+  createAction( VISU_UNSHRINK, tr("MEN_UNSHRINK"), QIconSet(aPixmap), tr("MEN_UNSHRINK"), "", 0, aParent, false,
+               this, SLOT(OnMakeShrink()));
+
+  aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
+  createAction( VISU_CELL_COLOR, tr("MEN_CELL_COLOR"), QIconSet(aPixmap), tr("MEN_CELL_COLOR"), "", 0, aParent, false,
+               this, SLOT(OnChangeColor()));
+
+  aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
+  createAction( VISU_COLOR, tr("MEN_COLOR"), QIconSet(aPixmap), tr("MEN_COLOR"), "", 0, aParent, false,
+               this, SLOT(OnChangeColor()));
+
+  aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
+  createAction( VISU_EDGE_COLOR, tr("MEN_EDGE_COLOR"), QIconSet(aPixmap), tr("MEN_EDGE_COLOR"), "", 0, aParent, false,
+               this, SLOT(OnChangeWireframeColor()));
+
+  aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
+  createAction( VISU_OPACITY, tr("MEN_OPACITY"), QIconSet(aPixmap), tr("MEN_OPACITY"), "", 0, aParent, false,
+               this, SLOT(OnChangeOpacity()));
+
+  aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
+  createAction( VISU_LINE_WIDTH, tr("MEN_LINE_WIDTH"), QIconSet(aPixmap), tr("MEN_LINE_WIDTH"), "", 0, aParent, false,
+               this, SLOT(OnChangeLines()));
+
+  aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
+  createAction( VISU_EDIT_PRS, tr("MEN_EDIT_PRS"), QIconSet(aPixmap), tr("MEN_EDIT_PRS"), "", 0, aParent, false,
+               this, SLOT(OnEditPrs()));
+
+  aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
+  createAction( VISU_CREATE_TABLE, tr("MEN_CREATE_TABLE"), QIconSet(aPixmap), tr("MEN_CREATE_TABLE"), "", 0, aParent, false,
+               this, SLOT(OnCreateTable()));
+
+  aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
+  createAction( VISU_SWEEP, tr("MEN_SWEEP"), QIconSet(aPixmap), tr("MEN_SWEEP"), "", 0, aParent, false,
+               this, SLOT(OnSweep()));
+
+  aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
+  createAction( VISU_SELECTION_INFO, tr("MEN_SELECTION_INFO"), QIconSet(aPixmap),
+                tr("MEN_SELECTION_INFO"), "", 0, aParent, false,
+               this, SLOT(OnSelectionInfo()));
+
+  aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
+  createAction( VISU_ANIMATION, tr("MEN_ANIMATION"), QIconSet(aPixmap), tr("MEN_ANIMATION"), "", 0, aParent, false,
+               this, SLOT(OnTimeAnimation()));
+
+  aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
+  createAction( VISU_ERASE_ALL, tr("MEN_ERASE_ALL"), QIconSet(aPixmap),
+                tr("MEN_ERASE_ALL"), "", 0, aParent, false,
+               this, SLOT(OnEraseAll()));
+
+  aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
+  createAction( VISU_GLOBAL_SELECTION, tr("MEN_GLOBAL_SELECTION"), QIconSet(aPixmap),
+                tr("MEN_GLOBAL_SELECTION"), "", 0, aParent, false,
+               //this, SLOT(OnEraseAll()));
+               this);
+
+  aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
+  createAction( VISU_PARTIAL_SELECTION, tr("MEN_PARTIAL_SELECTION"), QIconSet(aPixmap),
+                tr("MEN_PARTIAL_SELECTION"), "", 0, aParent, false,
+               //this, SLOT(OnEraseAll()));
+               this);
+
+  aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
+  createAction( VISU_SCALING, tr("MEN_SCALING"), QIconSet(aPixmap),
+                tr("MEN_SCALING"), "", 0, aParent, false,
+               this, SLOT(OnScaling()));
+}
+
+void
+VisuGUI::
+createMenus()
+{
+  // Add actions to menus
+  int aMenuId;
+  aMenuId = createMenu( tr( "MEN_FILE" ), -1 );
+  createMenu( separator(), aMenuId, -1, 10 );
+  createMenu( VISU_IMPORT_FROM_FILE, aMenuId, 10 ); // import from file
+  createMenu( VISU_EXPLORE_MED, aMenuId, 10 ); // explore MED file
+  createMenu( VISU_IMPORT_TABLE, aMenuId, 10 ); // 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_STREAM_LINES, aMenuId, 10 ); // stream lines
+  createMenu( VISU_CUT_LINES, aMenuId, 10 ); // cut lines
+
+  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
+  createMenu( VISU_SCALING, aMenuId, 10 ); // scaling
+}
+
+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_STREAM_LINES, aToolId );
+  createTool( VISU_CUT_LINES, aToolId );
+}
+
+void
+VisuGUI::
+createPopupMenus()
+{
+  // Prepare popup menus
+  QtxPopupMgr* mgr = popupMgr();
+
+  // VISU root commands
+  QString aRule( "client='ObjectBrowser' and selcount=1 and type='VISU::TVISUGEN'" );
+  mgr->insert( action(  VISU_IMPORT_FROM_FILE ), -1, -1, -1 ); // import MED
+  mgr->setRule( action( VISU_IMPORT_FROM_FILE ), aRule, true );
+  mgr->insert( action(  VISU_IMPORT_TABLE ), -1, -1, -1 ); // import tables
+  mgr->setRule( action( VISU_IMPORT_TABLE ), aRule, true );
+  mgr->insert( action(  VISU_PLOT2D ), -1, -1, -1 ); // create Plot2d
+  mgr->setRule( action( VISU_PLOT2D ), aRule, true );
+  aRule = "client='ObjectBrowser' and selcount=1 and $type in {'VISU::TRESULT' 'VISU::TTABLE' 'VISU::TCONTAINER'}";
+  mgr->insert( action(  VISU_DELETE ), -1, -1, -1 ); // delete object
+  mgr->setRule( action( VISU_DELETE ), aRule, true );
+
+  // timestamp commands
+  aRule = "client='ObjectBrowser' and selcount=1 and type='VISU::TTIMESTAMP'";
+  mgr->insert( action(  VISU_SCALAR_MAP ), -1, -1, -1 ); // scalar bar
+  mgr->setRule( action( VISU_SCALAR_MAP ), aRule, true );
+  mgr->insert( action(  VISU_ISO_SURFACES ), -1, -1, -1 ); // iso surface
+  mgr->setRule( action( VISU_ISO_SURFACES ), aRule, true );
+  mgr->insert( action(  VISU_CUT_PLANES ), -1, -1, -1 ); // cut planes
+  mgr->setRule( action( VISU_CUT_PLANES ), aRule, true );
+  mgr->insert( action(  VISU_CUT_LINES ), -1, -1, -1 ); // cut lines
+  mgr->setRule( action( VISU_CUT_LINES ), aRule, true );
+  aRule += " and nbComponents>1";
+  mgr->insert( action(  VISU_DEFORMED_SHAPE ), -1, -1, -1 ); // deformed shape
+  mgr->setRule( action( VISU_DEFORMED_SHAPE ), aRule, true );
+  mgr->insert( action(  VISU_VECTORS ), -1, -1, -1 ); // vectors
+  mgr->setRule( action( VISU_VECTORS ), aRule, true );
+  mgr->insert( action(  VISU_STREAM_LINES ), -1, -1, -1 ); // stream lines
+  mgr->setRule( action( VISU_STREAM_LINES ), aRule, true );
+
+  aRule = "client='ObjectBrowser' and selcount=1 and type='VISU::TTABLE'";
+  //mgr->insert( action(  4022 ), -1, -1, -1 ); // rename table
+  //mgr->setRule( action( 4022 ), aRule, true );
+  mgr->insert( action(  VISU_SHOW_TABLE ), -1, -1, -1 ); // show table
+  mgr->setRule( action( VISU_SHOW_TABLE ), aRule, true );
+  mgr->insert( action(  VISU_CREATE_CURVES ), -1, -1, -1 ); // create curves
+  mgr->setRule( action( VISU_CREATE_CURVES ), aRule, true );
+  mgr->insert( action(  VISU_EXPORT_TABLE ), -1, -1, -1 ); // export table
+  mgr->setRule( action( VISU_EXPORT_TABLE ), aRule, true );
+  mgr->insert( separator(), -1, -1, -1 );
+  aRule = "(client='ObjectBrowser' and selcount>0 and ((type='VISU::TTABLE' and nbChildren>0) "
+          "or (type='VISU::TCURVE'%1) or (type='VISU::TCONTAINER'))) "
+         " or (selcount>0 and $type in {"
+          "'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TISOSURFACE' 'VISU::TDEFORMEDSHAPE' "
+         "'VISU::TCUTPLANES' 'VISU::TCUTLINES' 'VISU::TVECTORS' 'VISU::TSTREAMLINES'})";
+  mgr->insert( action(  VISU_ERASE ), -1, -1, -1 ); // erase
+  mgr->setRule( action( VISU_ERASE ), aRule.arg(""), true );// TODO: aRule.arg(" and isVisible=1"), true );
+  mgr->insert( action(  VISU_DISPLAY ), -1, -1, -1 ); // display
+  mgr->setRule( action( VISU_DISPLAY ), aRule.arg(""), true );// TODO: aRule.arg(" and isVisible=0"), true );
+  mgr->insert( action(  VISU_DISPLAY_ONLY ), -1, -1, -1 ); // display only
+  mgr->setRule( action( VISU_DISPLAY_ONLY ), aRule.arg(""), true );
+
+  aRule = "client='ObjectBrowser' and selcount=1 and $type in {'VISU::TTABLE' "
+          "'VISU::TCURVE' 'VISU::TCONTAINER' 'VISU::TMESH' 'VISU::TSCALARMAP' "
+          "'VISU::TISOSURFACE' 'VISU::TDEFORMEDSHAPE' 'VISU::TCUTPLANES' "
+          "'VISU::TCUTLINES' 'VISU::TVECTORS' 'VISU::TSTREAMLINES'}";
+  mgr->insert( action(  VISU_DELETE_PRS ), -1, -1, -1 ); // delete presentation
+  mgr->setRule( action( VISU_DELETE_PRS ), aRule, true );
+
+  // View parameters
+  mgr->insert ( action( VISU_VIEW_PARAMS ), -1, -1, -1 ); // save view params
+  //jfa tmp:mgr->setRule( action( 4046 ), "(client='VTKViewer' and selcount=0) or (selcount=1 and type='VISU::TVIEW3D')", true );
+  mgr->setRule( action( VISU_VIEW_PARAMS ), "selcount=0", true ); //jfa tmp
+  mgr->insert ( action( VISU_RESTORE_VIEW_PARAMS ), -1, -1, -1 ); // restore view params
+  mgr->setRule( action( VISU_RESTORE_VIEW_PARAMS ), "selcount=1 and type='VISU::TVIEW3D'", true );
+  mgr->insert ( action( VISU_DELETE_VIEW_PARAMS ), -1, -1, -1 ); // delete view params
+  mgr->setRule( action( VISU_DELETE_VIEW_PARAMS ), "selcount=1 and type='VISU::TVIEW3D'", true );
+
+  // 3D presentations commands
+  QString aPrsType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TISOSURFACE' 'VISU::TDEFORMEDSHAPE' "
+                     "'VISU::TCUTPLANES' 'VISU::TCUTLINES' 'VISU::TVECTORS' 'VISU::TSTREAMLINES'}";
+  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'}";
+  QString aLineType   = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TISOSURFACE' 'VISU::TDEFORMEDSHAPE' "
+                        "'VISU::TCUTPLANES' 'VISU::TCUTLINES' 'VISU::TSTREAMLINES'}";
+  aRule = "selcount=1";
+
+  int parentId = mgr->insert( tr( "MEN_REPRESENTATION" ), -1, -1 ); // "Representation" submenu
+  mgr->insert( action(  VISU_POINTS ), parentId, -1, -1 ); // points
+  mgr->setRule( action( VISU_POINTS ), aRule + aPrsType +
+              " and $representation in {'VISU::WIREFRAME' 'VISU::SHADED' 'VISU::INSIDEFRAME' 'VISU::SURFACEFRAME'}", true );
+  mgr->insert( action(  VISU_WIREFRAME ), parentId, -1, -1 ); // wireframe
+  mgr->setRule( action( VISU_WIREFRAME ), aRule + aPrsType +
+              " and $representation in {'VISU::POINT' 'VISU::SHADED' 'VISU::INSIDEFRAME' 'VISU::SURFACEFRAME'}", true );
+  mgr->insert( action(  VISU_SURFACE ), parentId, -1, -1 ); // surface
+  mgr->setRule( action( VISU_SURFACE ), aRule + aPrsType +
+              " and $representation in {'VISU::POINT' 'VISU::WIREFRAME' 'VISU::INSIDEFRAME' 'VISU::SURFACEFRAME'}", true );
+  mgr->insert( action(  VISU_INSIDEFRAME ), parentId, -1, -1 ); // insideframe
+  mgr->setRule( action( VISU_INSIDEFRAME ), aRule + aInsideType +
+              " and $representation in {'VISU::POINT' 'VISU::WIREFRAME' 'VISU::SHADED' 'VISU::SURFACEFRAME'}", true );
+  mgr->insert( action(  VISU_SURFACEFRAME ), parentId, -1, -1 ); // surfaceframe
+  mgr->setRule( action( VISU_SURFACEFRAME ), aRule + aSurfType +
+              " and $representation in {'VISU::POINT' 'VISU::WIREFRAME' 'VISU::SHADED' 'VISU::INSIDEFRAME'}", true );
+  mgr->insert( action(  VISU_SHRINK ), parentId, -1, -1 ); // shrink
+  mgr->setRule( action( VISU_SHRINK ), aRule + aShrinkType + " and isShrunk=0", true );
+  mgr->insert( action(  VISU_UNSHRINK ), parentId, -1, -1 ); // unshrink
+  mgr->setRule( action( VISU_UNSHRINK ), aRule + aShrinkType + " and isShrunk=1", true );
+
+  parentId = mgr->insert( tr( "MEN_PROPERTIES" ), -1, -1 ); // "Properties" submenu
+  mgr->insert( action(  VISU_CELL_COLOR ), parentId, -1, -1 ); // cell color
+  mgr->setRule( action( VISU_CELL_COLOR ), aRule + " and type='VISU::TMESH' and representation='VISU::SURFACEFRAME'", true );
+  mgr->insert( action(  VISU_EDGE_COLOR ), parentId, -1, -1 ); // edge color
+  mgr->setRule( action( VISU_EDGE_COLOR ), aRule + " and type='VISU::TMESH' and representation='VISU::SURFACEFRAME'", true );
+  mgr->insert( action(  VISU_COLOR ), parentId, -1, -1 ); // color
+  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->insert( action(  VISU_OPACITY ), parentId, -1, -1 ); // opacity
+  mgr->setRule( action( VISU_OPACITY ), aRule + aShrinkType + " and hasActor=1", true );
+  mgr->insert( action(  VISU_LINE_WIDTH ), parentId, -1, -1 ); // line width
+  mgr->setRule( action( VISU_LINE_WIDTH ), aRule + aLineType + " and hasActor=1", true );
+
+  // rename command
+  QString aCurveType = "$type in {'VISU::TTABLE' 'VISU::TCURVE' 'VISU::TCONTAINER'}";
+  aPrsType = "$type in {'VISU::TSCALARMAP' 'VISU::TISOSURFACE' 'VISU::TDEFORMEDSHAPE' "
+             "'VISU::TCUTPLANES' 'VISU::TCUTLINES' 'VISU::TVECTORS' 'VISU::TSTREAMLINES'}";
+
+  aRule = "selcount=1 and (type=VISU::TVIEW3D or " + aCurveType + " or " + aPrsType + ")";
+  mgr->insert ( action( VISU_RENAME ), -1, -1, -1 ); // rename
+  mgr->setRule( action( VISU_RENAME ), aRule, true );
+
+  // copy presentation command
+  aRule = "selcount=1 and " + aPrsType;
+  mgr->insert ( action( VISU_COPY_PRS ), -1, -1, -1 ); // copy
+  mgr->setRule( action( VISU_COPY_PRS ), aRule, true );
+
+  // curve commands
+  aRule = "selcount=1 and type='VISU::TCURVE'";
+  mgr->insert( action(  VISU_CURVE_PROPS ), -1, -1, -1 ); // curve properties
+  mgr->setRule( action( VISU_CURVE_PROPS ), aRule, true );
+
+  // curve container commands
+  aRule = "client='ObjectBrowser' and selcount=1 and type='VISU::TCONTAINER'";
+  mgr->insert( action(  VISU_EDIT_CONTAINER ), -1, -1, -1 ); // edit container
+  mgr->setRule( action( VISU_EDIT_CONTAINER ), aRule, true );
+  //mgr->insert( action(  4043 ), -1, -1, -1 ); // rename container
+  //mgr->setRule( action( 4043 ), aRule, true );
+  mgr->insert( action(  VISU_CLEAR_CONTAINER ), -1, -1, -1 ); // clear container
+  mgr->setRule( action( VISU_CLEAR_CONTAINER ), aRule, true );
+
+  aRule = "selcount=1 and ";
+  mgr->insert( action(  VISU_EDIT_PRS ), -1, -1, -1 ); // edit prs
+  mgr->setRule( action( VISU_EDIT_PRS ), aRule + aPrsType, true );
+
+  aRule = "selcount=1 and type='VISU::TCUTLINES' and nbNamedChildren=0";
+  mgr->insert( action(  VISU_CREATE_TABLE ), -1, -1, -1 ); // create table
+  mgr->setRule( action( VISU_CREATE_TABLE ), aRule, true );
+
+  aRule = "client='ObjectBrowser' and selcount=1 and type='VISU::TSCALARMAP'";
+  mgr->insert ( action( VISU_SWEEP ), -1, -1, -1 ); // sweep
+  mgr->setRule( action( VISU_SWEEP ), aRule, true );
+
+  // Selection info popup item
+  aRule = "client='ObjectBrowser' and selcount=1" + aInsideType;
+  mgr->insert( action(  VISU_SELECTION_INFO ), -1, -1, -1 ); // Selection info
+  mgr->setRule( action( VISU_SELECTION_INFO ), aRule, true );
+
+  aRule = "client='ObjectBrowser' and selcount>0 and $type in {'VISU::TFIELD'} and nbTimeStamps>1";
+  mgr->insert( action(  VISU_ANIMATION ), -1, -1, -1 ); // animation
+  mgr->setRule( action( VISU_ANIMATION ), aRule, true );
+
+  aRule = "client='ObjectBrowser' and $type in {'VISU::TENTITY' 'VISU::TFAMILY' 'VISU::TGROUP'}";
+  mgr->insert( action(  VISU_CREATE_PRS ), -1, -1, -1 ); // create presentation
+  mgr->setRule( action( VISU_CREATE_PRS ), aRule + " and selcount=1", true );
+  mgr->insert( action(  VISU_CREATE_MANY_PRS ), -1, -1, -1 ); // create presentations
+  mgr->setRule( action( VISU_CREATE_MANY_PRS ), aRule + " and selcount>1", true );
+}
+
+void
+VisuGUI::
+windows( QMap<int, int>& theMap ) const
+{
+  theMap.clear();
+  theMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
 }
 
 
+void
+VisuGUI::
+viewManagers( QStringList& theList ) const
+{
+  theList.clear();
+  theList.append( SVTK_Viewer::Type() );
+}
 
-/* ======================================================================================== */
-/* Functions to State of VisuGUI and Dialog Box                                                    */
-/* ======================================================================================== */
 
-void VisuGUI::SetState(int aState )
-{  
-       this->myState = aState ;  
-       return ; 
+QString
+VisuGUI::
+engineIOR() const
+{
+  CORBA::String_var anIOR = GetVisuGen(this)->GetID();
+  return QString(anIOR.in());
 }
 
 
-void VisuGUI::ResetState()
-{  
-       this->myState = -1 ;  
-       return ; 
+bool
+VisuGUI::
+activateModule( SUIT_Study* theStudy )
+{
+  SalomeApp_Module::activateModule( theStudy );
+  studyActivated();
+  setMenuShown( true );
+  setToolShown( true );
+  return true;
 }
 
-void VisuGUI::EmitSignalDeactivateDialog()
+
+bool
+VisuGUI::
+deactivateModule( SUIT_Study* theStudy )
 {
-       emit this->SignalDeactivateActiveDialog() ;
-       return ;
+  setMenuShown( false );
+  setToolShown( false );
+
+  SalomeApp_Module::deactivateModule( theStudy );
+  return true;
 }
 
-void VisuGUI::EmitSignalCloseAllDialogs()
+SalomeApp_Selection*
+VisuGUI::
+createSelection() const
 {
-        emit this->SignalCloseAllDialogs() ;
-        return ;
+  return new VisuGUI_Selection( (SalomeApp_Module*)this );
 }
 
-QDialog* VisuGUI::GetActiveDialogBox()
+//******************************************************************
+void VisuGUI::studyActivated()
 {
-       return this->myActiveDialogBox ;
+  GetVisuGen(this)->SetCurrentStudy(GetDSStudy(GetCStudy(GetAppStudy(this))));
 }
 
-void VisuGUI::SetActiveDialogBox(QDialog* aDlg)
-{
-       this->myActiveDialogBox = (QDialog*)aDlg ;
-       return ;
+
+extern "C" {
+  CAM_Module*
+  createModule()
+  {
+    return new VisuGUI();
+  }
 }