File indexing completed on 2024-05-12 15:54:12
0001 /* 0002 * Copyright (C) 2001-2015 Klaralvdalens Datakonsult AB. All rights reserved. 0003 * 0004 * This file is part of the KD Chart library. 0005 * 0006 * This program is free software; you can redistribute it and/or 0007 * modify it under the terms of the GNU General Public License as 0008 * published by the Free Software Foundation; either version 2 of 0009 * the License, or (at your option) any later version. 0010 * 0011 * This program is distributed in the hope that it will be useful, 0012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0014 * GNU General Public License for more details. 0015 * 0016 * You should have received a copy of the GNU General Public License 0017 * along with this program. If not, see <https://www.gnu.org/licenses/>. 0018 */ 0019 0020 #ifndef KCHARTABSTRACTDIAGRAM_H 0021 #define KCHARTABSTRACTDIAGRAM_H 0022 0023 #include <QList> 0024 #include <QRectF> 0025 #include <QAbstractItemView> 0026 0027 #include "KChartGlobal.h" 0028 #include "KChartMarkerAttributes.h" 0029 #include "KChartAttributesModel.h" 0030 0031 namespace KChart { 0032 0033 class AbstractCoordinatePlane; 0034 class AttributesModel; 0035 class DataValueAttributes; 0036 class PaintContext; 0037 0038 /** 0039 * @brief AbstractDiagram defines the interface for diagram classes 0040 * 0041 * AbstractDiagram is the base class for diagram classes ("chart types"). 0042 * 0043 * It defines the interface, that needs to be implemented for the diagram, 0044 * to function within the KChart framework. It extends Interview's 0045 * QAbstractItemView. 0046 */ 0047 class KCHART_EXPORT AbstractDiagram : public QAbstractItemView 0048 { 0049 Q_OBJECT 0050 Q_DISABLE_COPY( AbstractDiagram ) 0051 KCHART_DECLARE_PRIVATE_BASE_POLYMORPHIC( AbstractDiagram ) 0052 0053 friend class AbstractCoordinatePlane; 0054 friend class CartesianCoordinatePlane; 0055 friend class PolarCoordinatePlane; 0056 0057 protected: 0058 explicit inline AbstractDiagram( 0059 Private *p, QWidget* parent, AbstractCoordinatePlane* plane ); 0060 explicit AbstractDiagram ( 0061 QWidget* parent = nullptr, AbstractCoordinatePlane* plane = nullptr ); 0062 public: 0063 virtual ~AbstractDiagram(); 0064 0065 0066 /** 0067 * Returns true if both diagrams have the same settings. 0068 */ 0069 bool compare( const AbstractDiagram* other ) const; 0070 0071 0072 /** 0073 * @brief Return the bottom left and top right data point, that the 0074 * diagram will display (unless the grid adjusts these values). 0075 * 0076 * This method returns a cached result of calculations done by 0077 * calculateDataBoundaries. 0078 * Classes derived from AbstractDiagram must implement the 0079 * calculateDataBoundaries function, to specify their own 0080 * way of calculating the data boundaries. 0081 * If derived classes want to force recalculation of the 0082 * data boundaries, they can call setDataBoundariesDirty() 0083 * 0084 * Returned value is in diagram coordinates. 0085 */ 0086 const QPair<QPointF, QPointF> dataBoundaries() const; 0087 0088 // protected: // FIXME: why should that be private? (Mirko) 0089 /** 0090 * Draw the diagram contents to the rectangle and painter, that are 0091 * passed in as part of the paint context. 0092 * 0093 * @param paintContext All information needed for painting. 0094 */ 0095 virtual void paint ( PaintContext* paintContext ) = 0; 0096 0097 /** 0098 * Called by the widget's sizeEvent. Adjust all internal structures, 0099 * that are calculated, dependending on the size of the widget. 0100 * 0101 * @param area 0102 */ 0103 virtual void resize ( const QSizeF& area ); 0104 0105 /** Associate a model with the diagram. */ 0106 void setModel ( QAbstractItemModel * model ) override; 0107 0108 /** Associate a seleection model with the diagrom. */ 0109 void setSelectionModel( QItemSelectionModel* selectionModel ) override; 0110 0111 /** 0112 * Associate an AttributesModel with this diagram. Note that 0113 * the diagram does _not_ take ownership of the AttributesModel. 0114 * This should thus only be used with AttributesModels that 0115 * have been explicitly created by the user, and are owned 0116 * by her. Setting an AttributesModel that is internal to 0117 * another diagram is an error. 0118 * 0119 * Correct: 0120 * 0121 * \code 0122 * AttributesModel *am = new AttributesModel( model, 0 ); 0123 * diagram1->setAttributesModel( am ); 0124 * diagram2->setAttributesModel( am ); 0125 * 0126 * \endcode 0127 * 0128 * Wrong: 0129 * 0130 * \code 0131 * 0132 * diagram1->setAttributesModel( diagram2->attributesModel() ); 0133 * 0134 * \endcode 0135 * 0136 * @param model The AttributesModel to use for this diagram. 0137 * @see AttributesModel, usesExternalAttributesModel 0138 */ 0139 virtual void setAttributesModel( AttributesModel* model ); 0140 0141 /** 0142 * Returns whether the diagram is using its own built-in attributes model 0143 * or an attributes model that was set via setAttributesModel. 0144 * 0145 * @see setAttributesModel 0146 */ 0147 virtual bool usesExternalAttributesModel() const; 0148 0149 /** 0150 * Returns the AttributesModel, that is used by this diagram. 0151 * By default each diagram owns its own AttributesModel, which 0152 * should never be deleted. Only if a user-supplied AttributesModel 0153 * has been set does the pointer returned here not belong to the 0154 * diagram. 0155 * 0156 * @return The AttributesModel associated with the diagram. 0157 * @see setAttributesModel 0158 */ 0159 virtual AttributesModel* attributesModel() const; 0160 0161 /** Set the root index in the model, where the diagram starts 0162 * referencing data for display. */ 0163 void setRootIndex ( const QModelIndex& idx ) override; 0164 0165 /** \reimpl */ 0166 QRect visualRect(const QModelIndex &index) const override; 0167 /** \reimpl */ 0168 void scrollTo(const QModelIndex &index, ScrollHint hint = EnsureVisible) override; 0169 /** \reimpl */ 0170 QModelIndex indexAt(const QPoint &point) const override; 0171 /** \reimpl */ 0172 QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers) override; 0173 /** \reimpl */ 0174 int horizontalOffset() const override; 0175 /** \reimpl */ 0176 int verticalOffset() const override; 0177 /** \reimpl */ 0178 bool isIndexHidden(const QModelIndex &index) const override; 0179 /** \reimpl */ 0180 void setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command) override; 0181 /** \reimpl */ 0182 QRegion visualRegionForSelection(const QItemSelection &selection) const override; 0183 virtual QRegion visualRegion(const QModelIndex &index) const; 0184 /** \reimpl */ 0185 void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles = QVector<int>()) override; 0186 /** \reimpl */ 0187 void doItemsLayout() override; 0188 0189 /** 0190 * The coordinate plane associated with the diagram. This determines 0191 * how coordinates in value space are mapped into pixel space. By default 0192 * this is a CartesianCoordinatePlane. 0193 * @return The coordinate plane associated with the diagram. 0194 */ 0195 AbstractCoordinatePlane* coordinatePlane() const; 0196 0197 /** 0198 * Set the coordinate plane associated with the diagram. This determines 0199 * how coordinates in value space are mapped into pixel space. The chart 0200 * takes ownership. 0201 */ 0202 virtual void setCoordinatePlane( AbstractCoordinatePlane* plane ); 0203 0204 0205 /** 0206 * Hide (or unhide, resp.) a data cell. 0207 * 0208 * \note Hidden data are still taken into account by the coordinate plane, 0209 * so neither the grid nor your axes' ranges will change, when you hide data. 0210 * For totally removing data from KChart's view you can use another approach: 0211 * e.g. you could define a proxy model on top of your data model, and register 0212 * the proxy model calling setModel() instead of registering your real data model. 0213 * 0214 * @param index The datapoint to set the hidden status for. With a dataset dimension 0215 * of two, this is the index of the key of each key/value pair. 0216 * @param hidden The hidden status to set. 0217 */ 0218 void setHidden( const QModelIndex & index, bool hidden ); 0219 0220 /** 0221 * Hide (or unhide, resp.) a dataset. 0222 * 0223 * \note Hidden data are still taken into account by the coordinate plane, 0224 * so neither the grid nor your axes' ranges will change, when you hide data. 0225 * For totally removing data from KChart's view you can use another approach: 0226 * e.g. you could define a proxy model on top of your data model, and register 0227 * the proxy model calling setModel() instead of registering your real data model. 0228 * 0229 * @param dataset The dataset to set the hidden status for. 0230 * @param hidden The hidden status to set. 0231 */ 0232 void setHidden( int dataset, bool hidden ); 0233 0234 /** 0235 * Hide (or unhide, resp.) all datapoints in the model. 0236 * 0237 * \note Hidden data are still taken into account by the coordinate plane, 0238 * so neither the grid nor your axes' ranges will change, when you hide data. 0239 * For totally removing data from KChart's view you can use another approach: 0240 * e.g. you could define a proxy model on top of your data model, and register 0241 * the proxy model calling setModel() instead of registering your real data model. 0242 * 0243 * @param hidden The hidden status to set. 0244 */ 0245 void setHidden( bool hidden ); 0246 0247 /** 0248 * Retrieve the hidden status specified globally. This will fall 0249 * back automatically to the default settings ( = not hidden), if there 0250 * are no specific settings. 0251 * @return The global hidden status. 0252 */ 0253 bool isHidden() const; 0254 0255 /** 0256 * Retrieve the hidden status for the given dataset. This will fall 0257 * back automatically to what was set at diagram level, if there 0258 * are no dataset specific settings. 0259 * @param dataset The dataset to retrieve the hidden status for. 0260 * @return The hidden status for the given dataset. 0261 */ 0262 bool isHidden( int dataset ) const; 0263 0264 /** 0265 * Retrieve the hidden status for the given index. This will fall 0266 * back automatically to what was set at dataset or diagram level, if there 0267 * are no datapoint specific settings. 0268 * @param index The datapoint to retrieve the hidden status for. 0269 * @return The hidden status for the given index. 0270 */ 0271 bool isHidden( const QModelIndex & index ) const; 0272 0273 0274 /** 0275 * Set the DataValueAttributes for the given index. 0276 * @param index The datapoint to set the attributes for. With a dataset dimension 0277 * of two, this is the index of the key of each key/value pair. 0278 * @param a The attributes to set. 0279 */ 0280 void setDataValueAttributes( const QModelIndex & index, 0281 const DataValueAttributes & a ); 0282 0283 /** 0284 * Set the DataValueAttributes for the given dataset. 0285 * @param dataset The dataset to set the attributes for. 0286 * @param a The attributes to set. 0287 */ 0288 void setDataValueAttributes( int dataset, const DataValueAttributes & a ); 0289 0290 /** 0291 * Set the DataValueAttributes for all datapoints in the model. 0292 * @param a The attributes to set. 0293 */ 0294 void setDataValueAttributes( const DataValueAttributes & a ); 0295 0296 /** 0297 * Retrieve the DataValueAttributes specified globally. This will fall 0298 * back automatically to the default settings, if there 0299 * are no specific settings. 0300 * @return The global DataValueAttributes. 0301 */ 0302 DataValueAttributes dataValueAttributes() const; 0303 0304 /** 0305 * Retrieve the DataValueAttributes for the given dataset. This will fall 0306 * back automatically to what was set at model level, if there 0307 * are no dataset specific settings. 0308 * @param dataset The dataset to retrieve the attributes for. 0309 * @return The DataValueAttributes for the given dataset. 0310 */ 0311 DataValueAttributes dataValueAttributes( int dataset ) const; 0312 0313 /** 0314 * Retrieve the DataValueAttributes for the given index. This will fall 0315 * back automatically to what was set at dataset or model level, if there 0316 * are no datapoint specific settings. 0317 * @param index The datapoint to retrieve the attributes for. With a dataset dimension 0318 * of two, this is the index of the key of each key/value pair. 0319 * @return The DataValueAttributes for the given index. 0320 */ 0321 DataValueAttributes dataValueAttributes( const QModelIndex & index ) const; 0322 0323 /** 0324 * Set the pen to be used, for painting the datapoint at the given index. 0325 * @param index The datapoint's index in the model. With a dataset dimension 0326 * of two, this is the index of the key of each key/value pair. 0327 * @param pen The pen to use. 0328 */ 0329 void setPen( const QModelIndex& index, const QPen& pen ); 0330 0331 /** 0332 * Set the pen to be used, for painting the given dataset. 0333 * @param dataset The dataset to set the pen for. 0334 * @param pen The pen to use. 0335 */ 0336 void setPen( int dataset, const QPen& pen ); 0337 0338 /** 0339 * Set the pen to be used, for painting all datasets in the model. 0340 * @param pen The pen to use. 0341 */ 0342 void setPen( const QPen& pen ); 0343 0344 /** 0345 * Retrieve the pen to be used for painting datapoints globally. This will fall 0346 * back automatically to the default settings, if there 0347 * are no specific settings. 0348 * @return The pen to use for painting. 0349 */ 0350 QPen pen() const; 0351 /** 0352 * Retrieve the pen to be used for the given dataset. This will fall 0353 * back automatically to what was set at model level, if there 0354 * are no dataset specific settings. 0355 * @param dataset The dataset to retrieve the pen for. 0356 * @return The pen to use for painting. 0357 */ 0358 QPen pen( int dataset ) const; 0359 /** 0360 * Retrieve the pen to be used, for painting the datapoint at the given 0361 * index in the model. 0362 * @param index The index of the datapoint in the model. With a dataset dimension 0363 * of two, this is the index of the key of each key/value pair. 0364 * @return The pen to use for painting. 0365 */ 0366 QPen pen( const QModelIndex& index ) const; 0367 0368 /** 0369 * Set the brush to be used, for painting the datapoint at the given index. 0370 * @param index The datapoint's index in the model. With a dataset dimension 0371 * of two, this is the index of the key of each key/value pair. 0372 * @param brush The brush to use. 0373 */ 0374 void setBrush( const QModelIndex& index, const QBrush& brush); 0375 0376 /** 0377 * Set the brush to be used, for painting the given dataset. 0378 * @param dataset The dataset to set the brush for. 0379 * @param brush The brush to use. 0380 */ 0381 void setBrush( int dataset, const QBrush& brush ); 0382 0383 /** 0384 * Set the brush to be used, for painting all datasets in the model. 0385 * @param brush The brush to use. 0386 */ 0387 void setBrush( const QBrush& brush); 0388 0389 /** 0390 * Retrieve the brush to be used for painting datapoints globally. This will fall 0391 * back automatically to the default settings, if there 0392 * are no specific settings. 0393 * @return The brush to use for painting. 0394 */ 0395 QBrush brush() const; 0396 /** 0397 * Retrieve the brush to be used for the given dataset. This will fall 0398 * back automatically to what was set at model level, if there 0399 * are no dataset specific settings. 0400 * @param dataset The dataset to retrieve the brush for. 0401 * @return The brush to use for painting. 0402 */ 0403 QBrush brush( int dataset ) const; 0404 /** 0405 * Retrieve the brush to be used, for painting the datapoint at the given 0406 * index in the model. 0407 * @param index The index of the datapoint in the model. With a dataset dimension 0408 * of two, this is the index of the key of each key/value pair. 0409 * @return The brush to use for painting. 0410 */ 0411 QBrush brush( const QModelIndex& index ) const; 0412 0413 /** 0414 * Set the unit prefix to be used on axes for one specific column. 0415 * @param prefix The prefix to be used. 0416 * @param column The column which should be set. 0417 * @param orientation The orientation of the axis to use. 0418 */ 0419 void setUnitPrefix( const QString& prefix, int column, Qt::Orientation orientation ); 0420 /** 0421 * Set the unit prefix to be used on axes for all columns. 0422 * @param prefix The prefix to be used. 0423 * @param orientation The orientation of the axis to use. 0424 */ 0425 void setUnitPrefix( const QString& prefix, Qt::Orientation orientation ); 0426 0427 /** 0428 * Set the unit prefix to be used on axes for one specific column. 0429 * @param suffix The suffix to be used. 0430 * @param column The column which should be set. 0431 * @param orientation The orientation of the axis to use. 0432 */ 0433 void setUnitSuffix( const QString& suffix, int column, Qt::Orientation orientation ); 0434 /** 0435 * Set the unit prefix to be used on axes for all columns. 0436 * @param suffix The suffix to be used. 0437 * @param orientation The orientation of the axis to use. 0438 */ 0439 void setUnitSuffix( const QString& suffix, Qt::Orientation orientation ); 0440 0441 /** 0442 * Retrieves the axis unit prefix for a specific column. 0443 * @param column The column whose prefix should be retrieved. 0444 * @param orientation The orientation of the axis. 0445 * @param fallback If true, the prefix for all columns is returned, when 0446 * none is set for the selected column. 0447 * @return The axis unit prefix. 0448 */ 0449 QString unitPrefix( int column, Qt::Orientation orientation, bool fallback = false ) const; 0450 /** 0451 * Retrieves the axis unit prefix. 0452 * @param orientation The orientation of the axis. 0453 * @return The axis unit prefix. 0454 */ 0455 QString unitPrefix( Qt::Orientation orientation ) const; 0456 0457 /** 0458 * Retrieves the axis unit suffix for a specific column. 0459 * @param column The column whose prefix should be retrieved. 0460 * @param orientation The orientation of the axis. 0461 * @param fallback If true, the suffix for all columns is returned, when 0462 * none is set for the selected column. 0463 * @return The axis unit suffix. 0464 */ 0465 QString unitSuffix( int column, Qt::Orientation orientation, bool fallback = false ) const; 0466 /** 0467 * Retrieves the axis unit suffix. 0468 * @param orientation The orientation of the axis. 0469 * @return The axis unit suffix. 0470 */ 0471 QString unitSuffix( Qt::Orientation orientation ) const; 0472 0473 /** 0474 * Set whether data value labels are allowed to overlap. 0475 * @param allow True means that overlapping labels are allowed. 0476 */ 0477 void setAllowOverlappingDataValueTexts( bool allow ); 0478 0479 /** 0480 * @return Whether data value labels are allowed to overlap. 0481 */ 0482 bool allowOverlappingDataValueTexts() const; 0483 0484 /** 0485 * Set whether anti-aliasing is to be used while rendering 0486 * this diagram. 0487 * @param enabled True means that AA is enabled. 0488 */ 0489 void setAntiAliasing( bool enabled ); 0490 0491 /** 0492 * @return Whether anti-aliasing is to be used for rendering 0493 * this diagram. 0494 */ 0495 bool antiAliasing() const; 0496 0497 /** 0498 * Set the palette to be used, for painting datasets to the default 0499 * palette. 0500 * @see KChart::Palette. 0501 * FIXME: fold into one usePalette (KChart::Palette&) method 0502 */ 0503 void useDefaultColors(); 0504 0505 /** 0506 * Set the palette to be used, for painting datasets to the rainbow 0507 * palette. 0508 * @see KChart::Palette. 0509 */ 0510 void useRainbowColors(); 0511 0512 /** 0513 * Set the palette to be used, for painting datasets to the subdued 0514 * palette. 0515 * @see KChart::Palette. 0516 */ 0517 void useSubduedColors(); 0518 0519 /** 0520 * The set of item row labels currently displayed, for use in Abscissa axes, etc. 0521 * @return The set of item row labels currently displayed. 0522 */ 0523 QStringList itemRowLabels() const; 0524 0525 /** 0526 * The set of dataset labels currently displayed, for use in legends, etc. 0527 * @return The set of dataset labels currently displayed. 0528 */ 0529 QStringList datasetLabels() const; 0530 0531 /** 0532 * The set of dataset brushes currently used, for use in legends, etc. 0533 * 0534 * @note Cell-level override brushes, if set, take precedence over the 0535 * dataset values, so you might need to check these too, in order to find 0536 * the brush, that is used for a single cell. 0537 * 0538 * @return The current set of dataset brushes. 0539 */ 0540 QList<QBrush> datasetBrushes() const; 0541 0542 /** 0543 * The set of dataset pens currently used, for use in legends, etc. 0544 * 0545 * @note Cell-level override pens, if set, take precedence over the 0546 * dataset values, so you might need to check these too, in order to find 0547 * the pens, that is used for a single cell. 0548 * 0549 * @return The current set of dataset pens. 0550 */ 0551 QList<QPen> datasetPens() const; 0552 0553 /** 0554 * The set of dataset markers currently used, for use in legends, etc. 0555 * 0556 * @note Cell-level override markers, if set, take precedence over the 0557 * dataset values, so you might need to check these too, in order to find 0558 * the marker, that is shown for a single cell. 0559 * 0560 * @return The current set of dataset brushes. 0561 */ 0562 QList<MarkerAttributes> datasetMarkers() const; 0563 0564 0565 /** 0566 * \deprecated 0567 * 0568 * \brief Deprecated method that turns the percent mode of this diagram on or off. 0569 * 0570 * This method is deprecated. Use the setType() method of a supporting diagram implementation 0571 * instead, e.g. BarDiagram::setType(). 0572 * 0573 * \see percentMode 0574 */ 0575 void setPercentMode( bool percent ); 0576 0577 0578 /** 0579 * \brief Returns whether this diagram is drawn in percent mode. 0580 * 0581 * If true, all data points in the same column of a diagram will 0582 * be be drawn at the same X coordinate and stacked up so that the distance from the 0583 * last data point (or the zero line) to a data point P is always the ratio of (Y-Value of P)/ 0584 * (sum of all Y-Values in same column as P) relative to the diagrams height 0585 * (or width, if abscissa and ordinate are swapped). 0586 * 0587 * Note that this property is not applicable to all diagram types. 0588 */ 0589 bool percentMode() const; 0590 0591 virtual void paintMarker( QPainter* painter, 0592 const MarkerAttributes& markerAttributes, 0593 const QBrush& brush, const QPen&, 0594 const QPointF& point, const QSizeF& size ); 0595 0596 /** 0597 * The dataset dimension of a diagram determines how many value dimensions 0598 * it expects each datapoint to have. 0599 * For each dimension and data series it will expect one column of values in the model. 0600 * If the dimension is 1, automatic values will be used for X. 0601 * 0602 * For example, a diagram with the default dimension of 1 will have one column 0603 * per data series (the Y values) and will use automatic values for X 0604 * (1, 2, 3, ... n). 0605 * If the dimension is 2, the diagram will use the first, (and the third, 0606 * fifth, etc) columns as X values, and the second, (and the fourth, sixth, 0607 * etc) column as Y values. 0608 * @return The dataset dimension of the diagram. 0609 */ 0610 int datasetDimension() const; 0611 0612 /** 0613 * \deprecated 0614 * 0615 * Sets the dataset dimension of the diagram. Using this method 0616 * is deprecated. Use the specific diagram types instead. 0617 */ 0618 void setDatasetDimension( int dimension ); 0619 0620 protected: 0621 void setDatasetDimensionInternal( int dimension ); 0622 0623 public: 0624 void update() const; 0625 0626 void paintMarker( QPainter* painter, const DataValueAttributes& a, 0627 const QModelIndex& index, 0628 const QPointF& pos ); 0629 void paintMarker( QPainter* painter, 0630 const QModelIndex& index, 0631 const QPointF& pos ); 0632 void paintDataValueText( QPainter* painter, const QModelIndex& index, 0633 const QPointF& pos, qreal value ); 0634 0635 // reverse mapping: 0636 /** This method is added alongside with indexAt from QAIM, 0637 since in KChart multiple indexes can be displayed at the same 0638 spot. */ 0639 QModelIndexList indexesAt( const QPoint& point ) const; 0640 QModelIndexList indexesIn( const QRect& rect ) const; 0641 0642 protected: 0643 virtual bool checkInvariants( bool justReturnTheStatus=false ) const; 0644 virtual const QPair<QPointF, QPointF> calculateDataBoundaries() const = 0; 0645 0646 protected Q_SLOTS: 0647 void setDataBoundariesDirty() const; 0648 0649 protected: 0650 /** 0651 * \deprecated 0652 * This method is deprecated and provided for backward-compatibility only. 0653 * Your own diagram classes should call 0654 * d->paintDataValueTextsAndMarkers() instead 0655 * which also is taking care for showing your cell-specific comments, if any, 0656 */ 0657 virtual void paintDataValueTexts( QPainter* painter ); 0658 /** 0659 * \deprecated 0660 * This method is deprecated and provided for backward-compatibility only. 0661 * Your own diagram classes should call 0662 * d->paintDataValueTextsAndMarkers() instead 0663 * which also is taking care for showing your cell-specific comments, if any, 0664 */ 0665 virtual void paintMarkers( QPainter* painter ); 0666 0667 /*! \internal */ 0668 void setAttributesModelRootIndex( const QModelIndex& ); 0669 0670 /*! returns a QModelIndex pointing into the AttributesModel that corresponds to the 0671 root index of the diagram. */ 0672 QModelIndex attributesModelRootIndex() const; 0673 0674 /** 0675 * Helper method, retrieving the data value (DisplayRole) for a given row and column 0676 * @param row The row to query. 0677 * @param column The column to query. 0678 * @return The value of the display role at the given row and column as a qreal. 0679 * @deprecated 0680 */ 0681 qreal valueForCell( int row, int column ) const; 0682 0683 Q_SIGNALS: 0684 /** Diagrams are supposed to emit this signal, when the layout of one 0685 of their element changes. Layouts can change, for example, when 0686 axes are added or removed, or when the configuration was changed 0687 in a way that the axes or the diagram itself are displayed in a 0688 different geometry. 0689 Changes in the diagrams coordinate system also result 0690 in the layoutChanged() signal being emitted. 0691 */ 0692 void layoutChanged( AbstractDiagram* ); 0693 0694 /** 0695 * This signal is emitted when this diagram is being destroyed, but before all the 0696 * data, i.e. the attributes model, is invalidated. 0697 */ 0698 void aboutToBeDestroyed(); 0699 0700 /** This signal is emitted when either the model or the AttributesModel is replaced. */ 0701 void modelsChanged(); 0702 0703 /** This signal is emitted just before the new attributes model is connected internally. 0704 It gives you a chance to connect to its signals first or perform other setup work. */ 0705 void attributesModelAboutToChange( AttributesModel* newModel, AttributesModel* oldModel ); 0706 0707 /** This signal is emitted, when the model data is changed. */ 0708 void modelDataChanged(); 0709 0710 /** This signal is emitted, when the hidden status of at least one data cell was (un)set. */ 0711 void dataHidden(); 0712 0713 /** Emitted upon change of a property of the Diagram. */ 0714 void propertiesChanged(); 0715 0716 /** Emitted upon change of a data boundary */ 0717 void boundariesChanged(); 0718 /** Emitted upon change of the view coordinate system */ 0719 void viewportCoordinateSystemChanged(); 0720 0721 private: 0722 QModelIndex conditionallyMapFromSource( const QModelIndex & sourceIndex ) const; 0723 }; 0724 0725 typedef QList<AbstractDiagram*> AbstractDiagramList; 0726 typedef QList<const AbstractDiagram*> ConstAbstractDiagramList; 0727 0728 /** 0729 * @brief Internally used class just adding a special constructor used by AbstractDiagram 0730 */ 0731 class PrivateAttributesModel : public AttributesModel { 0732 Q_OBJECT 0733 public: 0734 explicit PrivateAttributesModel( QAbstractItemModel* model, QObject * parent = nullptr ) 0735 : AttributesModel(model,parent) {} 0736 }; 0737 } 0738 0739 #endif