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_plot_style(0), d_x_offset(0.0), d_y_offset(0.0){};
00044
00046 int type(){return d_type;};
00047 void setType(int t){d_type = t;};
00048
00052 int plotStyle(){return d_plot_style;};
00053 void setPlotStyle(int s){d_plot_style = s;};
00054
00055 double xOffset(){return d_x_offset;};
00056 void setXOffset(double dx){d_x_offset = dx;};
00057
00058 double yOffset(){return d_y_offset;};
00059 void setYOffset(double dy){d_y_offset = dy;};
00060
00061 QString saveCurveLayout();
00062 void restoreCurveLayout(const QStringList& lst);
00063
00064 protected:
00065
00066 int d_type;
00067
00068 int d_plot_style;
00069 double d_x_offset, d_y_offset;
00070 };
00071
00072 class DataCurve: public PlotCurve
00073 {
00074 public:
00075 DataCurve(Table *t, const QString& xColName, const QString& name, int startRow = 0, int endRow = -1);
00076 void clone(DataCurve* c);
00077
00078 QString saveToString();
00079
00080 QString xColumnName(){return d_x_column;};
00081 void setXColumnName(const QString& name){d_x_column = name;};
00082
00083 bool hasLabels(){return !d_labels_list.isEmpty();};
00084 QString labelsColumnName(){return d_labels_column;};
00085 void setLabelsColumnName(const QString& name);
00086
00087 int labelsAlignment(){return d_labels_align;};
00088 void setLabelsAlignment(int flags);
00089
00090 int labelsXOffset(){return d_labels_x_offset;};
00091 int labelsYOffset(){return d_labels_y_offset;};
00092 void setLabelsOffset(int x, int y);
00093
00094 double labelsRotation(){return d_labels_angle;};
00095 void setLabelsRotation(double angle);
00096
00097 QFont labelsFont(){return d_labels_font;};
00098 void setLabelsFont(const QFont& font);
00099
00100 QColor labelsColor(){return d_labels_color;};
00101 void setLabelsColor(const QColor& c);
00102
00103 bool labelsWhiteOut(){return d_white_out_labels;};
00104 void setLabelsWhiteOut(bool whiteOut = true);
00105
00106 Table* table(){return d_table;};
00107
00108 int startRow(){return d_start_row;};
00109 int endRow(){return d_end_row;};
00110 void setRowRange(int startRow, int endRow);
00111
00112 bool isFullRange();
00113 void setFullRange();
00114
00115 virtual bool updateData(Table *t, const QString& colName);
00116 virtual void loadData();
00117
00119 int tableRow(int point);
00120
00121 void remove();
00122
00135 virtual QString plotAssociation();
00136 virtual void updateColumnNames(const QString& oldName, const QString& newName, bool updateTableName);
00137
00139 QList<DataCurve *> errorBarsList(){return d_error_bars;};
00141 void addErrorBars(DataCurve *c){if (c) d_error_bars << c;};
00143 void removeErrorBars(DataCurve *c);
00145 void clearErrorBars();
00147 void clearLabels();
00148
00149 void setVisible(bool on);
00150
00151 bool selectedLabels(const QPoint& pos);
00152 bool hasSelectedLabels();
00153 void setLabelsSelected(bool on = true);
00154
00155 void moveLabels(const QPoint& pos);
00156 void updateLabelsPosition();
00157
00158 protected:
00159 bool validCurveType();
00160 void loadLabels();
00161
00163 QList <DataCurve *> d_error_bars;
00165 Table *d_table;
00167
00168
00169
00170 QString d_x_column;
00171
00172 int d_start_row;
00173 int d_end_row;
00174
00176 QString d_labels_column;
00177
00179 QList <PlotMarker *> d_labels_list;
00181 double d_click_pos_x, d_click_pos_y;
00182
00183 QColor d_labels_color;
00184 QFont d_labels_font;
00185 double d_labels_angle;
00186 bool d_white_out_labels;
00187 int d_labels_align, d_labels_x_offset, d_labels_y_offset;
00189 PlotMarker *d_selected_label;
00190 };
00191
00192 class PlotMarker: public QwtPlotMarker
00193 {
00194 public:
00195 PlotMarker(int index, double angle);
00196
00197 int index(){return d_index;};
00198 void setIndex(int i){d_index = i;};
00199
00200 double angle(){return d_angle;};
00201 void setAngle(double a){d_angle = a;};
00202
00203
00204
00205 protected:
00207 void draw(QPainter *p, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRect &r) const;
00208
00209 int d_index;
00210 double d_angle;
00211 };
00212 #endif