From: Andreas Nicolai Date: Sat, 18 Jun 2005 14:38:17 +0000 (+0000) Subject: - axis are now called LeftAxis and BottomAxis to make provisions for X-Git-Tag: v3.4.90~25 X-Git-Url: https://git.rmz.fi/?a=commitdiff_plain;h=b19aea8fc026676c12f55583384b9e34df1350c0;p=libqmvoc.git - axis are now called LeftAxis and BottomAxis to make provisions for future Top and Right axes svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=426775 --- diff --git a/kdeeduplot/kplotwidget.cpp b/kdeeduplot/kplotwidget.cpp index aa46599..eb527ba 100644 --- a/kdeeduplot/kplotwidget.cpp +++ b/kdeeduplot/kplotwidget.cpp @@ -261,7 +261,7 @@ void KPlotWidget::drawBox( QPainter *p ) { p->setPen( fgColor() ); p->setBrush( Qt::NoBrush ); - if (XAxis.isVisible() || YAxis.isVisible()) p->drawRect( PixRect ); //box outline + if (BottomAxis.isVisible() || LeftAxis.isVisible()) p->drawRect( PixRect ); //box outline if ( ShowTickMarks ) { //spacing between minor tickmarks (in data units) @@ -274,8 +274,8 @@ void KPlotWidget::drawBox( QPainter *p ) { f.setPointSize( s - 2 ); p->setFont( f ); - //--- Draw X Axis ---// - if (XAxis.isVisible()) { + //--- Draw bottom X Axis ---// + if (BottomAxis.isVisible()) { // Draw X tickmarks double x0 = x() - dmod( x(), dXtick ); //zeropoint; tickmark i is this plus i*dXtick (in data units) if ( x() < 0.0 ) x0 -= dXtick; @@ -294,7 +294,7 @@ void KPlotWidget::drawBox( QPainter *p ) { double lab = x0 + ix*dXtick; if ( fabs(lab)/dXtick < 0.00001 ) lab = 0.0; //fix occassional roundoff error with "0.0" label - QString str = QString( "%1" ).arg( lab, XAxis.labelFieldWidth(), XAxis.labelFmt(), XAxis.labelPrec() ); + QString str = QString( "%1" ).arg( lab, BottomAxis.labelFieldWidth(), BottomAxis.labelFmt(), BottomAxis.labelPrec() ); if ( px > 0 && px < PixRect.width() ) { QRect r( px - BIGTICKSIZE, PixRect.height()+BIGTICKSIZE, 2*BIGTICKSIZE, BIGTICKSIZE ); p->drawText( r, Qt::AlignCenter | Qt::DontClip, str ); @@ -314,15 +314,15 @@ void KPlotWidget::drawBox( QPainter *p ) { } // end draw X tickmarks // Draw X Axis Label - if ( ! XAxis.label().isEmpty() ) { + if ( ! BottomAxis.label().isEmpty() ) { QRect r( 0, PixRect.height() + 2*YPADDING, PixRect.width(), YPADDING ); - p->drawText( r, Qt::AlignCenter, XAxis.label() ); + p->drawText( r, Qt::AlignCenter, BottomAxis.label() ); } } - //--- Draw Y Axis ---// - if (YAxis.isVisible()) { + //--- Draw left Y Axis ---// + if (LeftAxis.isVisible()) { // Draw Y tickmarks double y0 = y() - dmod( y(), dYtick ); //zeropoint; tickmark i is this plus i*dYtick1 (in data units) if ( y() < 0.0 ) y0 -= dYtick; @@ -340,7 +340,7 @@ void KPlotWidget::drawBox( QPainter *p ) { double lab = y0 + iy*dYtick; if ( fabs(lab)/dYtick < 0.00001 ) lab = 0.0; //fix occassional roundoff error with "0.0" label - QString str = QString( "%1" ).arg( lab, YAxis.labelFieldWidth(), YAxis.labelFmt(), YAxis.labelPrec() ); + QString str = QString( "%1" ).arg( lab, LeftAxis.labelFieldWidth(), LeftAxis.labelFmt(), LeftAxis.labelPrec() ); if ( py > 0 && py < PixRect.height() ) { QRect r( -2*BIGTICKSIZE, py-SMALLTICKSIZE, 2*BIGTICKSIZE, 2*SMALLTICKSIZE ); p->drawText( r, Qt::AlignCenter | Qt::DontClip, str ); @@ -359,7 +359,7 @@ void KPlotWidget::drawBox( QPainter *p ) { } // end draw Y tickmarks //Draw Y Axis Label. We need to draw the text sideways. - if ( ! YAxis.label().isEmpty() ) { + if ( ! LeftAxis.label().isEmpty() ) { //store current painter translation/rotation state p->save(); @@ -368,7 +368,7 @@ void KPlotWidget::drawBox( QPainter *p ) { p->rotate( -90.0 ); QRect r( 0, 0, PixRect.height(), XPADDING ); - p->drawText( r, Qt::AlignCenter, YAxis.label() ); //draw the label, now that we are sideways + p->drawText( r, Qt::AlignCenter, LeftAxis.label() ); //draw the label, now that we are sideways p->restore(); //restore translation/rotation state } @@ -381,8 +381,8 @@ void KPlotWidget::drawBox( QPainter *p ) { int KPlotWidget::leftPadding() const { if ( LeftPadding >= 0 ) return LeftPadding; - if ( ! YAxis.label().isEmpty() && ShowTickLabels ) return 3*XPADDING; - if ( ! YAxis.label().isEmpty() || ShowTickLabels ) return 2*XPADDING; + if ( ! LeftAxis.label().isEmpty() && ShowTickLabels ) return 3*XPADDING; + if ( ! LeftAxis.label().isEmpty() || ShowTickLabels ) return 2*XPADDING; return XPADDING; } @@ -398,8 +398,8 @@ int KPlotWidget::topPadding() const { int KPlotWidget::bottomPadding() const { if ( BottomPadding >= 0 ) return BottomPadding; - if ( ! XAxis.label().isEmpty() && ShowTickLabels ) return 3*YPADDING; - if ( ! XAxis.label().isEmpty() || ShowTickLabels ) return 2*YPADDING; + if ( ! BottomAxis.label().isEmpty() && ShowTickLabels ) return 3*YPADDING; + if ( ! BottomAxis.label().isEmpty() || ShowTickLabels ) return 2*YPADDING; return YPADDING; } diff --git a/kdeeduplot/kplotwidget.h b/kdeeduplot/kplotwidget.h index 119e7bd..4d57432 100644 --- a/kdeeduplot/kplotwidget.h +++ b/kdeeduplot/kplotwidget.h @@ -138,7 +138,7 @@ public: *@param show if true, axes will be drawn. *The axes are just a box outline around the plot. */ - virtual void setShowAxes( bool show ) { XAxis.setVisible(show); YAxis.setVisible(show); } + virtual void setShowAxes( bool show ) { BottomAxis.setVisible(show); LeftAxis.setVisible(show); ShowAxes = show; } /**@short toggle whether tick marks are drawn along the axes. *@param show if true, tick marks will be drawn. */ @@ -156,12 +156,12 @@ public: *@param xlabel a short string describing the data plotted on the x-axis. *Set the label to an empty string to omit the axis label. */ - virtual void setXAxisLabel( QString xlabel ) { XAxis.setLabel(xlabel); } + virtual void setXAxisLabel( QString xlabel ) { BottomAxis.setLabel(xlabel); XAxisLabel = xlabel; } /**@short set the Y-axis label *@param ylabel a short string describing the data plotted on the y-axis. *Set the label to an empty string to omit the axis label. */ - virtual void setYAxisLabel( QString ylabel ) { YAxis.setLabel(ylabel); } + virtual void setYAxisLabel( QString ylabel ) { LeftAxis.setLabel(ylabel); YAxisLabel = ylabel; } /**@returns the number of pixels to the left of the plot area. Padding values *are set to -1 by default; if unchanged, this function will try to guess @@ -204,10 +204,10 @@ public: /**@short revert all four padding values to be automatically determined. */ virtual void setDefaultPadding() { LeftPadding = -1; RightPadding = -1; TopPadding = -1; BottomPadding = -1; } - /**@short The X axis. */ - KPlotAxis XAxis; - /**@short The Y axis. */ - KPlotAxis YAxis; + /**@short The bottom X axis. */ + KPlotAxis BottomAxis; + /**@short The left Y axis. */ + KPlotAxis LeftAxis; protected: /**@short the paint event handler, executed when update() or repaint() is called. @@ -251,11 +251,18 @@ protected: //Colors QColor cBackground, cForeground, cGrid; //draw options - bool ShowAxes, ShowTickMarks, ShowTickLabels, ShowGrid; + bool ShowTickMarks, ShowTickLabels, ShowGrid; //padding int LeftPadding, RightPadding, TopPadding, BottomPadding; QPixmap *buffer; + + // Deprecated properties, kept for compatibility for KStars subclassed widget + // In new code DO NOT use them directly! + + //Axis Labels + bool ShowAxes; + QString XAxisLabel, YAxisLabel; }; #endif