Salome HOME
Fix on Bug PAL7927
[modules/visu.git] / src / VISU_I / VISU_ViewManager_i.cc
index 1ec6ddfbfb34859f81dcbb5d57ddb1be864443e0..6639b6b6476c9a012c6fef0fb2836bd934826440 100644 (file)
@@ -28,6 +28,7 @@
 
 #include "VISU_PrsObject_i.hh"
 #include "VISU_Result_i.hh"
+#include "VISU_Gen_i.hh"
 
 #include "VISU_Prs3d_i.hh"
 #include "VISU_Mesh_i.hh"
 #include "QAD_Desktop.h"
 #include "QAD_Tools.h"
 #include "QAD_Study.h"
+#include "QAD_LeftFrame.h"
 #include "QAD_RightFrame.h"
 #include "QAD_StudyFrame.h"
+#include "QAD_PyEditor.h"
 
 #include "VTKViewer_ViewFrame.h"
+#include "VTKViewer_RenderWindow.h"
 #include "SALOMEGUI_TableDlg.h"
 #include "Plot2d_CurveContainer.h"
 #include "Plot2d_ViewFrame.h"
@@ -62,8 +66,6 @@
 #include <qstring.h>
 #include <qfileinfo.h>
 
-#include <vtkTransformPolyDataFilter.h>
-#include <vtkDataSetMapper.h>
 #include <vtkRenderer.h>
 #include <vtkCamera.h>
 
@@ -76,7 +78,6 @@ static int MYDEBUG = 0;
 #endif
 
 static QFileInfo aFileInfo;
-static int MYDELAY = 1;
 
 namespace VISU{
   //===========================================================================
@@ -100,6 +101,233 @@ namespace VISU{
     }
   };
 
+  class TSetViewRepresentation: public SALOME_Event{
+    VISU::View::ViewRepresentation myViewRepr;
+    View_i*                        myView;
+    CORBA::Boolean                 myState;
+ public:
+    TSetViewRepresentation( View_i*  aView, 
+                           VISU::View::ViewRepresentation ViewRepr,
+                           CORBA::Boolean State ):
+      SALOME_Event(), myViewRepr( ViewRepr ), myView( aView ), myState( State )
+    {}
+    virtual void Execute(){
+
+  bool old = myView->IsPartShown( myViewRepr );
+
+  QAD_RightFrame* fr = myView->myStudyFrame->getRightFrame();
+
+  if( myView->myStudyFrame != NULL ){
+    switch( myViewRepr )
+      {
+      case VISU::View::OBJECTBROWSER:
+       if( myState!=old )
+         if( myState )
+           myView->myStudyFrame->unCompressLeft();
+         else
+           myView->myStudyFrame->compressLeft();
+       break;
+      case VISU::View::VIEWER:
+       if( myState!=old )
+         if( myState )
+           fr->unCompressUp();
+         else
+           fr->compressUp();
+       break;
+      case VISU::View::PYTHON:
+       if( myState!=old )
+         if( myState )
+           fr->unCompressLeft();
+         else
+           fr->compressLeft();
+       break;
+      case VISU::View::MESSAGES:
+       if( myState!=old )
+         if( myState )
+           fr->unCompressRight();
+         else
+           fr->compressRight();
+       break;
+      };
+    }
+  }
+};
+
+  class TGetViewRepresentation: public SALOME_Event
+  {
+  public:
+    typedef CORBA::Boolean TResult;
+    TResult myResult;
+    VISU::View::ViewRepresentation myPart;
+    View_i*  myView;
+
+    TGetViewRepresentation( View_i* aView, VISU::View::ViewRepresentation Part ):
+      SALOME_Event(), myResult( false ), myPart( Part ), myView( aView )
+       {
+       }
+      virtual void Execute(){
+       switch( myPart )
+         {
+         case VISU::View::OBJECTBROWSER:
+           myResult = !myView->myStudyFrame->isCompressedLeft();
+           break;
+         case VISU::View::VIEWER:
+           myResult = !myView->myStudyFrame->getRightFrame()->isCompressedViewFrame();
+           break;
+         case VISU::View::PYTHON:
+           myResult = !myView->myStudyFrame->getRightFrame()->isCompressedPython();
+           break;
+         case VISU::View::MESSAGES:
+           myResult = !myView->myStudyFrame->getRightFrame()->isCompressedMessage();
+         }
+      }
+  };
+
+  class TSetViewWidthHeight: public SALOME_Event{
+    CORBA::Long mySize;
+    bool myIsWidth;
+    View_i*  myView;
+  public:
+      TSetViewWidthHeight( View_i* aView, CORBA::Long Size, bool IsWidth ):
+       SALOME_Event(), mySize( Size ), myView( aView ), myIsWidth( IsWidth )
+         {}
+      virtual void Execute(){
+        if( myView->myStudyFrame != NULL ){
+         QWidget* aStudyParent = myView->myStudyFrame->parentWidget(true);
+         int aleft   = aStudyParent->frameGeometry().left();
+         int atop    = aStudyParent->frameGeometry().top();
+         int aheight = aStudyParent->frameGeometry().height();
+         int awidth  = aStudyParent->frameGeometry().width();
+         QRect aQRect;
+         if( myIsWidth )
+           aQRect = QRect( aleft, atop, mySize, aheight );
+         else
+           aQRect = QRect( aleft, atop, awidth, mySize );
+
+         aStudyParent->setGeometry(aQRect);
+       } 
+      }
+  };    
+
+  class TGetViewWidthHeight: public SALOME_Event{
+  public:
+    typedef CORBA::Long TResult;
+    TResult myResult;
+    bool myIsWidth;
+    View_i*  myView;
+  public:
+      TGetViewWidthHeight( View_i* aView, bool IsWidth ):
+       SALOME_Event(), myView( aView ), myIsWidth( IsWidth )
+         {}
+
+         virtual void Execute()
+           {
+             if( myView ) {
+               QWidget* aStudyParent = myView->myStudyFrame->parentWidget(true);
+               if( myIsWidth )
+                 myResult = aStudyParent->frameGeometry().width();
+               else
+                 myResult = aStudyParent->frameGeometry().height();
+             }
+           }
+  };
+
+  class TSetViewPositionHorizontal: public SALOME_Event{
+    VISU::View::ViewPosition     myViewPos;
+    View_i*                      myView;   
+  public:
+     TSetViewPositionHorizontal ( View_i* aView,
+                                 VISU::View::ViewPosition ViewPos  ):
+       SALOME_Event(), myView( aView ), myViewPos(ViewPos)
+    {}
+    virtual void Execute(){
+    QWidget* aWorkspace = dynamic_cast <QWidget*> (myView->myStudy->getApp()->getDesktop()->getMainFrame());
+    QWidget* aStudy = dynamic_cast <QWidget*> (myView->myStudyFrame);
+    QWidget* aStudyParent = aStudy->parentWidget(true);
+    if ( aStudyParent != 0 )
+      if ( aWorkspace!=NULL || aStudy != NULL )
+       switch(myViewPos){
+         case VISU::View::LEFT:
+         QAD_Tools::alignWidget(aStudyParent,aWorkspace,Qt::AlignLeft);
+           break;
+         case VISU::View::CENTER:
+           QAD_Tools::alignWidget(aStudyParent,aWorkspace,Qt::AlignHCenter);
+           break;
+         case VISU::View::RIGHT:
+           QAD_Tools::alignWidget(aStudyParent,aWorkspace,Qt::AlignRight);
+           break;
+       }
+    }
+  };
+
+  class TSetViewPositionVertical: public SALOME_Event{
+    VISU::View::ViewPosition     myViewPos;
+    View_i*                      myView;
+  public:
+      TSetViewPositionVertical ( View_i* aView,
+                                VISU::View::ViewPosition ViewPos  ):
+       SALOME_Event(), myView( aView ), myViewPos(ViewPos)
+    {}
+    virtual void Execute(){
+    QWidget* aWorkspace = dynamic_cast <QWidget*> (myView->myStudy->getApp()->getDesktop()->getMainFrame());
+    QWidget* aStudy = dynamic_cast <QWidget*>(myView->myStudyFrame);
+    QWidget* aStudyParent = aStudy->parentWidget(true);
+    if ( aStudyParent != 0 )
+      if ( aWorkspace!=NULL || aStudy != NULL )
+       switch(myViewPos){
+         case VISU::View::TOP:
+         QAD_Tools::alignWidget(aStudyParent,aWorkspace,Qt::AlignTop);
+           break;
+         case VISU::View::CENTER:
+           QAD_Tools::alignWidget(aStudyParent,aWorkspace,Qt::AlignVCenter);
+           break;
+         case VISU::View::BOTTOM:
+           QAD_Tools::alignWidget(aStudyParent,aWorkspace,Qt::AlignBottom);
+           break;
+       }
+    }
+  };
+
+  class TSetRelativePosition : public SALOME_Event
+  {
+    View_i*                      myView;
+    CORBA::Double                myX, myY;
+  public:
+    TSetRelativePosition ( View_i* aView, CORBA::Double X, CORBA::Double Y ):
+      SALOME_Event(), myView( aView ), myX( X ), myY( Y )
+    {}
+    virtual void Execute(){
+      QWidget* aWorkspace = dynamic_cast <QWidget*> (myView->myStudy->getApp()->getDesktop()->getMainFrame());
+      if( aWorkspace )
+      {
+       QAD_StudyFrame* aFrame = myView->myStudyFrame;
+       QWidget* aStudyParent = aFrame->parentWidget(true);
+       aStudyParent->move( int( myX * aWorkspace->width() ), int( myY * aWorkspace->height() ) );
+      }
+    }
+  };
+
+  class TSetRelativeSize : public SALOME_Event
+  {
+    View_i*                      myView;
+    CORBA::Double                myX, myY;
+  public:
+    TSetRelativeSize ( View_i* aView, CORBA::Double X, CORBA::Double Y ):
+      SALOME_Event(), myView( aView ), myX( X ), myY( Y )
+    {}
+    virtual void Execute(){
+      QWidget* aWorkspace = dynamic_cast <QWidget*> (myView->myStudy->getApp()->getDesktop()->getMainFrame());
+      if( aWorkspace )
+      {
+       QAD_StudyFrame* aFrame = myView->myStudyFrame;
+       QWidget* aStudyParent = aFrame->parentWidget(true);
+       aStudyParent->setGeometry( aStudyParent->x(), aStudyParent->y(),
+                            int( myX * aWorkspace->width() ), int( myY * aWorkspace->height() ) );
+      }
+    }
+  };
+
+
 
   class TSavePictureEvent: public SALOME_Event{
     QWidget* myWidget;
@@ -152,12 +380,16 @@ namespace VISU{
   }
 
 
-  void RepaintView(QAD_StudyFrame* theStudyFrame){
-    GetRenderer(theStudyFrame)->ResetCameraClippingRange();
-    GetViewFrame(theStudyFrame)->getRW()->getRenderWindow()->Render();
+  void RepaintView(VTKViewer_ViewFrame* theViewFrame){
+    theViewFrame->getRenderer()->ResetCameraClippingRange();
+    theViewFrame->getRW()->getRenderWindow()->Render();
     //GetViewFrame(theStudyFrame)->Repaint();
   }
 
+  void RepaintView(QAD_StudyFrame* theStudyFrame){
+    RepaintView(GetViewFrame(theStudyFrame));
+  }
+
 
   VISU_Actor* UpdateViewer(QAD_StudyFrame* theStudyFrame, int theDisplaing, Prs3d_i* thePrs){
     VTKViewer_ViewFrame* vf = GetViewFrame(theStudyFrame);
@@ -225,18 +457,23 @@ namespace VISU{
       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 )->setHorTitle( theCurve->GetHorTitle().c_str() );
+         clist.at( i )->setVerTitle( theCurve->GetVerTitle().c_str() );
+         clist.at( i )->setHorUnits( theCurve->GetHorUnits().c_str() );
+         clist.at( i )->setVerUnits( theCurve->GetVerUnits().c_str() );
+         double* xList = 0;
+         double* yList = 0;
+         int     nbPoints = theCurve->GetData( xList, yList );
+         if ( nbPoints > 0 && xList && yList ) {
+           clist.at( i )->setData( xList, yList, nbPoints );
+         }
+         if ( !theCurve->IsAuto() ) {
            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() );
          }
+         clist.at( i )->setAutoAssign( theCurve->IsAuto() );
          theView->displayCurve( clist.at( i ) );
          bFound = true;
        }
@@ -244,8 +481,17 @@ namespace VISU{
       if ( !bFound ) {
        Plot2d_Curve* crv = theCurve->CreatePresentation();
        if(MYDEBUG) MESSAGE("UpdatePlot2d - displaying : curve (new) - "<<crv );
-       if ( 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() );
+       }
       }
     }
     else if ( theDisplaying == eDisplayOnly ) {
@@ -253,18 +499,23 @@ namespace VISU{
       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 )->setHorTitle( theCurve->GetHorTitle().c_str() );
+         clist.at( i )->setVerTitle( theCurve->GetVerTitle().c_str() );
+         clist.at( i )->setHorUnits( theCurve->GetHorUnits().c_str() );
+         clist.at( i )->setVerUnits( theCurve->GetVerUnits().c_str() );
+         double* xList = 0;
+         double* yList = 0;
+         int     nbPoints = theCurve->GetData( xList, yList );
+         if ( nbPoints > 0 && xList && yList ) {
+           clist.at( i )->setData( xList, yList, nbPoints );
+         }
+         if ( !theCurve->IsAuto() ) {
            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() );
          }
+         clist.at( i )->setAutoAssign( theCurve->IsAuto() );
          theView->displayCurve( clist.at( i ) );
          bFound = true;
        }
@@ -275,8 +526,17 @@ namespace VISU{
       if ( !bFound ) {
        Plot2d_Curve* crv = theCurve->CreatePresentation();
        if(MYDEBUG) MESSAGE("UpdatePlot2d - displaying only : curve (new) - "<<crv );
-       if ( 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() );
+       }
       }
     }
   }
@@ -304,38 +564,36 @@ namespace VISU{
   }
 
 
-  VISU::View_ptr ViewManager_i::GetCurrentView(){
-    class TEvent: public SALOME_Event{
-      SALOMEDS::Study_ptr myStudyDocument;
-    public:
-      TEvent( SALOMEDS::Study_ptr theStudy):
-       myStudyDocument(theStudy)
-      {}
-      virtual void Execute(){
-       if(QAD_Study* aStudy = QAD_Application::getDesktop()->findStudy( myStudyDocument )){
-         if ( QAD_StudyFrame* aStudyFrame = aStudy->getActiveStudyFrame() ) {
-           if(MYDEBUG) 
-             MESSAGE("GetCurrentView::Execute - TypeView = "<<aStudyFrame->getTypeView());
-           if ( aStudyFrame->getTypeView() == VIEW_VTK ) {
-             VISU::View3D_i* pView = new View3D_i(myStudyDocument);
-             if(pView->Create(0)) 
-               myResult = pView->_this();
-           } else if ( aStudyFrame->getTypeView() == VIEW_PLOT2D ) {
-             VISU::XYPlot_i* pView = new XYPlot_i(myStudyDocument);
-             if(pView->Create(0)) 
-               myResult = pView->_this();
-           }
+  class TGetCurrentViewEvent: public SALOME_Event{
+    SALOMEDS::Study_ptr myStudyDocument;
+  public:
+    TGetCurrentViewEvent( SALOMEDS::Study_ptr theStudy):
+      myStudyDocument(theStudy),
+      myResult(VISU::View::_nil())
+    {}
+    virtual void Execute(){
+      if(QAD_Study* aStudy = QAD_Application::getDesktop()->findStudy( myStudyDocument )){
+       if ( QAD_StudyFrame* aStudyFrame = aStudy->getActiveStudyFrame() ) {
+         if(MYDEBUG) 
+           MESSAGE("GetCurrentView::Execute - TypeView = "<<aStudyFrame->getTypeView());
+         if ( aStudyFrame->getTypeView() == VIEW_VTK ) {
+           VISU::View3D_i* pView = new View3D_i(myStudyDocument);
+           if(pView->Create(0)) 
+             myResult = pView->_this();
+         } else if ( aStudyFrame->getTypeView() == VIEW_PLOT2D ) {
+           VISU::XYPlot_i* pView = new XYPlot_i(myStudyDocument);
+           if(pView->Create(0)) 
+             myResult = pView->_this();
          }
        }
       }
-      typedef VISU::View_var TResult;
-      TResult myResult;
-    };
-    TEvent* ve = new TEvent( myStudyDocument );
-    ve->process();
-    TEvent::TResult aResult = ve->myResult;
-    ve->release();
-    return aResult._retn();
+    }
+    typedef VISU::View_ptr TResult;
+    TResult myResult;
+  };
+
+  VISU::View_ptr ViewManager_i::GetCurrentView(){
+    return ProcessEvent(new TGetCurrentViewEvent( myStudyDocument ));
   }
   
   
@@ -381,31 +639,29 @@ namespace VISU{
   }
 
 
-  VISU::TableView_ptr ViewManager_i::CreateTableView(VISU::Table_ptr theTable){
-    class TEvent: public TCreateViewEvent{
-      Table_ptr myTable;
-    public:
-      TEvent(SALOMEDS::Study_ptr theStudy,
-            Table_ptr theTable):
-       TCreateViewEvent(theStudy),
-       myTable(theTable)
-      {}
-      virtual void Execute(){
-       if ( CheckStudy( myStudyDocument ) ) {
-         VISU::TableView_i* pView = new TableView_i(myStudyDocument);
-         if(pView->Create(myTable) != NULL) 
-           myResult = pView->_this();
-       }
+  class TCreateTableViewEvent: public TCreateViewEvent{
+    Table_ptr myTable;
+  public:
+    TCreateTableViewEvent(SALOMEDS::Study_ptr theStudy,
+                         Table_ptr theTable):
+      TCreateViewEvent(theStudy),
+      myTable(theTable),
+      myResult(VISU::TableView::_nil())
+    {}
+    virtual void Execute(){
+      if ( CheckStudy( myStudyDocument ) ) {
+       VISU::TableView_i* pView = new TableView_i(myStudyDocument);
+       if(pView->Create(myTable) != NULL) 
+         myResult = pView->_this();
       }
-      typedef VISU::TableView_var TResult;
-      TResult myResult;
-    };
+    }
+    typedef VISU::TableView_ptr TResult;
+    TResult myResult;
+  };
+
+  VISU::TableView_ptr ViewManager_i::CreateTableView(VISU::Table_ptr theTable){
     if(MYDEBUG) MESSAGE("ViewManager_i::CreateTableView");
-    TEvent* ve = new TEvent(myStudyDocument,theTable);
-    ve->process();
-    TEvent::TResult aResult = ve->myResult;
-    ve->release();
-    return aResult._retn();
+    return ProcessEvent(new TCreateTableViewEvent(myStudyDocument,theTable));
   }
 
 
@@ -432,6 +688,7 @@ namespace VISU{
 
   //===========================================================================
   View_i::View_i(SALOMEDS::Study_ptr theStudy) {
+    myStudyFrame =  NULL;
     if(MYDEBUG) MESSAGE("View_i::View_i");
     CORBA::String_var aName = theStudy->Name();
     myStudy = CheckStudy(theStudy);
@@ -741,11 +998,7 @@ namespace VISU{
 
 
   CORBA::Boolean XYPlot_i::SavePicture(const char* theFileName) {
-    TSavePictureEvent* ve = new TSavePictureEvent(myView->getViewWidget(),theFileName);
-    ve->process();
-    TSavePictureEvent::TResult aResult = ve->myResult;
-    ve->release();
-    return aResult;
+    return ProcessEvent(new TSavePictureEvent(myView->getViewWidget(),theFileName));
   }
 
 
@@ -829,9 +1082,8 @@ namespace VISU{
        vtkRenderer* Renderer = vf->getRenderer();
        vtkActorCollection* theActors = Renderer->GetActors();
        theActors->InitTraversal();
-       vtkActor *actor;
-       while(actor = theActors->GetNextActor()){
-         if(VISU_Actor* anActor = dynamic_cast<VISU_Actor*>(actor)){
+       while(vtkActor *anAct = theActors->GetNextActor()){
+         if(VISU_Actor* anActor = dynamic_cast<VISU_Actor*>(anAct)){
            VISU::Prs3d_i* aPrs3d  = anActor->GetPrs3d();
            if(anActor->GetVisibility() && aPrs3d){
              aPrs3d->Update();
@@ -847,11 +1099,7 @@ namespace VISU{
 
 
   CORBA::Boolean View3D_i::SavePicture(const char* theFileName) {
-    TSavePictureEvent* ve = new TSavePictureEvent(myStudyFrame->getRightFrame()->getViewFrame()->getViewWidget(),theFileName);
-    ve->process();
-    TSavePictureEvent::TResult aResult = ve->myResult;
-    ve->release();
-    return aResult;
+    return ProcessEvent(new TSavePictureEvent(myStudyFrame->getRightFrame()->getViewFrame()->getViewWidget(),theFileName));
   }
 
 
@@ -918,27 +1166,24 @@ namespace VISU{
   }
 
 
+  class TRestoreViewParamsEvent: public SALOME_Event{
+    QAD_StudyFrame* myStudyFrame;
+    const char* myName;
+  public:
+    TRestoreViewParamsEvent(QAD_StudyFrame* theStudyFrame,
+                           const char* theName):
+      myStudyFrame(theStudyFrame),
+      myName(theName)
+    {}
+    virtual void Execute(){
+      myResult = View3D_i::RestoreViewParams(myStudyFrame,myName);
+    }
+    typedef CORBA::Boolean TResult;
+    TResult myResult;
+  };
+
   CORBA::Boolean View3D_i::RestoreViewParams(const char* theName){
-    class TEvent: public SALOME_Event{
-      QAD_StudyFrame* myStudyFrame;
-      const char* myName;
-    public:
-      TEvent(QAD_StudyFrame* theStudyFrame,
-            const char* theName):
-       myStudyFrame(theStudyFrame),
-       myName(theName)
-      {}
-      virtual void Execute(){
-       myResult = RestoreViewParams(myStudyFrame,myName);
-      }
-      typedef CORBA::Boolean TResult;
-      TResult myResult;
-    };
-    TEvent* ve = new TEvent(myStudyFrame,theName);
-    ve->process();
-    TEvent::TResult aResult = ve->myResult;
-    ve->release();
-    return aResult;
+    return ProcessEvent(new TRestoreViewParamsEvent(myStudyFrame,theName));
   }
 
 
@@ -1038,6 +1283,56 @@ namespace VISU{
   }
 
   //-------------------- View interface --------------------
+
+  void View_i::ShowPart( VISU::View::ViewRepresentation ViewRepr, CORBA::Boolean state  ) {
+    ProcessVoidEvent( new TSetViewRepresentation( this, ViewRepr, state ) );
+    Update();
+  }
+
+  CORBA::Boolean View_i::IsPartShown( VISU::View::ViewRepresentation Part )
+  {
+    return ProcessEvent( new TGetViewRepresentation( this, Part ) );
+  }
+
+  void View_i::SetViewWidth(CORBA::Long Width){
+    ProcessVoidEvent( new TSetViewWidthHeight( this, Width, true ) );
+     }
+  
+  void View_i::SetViewHeight(CORBA::Long Height){ 
+    ProcessVoidEvent( new TSetViewWidthHeight( this, Height, false ) );
+     }
+
+  CORBA::Long View_i::GetViewWidth() 
+  {
+    return ProcessEvent( new TGetViewWidthHeight( this, true ) );
+  }
+
+  CORBA::Long View_i::GetViewHeight()
+  {
+    return ProcessEvent( new TGetViewWidthHeight( this, false ) );
+  }
+
+  void View_i::SetViewPositionHorizontal( VISU::View::ViewPosition ViewPosHor ){
+    ProcessVoidEvent( new TSetViewPositionHorizontal( this, ViewPosHor ) );
+  }
+
+  void View_i::SetViewPositionVertical( VISU::View::ViewPosition ViewPosVer ){
+    ProcessVoidEvent( new TSetViewPositionVertical( this, ViewPosVer ) );
+  }
+
+  void View_i::SetRelativePosition( CORBA::Double x, CORBA::Double y )
+  {
+    ProcessVoidEvent( new TSetRelativePosition( this, x, y ) );
+  }
+
+  void View_i::SetRelativeSize( CORBA::Double x, CORBA::Double y )
+  {
+    ProcessVoidEvent( new TSetRelativeSize( this, x, y ) );
+  }
+
+
+
+
   void View3D_i::SetTitle(const char* theTitle){
     ProcessVoidEvent(new TVoidMemFun1ArgEvent<QAD_StudyFrame,const QString&,QString>
                     (myStudyFrame,&QAD_StudyFrame::setTitle,QString(theTitle)));
@@ -1309,92 +1604,96 @@ namespace VISU{
     ProcessVoidEvent(new TSet3DViewParamEvent(&SetScaleView,myStudyFrame,aScale));
   }
   //===========================================================================
-};
 
 
-/*! SAN & VSR : Test QT_EVENT 
-  >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-*/
-#include "VISU_Gen_i.hh"
-#include "QAD_Config.h"
-#include <vtkPolyDataMapper.h>
-#include <vtkSphereSource.h>
-#include <vtkProperty.h>
+  VISU_Actor* GetActor(VISU::Prs3d_i* thePrs3d, VTKViewer_ViewFrame* 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;
+  }
 
-namespace VISU{
-  class TestViewEvent : public SALOME_Event {
-  public:
-    virtual void Execute(){
-      QAD_Desktop* desktop = QAD_Application::getDesktop();
-      QAD_Study*   aStudy = desktop->getActiveStudy();
-      if ( !aStudy ) {
-       QString defViewer = QAD_CONFIG->getSetting( "Viewer::DefaultViewer" );
-       int dv = defViewer.toInt();
-       QAD_CONFIG->addSetting( "Viewer::DefaultViewer", QString::number( VIEW_VTK ) );
-       desktop->createStudy();
-       if ( !defViewer.isEmpty() ) {
-         QAD_CONFIG->addSetting( "Viewer::DefaultViewer", QString::number( dv ) );
+
+  void DeletePrs3d(Prs3d_ptr thePrs3d){
+    if(Prs3d_i* aPrs3d = dynamic_cast<Prs3d_i*>(GetServant(thePrs3d).in())){
+      SALOMEDS::SObject_var aSObject = aPrs3d->GetSObject();
+      SALOMEDS::Study_var aStudyDocument = aSObject->GetStudy();
+      if(QAD_Desktop* aDesktop = QAD_Application::getDesktop()){
+       if(QAD_Study* aStudy = aDesktop->findStudy(aStudyDocument)){
+         aStudy->unHighlightAll();
+         int aNbStudyFrames = aStudy->getStudyFramesCount();
+         for(int aFrameId = 0; aFrameId < aNbStudyFrames; aFrameId++){
+           if(QAD_StudyFrame* aFrame = aStudy->getStudyFrame(aFrameId)){
+             QAD_ViewFrame* aViewFrame = aFrame->getRightFrame()->getViewFrame();
+             if(VTKViewer_ViewFrame* aVTKFrame = dynamic_cast<VTKViewer_ViewFrame*>(aViewFrame)){
+               if(VISU_Actor* anActor = VISU::GetActor(aPrs3d,aVTKFrame)){
+                 aVTKFrame->RemoveActor(anActor);
+                 anActor->Delete();
+               }
+               aVTKFrame->unHighlightAll();
+             }
+           }
+         }
+
+         aPrs3d->RemoveFromStudy(); 
+         aPrs3d->Destroy(); 
+
+         aStudy->updateObjBrowser(); //update Object browser
        }
       }
-      else {
-       aStudy->newWindow3d( "", VIEW_VTK );
-      }
     }
-  };
+  }
+
+
+  void VISU_Gen_i::DeleteResult(Result_ptr theResult)
+  {
+    class TEvent: public SALOME_Event{
+      Result_ptr myResult;
+    public:
+      TEvent(Result_ptr theResult): myResult(theResult) {}
+      virtual void Execute(){
+       if(Result_i* aResult = dynamic_cast<Result_i*>(GetServant(myResult).in())){
+         SALOMEDS::SObject_var aSObject = aResult->GetSObject();
+         SALOMEDS::Study_var aStudyDocument = aSObject->GetStudy();
+         SALOMEDS::ChildIterator_var aChildIter = aStudyDocument->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::DeletePrs3d(aPrs3d);
+         }
+
+         aResult->RemoveFromStudy(); 
+         aResult->Destroy(); 
 
-  void VISU_Gen_i::CreateTestView() {
-    TestViewEvent* ve = new TestViewEvent();
-    ve->process();
-    ve->release();
+         if(QAD_Desktop* aDesktop = QAD_Application::getDesktop())
+           if(QAD_Study* aStudy = aDesktop->findStudy(aStudyDocument))
+             aStudy->updateObjBrowser(); //update Object browser
+       }
+      }
+    };
+
+    ProcessVoidEvent(new TEvent(theResult));
   }
 
 
-  class TestObjectEvent : public SALOME_Event {
-  public:
-    virtual void Execute(){
-      float aRadius = 150.0 * random() / RAND_MAX + 10.;
-      float aX = 1000.0 * random() / RAND_MAX - 500.;
-      float aY = 1000.0 * random() / RAND_MAX - 500.;
-      float aZ = 1000.0 * random() / RAND_MAX - 500.;
-      float aR = (float)random() / RAND_MAX;
-      float aG = (float)random() / RAND_MAX;
-      float aB = (float)random() / RAND_MAX;
-
-      vtkSphereSource* aSource = vtkSphereSource::New();
-      aSource->SetRadius( aRadius );
-      aSource->SetCenter( aX, aY, aZ );
-  
-      vtkProperty* prop = vtkProperty::New();
-      prop->SetColor( aR, aG, aB );
-  
-      vtkPolyDataMapper* aMapper = vtkPolyDataMapper::New();
-      aMapper->SetInput( aSource->GetOutput() );
-      
-      vtkActor* sphere = vtkActor::New();
-      sphere->SetMapper( aMapper );
-      sphere->SetProperty( prop );
-
-      QAD_Desktop* desktop = QAD_Application::getDesktop();
-      QAD_Study*   aStudy = desktop->getActiveStudy();
-      if ( !aStudy )
-       return ;
-      QAD_StudyFrame* sf = desktop->getActiveStudy()->getActiveStudyFrame();
-      VTKViewer_ViewFrame* vf = GetViewFrame( sf );
-      if ( !vf )
-       return;
-      sphere->SetVisibility( true );
-      vf->getRenderer()->AddActor(sphere);
-      vf->Repaint();
-    }
-  };
+  void VISU_Gen_i::DeletePrs3d(Prs3d_ptr thePrs3d)
+  {
+    class TEvent: public SALOME_Event{
+      Prs3d_ptr myPrs3d;
+    public:
+      TEvent(Prs3d_ptr thePrs3d): myPrs3d(thePrs3d) {}
+      virtual void Execute(){
+       VISU::DeletePrs3d(myPrs3d);
+      }
+    };
 
-  void VISU_Gen_i::ShowTestObject() {
-    TestObjectEvent* ve = new TestObjectEvent();
-    ve->process();
-    ve->release();
-    return;
+    ProcessVoidEvent(new TEvent(thePrs3d));
   }
-  /*! SAN & VSR : Test QT_EVENT
-    <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-  */
-};
+
+}