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 ) {
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 );
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) Base class common for all coordinate planes, CartesianCoordinatePlane, PolarCoordinatePlane, TernaryCoordinatePlane.
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::DisplayRole) override
[reimplemented]
virtual AbstractCoordinatePlane * sharedAxisMasterPlane(QPainter *p=0)
void paintEvent(QPaintEvent *) override
virtual BarDiagram * clone() const
Creates an exact copy of this diagram.
BarAttributes barAttributes() const
void setPainter(QPainter *painter)
void setDataBoundariesDirty() const
virtual bool checkInvariants(bool justReturnTheStatus=false) const
AbstractCoordinatePlane * coordinatePlane() const
Set of attributes for changing the appearance of bar charts.
void setType(const BarType type)
Sets the bar diagram's type to type.
void setBarAttributes(const BarAttributes &a)
Sets the global bar attributes to ba.
void setPercentMode(bool percent)
Deprecated method that turns the percent mode of this diagram on or off.
QPainter * painter() const
virtual AttributesModel * attributesModel() const
Returns the AttributesModel, that is used by this diagram.
AbstractCoordinatePlane * coordinatePlane() const
The coordinate plane associated with the diagram.
BarDiagram defines a common bar diagram.
const QPair< QPointF, QPointF > calculateDataBoundaries() const override
[reimplemented]
qreal threeDItemDepth(const QModelIndex &index) const override
void paint(PaintContext *paintContext) override
Draw the diagram contents to the rectangle and painter, that are passed in as part of the paint conte...
void setThreeDBarAttributes(const ThreeDBarAttributes &a)
Sets the global 3D bar attributes to threeDAttrs.
BarDiagram(QWidget *parent=0, CartesianCoordinatePlane *plane=0)
const QPair< QPointF, QPointF > dataBoundaries() const
Return the bottom left and top right data point, that the diagram will display (unless the grid adjus...
bool compare(const BarDiagram *other) const
Returns true if both diagrams have the same settings.
void resizeEvent(QResizeEvent *) override
void propertiesChanged()
Emitted upon change of a property of the Diagram.
Qt::Orientation orientation() const
Base class for diagrams based on a cartesian coordianate system.
Stores information about painting diagrams.
A set of 3D bar attributes.
const int numberOfAbscissaSegments() const
[reimplemented]
const int numberOfOrdinateSegments() const
[reimplemented]
virtual qreal zoomFactorY() const
ThreeDBarAttributes threeDBarAttributes() const
void layoutChanged(AbstractDiagram *)
Diagrams are supposed to emit this signal, when the layout of one of their element changes...
QModelIndex attributesModelRootIndex() const
Cartesian coordinate plane.
void setCoordinatePlane(AbstractCoordinatePlane *plane)
void setRectangle(const QRectF &rect)
void resize(const QSizeF &area) override
Called by the widget's sizeEvent.
void setOrientation(Qt::Orientation orientation)
Sets the orientation of the bar diagram.
virtual qreal zoomFactorX() const