KD Chart 2
[rev.2.5]
|
00001 /**************************************************************************** 00002 ** Copyright (C) 2001-2012 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 __KDCHARTWIDGET_H__ 00024 #define __KDCHARTWIDGET_H__ 00025 00026 #include "KDChartGlobal.h" 00027 00028 #include <QWidget> 00029 00030 #include "KDChartEnums.h" 00031 #include "KDChartHeaderFooter.h" 00032 00033 QT_BEGIN_NAMESPACE 00034 template <typename T> class QVector; 00035 template <typename T1, typename T2> struct QPair; 00036 QT_END_NAMESPACE 00037 00038 namespace KDChart { 00039 00040 // some forward declarations 00041 class AbstractDiagram; 00042 class Chart; 00043 class AbstractCoordinatePlane; 00044 class TableModel; 00045 class BarDiagram; 00046 class LineDiagram; 00047 class Plotter; 00048 class PieDiagram; 00049 class RingDiagram; 00050 class PolarDiagram; 00051 class Legend; 00052 class Position; 00053 00060 class KDCHART_EXPORT Widget : public QWidget 00061 { 00062 Q_OBJECT 00063 00064 Q_DISABLE_COPY( Widget ) 00065 KDCHART_DECLARE_PRIVATE_BASE_POLYMORPHIC_QWIDGET( Widget ) 00066 00067 public: 00075 explicit Widget( QWidget* parent = 0 ); 00076 00078 ~Widget(); 00080 void setDataset( int column, const QVector< qreal > & data, const QString& title = QString() ); 00083 void setDataset( int column, const QVector< QPair< qreal, qreal > > & data, const QString& title = QString() ); 00085 void setDataCell( int row, int column, qreal data ); 00087 void setDataCell( int row, int column, QPair< qreal, qreal > data ); 00089 void resetData(); 00090 00091 public Q_SLOTS: 00093 void setGlobalLeading( int left, int top, int right, int bottom ); 00095 void setGlobalLeadingLeft( int leading ); 00097 void setGlobalLeadingTop( int leading ); 00099 void setGlobalLeadingRight( int leading ); 00101 void setGlobalLeadingBottom( int leading ); 00102 00103 public: 00105 int globalLeadingLeft() const; 00107 int globalLeadingTop() const; 00109 int globalLeadingRight() const; 00111 int globalLeadingBottom() const; 00112 00114 HeaderFooter* firstHeaderFooter(); 00116 QList<HeaderFooter*> allHeadersFooters(); 00117 00119 void addHeaderFooter( const QString& text, 00120 HeaderFooter::HeaderFooterType type, 00121 Position position ); 00122 00127 void addHeaderFooter( HeaderFooter* header ); 00128 00146 void replaceHeaderFooter( HeaderFooter* header, 00147 HeaderFooter* oldHeader = 0 ); 00148 00156 void takeHeaderFooter( HeaderFooter* header ); 00157 00159 Legend* legend(); 00161 QList<Legend*> allLegends(); 00162 00164 void addLegend( Position position ); 00166 void addLegend (Legend* legend ); 00167 00168 void replaceLegend( Legend* legend, Legend* oldLegend = 0 ); 00169 void takeLegend( Legend* legend ); 00170 00171 00173 AbstractDiagram* diagram(); 00174 00178 BarDiagram* barDiagram(); 00182 LineDiagram* lineDiagram(); 00190 Plotter* plotter(); 00194 PieDiagram* pieDiagram(); 00198 RingDiagram* ringDiagram(); 00202 PolarDiagram* polarDiagram(); 00203 00205 AbstractCoordinatePlane* coordinatePlane(); 00206 00207 00208 enum ChartType { NoType, Bar, Line, Plot, Pie, Ring, Polar }; 00209 00211 ChartType type() const; 00212 00214 enum SubType { Normal, Stacked, Percent, Rows }; 00215 00217 SubType subType() const; 00218 00219 public Q_SLOTS: 00221 void setType( ChartType chartType, SubType subType=Normal ); 00232 void setSubType( SubType subType ); 00233 00234 private: 00236 void justifyModelSize( int rows, int columns ); 00238 bool checkDatasetWidth( int width ); 00239 }; 00240 } 00241 00242 #endif // KDChartWidget_H