]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
Improvement PAL14012: access to FitAll() and other view window functionality from...
authorvsr <vsr@opencascade.com>
Wed, 29 Nov 2006 10:03:54 +0000 (10:03 +0000)
committervsr <vsr@opencascade.com>
Wed, 29 Nov 2006 10:03:54 +0000 (10:03 +0000)
src/SALOME_SWIG/SALOMEGUI_Swig.cxx
src/SALOME_SWIG/SALOMEGUI_Swig.hxx
src/SALOME_SWIG/SALOMEGUI_Swig.i

index 99195e10a8a67144f5807f3db44a07160cc99db4..d56fafe083388b288bd2ffa72256a0b72d80d327 100644 (file)
@@ -40,6 +40,9 @@
 #include "SALOME_Prs.h"
 #include "SOCC_ViewModel.h"
 #include "SVTK_ViewModel.h"
+#include "SVTK_ViewWindow.h"
+#include "SOCC_ViewWindow.h"
+#include "SPlot2d_ViewWindow.h"
 
 #include "SALOME_Event.hxx"
 #include "SALOME_ListIO.hxx"
@@ -591,3 +594,166 @@ void SALOMEGUI_Swig::UpdateView()
   };
   ProcessVoidEvent( new TEvent() );
 }
+
+/*!
+  Fit all the contents of the current view window
+ */
+void SALOMEGUI_Swig::FitAll()
+{
+  class TEvent: public SALOME_Event {
+  public:
+    TEvent() {}
+    virtual void Execute() {
+      if ( SalomeApp_Application* anApp = getApplication() ) {
+       SUIT_ViewWindow* window = anApp->desktop()->activeWindow();
+       if ( window ) {
+         if ( dynamic_cast<SVTK_ViewWindow*>( window ) )
+           (dynamic_cast<SVTK_ViewWindow*>( window ))->onFitAll();
+         else if ( dynamic_cast<SOCC_ViewWindow*>( window ) )
+           (dynamic_cast<SOCC_ViewWindow*>( window ))->onFitAll();
+         else if ( dynamic_cast<SPlot2d_ViewWindow*>( window ) )
+           (dynamic_cast<SPlot2d_ViewWindow*>( window ))->onFitAll();
+       }
+      }
+    }
+  };
+  ProcessVoidEvent( new TEvent() );
+}
+
+/*!
+  Reset current view window to the default state.
+ */
+void SALOMEGUI_Swig::ResetView()
+{
+  class TEvent: public SALOME_Event {
+  public:
+    TEvent() {}
+    virtual void Execute() {
+      if ( SalomeApp_Application* anApp = getApplication() ) {
+       SUIT_ViewWindow* window = anApp->desktop()->activeWindow();
+       if ( window ) {
+         if ( dynamic_cast<SVTK_ViewWindow*>( window ) )
+           (dynamic_cast<SVTK_ViewWindow*>( window ))->onResetView();
+         else if ( dynamic_cast<SOCC_ViewWindow*>( window ) )
+           (dynamic_cast<SOCC_ViewWindow*>( window ))->onResetView();
+         else if ( dynamic_cast<SPlot2d_ViewWindow*>( window ) )
+           (dynamic_cast<SPlot2d_ViewWindow*>( window ))->onFitAll();
+         // VSR: there is no 'ResetView' functionality for Plot2d viewer,
+         // so we use 'FitAll' instead.
+       }
+      }
+    }
+  };
+  ProcessVoidEvent( new TEvent() );
+}
+
+enum {
+  __ViewTop,
+  __ViewBottom,
+  __ViewLeft,
+  __ViewRight,
+  __ViewFront,
+  __ViewBack
+};
+
+void setView( int view )
+{
+  class TEvent: public SALOME_Event {
+  private:
+    int myView;
+  public:
+    TEvent( int view ) : myView( view ) {}
+    virtual void Execute() {
+      if ( SalomeApp_Application* anApp = getApplication() ) {
+       SUIT_ViewWindow* window = anApp->desktop()->activeWindow();
+       if ( window ) {
+         if ( dynamic_cast<SVTK_ViewWindow*>( window ) ) {
+           switch( myView ) {
+           case __ViewTop:
+             (dynamic_cast<SVTK_ViewWindow*>( window ))->onTopView(); break;
+           case __ViewBottom:
+             (dynamic_cast<SVTK_ViewWindow*>( window ))->onBottomView(); break;
+           case __ViewLeft:
+             (dynamic_cast<SVTK_ViewWindow*>( window ))->onLeftView(); break;
+           case __ViewRight:
+             (dynamic_cast<SVTK_ViewWindow*>( window ))->onRightView(); break;
+           case __ViewFront:
+             (dynamic_cast<SVTK_ViewWindow*>( window ))->onFrontView(); break;
+           case __ViewBack:
+             (dynamic_cast<SVTK_ViewWindow*>( window ))->onBackView(); break;
+           default:
+             break;
+           }
+         }
+         else if ( dynamic_cast<SOCC_ViewWindow*>( window ) ) {
+           switch( myView ) {
+           case __ViewTop:
+             (dynamic_cast<SOCC_ViewWindow*>( window ))->onTopView(); break;
+           case __ViewBottom:
+             (dynamic_cast<SOCC_ViewWindow*>( window ))->onBottomView(); break;
+           case __ViewLeft:
+             (dynamic_cast<SOCC_ViewWindow*>( window ))->onLeftView(); break;
+           case __ViewRight:
+             (dynamic_cast<SOCC_ViewWindow*>( window ))->onRightView(); break;
+           case __ViewFront:
+             (dynamic_cast<SOCC_ViewWindow*>( window ))->onFrontView(); break;
+           case __ViewBack:
+             (dynamic_cast<SOCC_ViewWindow*>( window ))->onBackView(); break;
+           default:
+             break;
+           }
+         }
+       }
+      }
+    }
+  };
+  ProcessVoidEvent( new TEvent( view ) );
+}
+
+/*!
+  Switch current view window to show top view
+ */
+void SALOMEGUI_Swig::ViewTop()
+{
+  setView( __ViewTop );
+}
+
+/*!
+  Switch current view window to show bottom view
+ */
+void SALOMEGUI_Swig::ViewBottom()
+{
+  setView( __ViewBottom );
+}
+
+/*!
+  Switch current view window to show left view
+ */
+void SALOMEGUI_Swig::ViewLeft()
+{
+  setView( __ViewLeft );
+}
+
+/*!
+  Switch current view window to show right view
+ */
+void SALOMEGUI_Swig::ViewRight()
+{
+  setView( __ViewRight );
+}
+
+/*!
+  Switch current view window to show front view
+ */
+void SALOMEGUI_Swig::ViewFront()
+{
+  setView( __ViewFront );
+}
+
+/*!
+  Switch current view window to show back view
+ */
+void SALOMEGUI_Swig::ViewBack()
+{
+  setView( __ViewBack );
+}
index c8777842ee615f74a3a25dd4ba4153e6a400baec..97e09fa28f137062849afa7a736188f73ba31bac 100644 (file)
@@ -62,6 +62,16 @@ public:
   bool             IsInCurrentView( const char *Entry );
   void             UpdateView();
 
+  /* view operations */
+  void             FitAll();
+  void             ResetView();
+  void             ViewTop();
+  void             ViewBottom();
+  void             ViewLeft();
+  void             ViewRight();
+  void             ViewFront();
+  void             ViewBack();
+
   /* get component name/username */
   const char*      getComponentName( const char* ComponentUserName );
   const char*      getComponentUserName( const char* ComponentName );
index 2d3a87a44f551fa69e26c4502fbb6b24ff439ce5..e01c9cf1eda03141c8a1863b26f0eba6f44159cd 100644 (file)
@@ -82,6 +82,16 @@ class SALOMEGUI_Swig
   bool IsInCurrentView(const char *Entry);
   void UpdateView();
 
+/* view operations */
+  void FitAll();
+  void ResetView();
+  void ViewTop();
+  void ViewBottom();
+  void ViewLeft();
+  void ViewRight();
+  void ViewFront();
+  void ViewBack();
+
 /* get component name/username */
   const char* getComponentName( const char* ComponentUserName );
   const char* getComponentUserName( const char* ComponentName );