KD Chart 2  [rev.2.7]
ReverseMapper.h
Go to the documentation of this file.
1 /****************************************************************************
2 ** Copyright (C) 2001-2020 Klaralvdalens Datakonsult AB. All rights reserved.
3 **
4 ** This file is part of the KD Chart library.
5 **
6 ** Licensees holding valid commercial KD Chart licenses may use this file in
7 ** accordance with the KD Chart Commercial License Agreement provided with
8 ** the Software.
9 **
10 **
11 ** This file may be distributed and/or modified under the terms of the
12 ** GNU General Public License version 2 and version 3 as published by the
13 ** Free Software Foundation and appearing in the file LICENSE.GPL.txt included.
14 **
15 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
17 **
18 ** Contact info@kdab.com if any conditions of this licensing are not
19 ** clear to you.
20 **
21 **********************************************************************/
22 
23 #ifndef REVERSEMAPPER_H
24 #define REVERSEMAPPER_H
25 
26 #include <QModelIndex>
27 #include <QHash>
28 
29 QT_BEGIN_NAMESPACE
30 class QRectF;
31 class QGraphicsScene;
32 class QPolygonF;
33 QT_END_NAMESPACE
34 
35 namespace KDChart {
36 
37  class AbstractDiagram;
38  class ChartGraphicsItem;
39 
45  {
46 
47  public:
48  ReverseMapper();
49  explicit ReverseMapper( AbstractDiagram* diagram );
50 
52 
53  void setDiagram( AbstractDiagram* diagram );
54 
55  void clear();
56 
57  QModelIndexList indexesAt( const QPointF& point ) const;
58  QModelIndexList indexesIn( const QRect& rect ) const;
59 
60  QPolygonF polygon( int row, int column ) const;
61  QRectF boundingRect( int row, int column ) const;
62 
63  void addItem( ChartGraphicsItem* item );
64 
65  // convenience methods:
66  void addPolygon( int row, int column, const QPolygonF& polygon );
67  void addRect( int row, int column, const QRectF& rect );
68  void addCircle( int row, int column, const QPointF& location, const QSizeF& diameter );
69  void addLine( int row, int column, const QPointF& from, const QPointF& to );
70 
71  private:
72  QGraphicsScene* m_scene;
73  AbstractDiagram* m_diagram;
74  QHash<QModelIndex, ChartGraphicsItem*> m_itemMap;
75  };
76 
77 }
78 
79 #endif
Graphics item used inside of the ReverseMapper.
QModelIndexList indexesAt(const QPointF &point) const
QModelIndexList indexesIn(const QRect &rect) const
AbstractDiagram defines the interface for diagram classes.
The ReverseMapper stores information about objects on a chart and their respective model indexes...
Definition: ReverseMapper.h:44
void addRect(int row, int column, const QRectF &rect)
void addItem(ChartGraphicsItem *item)
void addLine(int row, int column, const QPointF &from, const QPointF &to)
void setDiagram(AbstractDiagram *diagram)
void addPolygon(int row, int column, const QPolygonF &polygon)
QPolygonF polygon(int row, int column) const
void addCircle(int row, int column, const QPointF &location, const QSizeF &diameter)
QRectF boundingRect(int row, int column) const

Klarälvdalens Datakonsult AB (KDAB)
"The Qt, C++ and OpenGL Experts"
https://www.kdab.com/

https://www.kdab.com/development-resources/qt-tools/kd-chart/