00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef PLOTCURVE_H
00030 #define PLOTCURVE_H
00031
00032 #include <qwt_plot_curve.h>
00033 #include <qwt_plot_marker.h>
00034 #include "Table.h"
00035
00036 class PlotMarker;
00037
00039 class PlotCurve: public QwtPlotCurve
00040 {
00041
00042 public:
00043 PlotCurve(const QString& name = QString()): QwtPlotCurve(name), d_type(0), d_x_offset(0.0), d_y_offset(0.0){};
00044
00045 int type(){return d_type;};
00046 void setType(int t){d_type = t;};
00047
00048 double xOffset(){return d_x_offset;};
00049 void setXOffset(double dx){d_x_offset = dx;};
00050
00051 double yOffset(){return d_y_offset;};
00052 void setYOffset(double dy){d_y_offset = dy;};
00053
00054 QwtDoubleRect boundingRect() const;
00055
00056 protected:
00057 int d_type;
00058 double d_x_offset, d_y_offset;
00059 };
00060
00061 class DataCurve: public PlotCurve
00062 {
00063 public:
00064 DataCurve(Table *t, const QString& xColName, const QString& name, int startRow = 0, int endRow = -1);
00065 void clone(DataCurve* c);
00066
00067 QString saveToString();
00068
00069 QString xColumnName(){return d_x_column;};
00070 void setXColumnName(const QString& name){d_x_column = name;};
00071
00072 bool hasLabels(){return !d_labels_list.isEmpty();};
00073 QString labelsColumnName(){return d_labels_column;};
00074 void setLabelsColumnName(const QString& name);
00075
00076 int labelsAlignment(){return d_labels_align;};
00077 void setLabelsAlignment(int flags);
00078
00079 int labelsXOffset(){return d_labels_x_offset;};
00080 int labelsYOffset(){return d_labels_y_offset;};
00081 void setLabelsOffset(int x, int y);
00082
00083 double labelsRotation(){return d_labels_angle;};
00084 void setLabelsRotation(double angle);
00085
00086 QFont labelsFont(){return d_labels_font;};
00087 void setLabelsFont(const QFont& font);
00088
00089 QColor labelsColor(){return d_labels_color;};
00090 void setLabelsColor(const QColor& c);
00091
00092 bool labelsWhiteOut(){return d_white_out_labels;};
00093 void setLabelsWhiteOut(bool whiteOut = true);
00094
00095 Table* table(){return d_table;};
00096
00097 int startRow(){return d_start_row;};
00098 int endRow(){return d_end_row;};
00099 void setRowRange(int startRow, int endRow);
00100
00101 bool isFullRange();
00102 void setFullRange();
00103
00104 virtual bool updateData(Table *t, const QString& colName);
00105 virtual void loadData();
00106
00108 int tableRow(int point);
00109
00110 void remove();
00111
00124 virtual QString plotAssociation();
00125 virtual void updateColumnNames(const QString& oldName, const QString& newName, bool updateTableName);
00126
00128 QList<DataCurve *> errorBarsList(){return d_error_bars;};
00130 void addErrorBars(DataCurve *c){if (c) d_error_bars << c;};
00132 void removeErrorBars(DataCurve *c);
00134 void clearErrorBars();
00136 void clearLabels();
00137
00138 void setVisible(bool on);
00139
00140 bool selectedLabels(const QPoint& pos);
00141 bool hasSelectedLabels();
00142 void setLabelsSelected(bool on = true);
00143
00144 void moveLabels(const QPoint& pos);
00145 void updateLabelsPosition();
00146
00147 protected:
00148 bool validCurveType();
00149 void loadLabels();
00150
00152 QList <DataCurve *> d_error_bars;
00154 Table *d_table;
00156
00157
00158
00159 QString d_x_column;
00160
00161 int d_start_row;
00162 int d_end_row;
00163
00165 QString d_labels_column;
00166
00168 QList <PlotMarker *> d_labels_list;
00170 PlotMarker *d_selected_label;
00172 double d_click_pos_x, d_click_pos_y;
00173
00174 QColor d_labels_color;
00175 QFont d_labels_font;
00176 double d_labels_angle;
00177 bool d_white_out_labels;
00178 int d_labels_align, d_labels_x_offset, d_labels_y_offset;
00179 };
00180
00181 class PlotMarker: public QwtPlotMarker
00182 {
00183 public:
00184 PlotMarker(int index, double angle);
00185
00186 int index(){return d_index;};
00187 void setIndex(int i){d_index = i;};
00188
00189 double angle(){return d_angle;};
00190 void setAngle(double a){d_angle = a;};
00191
00192
00193
00194 protected:
00196 void draw(QPainter *p, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRect &r) const;
00197
00198 int d_index;
00199 double d_angle;
00200 };
00201 #endif