From 1220f008cc4a29c23a2a0889f38ff9e1f078a696 Mon Sep 17 00:00:00 2001 From: vsr Date: Wed, 29 Nov 2006 10:03:54 +0000 Subject: [PATCH] Improvement PAL14012: access to FitAll() and other view window functionality from the Python --- src/SALOME_SWIG/SALOMEGUI_Swig.cxx | 166 +++++++++++++++++++++++++++++ src/SALOME_SWIG/SALOMEGUI_Swig.hxx | 10 ++ src/SALOME_SWIG/SALOMEGUI_Swig.i | 10 ++ 3 files changed, 186 insertions(+) diff --git a/src/SALOME_SWIG/SALOMEGUI_Swig.cxx b/src/SALOME_SWIG/SALOMEGUI_Swig.cxx index 99195e10a..d56fafe08 100644 --- a/src/SALOME_SWIG/SALOMEGUI_Swig.cxx +++ b/src/SALOME_SWIG/SALOMEGUI_Swig.cxx @@ -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( window ) ) + (dynamic_cast( window ))->onFitAll(); + else if ( dynamic_cast( window ) ) + (dynamic_cast( window ))->onFitAll(); + else if ( dynamic_cast( window ) ) + (dynamic_cast( 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( window ) ) + (dynamic_cast( window ))->onResetView(); + else if ( dynamic_cast( window ) ) + (dynamic_cast( window ))->onResetView(); + else if ( dynamic_cast( window ) ) + (dynamic_cast( 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( window ) ) { + switch( myView ) { + case __ViewTop: + (dynamic_cast( window ))->onTopView(); break; + case __ViewBottom: + (dynamic_cast( window ))->onBottomView(); break; + case __ViewLeft: + (dynamic_cast( window ))->onLeftView(); break; + case __ViewRight: + (dynamic_cast( window ))->onRightView(); break; + case __ViewFront: + (dynamic_cast( window ))->onFrontView(); break; + case __ViewBack: + (dynamic_cast( window ))->onBackView(); break; + default: + break; + } + } + else if ( dynamic_cast( window ) ) { + switch( myView ) { + case __ViewTop: + (dynamic_cast( window ))->onTopView(); break; + case __ViewBottom: + (dynamic_cast( window ))->onBottomView(); break; + case __ViewLeft: + (dynamic_cast( window ))->onLeftView(); break; + case __ViewRight: + (dynamic_cast( window ))->onRightView(); break; + case __ViewFront: + (dynamic_cast( window ))->onFrontView(); break; + case __ViewBack: + (dynamic_cast( 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 ); +} diff --git a/src/SALOME_SWIG/SALOMEGUI_Swig.hxx b/src/SALOME_SWIG/SALOMEGUI_Swig.hxx index c8777842e..97e09fa28 100644 --- a/src/SALOME_SWIG/SALOMEGUI_Swig.hxx +++ b/src/SALOME_SWIG/SALOMEGUI_Swig.hxx @@ -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 ); diff --git a/src/SALOME_SWIG/SALOMEGUI_Swig.i b/src/SALOME_SWIG/SALOMEGUI_Swig.i index 2d3a87a44..e01c9cf1e 100644 --- a/src/SALOME_SWIG/SALOMEGUI_Swig.i +++ b/src/SALOME_SWIG/SALOMEGUI_Swig.i @@ -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 ); -- 2.39.2