ReverseMapper.h

Go to the documentation of this file.
00001 /****************************************************************************
00002 ** Copyright (C) 2001-2011 Klaralvdalens Datakonsult AB.  All rights reserved.
00003 **
00004 ** This file is part of the KD Chart library.
00005 **
00006 ** Licensees holding valid commercial KD Chart licenses may use this file in
00007 ** accordance with the KD Chart Commercial License Agreement provided with
00008 ** the Software.
00009 **
00010 **
00011 ** This file may be distributed and/or modified under the terms of the
00012 ** GNU General Public License version 2 and version 3 as published by the
00013 ** Free Software Foundation and appearing in the file LICENSE.GPL.txt included.
00014 **
00015 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00016 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00017 **
00018 ** Contact info@kdab.com if any conditions of this licensing are not
00019 ** clear to you.
00020 **
00021 **********************************************************************/
00022 
00023 #ifndef REVERSEMAPPER_H
00024 #define REVERSEMAPPER_H
00025 
00026 #include <QModelIndex>
00027 #include <QHash>
00028 
00029 class QRectF;
00030 class QGraphicsScene;
00031 class QPolygonF;
00032 
00033 namespace KDChart {
00034 
00035     class AbstractDiagram;
00036     class ChartGraphicsItem;
00037 
00042     class ReverseMapper
00043     {
00044 
00045     public:
00046         ReverseMapper();
00047         explicit ReverseMapper( AbstractDiagram* diagram );
00048 
00049         ~ReverseMapper();
00050 
00051         void setDiagram( AbstractDiagram* diagram );
00052 
00053         void clear();
00054 
00055         QModelIndexList indexesAt( const QPointF& point ) const;
00056         QModelIndexList indexesIn( const QRect& rect ) const;
00057 
00058         QPolygonF polygon( int row, int column ) const;
00059         QRectF boundingRect( int row, int column ) const;
00060 
00061         void addItem( ChartGraphicsItem* item );
00062 
00063         // convenience methods:
00064         void addPolygon( int row, int column, const QPolygonF& polygon );
00065         void addRect( int row, int column, const QRectF& rect );
00066         void addCircle( int row, int column, const QPointF& location, const QSizeF& diameter );
00067         void addLine( int row, int column, const QPointF& from, const QPointF& to );
00068 
00069     private:
00070         QGraphicsScene* m_scene;
00071         AbstractDiagram* m_diagram;
00072         QHash<QModelIndex, ChartGraphicsItem*> m_itemMap;
00073     };
00074 
00075 }
00076 
00077 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Defines

Klarälvdalens Datakonsult AB (KDAB)
Qt-related services and products
http://www.kdab.com/
http://www.kdab.com/products/kd-chart/