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)
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;
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 );
} // 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;
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 );
} // 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();
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
}
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;
}
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;
}
*@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.
*/
*@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
/**@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.
//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