QColor cBackground, cForeground, cGrid;
//draw options
bool showGrid, showObjectToolTips, useAntialias;
+ //padding
+ int leftPadding, rightPadding, topPadding, bottomPadding;
};
KPlotWidget::KPlotWidget( QWidget *parent, double x1, double x2, double y1, double y2 )
return mAxes.contains( a ) ? mAxes[a] : 0;
}
+const KPlotAxis* KPlotWidget::axis( Axis a ) const
+{
+ return mAxes.contains( a ) ? mAxes[a] : 0;
+}
+
QList<KPlotPoint*> KPlotWidget::pointsUnderPoint( const QPoint& p ) const {
QList<KPlotPoint*> pts;
foreach ( KPlotObject *po, ObjectList ) {
} //End of RightAxis
}
-int KPlotWidget::leftPadding() {
- if ( LeftPadding >= 0 ) return LeftPadding;
+int KPlotWidget::leftPadding() const
+{
+ if ( d->leftPadding >= 0 ) return d->leftPadding;
if ( axis(LeftAxis)->isVisible() && axis(LeftAxis)->showTickLabels() ) {
if ( ! axis(LeftAxis)->label().isEmpty() ) return 3*XPADDING;
else return 2*XPADDING;
return XPADDING;
}
-int KPlotWidget::rightPadding() {
- if ( RightPadding >= 0 ) return RightPadding;
+int KPlotWidget::rightPadding() const
+{
+ if ( d->rightPadding >= 0 ) return d->rightPadding;
if ( axis(RightAxis)->isVisible() && axis(RightAxis)->showTickLabels() ) {
if ( ! axis(RightAxis)->label().isEmpty() ) return 3*XPADDING;
else return 2*XPADDING;
return XPADDING;
}
-int KPlotWidget::topPadding() {
- if ( TopPadding >= 0 ) return TopPadding;
+int KPlotWidget::topPadding() const
+{
+ if ( d->topPadding >= 0 ) return d->topPadding;
if ( axis(TopAxis)->isVisible() && axis(TopAxis)->showTickLabels() ) {
if ( ! axis(TopAxis)->label().isEmpty() ) return 3*YPADDING;
else return 2*YPADDING;
return YPADDING;
}
-int KPlotWidget::bottomPadding() {
- if ( BottomPadding >= 0 ) return BottomPadding;
+int KPlotWidget::bottomPadding() const
+{
+ if ( d->bottomPadding >= 0 ) return d->bottomPadding;
if ( axis(BottomAxis)->isVisible() && axis(BottomAxis)->showTickLabels() ) {
if ( ! axis(BottomAxis)->label().isEmpty() ) return 3*YPADDING;
else return 2*YPADDING;
}
return YPADDING;
}
+
+void KPlotWidget::setLeftPadding( int padding )
+{
+ d->leftPadding = padding;
+}
+
+void KPlotWidget::setRightPadding( int padding )
+{
+ d->rightPadding = padding;
+}
+
+void KPlotWidget::setTopPadding( int padding )
+{
+ d->topPadding = padding;
+}
+
+void KPlotWidget::setBottomPadding( int padding )
+{
+ d->bottomPadding = padding;
+}
+
+void KPlotWidget::setDefaultPaddings()
+{
+ d->leftPadding = -1;
+ d->rightPadding = -1;
+ d->topPadding = -1;
+ d->bottomPadding = -1;
+}
+
* Padding values are set to -1 by default; if unchanged, this function will try to guess
* a good value, based on whether ticklabels and/or axis labels are to be drawn.
*/
- virtual int leftPadding();
+ virtual int leftPadding() const;
/**
* @return the number of pixels to the right of the plot area.
* Padding values are set to -1 by default; if unchanged, this function will try to guess
* a good value, based on whether ticklabels and/or axis labels are to be drawn.
*/
- virtual int rightPadding();
+ virtual int rightPadding() const;
/**
* @return the number of pixels above the plot area.
* Padding values are set to -1 by default; if unchanged, this function will try to guess
* a good value, based on whether ticklabels and/or axis labels are to be drawn.
*/
- virtual int topPadding();
+ virtual int topPadding() const;
/**
* @return the number of pixels below the plot area.
* Padding values are set to -1 by default; if unchanged, this function will try to guess
* a good value, based on whether ticklabels and/or axis labels are to be drawn.
*/
- virtual int bottomPadding();
+ virtual int bottomPadding() const;
/**
* Set the number of pixels to the left of the plot area.
* Set this to -1 to revert to automatic determination of padding values.
*/
- virtual void setLeftPadding( int pad ) { LeftPadding = pad; }
+ virtual void setLeftPadding( int padding );
/**
* Set the number of pixels to the right of the plot area.
* Set this to -1 to revert to automatic determination of padding values.
*/
- virtual void setRightPadding( int pad ) { RightPadding = pad; }
+ virtual void setRightPadding( int padding );
/**
* Set the number of pixels above the plot area.
* Set this to -1 to revert to automatic determination of padding values.
*/
- virtual void setTopPadding( int pad ) { TopPadding = pad; }
+ virtual void setTopPadding( int padding );
/**
* Set the number of pixels below the plot area.
* Set this to -1 to revert to automatic determination of padding values.
*/
- virtual void setBottomPadding( int pad ) { BottomPadding = pad; }
+ virtual void setBottomPadding( int padding );
/**
* Revert all four padding values to be automatically determined.
*/
- void setDefaultPaddings() { LeftPadding = -1; RightPadding = -1; TopPadding = -1; BottomPadding = -1; }
+ void setDefaultPaddings();
/**
* Map a coordinate @p p from the data rect to the physical pixel rect.
*/
KPlotAxis* axis( Axis a );
+ const KPlotAxis* axis( Axis a ) const;
+
inline QRect& pixRect() { return PixRect; }
public slots:
*/
QHash<Axis, KPlotAxis*> mAxes;
- //padding
- int LeftPadding, RightPadding, TopPadding, BottomPadding;
-
//Grid of bools to mask "used" regions of the plot
float PlotMask[100][100];
double px[100], py[100];