 |
KD Chart 2
[rev.2.7]
|
Go to the documentation of this file.
24 #include "KDChartBarDiagram_p.h"
29 #include "KDChartAbstractGrid.h"
30 #include "KDChartPainterSaver_p.h"
35 #include <KDABLibFakes>
37 #include "KDChartNormalBarDiagram_p.h"
38 #include "KDChartStackedBarDiagram_p.h"
39 #include "KDChartPercentBarDiagram_p.h"
40 #include "KDChartNormalLyingBarDiagram_p.h"
41 #include "KDChartStackedLyingBarDiagram_p.h"
42 #include "KDChartPercentLyingBarDiagram_p.h"
47 BarDiagram::Private::Private()
48 : orientation( Qt::Vertical )
53 , normalLyingDiagram( 0 )
54 , stackedLyingDiagram( 0 )
55 , percentLyingDiagram( 0 )
59 BarDiagram::Private::~Private()
62 delete stackedDiagram;
63 delete percentDiagram;
64 delete normalLyingDiagram;
65 delete stackedLyingDiagram;
66 delete percentLyingDiagram;
69 void BarDiagram::Private::setOrientationAndType( Qt::Orientation o,
BarDiagram::BarType type )
71 if ( orientation == o && implementor->type() == type ) {
74 BarDiagram *barDia = qobject_cast< BarDiagram * >( diagram );
78 if ( orientation == Qt::Vertical ) {
81 implementor = normalDiagram;
84 implementor = stackedDiagram;
87 implementor = percentDiagram;
90 Q_ASSERT_X(
false,
"BarDiagram::setType",
"unknown diagram subtype" );
95 implementor = normalLyingDiagram;
98 implementor = stackedLyingDiagram;
101 implementor = percentLyingDiagram;
104 Q_ASSERT_X(
false,
"BarDiagram::setType",
"unknown diagram subtype" );
108 Q_ASSERT( implementor->type() == type );
126 void BarDiagram::init()
128 d->normalDiagram =
new NormalBarDiagram(
this );
129 d->stackedDiagram =
new StackedBarDiagram(
this );
130 d->percentDiagram =
new PercentBarDiagram(
this );
131 d->normalLyingDiagram =
new NormalLyingBarDiagram(
this );
132 d->stackedLyingDiagram =
new StackedLyingBarDiagram(
this );
133 d->percentLyingDiagram =
new PercentLyingBarDiagram(
this );
134 d->implementor =
d->normalDiagram;
155 if ( other ==
this )
return true;
172 d->setOrientationAndType(
d->orientation,
type );
180 return d->implementor->type();
188 d->setOrientationAndType(
orientation,
d->implementor->type() );
196 return d->orientation;
223 d->attributesModel->mapFromSource( index ),
224 qVariantFromValue( ba ),
243 if ( attrs.isValid() )
253 return d->attributesModel->data(
254 d->attributesModel->mapFromSource( index ),
286 d->attributesModel->setData(
287 d->attributesModel->mapFromSource(index),
288 qVariantFromValue( threeDAttrs ),
308 if ( attrs.isValid() )
318 return d->attributesModel->data(
319 d->attributesModel->mapFromSource(index),
340 d->compressor.setResolution(
static_cast<int>( this->size().width() *
coordinatePlane()->zoomFactorX() ),
341 static_cast<int>( this->size().height() *
coordinatePlane()->zoomFactorY() ) );
351 return d->implementor->calculateDataBoundaries();
356 QPainter painter ( viewport() );
367 const PainterSaver p( ctx->
painter() );
368 if ( model()->rowCount( rootIndex() ) == 0 || model()->columnCount( rootIndex() ) == 0 )
386 d->implementor->paint( ctx );
393 d->compressor.setResolution(
static_cast< int >( size.width() *
coordinatePlane()->zoomFactorX() ),
394 static_cast< int >( size.height() *
coordinatePlane()->zoomFactorY() ) );
396 QAbstractItemView::resize( size.toSize() );
399 #if QT_VERSION < 0x040400 || defined(Q_COMPILER_MANGLES_RETURN_TYPE)
407 #if QT_VERSION < 0x040400 || defined(Q_COMPILER_MANGLES_RETURN_TYPE)
virtual AbstractCoordinatePlane * sharedAxisMasterPlane(QPainter *p=0)
void resizeEvent(QResizeEvent *) override
Qt::Orientation orientation() const
@ ThreeDBarAttributesRole
void setOrientation(Qt::Orientation orientation)
Sets the orientation of the bar diagram.
AbstractCoordinatePlane * coordinatePlane() const
The coordinate plane associated with the diagram.
const QPair< QPointF, QPointF > dataBoundaries() const
Return the bottom left and top right data point, that the diagram will display (unless the grid adjus...
void layoutChanged(AbstractDiagram *)
Diagrams are supposed to emit this signal, when the layout of one of their element changes.
void paint(PaintContext *paintContext) override
Draw the diagram contents to the rectangle and painter, that are passed in as part of the paint conte...
virtual BarDiagram * clone() const
Creates an exact copy of this diagram.
AbstractCoordinatePlane * coordinatePlane() const
const QPair< QPointF, QPointF > calculateDataBoundaries() const override
[reimplemented]
void setPainter(QPainter *painter)
void setBarAttributes(const BarAttributes &a)
Sets the global bar attributes to ba.
BarDiagram(QWidget *parent=0, CartesianCoordinatePlane *plane=0)
qreal threeDItemDepth(const QModelIndex &index) const override
void setDataBoundariesDirty() const
void setType(const BarType type)
Sets the bar diagram's type to type.
BarAttributes barAttributes() const
Stores information about painting diagrams.
ThreeDBarAttributes threeDBarAttributes() const
QPainter * painter() const
void setPercentMode(bool percent)
Deprecated method that turns the percent mode of this diagram on or off.
Base class for diagrams based on a cartesian coordianate system.
virtual AttributesModel * attributesModel() const
Returns the AttributesModel, that is used by this diagram.
void paintEvent(QPaintEvent *) override
Set of attributes for changing the appearance of bar charts.
const int numberOfOrdinateSegments() const
[reimplemented]
void setCoordinatePlane(AbstractCoordinatePlane *plane)
A set of 3D bar attributes.
const int numberOfAbscissaSegments() const
[reimplemented]
QModelIndex attributesModelRootIndex() const
void setThreeDBarAttributes(const ThreeDBarAttributes &a)
Sets the global 3D bar attributes to threeDAttrs.
void setRectangle(const QRectF &rect)
void propertiesChanged()
Emitted upon change of a property of the Diagram.
bool compare(const BarDiagram *other) const
Returns true if both diagrams have the same settings.
Cartesian coordinate plane.
void resize(const QSizeF &area) override
Called by the widget's sizeEvent.
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::DisplayRole) override
[reimplemented]
virtual bool checkInvariants(bool justReturnTheStatus=false) const
BarDiagram defines a common bar diagram.
Base class common for all coordinate planes, CartesianCoordinatePlane, PolarCoordinatePlane,...