From: ouv Date: Fri, 13 Aug 2010 14:00:40 +0000 (+0000) Subject: Introducing margin ratio parameter X-Git-Tag: DIAGRAM_0_1~43 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=e3d1a1276cadeee685f982a27b2d5e3afeca75b2;p=modules%2Fgui.git Introducing margin ratio parameter --- diff --git a/src/GLViewer/GLViewer_ViewPort2d.cxx b/src/GLViewer/GLViewer_ViewPort2d.cxx index 47cc94fa7..78b79e2c8 100644 --- a/src/GLViewer/GLViewer_ViewPort2d.cxx +++ b/src/GLViewer/GLViewer_ViewPort2d.cxx @@ -48,9 +48,10 @@ #include #include -#define WIDTH 640 -#define HEIGHT 480 -#define MARGIN 100 +#define WIDTH 640 +#define HEIGHT 480 +#define MARGIN 100 +#define MARGIN_RATIO 0.2 #define GRID_XSIZE 100 #define GRID_YSIZE 100 @@ -70,7 +71,8 @@ void rotate_point( float& theX, float& theY, float theAngle ) */ GLViewer_ViewPort2d::GLViewer_ViewPort2d( QWidget* parent, GLViewer_ViewFrame* theViewFrame ) : GLViewer_ViewPort( parent ), - myMargin( MARGIN ), myWidth( WIDTH ), myHeight( HEIGHT ), + myMargin( MARGIN ), myMarginRatio( (GLfloat)MARGIN_RATIO ), + myWidth( WIDTH ), myHeight( HEIGHT ), myXScale( 1.0 ), myYScale( 1.0 ), myXOldScale( 1.0 ), myYOldScale( 1.0 ), myXPan( 0.0 ), myYPan( 0.0 ), myIsMouseReleaseBlock( false ), @@ -838,7 +840,7 @@ void GLViewer_ViewPort2d::fitAll( bool keepScale, bool withZ ) float dx, dy, zm; float xScale, yScale; - myMargin = qMax( myBorder->width(), myBorder->height() ) / 5; + myMargin = qMax( myBorder->width(), myBorder->height() ) * myMarginRatio; xa = myBorder->left() - myMargin; xb = myBorder->right() + myMargin; diff --git a/src/GLViewer/GLViewer_ViewPort2d.h b/src/GLViewer/GLViewer_ViewPort2d.h index 51a6c937d..3812e62a4 100644 --- a/src/GLViewer/GLViewer_ViewPort2d.h +++ b/src/GLViewer/GLViewer_ViewPort2d.h @@ -100,6 +100,11 @@ public: //! Returns margin of borders GLfloat getMargin() const { return myMargin; } + //! Sets margin ratio (smaller the ratio, smaller an empty gap for fit all operation) + void setMarginRatio( GLfloat marginRatio ) { myMarginRatio = marginRatio; } + //! Returns margin ratio + GLfloat getMarginRatio() const { return myMarginRatio; } + //! Returns width of view int getWidth() const { return myWidth; } //! Returns height of view @@ -214,6 +219,7 @@ protected: QColor myBackgroundColor; GLfloat myMargin; + GLfloat myMarginRatio; int myHeight; int myWidth;