[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: koffice/plugins/chartshape/kdchart/src
From: Johannes Simon <johannes.simon () gmail ! com>
Date: 2010-10-17 21:42:15
Message-ID: 20101017214215.76D57AC89A () svn ! kde ! org
[Download RAW message or body]
SVN commit 1186907 by jsimon:
Allow disabling of drawing area margins that were meant to do.. well I dont really \
know what they were for. They only caused weird offsets between an axis and the \
coordinate plane's a frame.
M +20 -6 KDChartCartesianCoordinatePlane.cpp
M +14 -0 KDChartCartesianCoordinatePlane.h
M +5 -0 KDChartCartesianCoordinatePlane_p.h
--- trunk/koffice/plugins/chartshape/kdchart/src/KDChartCartesianCoordinatePlane.cpp \
#1186906:1186907 @@ -55,6 +55,15 @@
, horizontalMax(0)
, verticalMin(0)
, verticalMax(0)
+ , drawingAreaMarginLeft( 1 )
+ , drawingAreaMarginTop( 1 )
+ // (Why -3? We save 1px on each side for the antialiased drawing, and
+ // respect the way QPainter calculates the width of a painted rect (the
+ // size is the rectangle size plus the pen width). This way, most clipping
+ // for regular pens should be avoided. When pens with a penWidth or larger
+ // than 1 are used, this may not be sufficient.
+ , drawingAreaMarginRight( -3 )
+ , drawingAreaMarginBottom( -3 )
, autoAdjustHorizontalRangeToData(67)
, autoAdjustVerticalRangeToData( 67)
, autoAdjustGridToZoom( true )
@@ -325,15 +334,20 @@
QRectF CartesianCoordinatePlane::drawingArea() const
{
// the rectangle the diagrams cover in the *plane*:
- // (Why -3? We save 1px on each side for the antialiased drawing, and
- // respect the way QPainter calculates the width of a painted rect (the
- // size is the rectangle size plus the pen width). This way, most clipping
- // for regular pens should be avoided. When pens with a penWidth or larger
- // than 1 are used, this may not be sufficient.
const QRect rect( areaGeometry() );
- return QRectF ( rect.left()+1, rect.top()+1, rect.width() - 3, rect.height() - 3 \
); + return QRectF ( rect.left() + d->drawingAreaMarginLeft,
+ rect.top() + d->drawingAreaMarginTop,
+ rect.width() + d->drawingAreaMarginRight,
+ rect.height() + d->drawingAreaMarginBottom );
}
+void CartesianCoordinatePlane::setDrawingAreaMargins( qreal left, qreal top, qreal \
right, qreal bottom ) +{
+ d->drawingAreaMarginLeft = left;
+ d->drawingAreaMarginTop = top;
+ d->drawingAreaMarginRight = right;
+ d->drawingAreaMarginBottom = bottom;
+}
QRectF CartesianCoordinatePlane::logicalArea() const
{
--- trunk/koffice/plugins/chartshape/kdchart/src/KDChartCartesianCoordinatePlane.h \
#1186906:1186907 @@ -389,6 +389,20 @@
QRectF diagramArea() const;
/**
+ * Margins that will be added to geometry() for internal layouting
+ * methods. For historical reasons the the default is (1, 1, -3, -3).
+ *
+ * Use this method if data points or lines are just slightly cut off
+ * at the edge of the coordinate plane. This does not play nicely in
+ * conjunction with KDChart::Chart however, especially if you draw a
+ * frame around the coordinate plane as there will be odd offsets
+ * at the sides between axis (or axis ticks) and the chart's frame.
+ *
+ * To avoid the latter, problem, set all margins to 0.
+ */
+ void setDrawingAreaMargins( qreal left, qreal top, qreal right, qreal bottom \
); +
+ /**
* Returns the visible part of the diagram area, i.e.
* \code diagramArea().intersected( drawingArea() ) \endcode
* \sa diagramArea
--- trunk/koffice/plugins/chartshape/kdchart/src/KDChartCartesianCoordinatePlane_p.h \
#1186906:1186907 @@ -105,6 +105,11 @@
qreal verticalMin;
qreal verticalMax;
+ qreal drawingAreaMarginLeft;
+ qreal drawingAreaMarginTop;
+ qreal drawingAreaMarginRight;
+ qreal drawingAreaMarginBottom;
+
// autoAdjustHorizontalRangeToData determines if and how much the horizontal \
range is adjusted.
// A value of 100 means that the fixed horizontal range will be used (e.g. set \
by the user),
// otherwise the value will be the percentage of the diagram's horizontal range \
that is to be
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic