PieCurve.h
Go to the documentation of this file.
/***************************************************************************
File : PieCurve.h
Project : QtiPlot
--------------------------------------------------------------------
Copyright : (C) 2004 - 2010 by Ion Vasilief
Email (use @ for *) : ion_vasilief*yahoo.fr
Description : Pie plot class
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
***************************************************************************/
#include <qwt_plot.h>
#include "PlotCurve.h"
#include "LegendWidget.h"
class PieLabel;
class PieCurve: public DataCurve
{
public:
PieCurve(Table *t, const QString& name, int startRow, int endRow);
void clone(PieCurve* c);
double viewAngle(){return d_view_angle;};
void setViewAngle(double a){d_view_angle = a;};
double thickness(){return d_thickness;};
void setThickness(double t){d_thickness = t;};
double horizontalOffset(){return d_horizontal_offset;};
void setHorizontalOffset(double d){d_horizontal_offset = d;};
bool counterClockwise(){return d_counter_clockwise;};
void setCounterClockwise(bool on){d_counter_clockwise = on;};
double startAzimuth(){return d_start_azimuth;};
void setStartAzimuth(double angle){d_start_azimuth = angle;};
double labelsEdgeDistance(){return d_edge_dist;};
void setLabelsEdgeDistance(double d){d_edge_dist = d;};
bool labelsAutoFormat(){return d_auto_labeling;};
void setLabelsAutoFormat(bool on){d_auto_labeling = on;};
bool labelsValuesFormat(){return d_values;};
void setLabelValuesFormat(bool on){d_values = on;};
bool labelsPercentagesFormat(){return d_percentages;};
void setLabelPercentagesFormat(bool on){d_percentages = on;};
bool labelCategories(){return d_categories;};
void setLabelCategories(bool on){d_categories = on;};
bool fixedLabelsPosition(){return d_fixed_labels_pos;};
void setFixedLabelsPosition(bool on){d_fixed_labels_pos = on;};
QColor color(int i) const;
int radius(){return d_pie_ray;};
void setRadius(int size){d_pie_ray = size;};
Qt::BrushStyle pattern(){return QwtPlotCurve::brush().style();};
void setBrushStyle(const Qt::BrushStyle& style);
void setFirstColor(int index){d_first_color = index;};
int firstColor(){return d_first_color;};
void loadData();
void initLabels();
void clearLabels();
PieLabel* addLabel(PieLabel *l, bool clone = false);
QList <PieLabel *> labelsList(){return d_texts_list;};
private:
void draw(QPainter *painter,const QwtScaleMap &xMap,
const QwtScaleMap &yMap, int from, int to) const;
void drawSlices(QPainter *painter, const QwtScaleMap &xMap,
const QwtScaleMap &yMap, int from, int to) const;
void drawDisk(QPainter *painter, const QwtScaleMap &xMap, const QwtScaleMap &yMap) const;
int d_pie_ray;
int d_first_color;
double d_start_azimuth;
double d_view_angle;
double d_thickness;
double d_horizontal_offset;
double d_edge_dist;
bool d_counter_clockwise;
bool d_auto_labeling;
bool d_values;
bool d_percentages;
bool d_categories;
bool d_fixed_labels_pos;
QList <PieLabel *> d_texts_list;
QVarLengthArray<int> d_table_rows;
};
class PieLabel: public LegendWidget
{
Q_OBJECT
public:
PieLabel(Graph *, PieCurve *pie = 0);
QString customText();
void setCustomText(const QString& s){d_custom_text = s;};
void setPieCurve(PieCurve *pie){d_pie_curve = pie;};
QString saveToString();
static void restore(Graph *g, const QStringList& lst);
private:
void closeEvent(QCloseEvent* e);
PieCurve *d_pie_curve;
QString d_custom_text;
};
PieCurve::PieCurve
PieCurve(Table *t, const QString &name, int startRow, int endRow)
Definition: PieCurve.cpp:44
PieCurve::d_horizontal_offset
double d_horizontal_offset
Definition: PieCurve.h:106
PieCurve::setLabelPercentagesFormat
void setLabelPercentagesFormat(bool on)
Definition: PieCurve.h:67
PieCurve::labelsPercentagesFormat
bool labelsPercentagesFormat()
Definition: PieCurve.h:66
PieCurve::setHorizontalOffset
void setHorizontalOffset(double d)
Definition: PieCurve.h:49
PieCurve::firstColor
int firstColor()
Definition: PieCurve.h:84
PieCurve::d_fixed_labels_pos
bool d_fixed_labels_pos
Definition: PieCurve.h:113
PieCurve::horizontalOffset
double horizontalOffset()
Definition: PieCurve.h:48
PieCurve::d_thickness
double d_thickness
Definition: PieCurve.h:105
PieCurve::setBrushStyle
void setBrushStyle(const Qt::BrushStyle &style)
Definition: PieCurve.cpp:384
PieCurve::d_counter_clockwise
bool d_counter_clockwise
Definition: PieCurve.h:108
Graph
A 2D-plotting widget.
Definition: Graph.h:123
PieCurve::setLabelsEdgeDistance
void setLabelsEdgeDistance(double d)
Definition: PieCurve.h:58
PieCurve::d_edge_dist
double d_edge_dist
Definition: PieCurve.h:107
PieCurve::radius
int radius()
Definition: PieCurve.h:77
PieCurve::setViewAngle
void setViewAngle(double a)
Definition: PieCurve.h:43
PieCurve::pattern
Qt::BrushStyle pattern()
Definition: PieCurve.h:80
PieLabel::restore
static void restore(Graph *g, const QStringList &lst)
Definition: PieCurve.cpp:536
PieCurve::addLabel
PieLabel * addLabel(PieLabel *l, bool clone=false)
Definition: PieCurve.cpp:431
PieCurve::setLabelsAutoFormat
void setLabelsAutoFormat(bool on)
Definition: PieCurve.h:61
PieCurve::counterClockwise
bool counterClockwise()
Definition: PieCurve.h:51
DataCurve::endRow
int endRow()
Definition: PlotCurve.h:145
PlotCurve.h
PieCurve::labelsAutoFormat
bool labelsAutoFormat()
Definition: PieCurve.h:60
PieCurve::d_view_angle
double d_view_angle
Definition: PieCurve.h:104
PieCurve::clearLabels
void clearLabels()
Definition: PieCurve.cpp:476
PieLabel::setPieCurve
void setPieCurve(PieCurve *pie)
Definition: PieCurve.h:129
PieCurve::drawSlices
void drawSlices(QPainter *painter, const QwtScaleMap &xMap, const QwtScaleMap &yMap, int from, int to) const
Definition: PieCurve.cpp:197
PieCurve
Pie plot class.
Definition: PieCurve.h:36
PieCurve::d_auto_labeling
bool d_auto_labeling
Definition: PieCurve.h:109
PieCurve::labelCategories
bool labelCategories()
Definition: PieCurve.h:69
PieCurve::draw
void draw(QPainter *painter, const QwtScaleMap &xMap, const QwtScaleMap &yMap, int from, int to) const
Definition: PieCurve.cpp:97
PieLabel::closeEvent
void closeEvent(QCloseEvent *e)
Definition: PieCurve.cpp:500
LegendWidget.h
PieCurve::viewAngle
double viewAngle()
Definition: PieCurve.h:42
PieCurve::color
QColor color(int i) const
Definition: PieCurve.cpp:379
PieLabel::customText
QString customText()
Definition: PieCurve.cpp:492
LegendWidget
Definition: LegendWidget.h:42
PieCurve::setLabelValuesFormat
void setLabelValuesFormat(bool on)
Definition: PieCurve.h:64
PieCurve::setFirstColor
void setFirstColor(int index)
Definition: PieCurve.h:83
PieCurve::d_values
bool d_values
Definition: PieCurve.h:110
PieLabel::d_custom_text
QString d_custom_text
Definition: PieCurve.h:138
DataCurve
Definition: PlotCurve.h:96
PieCurve::setFixedLabelsPosition
void setFixedLabelsPosition(bool on)
Definition: PieCurve.h:73
PieCurve::setCounterClockwise
void setCounterClockwise(bool on)
Definition: PieCurve.h:52
PieCurve::d_percentages
bool d_percentages
Definition: PieCurve.h:111
PieCurve::labelsList
QList< PieLabel * > labelsList()
Definition: PieCurve.h:92
PieLabel
Definition: PieCurve.h:119
PieLabel::d_pie_curve
PieCurve * d_pie_curve
Definition: PieCurve.h:137
DataCurve::startRow
int startRow()
Definition: PlotCurve.h:144
PieCurve::setRadius
void setRadius(int size)
Definition: PieCurve.h:78
PieLabel::saveToString
QString saveToString()
Definition: PieCurve.cpp:507
PieCurve::d_texts_list
QList< PieLabel * > d_texts_list
Definition: PieCurve.h:114
PieCurve::labelsValuesFormat
bool labelsValuesFormat()
Definition: PieCurve.h:63
PieCurve::setLabelCategories
void setLabelCategories(bool on)
Definition: PieCurve.h:70
PieCurve::setThickness
void setThickness(double t)
Definition: PieCurve.h:46
PieCurve::drawDisk
void drawDisk(QPainter *painter, const QwtScaleMap &xMap, const QwtScaleMap &yMap) const
Definition: PieCurve.cpp:112
PieCurve::initLabels
void initLabels()
Definition: PieCurve.cpp:454
PieCurve::d_table_rows
QVarLengthArray< int > d_table_rows
Stores table row indices to be displayed in PieLabels if d_categories is true.
Definition: PieCurve.h:116
PieCurve::startAzimuth
double startAzimuth()
Definition: PieCurve.h:54
Table
MDI window providing a spreadsheet table with column logic.
Definition: Table.h:57
PieCurve::d_first_color
int d_first_color
Definition: PieCurve.h:102
PieLabel::setCustomText
void setCustomText(const QString &s)
Definition: PieCurve.h:127
PieCurve::d_categories
bool d_categories
Definition: PieCurve.h:112
PieCurve::d_pie_ray
int d_pie_ray
Definition: PieCurve.h:101
PieCurve::loadData
void loadData()
Definition: PieCurve.cpp:394
PieCurve::fixedLabelsPosition
bool fixedLabelsPosition()
Definition: PieCurve.h:72
PieLabel::PieLabel
PieLabel(Graph *, PieCurve *pie=0)
Definition: PieCurve.cpp:483
PieCurve::d_start_azimuth
double d_start_azimuth
Definition: PieCurve.h:103
PieCurve::clone
void clone(PieCurve *c)
Definition: PieCurve.cpp:68
PieCurve::setStartAzimuth
void setStartAzimuth(double angle)
Definition: PieCurve.h:55
PieCurve::labelsEdgeDistance
double labelsEdgeDistance()
Definition: PieCurve.h:57
PieCurve::thickness
double thickness()
Definition: PieCurve.h:45