Salome HOME
Update Help for VISU module.
[modules/visu.git] / src / VISU_I / VISU_ViewManager_i.cc
index 82df8ba5a0379bd1a32cd58060f742c654d3e109..670656c113ab52ab78744550d10481dd711906b6 100644 (file)
-using namespace std;
-// File:       VISU_ViewManager_i.cxx
-// Created:    Wed Jan 22 17:53:23 2003
-// Author:     Alexey PETROV
-//             <apo@ivanox.nnov.matra-dtv.fr>
+//  VISU OBJECT : interactive object for VISU entities implementation
+//
+//  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
+//
+//
+//  File   : VISU_ViewManager_i.cc
+//  Author : Alexey PETROV
+//  Module : VISU
 
 #include "VISU_ViewManager_i.hh"
-#include "VISU_PrsObject_i.hh"
+#include "VISU_View_i.hh"
+#include "VISU_Prs3d_i.hh"
 #include "VISU_Table_i.hh"
-#include "VISU_ScalarBarActor.hxx"
+
 #include "VISU_Actor.h"
 
-#include "QAD_Application.h"
-#include "QAD_Desktop.h"
-#include "QAD_Tools.h"
-#include "QAD_Study.h"
-#include "QAD_RightFrame.h"
-#include "QAD_StudyFrame.h"
+#include "SUIT_Tools.h"
+#include "SUIT_Session.h"
+#include "SUIT_ViewWindow.h"
+#include "SUIT_ViewManager.h"
 
-#include "VTKViewer_ViewFrame.h"
-#include "SALOMEGUI_TableDlg.h"
-#include "Plot2d_CurveContainer.h"
+#include "SVTK_RenderWindow.h"
+#include "SVTK_ViewWindow.h"
+#include "SVTK_ViewModel.h"
+#include "SPlot2d_Curve.h"
 #include "Plot2d_ViewFrame.h"
-//#include "SALOMEGUI_SetupCurveDlg.h"
-//#include "SALOMEGUI_SetupPlot2dDlg.h"
+#include "Plot2d_ViewWindow.h"
+#include "Plot2d_ViewModel.h"
+
+#include "SalomeApp_Study.h"
+#include "SalomeApp_Application.h"
+#include "LightApp_SelectionMgr.h"
+
+#include "SALOME_Event.hxx"
+#include "SALOME_ListIO.hxx"
+#include "SALOME_ListIteratorOfListIO.hxx"
 
-#include <vtkTransformPolyDataFilter.h>
-#include <vtkDataSetMapper.h>
-#include <vtkRenderer.h>
 #include <vtkCamera.h>
+#include <vtkRenderer.h>
+#include <vtkRenderWindow.h>
 
-#include <memory>
-#include <qstring.h>
+#include <qapplication.h>
+
+using namespace std;
 
-#ifdef DEBUG
+#ifdef _DEBUG_
 static int MYDEBUG = 1;
 #else
 static int MYDEBUG = 0;
 #endif
 
-namespace VISU{
+namespace VISU {
+
+  struct TNewViewManagerEvent: public SALOME_Event
+  {
+    int myStudyId;
+    typedef SalomeApp_Application* TResult;
+    TResult myResult;
+
+    TNewViewManagerEvent (const int theStudyId):
+      myStudyId(theStudyId),
+      myResult(NULL)
+    {}
+
+    virtual
+    void
+    Execute()
+    {
+      MESSAGE("Find application for study with id = : " << myStudyId);
+      SUIT_Session* aSession = SUIT_Session::session();
+      QPtrList<SUIT_Application> anApplications = aSession->applications();
+      QPtrListIterator<SUIT_Application> anIter (anApplications);
+      while (SUIT_Application* anApp = anIter.current()) {
+       ++anIter;
+       if (SUIT_Study* aSStudy = anApp->activeStudy()) {
+         if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
+            if (_PTR(Study) aCStudy = aStudy->studyDS()) {
+              //if (myStudyName == aCStudy->Name()) {
+              if (myStudyId == aCStudy->StudyId()) {
+               myResult = dynamic_cast<SalomeApp_Application*>(anApp);
+               break;
+             }
+           }
+         }
+       }
+      }
+      if (!myResult) {
+        //MESSAGE("Error: application is not found for study : " << myStudyName);
+        MESSAGE("Error: application is not found for study with id = : " << myStudyId);
+      }
+    }
+  };
+
   //===========================================================================
-  VTKViewer_ViewFrame* GetViewFrame(QAD_StudyFrame* theStudyFrame){
-    return dynamic_cast<VTKViewer_ViewFrame*>(theStudyFrame->getRightFrame()->getViewFrame());
+  ViewManager_i::ViewManager_i(SALOMEDS::Study_ptr theStudy)
+  {
+    if(MYDEBUG) MESSAGE("ViewManager_i::ViewManager_i - "<<this);
+
+    //CORBA::String_var aStudyName = theStudy->Name();
+    //myApplication = ProcessEvent(new TNewViewManagerEvent(aStudyName.in()));
+    int aStudyID = theStudy->StudyId();
+    myApplication = ProcessEvent(new TNewViewManagerEvent(aStudyID));
   }
-  vtkRenderer* GetRenderer(QAD_StudyFrame* theStudyFrame){
-    return GetViewFrame(theStudyFrame)->getRenderer();
+
+
+  ViewManager_i::~ViewManager_i()
+  {
+    if(MYDEBUG) MESSAGE("ViewManager_i::~ViewManager_i - "<<this);
+  }
+
+
+  struct TCurrentViewEvent: public SALOME_Event
+  {
+    const SalomeApp_Application* myApplication;
+    typedef VISU::View_ptr TResult;
+    TResult myResult;
+
+    TCurrentViewEvent(const SalomeApp_Application* theApplication):
+      myApplication(theApplication),
+      myResult(VISU::View::_nil())
+    {}
+
+    virtual
+    void
+    Execute()
+    {
+      //if (SUIT_ViewManager *aViewManager = myApplication->activeViewManager()) {
+      //  if (aViewManager->getType() == "VTKViewer") {
+      //    if (SUIT_ViewWindow *aViewWindow = aViewManager->getActiveView()) {
+           VISU::View3D_i* pView =
+             new View3D_i ((SalomeApp_Application*)myApplication);
+           if (pView->Create(0))
+             myResult = pView->_this();
+      //    }
+      //  }
+      //}
+    }
+  };
+
+  VISU::View_ptr ViewManager_i::GetCurrentView(){
+    return ProcessEvent(new TCurrentViewEvent(myApplication));
   }
-  vtkCamera* GetCamera(QAD_StudyFrame* theStudyFrame){
+
+
+  template<class TViewFrame>
+  struct TCreateViewFrameEvent: public SALOME_Event
+  {
+    SalomeApp_Application* myApplication;
+    typedef typename TViewFrame::TInterface TInterface;
+    typedef typename TInterface::_ptr_type TResult;
+    TResult myResult;
+
+    TCreateViewFrameEvent (SalomeApp_Application* theApplication):
+      myApplication(theApplication),
+      myResult(TInterface::_nil())
+    {}
+
+    virtual
+    void
+    Execute()
+    {
+      //if (CheckStudy(myStudyDocument)) {
+      if (myApplication) {
+       TViewFrame* pView = new TViewFrame (myApplication);
+       if (pView->Create(1)) {
+         myResult = pView->_this();
+         qApp->processEvents(); // Fix for bug 9929
+       }
+      }
+    }
+  };
+
+
+  VISU::View3D_ptr ViewManager_i::Create3DView()
+  {
+    if (MYDEBUG) MESSAGE("ViewManager_i::Create3DView");
+    return ProcessEvent(new TCreateViewFrameEvent<View3D_i>(myApplication));
+  }
+
+  VISU::XYPlot_ptr ViewManager_i::CreateXYPlot()
+  {
+    if (MYDEBUG) MESSAGE("ViewManager_i::CreateXYPlot");
+    return ProcessEvent(new TCreateViewFrameEvent<XYPlot_i>(myApplication));
+  }
+
+  class TCreateViewEvent: public SALOME_Event
+  {
+  public:
+    TCreateViewEvent (SalomeApp_Application* theApplication)
+      : myApplication(theApplication)
+    {}
+  protected:
+    SalomeApp_Application* myApplication;
+  };
+
+  class TCreateTableViewFrameEvent: public TCreateViewEvent
+  {
+    Table_ptr myTable;
+  public:
+    TCreateTableViewFrameEvent (SalomeApp_Application* theApplication,
+                               Table_ptr theTable):
+      TCreateViewEvent(theApplication),
+      myTable(theTable),
+      myResult(VISU::TableView::_nil())
+    {}
+
+    virtual void Execute()
+    {
+      //if (CheckStudy(myStudyDocument)) {
+       VISU::TableView_i* pView = new TableView_i (myApplication);
+       if (pView->Create(myTable) != NULL)
+         myResult = pView->_this();
+      //}
+    }
+    typedef VISU::TableView_ptr TResult;
+    TResult myResult;
+  };
+
+  VISU::TableView_ptr ViewManager_i::CreateTableView (VISU::Table_ptr theTable)
+  {
+    if (MYDEBUG) MESSAGE("ViewManager_i::CreateTableView");
+    //return ProcessEvent(new TCreateViewFrameEvent<TableView_i>(myApplication));
+    return ProcessEvent(new TCreateTableViewFrameEvent (myApplication, theTable));
+  }
+
+  void ViewManager_i::Destroy (View_ptr theView)
+  {
+    class TEvent: public SALOME_Event {
+      View_ptr myView;
+    public:
+      TEvent(View_ptr theView):
+       myView(theView)
+      {}
+      virtual void Execute(){
+       if (!CORBA::is_nil(myView)) {
+         if (VISU::View_i* pView = dynamic_cast<VISU::View_i*>(VISU::GetServant(myView).in())) {
+           pView->Close();
+           pView->_remove_ref();
+         }
+       }
+      }
+    };
+
+    if (MYDEBUG) MESSAGE("ViewManager_i::Destroy - " << theView->_is_nil());
+    ProcessVoidEvent(new TEvent(theView));
+  }
+
+  //===========================================================================
+  // VISU namespace functions
+  //===========================================================================
+  SVTK_ViewWindow* GetViewWindow (SUIT_ViewWindow* theStudyFrame)
+  {
+    return dynamic_cast<SVTK_ViewWindow*>(theStudyFrame);
+  }
+
+  vtkRenderer* GetRenderer (SUIT_ViewWindow* theStudyFrame)
+  {
+    return GetViewWindow(theStudyFrame)->getRenderer();
+  }
+
+  vtkCamera* GetCamera (SUIT_ViewWindow* theStudyFrame)
+  {
     return GetRenderer(theStudyFrame)->GetActiveCamera();
   }
-  void RepaintView(QAD_StudyFrame* theStudyFrame){
-    GetRenderer(theStudyFrame)->ResetCameraClippingRange();
-    GetViewFrame(theStudyFrame)->Repaint();
+
+  void RepaintView (SUIT_ViewWindow* theViewWindow)
+  {
+    SVTK_ViewWindow* vf = GetViewWindow(theViewWindow);
+    vf->getRenderer()->ResetCameraClippingRange();
+    vf->getRenderWindow()->getRenderWindow()->Render();
   }
-  VISU_Actor* UpdateViewer(QAD_StudyFrame* theStudyFrame, int theDisplaing, Prs3d_i* thePrs){
-    VTKViewer_ViewFrame* vf = GetViewFrame(theStudyFrame);
+
+  VISU_Actor* UpdateViewer (SUIT_ViewWindow* theStudyFrame, int theDisplaing, Prs3d_i* thePrs)
+  {
+    SVTK_ViewWindow* vf = GetViewWindow(theStudyFrame);
     if (!vf) return NULL;
     if(MYDEBUG) MESSAGE("UpdateViewer - theDisplaing = "<<theDisplaing<<"; thePrs = "<<thePrs);
     vtkRenderer *aRen = vf->getRenderer();
     vtkActorCollection *anActColl = aRen->GetActors();
     vtkActor *anActor;
     VISU_Actor *anVISUActor = NULL, *aResActor = NULL;
-    void *aSrcAddr = thePrs != NULL? (void*)thePrs->GetMapper(): NULL;
-    if(MYDEBUG) MESSAGE("UpdateViewer - aSrcAddr = "<<aSrcAddr);
-    for(anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL; ){
-      if(anActor->IsA("VISU_Actor")){ 
+    for(anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL;){
+      if(anActor->IsA("VISU_Actor")){
        anVISUActor = VISU_Actor::SafeDownCast(anActor);
-       void* aCurrAddr = (void*)anVISUActor->GetMapper();      
-       if(MYDEBUG) MESSAGE("UpdateViewer - aCurrAddr = "<<aCurrAddr);
-       if (aSrcAddr == aCurrAddr) {
-         if(MYDEBUG) MESSAGE("UpdateViewer - aSrcAddr == aCurrAddr");
-         aResActor = anVISUActor;
-         if(theDisplaing < eErase){
+       if (thePrs == anVISUActor->GetPrs3d()) {
+         aResActor = anVISUActor->GetParent();
+         if(theDisplaing < eErase)
            aResActor->VisibilityOn();
-           if (aResActor->HasScalarBar()) aResActor->getScalarBar()->VisibilityOn();
-         }else{
+         else
            aResActor->VisibilityOff();
-           if (aResActor->HasScalarBar()) aResActor->getScalarBar()->VisibilityOff();
-         }
        } else {
-         if(theDisplaing > eDisplay){
+         if(theDisplaing > eDisplay)
            anVISUActor->VisibilityOff();
-           if (anVISUActor->HasScalarBar()) anVISUActor->getScalarBar()->VisibilityOff();
-         }else{
+         else
            anVISUActor->VisibilityOn();
-           if (anVISUActor->HasScalarBar()) anVISUActor->getScalarBar()->VisibilityOn();
-         }
-       } 
+       }
       }
     }
     if (aResActor) {
@@ -94,1045 +318,392 @@ namespace VISU{
       return aResActor;
     }
     if(thePrs != NULL && theDisplaing < eErase){
-      anVISUActor = thePrs->CreateActor();
-      if (anVISUActor ) {
-       if(MYDEBUG) MESSAGE("UpdateViewer - thePrs->CreateActor() = "<<anVISUActor->GetMapper());
+      try{
+       anVISUActor = thePrs->CreateActor();
        vf->AddActor(anVISUActor);
-       if(anVISUActor->HasScalarBar()){
-         if(MYDEBUG) MESSAGE("UpdateViewer - anVISUActor->getScalarBar()");
-         aRen->AddActor2D(anVISUActor->getScalarBar());
-       }
-      } else {
-       MESSAGE ("Null actor is created");
+      }catch(std::exception& exc){
+       if(MYDEBUG) INFOS(exc.what());
+       return NULL;
+      }catch(...){
+       if(MYDEBUG) INFOS("Unknown exception was occured!!!");
        return NULL;
       }
     }
     RepaintView(theStudyFrame);
     return anVISUActor;
   }
-  void UpdatePlot2d(Plot2d_ViewFrame *theView,int theDisplaying, Curve_i* theCurve) {
-    if(MYDEBUG) MESSAGE("UpdatePlot2d - theDisplaying = "<<theDisplaying);
-    if ( !theView )
+
+  void UpdatePlot2d (Plot2d_ViewFrame *theView,int theDisplaying, Curve_i* theCurve)
+  {
+    if(MYDEBUG) MESSAGE("UpdatePlot2d - theDisplaying = " << theDisplaying);
+    if (!theView)
       return;
     QList<Plot2d_Curve> clist;
-    theView->getCurves( clist );
-    if ( theDisplaying == eEraseAll ) {
-      for ( int i = 0; i < clist.count(); i++ ) {
-       if(MYDEBUG) MESSAGE("UpdatePlot2d - erasing all : curve - "<<clist.at( i ));
-       theView->eraseCurve( clist.at( i ) );
+    theView->getCurves(clist);
+    if (theDisplaying == eEraseAll) {
+      for (int i = 0; i < clist.count(); i++) {
+       if(MYDEBUG) MESSAGE("UpdatePlot2d - erasing all : curve - " << clist.at(i));
+       theView->eraseCurve(clist.at(i));
       }
-    }
-    else if ( theDisplaying == eErase ) {
-      for ( int i = 0; i < clist.count(); i++ ) {
-       if ( theCurve && clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) ) {
-         if(MYDEBUG) MESSAGE("UpdatePlot2d - erasing : curve - "<<clist.at( i ) );
-         theView->eraseCurve( clist.at( i ) );
+    } else if (theDisplaying == eErase) {
+      if (theCurve) {
+       for (int i = 0; i < clist.count(); i++) {
+         SPlot2d_Curve* aSPlot2dC = dynamic_cast<SPlot2d_Curve*>(clist.at(i));
+         if (aSPlot2dC->hasIO() &&
+             !strcmp(aSPlot2dC->getIO()->getEntry(), theCurve->GetEntry())) {
+           if(MYDEBUG) MESSAGE("UpdatePlot2d - erasing : curve - " << aSPlot2dC);
+           theView->eraseCurve(aSPlot2dC);
+         }
        }
       }
-    }
-    else if ( theDisplaying == eDisplay ) {
-      bool bFound = false;
-      for ( int i = 0; i < clist.count(); i++ ) {
-       if ( theCurve && clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) ) {
-         if(MYDEBUG) MESSAGE("UpdatePlot2d - displaying : curve - "<<clist.at( i ) );
-         clist.at( i )->setHorTitle( strdup( theCurve->GetHorTitle().c_str() ) );
-         clist.at( i )->setVerTitle( strdup( theCurve->GetVerTitle().c_str() ) );
-         clist.at( i )->setHorUnits( strdup( theCurve->GetHorUnits().c_str() ) );
-         clist.at( i )->setVerUnits( strdup( theCurve->GetVerUnits().c_str() ) );
-         /* - DATA NOT UPDATED */
-         if ( !clist.at( i )->isAutoAssign() ) {
-           clist.at( i )->setLine( (Plot2d_Curve::LineType)theCurve->GetLine(), theCurve->GetLineWidth() );
-           clist.at( i )->setMarker( (Plot2d_Curve::MarkerType)theCurve->GetMarker() ); 
-           SALOMEDS::Color color = theCurve->GetColor();
-           clist.at( i )->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
-           clist.at( i )->setAutoAssign( theCurve->IsAuto() );
+    } else if (theDisplaying == eDisplay) {
+      if (theCurve) {
+       bool bFound = false;
+       for (int i = 0; i < clist.count(); i++) {
+         SPlot2d_Curve* aSPlot2dC = dynamic_cast<SPlot2d_Curve*>(clist.at(i));
+         if (aSPlot2dC->hasIO() &&
+             !strcmp(aSPlot2dC->getIO()->getEntry(), theCurve->GetEntry())) {
+           if(MYDEBUG) MESSAGE("UpdatePlot2d - displaying : curve - " << aSPlot2dC);
+           aSPlot2dC->setHorTitle( theCurve->GetHorTitle().c_str() );
+           aSPlot2dC->setVerTitle( theCurve->GetVerTitle().c_str() );
+           aSPlot2dC->setHorUnits( theCurve->GetHorUnits().c_str() );
+           aSPlot2dC->setVerUnits( theCurve->GetVerUnits().c_str() );
+           double* xList = 0;
+           double* yList = 0;
+           int     nbPoints = theCurve->GetData( xList, yList );
+           if (nbPoints > 0 && xList && yList) {
+             aSPlot2dC->setData( xList, yList, nbPoints );
+           }
+           if (!theCurve->IsAuto()) {
+             aSPlot2dC->setLine((Plot2d_Curve::LineType)theCurve->GetLine(),
+                                theCurve->GetLineWidth());
+             aSPlot2dC->setMarker((Plot2d_Curve::MarkerType)theCurve->GetMarker());
+             SALOMEDS::Color color = theCurve->GetColor();
+             aSPlot2dC->setColor(QColor((int)(color.R*255.),
+                                        (int)(color.G*255.),
+                                        (int)(color.B*255.)));
+           }
+           aSPlot2dC->setAutoAssign(theCurve->IsAuto());
+           theView->displayCurve(aSPlot2dC);
+           bFound = true;
+         }
+       }
+       if (!bFound) {
+         Plot2d_Curve* crv = theCurve->CreatePresentation();
+         if(MYDEBUG) MESSAGE("UpdatePlot2d - displaying : curve (new) - "<<crv );
+         if (crv) {
+           theView->displayCurve( crv );
+           theCurve->SetLine( (VISU::Curve::LineType)crv->getLine(), crv->getLineWidth() );
+           theCurve->SetMarker( (VISU::Curve::MarkerType)crv->getMarker());
+           SALOMEDS::Color newColor;
+           newColor.R = crv->getColor().red()/255.;
+           newColor.G = crv->getColor().green()/255.;
+           newColor.B = crv->getColor().blue()/255.;
+           theCurve->SetColor( newColor );
+           crv->setAutoAssign( theCurve->IsAuto() );
          }
-         theView->displayCurve( clist.at( i ) );
-         bFound = true;
        }
       }
-      if ( !bFound ) {
-       Plot2d_Curve* crv = theCurve->CreatePresentation();
-       if(MYDEBUG) MESSAGE("UpdatePlot2d - displaying : curve (new) - "<<crv );
-       if ( crv )
-         theView->displayCurve( crv );
-      }
-    }
-    else if ( theDisplaying == eDisplayOnly ) {
-      bool bFound = false;
-      for ( int i = 0; i < clist.count(); i++ ) {
-       if ( theCurve && clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) ) {
-         if(MYDEBUG) MESSAGE("UpdatePlot2d - displaying only : curve - "<<clist.at( i ) );
-         clist.at( i )->setHorTitle( strdup( theCurve->GetHorTitle().c_str() ) );
-         clist.at( i )->setVerTitle( strdup( theCurve->GetVerTitle().c_str() ) );
-         clist.at( i )->setHorUnits( strdup( theCurve->GetHorUnits().c_str() ) );
-         clist.at( i )->setVerUnits( strdup( theCurve->GetVerUnits().c_str() ) );
-         /* - DATA NOT UPDATED */
-         if ( !clist.at( i )->isAutoAssign() ) {
-           clist.at( i )->setLine( (Plot2d_Curve::LineType)theCurve->GetLine(), theCurve->GetLineWidth() );
-           clist.at( i )->setMarker( (Plot2d_Curve::MarkerType)theCurve->GetMarker() ); 
-           SALOMEDS::Color color = theCurve->GetColor();
-           clist.at( i )->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
-           clist.at( i )->setAutoAssign( theCurve->IsAuto() );
+    } else if (theDisplaying == eDisplayOnly) {
+      if (theCurve) {
+       bool bFound = false;
+       for (int i = 0; i < clist.count(); i++) {
+         SPlot2d_Curve* aSPlot2dC = dynamic_cast<SPlot2d_Curve*>(clist.at(i));
+         if (aSPlot2dC->hasIO() &&
+             !strcmp(aSPlot2dC->getIO()->getEntry(), theCurve->GetEntry())) {
+           if(MYDEBUG) MESSAGE("UpdatePlot2d - displaying only : curve - " << aSPlot2dC);
+           aSPlot2dC->setHorTitle( theCurve->GetHorTitle().c_str() );
+           aSPlot2dC->setVerTitle( theCurve->GetVerTitle().c_str() );
+           aSPlot2dC->setHorUnits( theCurve->GetHorUnits().c_str() );
+           aSPlot2dC->setVerUnits( theCurve->GetVerUnits().c_str() );
+           double* xList = 0;
+           double* yList = 0;
+           int     nbPoints = theCurve->GetData( xList, yList );
+           if ( nbPoints > 0 && xList && yList ) {
+             aSPlot2dC->setData( xList, yList, nbPoints );
+           }
+           if ( !theCurve->IsAuto() ) {
+             aSPlot2dC->setLine((Plot2d_Curve::LineType)theCurve->GetLine(), theCurve->GetLineWidth());
+             aSPlot2dC->setMarker((Plot2d_Curve::MarkerType)theCurve->GetMarker());
+             SALOMEDS::Color color = theCurve->GetColor();
+             aSPlot2dC->setColor(QColor((int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.)));
+           }
+           aSPlot2dC->setAutoAssign(theCurve->IsAuto());
+           theView->displayCurve(aSPlot2dC);
+           bFound = true;
+         } else {
+           theView->eraseCurve(aSPlot2dC);
          }
-         theView->displayCurve( clist.at( i ) );
-         bFound = true;
        }
-       else {
-         theView->eraseCurve( clist.at( i ) );
+       if (!bFound) {
+         Plot2d_Curve* crv = theCurve->CreatePresentation();
+         if(MYDEBUG) MESSAGE("UpdatePlot2d - displaying only : curve (new) - " << crv);
+         if (crv) {
+           theView->displayCurve(crv);
+           theCurve->SetLine((VISU::Curve::LineType)crv->getLine(), crv->getLineWidth());
+           theCurve->SetMarker((VISU::Curve::MarkerType)crv->getMarker());
+           SALOMEDS::Color newColor;
+           newColor.R = crv->getColor().red()/255.;
+           newColor.G = crv->getColor().green()/255.;
+           newColor.B = crv->getColor().blue()/255.;
+           theCurve->SetColor(newColor);
+           crv->setAutoAssign(theCurve->IsAuto());
+         }
        }
       }
-      if ( !bFound ) {
-       Plot2d_Curve* crv = theCurve->CreatePresentation();
-       if(MYDEBUG) MESSAGE("UpdatePlot2d - displaying only : curve (new) - "<<crv );
-       if ( crv )
-         theView->displayCurve( crv );
-      }
     }
   }
-  //===========================================================================
-  ViewManager_i::ViewManager_i(SALOMEDS::Study_ptr theStudy) {
-    if(MYDEBUG) MESSAGE("ViewManager_i::ViewManager_i");
-    Mutex mt(myMutex,qApp);
-    myStudyDocument = SALOMEDS::Study::_duplicate(theStudy);
-    /*
-    CORBA::String_var aName = myStudyDocument->Name();
-    if(QAD_Application::getDesktop()->getActiveApp()->isStudyOpened(aName.in()))
-      QAD_Application::getDesktop()->getActiveApp()->loadStudy(aName.in());
-      */
-  }
-  VISU::View3D_ptr ViewManager_i::Create3DView(){
-    if(MYDEBUG) MESSAGE("ViewManager_i::Create3DView");
-    VISU::View3D_i* pView = new View3D_i(myStudyDocument);
-    if(pView->Create(1) != NULL) 
-      return VISU::View3D::_duplicate(pView->_this());
-    return VISU::View3D::_nil();
-  }
-  VISU::View_ptr ViewManager_i::GetCurrentView(){
-    if(MYDEBUG) MESSAGE("ViewManager_i::GetCurrent3DView");
-    QAD_Study* Study = QAD_Application::getDesktop()->findStudy( myStudyDocument );
-    QAD_StudyFrame* StudyFrame;
-    if ( Study && ( StudyFrame = Study->getActiveStudyFrame() ) ) {
-      if ( StudyFrame->getTypeView() == VIEW_VTK ) {
-       VISU::View3D_i* pView = new View3D_i(myStudyDocument);
-       if(pView->Create(0) != NULL) 
-         return VISU::View3D::_duplicate(pView->_this());
-      }
-      else if ( StudyFrame->getTypeView() == VIEW_PLOT2D ) {
-       VISU::XYPlot_i* pView = new XYPlot_i(myStudyDocument);
-       if(pView->Create(0) != NULL) 
-         return VISU::XYPlot::_duplicate(pView->_this());
-      }
-    }
-    return VISU::View::_nil();
-  }
-  VISU::XYPlot_ptr ViewManager_i::CreateXYPlot(){
-    if(MYDEBUG) MESSAGE("ViewManager_i::CreateXYPlot");
-    VISU::XYPlot_i* pView = new XYPlot_i(myStudyDocument);
-    if(pView->Create(1) != NULL) 
-      return VISU::XYPlot::_duplicate(pView->_this());
-    return VISU::XYPlot::_nil();
-  }
-  VISU::TableView_ptr ViewManager_i::CreateTableView(VISU::Table_ptr theTable){
-    if(MYDEBUG) MESSAGE("ViewManager_i::CreateTableView");
-    VISU::TableView_i* pView = new TableView_i(myStudyDocument);
-    if(pView->Create(VISU::Table::_duplicate(theTable)) != NULL) 
-      return VISU::TableView::_duplicate(pView->_this());
-    return VISU::TableView::_nil();
-  }
-  void ViewManager_i::Destroy(View_ptr theView){
-    if(MYDEBUG) MESSAGE("ViewManager_i::Destroy - "<<theView->_is_nil());
-    if(theView->_is_nil()) return;
-    CORBA::Object_var aView = VISU::View::_narrow(theView);
-    if(!CORBA::is_nil(aView)){
-      if(MYDEBUG) MESSAGE("ViewManager_i::Destroy - VISU::View"<<(!CORBA::is_nil(aView)));
-      VISU::View_i* pView = dynamic_cast<VISU::View_i*>(VISU::GetServant(aView));
-      if(MYDEBUG) MESSAGE("ViewManager_i::Destroy - dynamic_cast"<<pView);
-      if(pView) {
-       pView->Close();
-       pView->_remove_ref();
-      }
-      //if(pView) delete pView;
-      return;
-    }
-  }
-  //===========================================================================
-  View_i::View_i(SALOMEDS::Study_ptr theStudy) {
-    if(MYDEBUG) MESSAGE("View_i::View_i");
-    Mutex mt(myMutex,qApp);
-    CORBA::String_var aName = theStudy->Name();
-    myStudy = QAD_Application::getDesktop()->findStudy( theStudy );
-    if(MYDEBUG) MESSAGE("View_i::View_i - isStudyOpened = "<<myStudy);
-    if ( !myStudy ) 
-      myStudy = myStudy = QAD_Application::getDesktop()->getActiveApp()->loadStudy(aName.in());
-  }
-  View_i::~View_i(){
-    if(MYDEBUG) MESSAGE("View_i::~View_i");
-  }
 
-  void View_i::SetBackground(const SALOMEDS::Color& theColor) {}
-  SALOMEDS::Color View_i::GetBackground() { return SALOMEDS::Color();}
-  void View_i::Minimize() {}
-  void View_i::Restore() {}
-  void View_i::Maximize() {}
-  void View_i::EraseAll() {}
-  void View_i::DisplayAll() {}
-  void View_i::Erase(PrsObject_ptr thePrsObj) {}
-  void View_i::Display(PrsObject_ptr thePrsObj) {}
-  void View_i::DisplayOnly(PrsObject_ptr thePrsObj) {}
-  void View_i::Update() {}
-
-  CORBA::Boolean View_i::SavePicture(const char* theFileName) { return false; }
-
-  const char* View_i::GetComment() const { return "";}
-  void View_i::ToStream(ostrstream& theStr) {}
-
-  const char* View_i::GetEntry(){ 
-    SALOMEDS::SObject_var aSObject = myStudy->getStudyDocument()->FindObjectIOR(GetID());
-    CORBA::String_var anEntry = aSObject->GetID();
-    string aString(anEntry);
-    if(MYDEBUG) MESSAGE("Result_i::GetEntry - "<<aString);
-    return aString.c_str();
-  }
-  //===========================================================================
-  XYPlot_i::XYPlot_i(SALOMEDS::Study_ptr theStudy) : View_i(theStudy) {
-    if(MYDEBUG) MESSAGE("XYPlot_i::XYPlot_i");
-  }
-  Storable* XYPlot_i::Create(int theNew){
-    if(MYDEBUG) MESSAGE("XYPlot_i::Create");
-    Mutex mt(myMutex,qApp);
-    if(theNew)
-      myStudyFrame = myStudy->newWindow3d("",VIEW_PLOT2D);
-    else
-      myStudyFrame = myStudy->getActiveStudyFrame();
-    myView = dynamic_cast<Plot2d_ViewFrame*>(myStudyFrame->getRightFrame()->getViewFrame());
-    Update();
-    return this;
-  } 
-  void XYPlot_i::Update() {
-    if(MYDEBUG) MESSAGE("XYPlot_i::Update");
-    Mutex mt(myMutex,qApp);
-    myName = myStudyFrame->title();
-    myView->Repaint();
-  }
-  void XYPlot_i::Close(){
-    if(MYDEBUG) MESSAGE("XYPlot_i::Close");
-    Mutex mt(myMutex,qApp);
-    myStudyFrame->close();
-  }
-  XYPlot_i::~XYPlot_i() {
-    if(MYDEBUG) MESSAGE("XYPlot_i::~XYPlot_i");
-    Mutex mt(myMutex,qApp);
-    myStudyFrame->close();
-  }
-  void XYPlot_i::SetTitle(const char* theTitle){
-    if(MYDEBUG) MESSAGE("XYPlot_i::SetTitle");
-    Mutex mt(myMutex,qApp);
-    myName = theTitle;
-    myStudyFrame->setCaption(myName.c_str());
-  }
-  char* XYPlot_i::GetTitle() {
-    if(MYDEBUG) MESSAGE("XYPlot_i::GetTitle");
-    Mutex mt(myMutex,qApp);
-    myName = myStudyFrame->title();
-    return CORBA::string_dup(myName.c_str());
-  }
-
-  void XYPlot_i::SetSubTitle(const char* theTitle){
-    if(MYDEBUG) MESSAGE("XYPlot_i::SetSubTitle");
-    Mutex mt(myMutex,qApp);
-    myView->setTitle(theTitle);
-  }
-  char* XYPlot_i::GetSubTitle() {
-    if(MYDEBUG) MESSAGE("XYPlot_i::GetSubTitle");
-    Mutex mt(myMutex,qApp);
-    return CORBA::string_dup(myView->getTitle());
-  }
-
-  void XYPlot_i::SetCurveType(VISU::XYPlot::CurveType theType){
-    if(MYDEBUG) MESSAGE("XYPlot_i::SetCurveType");
-    Mutex mt(myMutex,qApp);
-    myView->setCurveType(theType);
-  }
-  VISU::XYPlot::CurveType XYPlot_i::GetCurveType(){
-    if(MYDEBUG) MESSAGE("XYPlot_i::GetCurveType");
-    Mutex mt(myMutex,qApp);
-    return (VISU::XYPlot::CurveType)myView->getCurveType();
-  }
-
-  void XYPlot_i::SetMarkerSize(CORBA::Long theSize){
-    if(MYDEBUG) MESSAGE("XYPlot_i::SetMarkerSize");
-    Mutex mt(myMutex,qApp);
-    myView->setMarkerSize(theSize);
-  }
-  CORBA::Long XYPlot_i::GetMarkerSize(){
-    if(MYDEBUG) MESSAGE("XYPlot_i::GetMarkerSize");
-    Mutex mt(myMutex,qApp);
-    return myView->getMarkerSize();
-  }
-
-  void XYPlot_i::EnableXGrid(CORBA::Boolean theMajor, CORBA::Long theNumMajor, 
-                            CORBA::Boolean theMinor, CORBA::Long theNumMinor){
-    if(MYDEBUG) MESSAGE("XYPlot_i::EnableXGrid");
-    Mutex mt(myMutex,qApp);
-    myView->setXGrid(theMajor,theNumMajor,theMinor,theNumMinor);
-  }
-  void XYPlot_i::EnableYGrid(CORBA::Boolean theMajor, CORBA::Long theNumMajor, 
-                            CORBA::Boolean theMinor, CORBA::Long theNumMinor){
-    if(MYDEBUG) MESSAGE("XYPlot_i::EnableYGrid");
-    Mutex mt(myMutex,qApp);
-    myView->setYGrid(theMajor,theNumMajor,theMinor,theNumMinor);
-  }
-
-  void XYPlot_i::SetHorScaling(VISU::Scaling theScaling){
-    if(MYDEBUG) MESSAGE("XYPlot_i::SetHorScaling");
-    Mutex mt(myMutex,qApp);
-    if(theScaling == VISU::LOGARITHMIC)
-      myView->setHorScaleMode(1);
-    else
-      myView->setHorScaleMode(0);
-  }
-  VISU::Scaling XYPlot_i::GetHorScaling(){
-    if(MYDEBUG) MESSAGE("XYPlot_i::GetHorScaling");
-    Mutex mt(myMutex,qApp);
-    return (VISU::Scaling)myView->getHorScaleMode();
-  }
-
-  void XYPlot_i::SetVerScaling(VISU::Scaling theScaling){
-    if(MYDEBUG) MESSAGE("XYPlot_i::SetVerScaling");
-    Mutex mt(myMutex,qApp);
-    if(theScaling == VISU::LOGARITHMIC)
-      myView->setVerScaleMode(1);
-    else
-      myView->setVerScaleMode(0);
-  }
-  VISU::Scaling XYPlot_i::GetVerScaling(){
-    if(MYDEBUG) MESSAGE("XYPlot_i::SetVerScaling");
-    Mutex mt(myMutex,qApp);
-    return (VISU::Scaling)myView->getVerScaleMode();
-  }
-
-  void XYPlot_i::SetXTitle(const char* theTitle){
-    if(MYDEBUG) MESSAGE("XYPlot_i::SetXTitle");
-    Mutex mt(myMutex,qApp);
-    myView->setXTitle(true,theTitle);
-  }
-  char* XYPlot_i::GetXTitle() {
-    if(MYDEBUG) MESSAGE("XYPlot_i::GetXTitle");
-    Mutex mt(myMutex,qApp);
-    return CORBA::string_dup(myView->getXTitle());
+  VISU_Actor* GetActor (VISU::Prs3d_i* thePrs3d, SVTK_ViewWindow* theVTKFrame)
+  {
+    vtkActorCollection *anActColl = theVTKFrame->getRenderer()->GetActors();
+    anActColl->InitTraversal();
+    while (vtkActor *anActor = anActColl->GetNextActor())
+      if (VISU_Actor* anVISUActor = dynamic_cast<VISU_Actor*>(anActor))
+       if (thePrs3d == anVISUActor->GetPrs3d())
+         return anVISUActor->GetParent();
+    return NULL;
   }
 
-  void XYPlot_i::SetYTitle(const char* theTitle){
-    if(MYDEBUG) MESSAGE("XYPlot_i::SetYTitle");
-    Mutex mt(myMutex,qApp);
-    myView->setYTitle(true,theTitle);
-  }
-  char* XYPlot_i::GetYTitle() {
-    if(MYDEBUG) MESSAGE("XYPlot_i::GetYTitle");
-    Mutex mt(myMutex,qApp);
-    return CORBA::string_dup(myView->getYTitle());
-  }
+  struct TDeleteActorsEvent: public SALOME_Event
+  {
+    VISU::Curve_i* myPrs;
 
-  void XYPlot_i::ShowLegend(CORBA::Boolean theShowing){
-    if(MYDEBUG) MESSAGE("XYPlot_i::ShowLegend");
-    Mutex mt(myMutex,qApp);
-    myView->showLegend(theShowing);
-  }
+    TDeleteActorsEvent (VISU::Curve_i* thePrs):
+      myPrs(thePrs)
+    {}
 
-  void XYPlot_i::SetBackground(const SALOMEDS::Color& theColor){
-    if(MYDEBUG) MESSAGE("XYPlot_i::SetBackground");
-    Mutex mt(myMutex,qApp);
-    QColor aColor(255.0*theColor.R,255.0*theColor.G,255.0*theColor.B);
-    myView->setBackgroundColor(aColor);
-  }
-  SALOMEDS::Color XYPlot_i::GetBackground() {
-    if(MYDEBUG) MESSAGE("XYPlot_i::GetBackground");
-    Mutex mt(myMutex,qApp);
-    SALOMEDS::Color aColor;
-    aColor.R = myView->backgroundColor().red()/255.0;
-    aColor.G = myView->backgroundColor().green()/255.0;
-    aColor.B = myView->backgroundColor().blue()/255.0;
-    return aColor;
-  }
-  void XYPlot_i::Minimize() {
-    if(MYDEBUG) MESSAGE("XYPlot_i::Minimize");
-    Mutex mt(myMutex,qApp);
-    myStudyFrame->showMinimized();
-  }
-  void XYPlot_i::Restore() {
-    if(MYDEBUG) MESSAGE("XYPlot_i::Restore");
-    Mutex mt(myMutex,qApp);
-    myStudyFrame->showNormal();
-  }
-  void XYPlot_i::Maximize() {
-    if(MYDEBUG) MESSAGE("XYPlot_i::Maximize");
-    Mutex mt(myMutex,qApp);
-    myStudyFrame->showMaximized();
-  }
-  void XYPlot_i::Display(PrsObject_ptr thePrsObj) {
-    if(MYDEBUG) MESSAGE("View3D_i::Display"); 
-    Mutex mt(myMutex,qApp);
-    CORBA::Object_var anObj = thePrsObj;
-    // is it Curve ?
-    if(Curve_i* aCurve =  dynamic_cast<Curve_i*>(VISU::GetServant(anObj))) {
-      UpdatePlot2d(myView,eDisplay,aCurve);
-    }
-    // is it Container ?
-    if(Container_i* aContainer =  dynamic_cast<Container_i*>(VISU::GetServant(anObj))) {
-      int nbCurves = aContainer->GetNbCurves();
-      for ( int i = 1; i <= nbCurves; i++ ) {
-       VISU::Curve_i* aCurve = aContainer->GetCurve( i );
-       if ( aCurve && aCurve->IsValid() ) {
-         UpdatePlot2d(myView,eDisplay,aCurve);
-       }
-      }
-      myView->Repaint();
-    }
-    // is it Table ?
-    if(Table_i* aTable =  dynamic_cast<Table_i*>(VISU::GetServant(anObj))) {
-      SALOMEDS::SObject_var TableSO = myStudy->getStudyDocument()->FindObjectID( aTable->GetEntry() );
-      if ( !TableSO->_is_nil() ) {
-       SALOMEDS::ChildIterator_var Iter = myStudy->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 ) )
-             UpdatePlot2d(myView,eDisplay,dynamic_cast<VISU::Curve_i*>( VISU::GetServant( aCurve ) ));
+    virtual
+    void
+    Execute()
+    {
+      if (!myPrs) return;
+
+      // 1. Find appropriate application (code like in TNewViewManagerEvent::Execute())
+      SALOMEDS::Study_var myStudyDocument = myPrs->GetStudyDocument();
+      SalomeApp_Application* anApp = NULL;
+      CORBA::String_var studyName = myStudyDocument->Name();
+      std::string aStudyName = studyName.in();
+      SUIT_Session* aSession = SUIT_Session::session();
+      QPtrList<SUIT_Application> anApplications = aSession->applications();
+      QPtrListIterator<SUIT_Application> anIter (anApplications);
+      while (SUIT_Application* aSUITApp = anIter.current()) {
+        ++anIter;
+       if (SUIT_Study* aSStudy = aSUITApp->activeStudy()) {
+          if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
+            if (_PTR(Study) aCStudy = aStudy->studyDS()) {
+              if (aStudyName == aCStudy->Name()) {
+                anApp = dynamic_cast<SalomeApp_Application*>(aSUITApp);
+               break;
+             }
+           }
          }
-       }
-       myView->Repaint();
+        }
       }
-    }
-  }
-  void XYPlot_i::Erase(PrsObject_ptr thePrsObj) {
-    if(MYDEBUG) MESSAGE("View3D_i::Display"); 
-    Mutex mt(myMutex,qApp);
-    CORBA::Object_var anObj = thePrsObj;
-    // is it Curve ?
-    if(Curve_i* aCurve =  dynamic_cast<Curve_i*>(VISU::GetServant(anObj))) {
-      UpdatePlot2d(myView,eErase,aCurve);
-    }
-    // is it Container ?
-    if(Container_i* aContainer =  dynamic_cast<Container_i*>(VISU::GetServant(anObj))) {
-      int nbCurves = aContainer->GetNbCurves();
-      for ( int i = 1; i <= nbCurves; i++ ) {
-       VISU::Curve_i* aCurve = aContainer->GetCurve( i );
-       if ( aCurve && aCurve->IsValid() ) {
-         UpdatePlot2d(myView,eErase,aCurve);
-       }
-      }
-      myView->Repaint();
-    }
-    // is it Table ?
-    if(Table_i* aTable =  dynamic_cast<Table_i*>(VISU::GetServant(anObj))) {
-      SALOMEDS::SObject_var TableSO = myStudy->getStudyDocument()->FindObjectID( aTable->GetEntry() );
-      if ( !TableSO->_is_nil() ) {
-       SALOMEDS::ChildIterator_var Iter = myStudy->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 ) )
-             UpdatePlot2d(myView,eErase,dynamic_cast<VISU::Curve_i*>( VISU::GetServant( aCurve ) ));
-         }
-       }
-       myView->Repaint();
+      if (!anApp)
+        return;
+
+      // 2. Remove corresponding IO from selection
+      SALOMEDS::SObject_var aSObject = myPrs->GetSObject();
+      CORBA::String_var anEntry = aSObject->GetID();
+
+      LightApp_SelectionMgr* aSelectionMgr = anApp->selectionMgr();
+      SALOME_ListIO aListIO, aNewListIO;
+      aSelectionMgr->selectedObjects(aListIO);
+
+      for (SALOME_ListIteratorOfListIO it (aListIO); it.More(); it.Next()) {
+        if (it.Value()->hasEntry()) {
+          std::string aCurEntry (it.Value()->getEntry());
+          if (aCurEntry != std::string( anEntry.in() ) ) {
+            aNewListIO.Append(it.Value());
+          }
+        }
       }
-    }
-  }
-  void XYPlot_i::EraseAll() {
-    if(MYDEBUG) MESSAGE("XYPlot_i::EraseAll");
-    Mutex mt(myMutex,qApp);
-    myView->EraseAll();
-  }
-  void XYPlot_i::DisplayOnly(PrsObject_ptr thePrsObj) {
-    if(MYDEBUG) MESSAGE("View3D_i::Display"); 
-    Mutex mt(myMutex,qApp);
-    CORBA::Object_var anObj = thePrsObj;
-    // is it Curve ?
-    if(Curve_i* aCurve =  dynamic_cast<Curve_i*>(VISU::GetServant(anObj))) {
-      UpdatePlot2d(myView,eDisplayOnly,aCurve);
-    }
-    // is it Container ?
-    if(Container_i* aContainer =  dynamic_cast<Container_i*>(VISU::GetServant(anObj))) {
-      int nbCurves = aContainer->GetNbCurves();
-      for ( int i = 1; i <= nbCurves; i++ ) {
-       VISU::Curve_i* aCurve = aContainer->GetCurve( i );
-       if ( aCurve && aCurve->IsValid() ) {
-         UpdatePlot2d(myView,eDisplayOnly,aCurve);
-       }
+
+      aSelectionMgr->setSelectedObjects(aNewListIO);
+
+      // 3. Remove Actors
+      ViewManagerList aViewManagerList;
+      anApp->viewManagers(SVTK_Viewer::Type(), aViewManagerList);
+      QPtrListIterator<SUIT_ViewManager> anVMIter (aViewManagerList);
+      for (; anVMIter.current(); ++anVMIter) {
+        SUIT_ViewManager* aViewManager = anVMIter.current();
+       QPtrVector<SUIT_ViewWindow> aViews = aViewManager->getViews();
+       for (int i = 0, iEnd = aViews.size(); i < iEnd; i++) {
+         if (SUIT_ViewWindow* aViewWindow = aViews.at(i)) {
+           if (Plot2d_ViewWindow* vw = dynamic_cast<Plot2d_ViewWindow*>(aViewWindow)) {
+              Plot2d_ViewFrame* vf = vw->getViewFrame();
+             QList<Plot2d_Curve> clist;
+             vf->getCurves(clist);
+             for (int i = 0; i < clist.count(); i++) {
+                if (SPlot2d_Curve* cu = dynamic_cast<SPlot2d_Curve*>(clist.at(i))) {
+                 if (cu->hasIO() &&
+                     strcmp(cu->getIO()->getEntry(), myPrs->GetEntry()) == 0) {
+                   vf->eraseCurve(cu);
+                 }
+               }
+             }
+             vf->Repaint();
+             //jfa tmp:aViewFrame->unHighlightAll();
+            }
+          }
+        }
       }
-      myView->Repaint();
     }
-    // is it Table ?
-    if(Table_i* aTable =  dynamic_cast<Table_i*>(VISU::GetServant(anObj))) {
-      SALOMEDS::SObject_var TableSO = myStudy->getStudyDocument()->FindObjectID( aTable->GetEntry() );
-      if ( !TableSO->_is_nil() ) {
-       SALOMEDS::ChildIterator_var Iter = myStudy->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 ) )
-             UpdatePlot2d(myView,eDisplayOnly,dynamic_cast<VISU::Curve_i*>( VISU::GetServant( aCurve ) ));
+  };
+
+  void DeleteActors (VISU::Curve_i* thePrs)
+  {
+    if (!thePrs) return;
+    ProcessVoidEvent(new TDeleteActorsEvent (thePrs));
+
+/*    // 1. Find appropriate application (code like in TNewViewManagerEvent::Execute())
+    SALOMEDS::Study_var myStudyDocument = thePrs->GetStudyDocument();
+    SalomeApp_Application* anApp = NULL;
+    CORBA::String_var studyName = myStudyDocument->Name();
+    std::string aStudyName = studyName.in();
+    SUIT_Session* aSession = SUIT_Session::session();
+    QPtrList<SUIT_Application> anApplications = aSession->applications();
+    QPtrListIterator<SUIT_Application> anIter (anApplications);
+    while (SUIT_Application* aSUITApp = anIter.current()) {
+      ++anIter;
+      if (SUIT_Study* aSStudy = aSUITApp->activeStudy()) {
+        if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
+          if (_PTR(Study) aCStudy = aStudy->studyDS()) {
+            if (aStudyName == aCStudy->Name()) {
+              anApp = dynamic_cast<SalomeApp_Application*>(aSUITApp);
+             break;
+           }
          }
        }
-       myView->Repaint();
       }
     }
-  }
-  void XYPlot_i::FitAll() {
-    if(MYDEBUG) MESSAGE("XYPlot_i::FitAll");
-    Mutex mt(myMutex,qApp);
-    myView->fitAll();
-  }
-  CORBA::Boolean XYPlot_i::SavePicture(const char* theFileName) {
-    if(MYDEBUG) MESSAGE("XYPlot_i::SavePicture");
-    Mutex mt(myMutex,qApp);
-    if (!myView->getViewWidget())
-      return false;
-
-    QApplication::setOverrideCursor( Qt::waitCursor );
-    QPixmap px = QPixmap::grabWindow(myView->getViewWidget()->winId());
-    QApplication::restoreOverrideCursor();
-    
-    if (!QString(theFileName).isNull()) {
-      QApplication::setOverrideCursor( Qt::waitCursor );
-      QString fmt = QAD_Tools::getFileExtensionFromPath(theFileName).upper();
-      if (fmt.isEmpty())
-       fmt = QString("BMP"); // default format
-      if (fmt == "JPG")
-       fmt = "JPEG";
-      bool bOk = px.save(theFileName, fmt.latin1());
-      QApplication::restoreOverrideCursor();
-      return bOk;
-    }
-    return false;
-  }
-
-  //===========================================================================
-  TableView_i::TableView_i(SALOMEDS::Study_ptr theStudy) : View_i(theStudy) {}
-  Storable* TableView_i::Create(VISU::Table_var theTable){
-    if(MYDEBUG) MESSAGE("TableView_i::Create - "<<(!theTable->_is_nil()));
-    Mutex mt(myMutex,qApp);
-    if(!theTable->_is_nil()){
-      VISU::Table_i* table = dynamic_cast<VISU::Table_i*>(VISU::GetServant(theTable.in()));
-      if(MYDEBUG) MESSAGE("TableView_i::Create - dynamic_cast = "<<table);
-      if(table != NULL) {
-       SALOMEDS::SObject_var aSObject = myStudy->getStudyDocument()->FindObjectID(table->GetObjectEntry());
-       if(!aSObject->_is_nil()) {
-         myView = new SALOMEGUI_TableDlg(QAD_Application::getDesktop(),aSObject);
-         myView->show();
-         myName = (myView->caption()).latin1();
-         return this;
-       }
-      }
-    }
-    return NULL;
-  }
-  void TableView_i::SetTitle(const char* theTitle){
-    if(MYDEBUG) MESSAGE("TableView_i::SetTitle");
-    Mutex mt(myMutex,qApp);
-    myName = theTitle;
-    myView->setCaption(myName.c_str());
-  }
-  char* TableView_i::GetTitle() {
-    if(MYDEBUG) MESSAGE("TableView_i::GetTitle");
-    Mutex mt(myMutex,qApp);
-    myName = (myView->caption()).latin1();
-    return CORBA::string_dup(myName.c_str());
-  }
-  void TableView_i::Close(){
-    if(MYDEBUG) MESSAGE("TableView_i::Close");
-    Mutex mt(myMutex,qApp);
-    myView->close();
-  }
-  TableView_i::~TableView_i() {
-    if(MYDEBUG) MESSAGE("TableView_i::~TableView_i");
-    Mutex mt(myMutex,qApp);
-    Close();
-    delete myView;
-  }
-  //===========================================================================
-  int View3D_i::myNbViewParams = 0;
-  const string View3D_i::myComment = "VIEW3D";
-  const char* View3D_i::GetComment() const { return myComment.c_str();}
-  const char* View3D_i::GenerateViewParamsName() { 
-    return VISU::GenerateName( "ViewParams", ++myNbViewParams ); 
-  }
-
-  View3D_i::View3D_i(SALOMEDS::Study_ptr theStudy) : View_i(theStudy) {
-    if(MYDEBUG) MESSAGE("View3D_i::View3D_i");
-  }
-
-  Storable* View3D_i::Create(int theNew){
-    if(MYDEBUG) MESSAGE("View3D_i::Create");
-    Mutex mt(myMutex,qApp);
-    if(theNew)
-      myStudyFrame = myStudy->newWindow3d("",VIEW_VTK);
-    else
-      myStudyFrame = myStudy->getActiveStudyFrame();
-
-    VTKViewer_NonIsometricTransform *NITr = GetViewFrame(myStudyFrame)->getNonIsometricTransform();
-    myScaleFactor[0] = NITr->GetCoeff(AxisFunction::XAxis);
-    myScaleFactor[1] = NITr->GetCoeff(AxisFunction::YAxis);
-    myScaleFactor[2] = NITr->GetCoeff(AxisFunction::ZAxis);
-
-    return Build(false);
-  }
-
-  Storable* View3D_i::Build(int theRestoring){
-    if(MYDEBUG) MESSAGE("View3D_i::Build");
-    if(theRestoring){
-      myStudyFrame->setTitle(myName.c_str());
-      SetBackground(myColor);
-      SetPointOfView(myPosition);
-      SetViewUp(myViewUp);
-      SetFocalPoint(myFocalPnt);
-      SetParallelScale(myParallelScale);
-      ScaleView(VISU::View3D::XAxis,myScaleFactor[0]);
-      ScaleView(VISU::View3D::YAxis,myScaleFactor[1]);
-      ScaleView(VISU::View3D::ZAxis,myScaleFactor[2]);
-      RepaintView(myStudyFrame);
-    }else{
-      Update();
-      /*
-      SALOMEDS::SComponent_var aSComponent = FindOrCreateVisuComponent(myStudyDocument);
-      CORBA::String_var aSComponentEntry = aSComponent->GetID(), anIOR(GetID());
-      string anEntry = CreateAttributes(myStudyDocument,aSComponentEntry,"",anIOR,myName.c_str(),"",GetComment());
-      */
-    }
-    return this;
-  }
+    if (!anApp)
+      return;
 
-  void View3D_i::Update(){
-    if(MYDEBUG) MESSAGE("View3D_i::Update");
-    Mutex mt(myMutex,qApp);
-    myName = myStudyFrame->title();
-    myColor = GetBackground();
-    GetCamera(myStudyFrame)->GetPosition(myPosition);
-    GetCamera(myStudyFrame)->GetViewUp(myViewUp);
-    GetCamera(myStudyFrame)->GetFocalPoint(myFocalPnt);
-    myParallelScale = GetCamera(myStudyFrame)->GetParallelScale();
-    RepaintView(myStudyFrame);
-
-    VTKViewer_NonIsometricTransform *NITr = GetViewFrame(myStudyFrame)->getNonIsometricTransform();
-    myScaleFactor[0] = NITr->GetCoeff(AxisFunction::XAxis);
-    myScaleFactor[1] = NITr->GetCoeff(AxisFunction::YAxis);
-    myScaleFactor[2] = NITr->GetCoeff(AxisFunction::ZAxis);
-  }
+    // 2. Remove corresponding IO from selection
+    SALOMEDS::SObject_var aSObject = thePrs->GetSObject();
+    CORBA::String_var anEntry = aSObject->GetID();
 
-  CORBA::Boolean View3D_i::SavePicture(const char* theFileName) {
-    if(MYDEBUG) MESSAGE("View3D_i::SavePicture");
-    Mutex mt(myMutex,qApp);
-    if (!myStudyFrame->getRightFrame()->getViewFrame()->getViewWidget())
-      return false;
-
-    QApplication::setOverrideCursor( Qt::waitCursor );
-    QPixmap px = QPixmap::grabWindow(myStudyFrame->getRightFrame()->getViewFrame()->getViewWidget()->winId());
-    QApplication::restoreOverrideCursor();
-    
-    if (!QString(theFileName).isNull()) {
-      QApplication::setOverrideCursor( Qt::waitCursor );
-      QString fmt = QAD_Tools::getFileExtensionFromPath(theFileName).upper();
-      if (fmt.isEmpty())
-       fmt = QString("BMP"); // default format
-      if (fmt == "JPG")
-       fmt = "JPEG";
-      bool bOk = px.save(theFileName, fmt.latin1());
-      QApplication::restoreOverrideCursor();
-      return bOk;
-    }
-    return false;
-  }
+    LightApp_SelectionMgr* aSelectionMgr = anApp->selectionMgr();
+    SALOME_ListIO aListIO, aNewListIO;
+    aSelectionMgr->selectedObjects(aListIO);
 
-  CORBA::Boolean View3D_i::SaveViewParams(const char* theName){
-    if(MYDEBUG)  MESSAGE("View3D_i::SaveViewPoint");
-    Mutex mt(myMutex,qApp);
-    if ( theName ) {
-      SALOMEDS::Study::ListOfSObject_var aList = 
-       myStudy->getStudyDocument()->FindObjectByName(theName,"VISU");
-      SALOMEDS::GenericAttribute_var anAttr;
-      int iEnd = aList->length();
-      for(int i = 0; i < iEnd; i++){
-       SALOMEDS::SObject_var anObj = aList[i];
-       CORBA::String_var aString = anObj->GetID();
-       string anEntry(aString);
-       if(MYDEBUG)  MESSAGE("View3D_i::SaveViewPoint - anEntry = "<<anEntry);
-       if(anObj->FindAttribute(anAttr, "AttributeComment")){
-         SALOMEDS::AttributeComment_var aCmnt = SALOMEDS::AttributeComment::_narrow(anAttr);
-         aString = aCmnt->Value();
-         string aComm(aString);
-         if(MYDEBUG)  MESSAGE("View3D_i::SaveViewPoint - aComm = "<<aComm);
-         if(aComm.compare(View3D_i::myComment) >= 0){
-           aCmnt->SetValue(ToString());
-           return 1;
-         }
-       }
+    for (SALOME_ListIteratorOfListIO it (aListIO); it.More(); it.Next()) {
+      if (it.Value()->hasEntry()) {
+        std::string aCurEntry (it.Value()->getEntry());
+        if (aCurEntry != std::string( anEntry.in() ) ) {
+          aNewListIO.Append(it.Value());
+        }
       }
     }
-    QString newName;
-    if ( theName )
-      newName = QString( theName );
-    else
-      newName = QString( GenerateViewParamsName() );
-    SALOMEDS::SComponent_var aSComponent = 
-      FindOrCreateVisuComponent(myStudy->getStudyDocument());
-    CORBA::String_var aSComponentEntry = aSComponent->GetID(), anIOR(GetID());
-    string anEntry = CreateAttributes(myStudy->getStudyDocument(),aSComponentEntry,"","",newName.latin1(),"",ToString());
-    return 1;
-  }
 
-  CORBA::Boolean View3D_i::RestoreViewParams(const char* theName){
-    if(MYDEBUG)  MESSAGE("View3D_i::RestoreViewPoint - "<<theName);
-    Mutex mt(myMutex,qApp);
-    SALOMEDS::Study::ListOfSObject_var aList = 
-      myStudy->getStudyDocument()->FindObjectByName(theName,"VISU");
-    SALOMEDS::GenericAttribute_var anAttr;
-    int iEnd = aList->length();
-    if(MYDEBUG)  MESSAGE("View3D_i::RestoreViewPoint - iEnd = "<<iEnd);
-    for(int i = 0; i < iEnd; i++){
-      SALOMEDS::SObject_var anObj = aList[i];
-      CORBA::String_var aString = anObj->GetID();
-      string anEntry(aString);
-      if(MYDEBUG)  MESSAGE("View3D_i::RestoreViewPoint - anEntry = "<<anEntry);
-      if(anObj->FindAttribute(anAttr, "AttributeComment")){
-       SALOMEDS::AttributeComment_var aCmnt = SALOMEDS::AttributeComment::_narrow(anAttr);
-       aString = aCmnt->Value();
-       QString strIn(aString);
-       Storable::TRestoringMap aMap;
-       Storable::StrToMap(strIn,aMap);
-       if ( Storable::FindValue( aMap,"myComment").compare( View3D_i::myComment.c_str() ) >= 0 ) {
-         if(MYDEBUG)  MESSAGE("View3D_i::RestoreViewPoint - aComm = "<<strIn);
-         return Restore( aMap ) != NULL;
+    aSelectionMgr->setSelectedObjects(aNewListIO);
+
+    // 3. Remove Actors
+    ViewManagerList aViewManagerList;
+    anApp->viewManagers(SVTK_Viewer::Type(), aViewManagerList);
+    QPtrListIterator<SUIT_ViewManager> anVMIter (aViewManagerList);
+    for (; anVMIter.current(); ++anVMIter) {
+      SUIT_ViewManager* aViewManager = anVMIter.current();
+      QPtrVector<SUIT_ViewWindow> aViews = aViewManager->getViews();
+      for (int i = 0, iEnd = aViews.size(); i < iEnd; i++) {
+       if (SUIT_ViewWindow* aViewWindow = aViews.at(i)) {
+         if (Plot2d_ViewWindow* vw = dynamic_cast<Plot2d_ViewWindow*>(aViewWindow)) {
+            Plot2d_ViewFrame* vf = vw->getViewFrame();
+            QList<Plot2d_Curve> clist;
+            vf->getCurves(clist);
+           for (int i = 0; i < clist.count(); i++) {
+              if (SPlot2d_Curve* cu = dynamic_cast<SPlot2d_Curve*>(clist.at(i))) {
+               if (cu->hasIO() &&
+                   strcmp(cu->getIO()->getEntry(), thePrs->GetEntry()) == 0) {
+                 vf->eraseCurve(cu);
+               }
+             }
+           }
+           vf->Repaint();
+           //jfa tmp:aViewFrame->unHighlightAll();
+          }
+        }
+      }
+}*/
+  }
+
+  void DeleteActors (VISU::Prs3d_i* thePrs)
+  {
+    if (!thePrs) return;
+
+    // 1. Find appropriate application (code like in TNewViewManagerEvent::Execute())
+    SALOMEDS::Study_var myStudyDocument = thePrs->GetStudyDocument();
+    SalomeApp_Application* anApp = NULL;
+    CORBA::String_var studyName = myStudyDocument->Name();
+    std::string aStudyName = studyName.in();
+    SUIT_Session* aSession = SUIT_Session::session();
+    QPtrList<SUIT_Application> anApplications = aSession->applications();
+    QPtrListIterator<SUIT_Application> anIter (anApplications);
+    while (SUIT_Application* aSUITApp = anIter.current()) {
+      ++anIter;
+      if (SUIT_Study* aSStudy = aSUITApp->activeStudy()) {
+        if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
+          if (_PTR(Study) aCStudy = aStudy->studyDS()) {
+            if (aStudyName == aCStudy->Name()) {
+              anApp = dynamic_cast<SalomeApp_Application*>(aSUITApp);
+             break;
+           }
+         }
        }
       }
     }
-    return 0;
-  }
-
-#define  RESTORE(MAP,ARG,FMT) ARG = VISU::Storable::FindValue(MAP,#ARG).FMT()
-
-  Storable* View3D_i::Restore(const Storable::TRestoringMap& theMap) throw(std::logic_error&) {
-    if(MYDEBUG)  MESSAGE("View3D_i::Restore");
-    //RESTORE(theMap,myName,latin1);
-    
-    RESTORE(theMap,myColor.R,toDouble);
-    RESTORE(theMap,myColor.G,toDouble);
-    RESTORE(theMap,myColor.B,toDouble);
-    
-    RESTORE(theMap,myPosition[0],toDouble);
-    RESTORE(theMap,myPosition[1],toDouble);
-    RESTORE(theMap,myPosition[2],toDouble);
-    
-    RESTORE(theMap,myFocalPnt[0],toDouble);
-    RESTORE(theMap,myFocalPnt[1],toDouble);
-    RESTORE(theMap,myFocalPnt[2],toDouble);
-    
-    RESTORE(theMap,myViewUp[0],toDouble);
-    RESTORE(theMap,myViewUp[1],toDouble);
-    RESTORE(theMap,myViewUp[2],toDouble);
-    
-    RESTORE(theMap,myParallelScale,toDouble);
-    
-    RESTORE(theMap,myScaleFactor[0],toDouble);
-    RESTORE(theMap,myScaleFactor[1],toDouble);
-    RESTORE(theMap,myScaleFactor[2],toDouble);
-    
-    return Build(true);
-  }
-    
-#undef RESTORE
-
-  void View3D_i::ToStream(ostrstream& theStr) {
-    if(MYDEBUG) MESSAGE(GetComment());
-    Update();
-    Storable::DataToStream(theStr,"myType",VISU::TVIEW3D);
-
-    Storable::DataToStream(theStr,"myColor.R",myColor.R);
-    Storable::DataToStream(theStr,"myColor.G",myColor.G);
-    Storable::DataToStream(theStr,"myColor.B",myColor.B);
-
-    Storable::DataToStream(theStr,"myPosition[0]",myPosition[0]);
-    Storable::DataToStream(theStr,"myPosition[1]",myPosition[1]);
-    Storable::DataToStream(theStr,"myPosition[2]",myPosition[2]);
-
-    Storable::DataToStream(theStr,"myFocalPnt[0]",myFocalPnt[0]);
-    Storable::DataToStream(theStr,"myFocalPnt[1]",myFocalPnt[1]);
-    Storable::DataToStream(theStr,"myFocalPnt[2]",myFocalPnt[2]);
-
-    Storable::DataToStream(theStr,"myViewUp[0]",myViewUp[0]);
-    Storable::DataToStream(theStr,"myViewUp[1]",myViewUp[1]);
-    Storable::DataToStream(theStr,"myViewUp[2]",myViewUp[2]);
+    if (!anApp)
+      return;
 
-    Storable::DataToStream(theStr,"myParallelScale",myParallelScale);
+    // 2. Remove corresponding IO from selection
+    SALOMEDS::SObject_var aSObject = thePrs->GetSObject();
+    CORBA::String_var anEntry = aSObject->GetID();
 
-    Storable::DataToStream(theStr,"myScaleFactor[0]",myScaleFactor[0]);
-    Storable::DataToStream(theStr,"myScaleFactor[1]",myScaleFactor[1]);
-    Storable::DataToStream(theStr,"myScaleFactor[2]",myScaleFactor[2]);
-  }
+    LightApp_SelectionMgr* aSelectionMgr = anApp->selectionMgr();
+    SALOME_ListIO aListIO, aNewListIO;
+    aSelectionMgr->selectedObjects(aListIO);
 
-  Storable* VISU::View3DRestore(SALOMEDS::SComponent_var& theSComponent, SALOMEDS::Study_var& theStudy,
-                               const char* thePrefix, const Storable::TRestoringMap& theMap)
-    {
-      try{
-       View3D_i* pView3D = new View3D_i(theStudy);
-       return pView3D->Restore(theMap);
-      }catch(std::logic_error& exc){
-       MESSAGE("Follow exception was accured :\n"<<exc.what());
-      }catch(...){
-       MESSAGE("Unknown exception was accured!");
+    for (SALOME_ListIteratorOfListIO it (aListIO); it.More(); it.Next()) {
+      if (it.Value()->hasEntry()) {
+        std::string aCurEntry (it.Value()->getEntry());
+        if (aCurEntry != std::string( anEntry.in() ) ) {
+          aNewListIO.Append(it.Value());
+        }
       }
-      return NULL;
-    }
-  
-  void View3D_i::Close(){
-    if(MYDEBUG) MESSAGE("View3D_i::Close");
-    Mutex mt(myMutex,qApp);
-    myStudyFrame->close();
-  }
-
-  View3D_i::~View3D_i() {
-    if(MYDEBUG) MESSAGE("View3D_i::~View3D_i");
-    Mutex mt(myMutex,qApp);
-    myStudyFrame->close();
-  }
-  
-  //-------------------- View interface --------------------
-  void View3D_i::SetTitle(const char* theTitle){
-    if(MYDEBUG) MESSAGE("View3D_i::SetTitle");
-    Mutex mt(myMutex,qApp);
-    myName = theTitle;
-    /*
-    SALOMEDS::SObject_var aSObject = 
-    myStudy->getStudyDocument()->FindObjectID(GetEntry());
-    SALOMEDS::GenericAttribute_var anAttr;
-    if(aSObject->FindAttribute(anAttr,"AttributeName")){
-      SALOMEDS::AttributeName_ptr aName = SALOMEDS::AttributeName::_narrow(anAttr);
-      aName->SetValue(myName.c_str());
-    }
-    */
-    myStudyFrame->setTitle(myName.c_str());
-  }
-  char* View3D_i::GetTitle() {
-    if(MYDEBUG) MESSAGE("View3D_i::GetTitle");
-    Mutex mt(myMutex,qApp);
-    myName = myStudyFrame->title();
-    return CORBA::string_dup(myName.c_str());
-  }
-  void View3D_i::SetBackground(const SALOMEDS::Color& theColor) {
-    if(MYDEBUG) MESSAGE("View3D_i::SetBackground");
-    Mutex mt(myMutex,qApp);
-    myColor.R = theColor.R;
-    myColor.G = theColor.G;
-    myColor.B = theColor.B;
-    QColor aColor(255.0*myColor.R,255.0*myColor.G,255.0*myColor.B);
-    GetViewFrame(myStudyFrame)->setBackgroundColor(aColor);
-  }
-  SALOMEDS::Color View3D_i::GetBackground() { 
-    if(MYDEBUG) MESSAGE("View3D_i::GetBackground");
-    Mutex mt(myMutex,qApp);
-    float backint[3];
-    GetRenderer(myStudyFrame)->GetBackground(backint);
-    myColor.R = backint[0];
-    myColor.G = backint[1];
-    myColor.B = backint[2];
-    return myColor;
-  }
-  void View3D_i::Minimize() {
-    if(MYDEBUG) MESSAGE("View3D_i::Minimize");
-    Mutex mt(myMutex,qApp);
-    myStudyFrame->showMinimized();
-  }
-  void View3D_i::Restore() {
-    if(MYDEBUG) MESSAGE("View3D_i::Restore");
-    Mutex mt(myMutex,qApp);
-    myStudyFrame->showNormal();
-  }
-  void View3D_i::Maximize() {
-    if(MYDEBUG) MESSAGE("View3D_i::Maximize");
-    Mutex mt(myMutex,qApp);
-    myStudyFrame->showMaximized();
-  }
-  //===========================================================================
-  void View3D_i::EraseAll() {
-    if(MYDEBUG) MESSAGE("View3D_i::EraseAll");
-    Mutex mt(myMutex,qApp);
-    UpdateViewer(myStudyFrame,eEraseAll);
-  }
-  void View3D_i::DisplayAll() {
-    if(MYDEBUG) MESSAGE("View3D_i::DisplayAll");
-    Mutex mt(myMutex,qApp);
-    UpdateViewer(myStudyFrame,eDisplayAll);
-  }
-  void View3D_i::Erase(PrsObject_ptr thePrsObj) {
-    if(MYDEBUG) MESSAGE("View3D_i::Erase");
-    Mutex mt(myMutex,qApp);
-    CORBA::Object_var anObj = thePrsObj;
-    if(Prs3d_i* aPrs =  dynamic_cast<Prs3d_i*>(VISU::GetServant(anObj)))
-      UpdateViewer(myStudyFrame,eErase,aPrs);
-  }
-  void View3D_i::Display(PrsObject_ptr thePrsObj) {
-    if(MYDEBUG) MESSAGE("View3D_i::Display"); 
-    Mutex mt(myMutex,qApp);
-    CORBA::Object_var anObj = thePrsObj;
-    if(Prs3d_i* aPrs =  dynamic_cast<Prs3d_i*>(VISU::GetServant(anObj)))
-      UpdateViewer(myStudyFrame,eDisplay,aPrs);
-  }
-  void View3D_i::DisplayOnly(PrsObject_ptr thePrsObj) {
-    if(MYDEBUG) MESSAGE("View3D_i::DisplayOnly");
-    Mutex mt(myMutex,qApp);
-    CORBA::Object_var anObj = thePrsObj;
-    if(Prs3d_i* aPrs =  dynamic_cast<Prs3d_i*>(VISU::GetServant(anObj)))
-      UpdateViewer(myStudyFrame,eDisplayOnly,aPrs);
-  }
-
-  //-------------------- View3D interface --------------------
-  void View3D_i::FitAll() { 
-    if(MYDEBUG) MESSAGE("View3D_i::FitAll");
-    Mutex mt(myMutex,qApp);
-    GetViewFrame(myStudyFrame)->onViewFitAll();
-    Update();
-  }
-  void View3D_i::SetView(VISU::View3D::ViewType theType) {
-    if(MYDEBUG) MESSAGE("View3D_i::SetView");
-    Mutex mt(myMutex,qApp);
-    switch(theType){
-    case VISU::View3D::FRONT : GetViewFrame(myStudyFrame)->onViewFront(); break;
-    case VISU::View3D::BACK : GetViewFrame(myStudyFrame)->onViewBack(); break;
-    case VISU::View3D::LEFT : GetViewFrame(myStudyFrame)->onViewLeft(); break;
-    case VISU::View3D::RIGHT : GetViewFrame(myStudyFrame)->onViewRight(); break;
-    case VISU::View3D::TOP : GetViewFrame(myStudyFrame)->onViewTop(); break;
-    case VISU::View3D::BOTTOM : GetViewFrame(myStudyFrame)->onViewBottom(); break;
     }
-    Update();
-  }
 
-  void View3D_i::SetPointOfView(const VISU::View3D::XYZ theCoord) {
-    if(MYDEBUG) MESSAGE("View3D_i::SetPointOfView");
-    Mutex mt(myMutex,qApp);
-    VISU::View3D::XYZ_copy(myPosition,theCoord);
-    GetCamera(myStudyFrame)->SetPosition(myPosition);
-  }
-  VISU::View3D::XYZ_slice* View3D_i::GetPointOfView() { 
-    if(MYDEBUG) MESSAGE("View3D_i::GetPointOfView");
-    Mutex mt(myMutex,qApp);
-    GetCamera(myStudyFrame)->GetPosition(myPosition);
-    return VISU::View3D::XYZ_dup(myPosition);
-  }
-
-  void View3D_i::SetViewUp(const VISU::View3D::XYZ theDir) {
-    if(MYDEBUG) MESSAGE("View3D_i::SetViewUp");
-    Mutex mt(myMutex,qApp);
-    VISU::View3D::XYZ_copy(myViewUp,theDir);
-    GetCamera(myStudyFrame)->SetViewUp(myViewUp);
-  }
-  VISU::View3D::XYZ_slice* View3D_i::GetViewUp() { 
-    if(MYDEBUG) MESSAGE("View3D_i::GetViewUp");
-    Mutex mt(myMutex,qApp);
-    GetCamera(myStudyFrame)->GetViewUp(myViewUp);
-    return VISU::View3D::XYZ_dup(myViewUp);
-  }
-
-  void View3D_i::SetFocalPoint(const VISU::View3D::XYZ theCoord) {
-    if(MYDEBUG) MESSAGE("View3D_i::SetFocalPoint");
-    Mutex mt(myMutex,qApp);
-    VISU::View3D::XYZ_copy(myFocalPnt,theCoord);
-    GetCamera(myStudyFrame)->SetFocalPoint(myFocalPnt);
-  }
-  VISU::View3D::XYZ_slice* View3D_i::GetFocalPoint() { 
-    if(MYDEBUG) MESSAGE("View3D_i::GetFocalPoint");
-    Mutex mt(myMutex,qApp);
-    GetCamera(myStudyFrame)->GetFocalPoint(myFocalPnt);
-    return VISU::View3D::XYZ_dup(myFocalPnt);
-  }
-
-  void View3D_i::SetParallelScale(CORBA::Double theScale) {
-    if(MYDEBUG) MESSAGE("View3D_i::SetParallelScale");
-    Mutex mt(myMutex,qApp);
-    myParallelScale = theScale;
-    GetCamera(myStudyFrame)->SetParallelScale(myParallelScale);
-  }
-  CORBA::Double View3D_i::GetParallelScale() { 
-    if(MYDEBUG) MESSAGE("View3D_i::GetParallelScale");
-    Mutex mt(myMutex,qApp);
-    return myParallelScale = GetCamera(myStudyFrame)->GetParallelScale();
-  }
-
-  void View3D_i::ScaleView(VISU::View3D::Axis theAxis, CORBA::Double theParam) {
-    Mutex mt(myMutex,qApp);
-    bool changed = false;
-    VTKViewer_ViewFrame* vf =  GetViewFrame(myStudyFrame);
-    VTKViewer_NonIsometricTransform *aTransform = vf->getNonIsometricTransform();
-    static double EPS =1.0E-3;
-    VTKViewer_NonIsometricTransform::Function 
-      aFunction = (fabs(theParam - 1.0) < EPS? 
-                  VTKViewer_NonIsometricTransform::Identical: 
-                  VTKViewer_NonIsometricTransform::Linear);
-    AxisFunction::Axis anAxis;
-    if(theAxis == VISU::View3D::XAxis){
-      myScaleFactor[0] = theParam;
-      anAxis = AxisFunction::XAxis;
-    }else if(theAxis == VISU::View3D::YAxis){
-      myScaleFactor[1] = theParam;
-      anAxis = AxisFunction::YAxis;
-    }else{
-      myScaleFactor[2] = theParam;
-      anAxis = AxisFunction::ZAxis;
-    }
-    if(MYDEBUG) 
-      MESSAGE("View3D_i::ScaleView - theParam = "<<theParam<<"; aFunction = "<<aFunction);
-    vtkRenderer* Renderer = vf->getRenderer();
-    vtkActorCollection* theActors = Renderer->GetActors();
-    theActors->InitTraversal();
-    vtkActor *actor = theActors->GetNextActor();
-    while(actor){
-      //SALOME_Actor* pSA = dynamic_cast<SALOME_Actor*> (actor);
-      SALOME_Actor* pSA = dynamic_cast<VISU_Actor*> (actor);
-      if(pSA){
-       vtkPolyDataMapper* mapper = NULL;
-       vtkMapper* initialMapper = pSA->GetInitialMapper();
-       if ( initialMapper == NULL )
-         initialMapper =   actor->GetMapper();
-       if ( initialMapper->IsA("vtkDataSetMapper") )
-         mapper = vtkDataSetMapper::SafeDownCast( initialMapper )->GetPolyDataMapper ();
-       else
-         mapper = vtkPolyDataMapper::SafeDownCast( initialMapper );
-       if(mapper){
-         //create transformation
-         if(MYDEBUG) MESSAGE("View3D_i::ScaleView - theActors->GetNextActor()");
-         aTransform->SetFunction(anAxis,aFunction,theParam); 
-         //create Filter
-         vtkTransformPolyDataFilter *aTransformFilter = vtkTransformPolyDataFilter::New();
-         aTransformFilter->SetInput ( mapper->GetInput() );
-         aTransformFilter->SetTransform (aTransform);
-         //create new mapper
-         vtkPolyDataMapper *aMapper = vtkPolyDataMapper::New();
-         aMapper->SetInput (aTransformFilter->GetOutput());
-         aMapper->ShallowCopy ( actor->GetMapper());
-         //set new mapper
-         actor->SetMapper (aMapper);
-         aTransformFilter->Delete();
-         aMapper->Delete();
-         changed = true;
-       }
+    aSelectionMgr->setSelectedObjects(aNewListIO);
+
+    // 3. Remove Actors
+    ViewManagerList aViewManagerList;
+    anApp->viewManagers(SVTK_Viewer::Type(), aViewManagerList);
+    QPtrListIterator<SUIT_ViewManager> anVMIter (aViewManagerList);
+    for (; anVMIter.current(); ++anVMIter) {
+      SUIT_ViewManager* aViewManager = anVMIter.current();
+      QPtrVector<SUIT_ViewWindow> aViews = aViewManager->getViews();
+      for (int i = 0, iEnd = aViews.size(); i < iEnd; i++) {
+       if (SUIT_ViewWindow* aViewWindow = aViews.at(i)) {
+         if (SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>(aViewWindow)) {
+            VISU_Actor* anActor = NULL;
+            vtkActorCollection *anActColl = vw->getRenderer()->GetActors();
+           anActColl->InitTraversal();
+            vtkActor *aVTKActor = anActColl->GetNextActor();
+           for (; !anActor && aVTKActor; aVTKActor = anActColl->GetNextActor()) {
+              if (VISU_Actor* anVISUActor = dynamic_cast<VISU_Actor*>(aVTKActor)) {
+               if (thePrs == anVISUActor->GetPrs3d()) {
+                 anActor = anVISUActor->GetParent();
+                }
+              }
+            }
+            if (anActor) {
+             vw->RemoveActor(anActor);
+             anActor->Delete();
+            }
+          }
+        }
       }
-      actor = theActors->GetNextActor();
     }
-    if(MYDEBUG) 
-      MESSAGE("View3D_i::ScaleView - myScaleFactor = "<<
-             myScaleFactor[0]<<"; "<<myScaleFactor[1]<<"; "<<myScaleFactor[2]);
-    if (changed)
-      RepaintView(myStudyFrame);
-  }
-  void View3D_i::RemoveScale() {
-    if(MYDEBUG) MESSAGE("View3D_i::RemoveScale");
-    Mutex mt(myMutex,qApp);
-    ScaleView(VISU::View3D::XAxis,1.0);
-    ScaleView(VISU::View3D::YAxis,1.0);
-    ScaleView(VISU::View3D::ZAxis,1.0);
   }
-  //===========================================================================
 }