File indexing completed on 2024-05-12 04:20:38
0001 /* 0002 * SPDX-FileCopyrightText: 2001-2015 Klaralvdalens Datakonsult AB. All rights reserved. 0003 * 0004 * This file is part of the KD Chart library. 0005 * 0006 * SPDX-License-Identifier: GPL-2.0-or-later 0007 */ 0008 0009 #ifndef REVERSEMAPPER_H 0010 #define REVERSEMAPPER_H 0011 0012 #include <QModelIndex> 0013 #include <QHash> 0014 0015 QT_BEGIN_NAMESPACE 0016 class QRectF; 0017 class QGraphicsScene; 0018 class QPolygonF; 0019 QT_END_NAMESPACE 0020 0021 namespace KChart { 0022 0023 class AbstractDiagram; 0024 class ChartGraphicsItem; 0025 0026 /** 0027 * @brief The ReverseMapper stores information about objects on a chart and their respective model indexes 0028 * \internal 0029 */ 0030 class ReverseMapper 0031 { 0032 0033 public: 0034 ReverseMapper(); 0035 explicit ReverseMapper( AbstractDiagram* diagram ); 0036 0037 ~ReverseMapper(); 0038 0039 void setDiagram( AbstractDiagram* diagram ); 0040 0041 void clear(); 0042 0043 QModelIndexList indexesAt( const QPointF& point ) const; 0044 QModelIndexList indexesIn( const QRect& rect ) const; 0045 0046 QPolygonF polygon( int row, int column ) const; 0047 QRectF boundingRect( int row, int column ) const; 0048 0049 // convenience methods: 0050 void addPolygon( int row, int column, const QPolygonF& polygon ); 0051 void addRect( int row, int column, const QRectF& rect ); 0052 void addCircle( int row, int column, const QPointF& location, const QSizeF& diameter ); 0053 void addLine( int row, int column, const QPointF& from, const QPointF& to ); 0054 0055 private: 0056 void populateScene() const; 0057 0058 AbstractDiagram* m_diagram; 0059 QHash<QModelIndex, QPolygonF> m_polygons; 0060 mutable QGraphicsScene* m_scene; 0061 mutable bool m_sceneDirty = true; 0062 }; 0063 0064 } 0065 0066 #endif