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