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());
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 bool sideLinesEnabled(){return d_side_lines;};
00063 void enableSideLines(bool on){d_side_lines = on;};
00064
00065 QString saveCurveLayout();
00066 void restoreCurveLayout(const QStringList& lst);
00067
00069 void setSkipSymbolsCount(int count);
00071 int skipSymbolsCount(){return d_skip_symbols;};
00072
00073 protected:
00074 virtual void drawCurve(QPainter *p, int style, const QwtScaleMap &xMap, const QwtScaleMap &yMap, int from, int to) const;
00075 void drawSideLines(QPainter *p, const QwtScaleMap &xMap, const QwtScaleMap &yMap, int from, int to) const;
00076
00077 virtual void drawSymbols(QPainter *p, const QwtSymbol &,
00078 const QwtScaleMap &xMap, const QwtScaleMap &yMap, int from, int to) const;
00079
00080 void drawSticks(QPainter *p,
00081 const QwtScaleMap &xMap, const QwtScaleMap &yMap, int from, int to) const;
00082
00083 QwtDoubleRect boundingRect() const;
00084
00085
00086 int d_type;
00087
00088 int d_plot_style;
00089 double d_x_offset, d_y_offset;
00090 bool d_side_lines;
00091 int d_skip_symbols;
00092 };
00093
00094 class DataCurve: public PlotCurve
00095 {
00096 public:
00097 DataCurve(Table *t, const QString& xColName, const QString& name, int startRow = 0, int endRow = -1);
00098 void clone(DataCurve* c);
00099
00100 virtual QString saveToString();
00101 void restoreLabels(const QStringList& lst);
00102
00103 QString xColumnName(){return d_x_column;};
00104 void setXColumnName(const QString& name){d_x_column = name;};
00105
00106 bool hasLabels(){return !d_labels_list.isEmpty();};
00107 QString labelsColumnName(){return d_labels_column;};
00108 void setLabelsColumnName(const QString& name);
00109
00110 int labelsAlignment(){return d_labels_align;};
00111 void setLabelsAlignment(int flags);
00112
00113 int labelsXOffset(){return d_labels_x_offset;};
00114 int labelsYOffset(){return d_labels_y_offset;};
00115 void setLabelsOffset(int x, int y);
00116
00117 double labelsRotation(){return d_labels_angle;};
00118 void setLabelsRotation(double angle);
00119
00120 QFont labelsFont(){return d_labels_font;};
00121 void setLabelsFont(const QFont& font);
00122
00123 QColor labelsColor(){return d_labels_color;};
00124 void setLabelsColor(const QColor& c);
00125
00126 bool labelsWhiteOut(){return d_white_out_labels;};
00127 void setLabelsWhiteOut(bool whiteOut = true);
00128
00129 Table* table(){return d_table;};
00130
00131 int startRow(){return d_start_row;};
00132 int endRow(){return d_end_row;};
00133 void setRowRange(int startRow, int endRow);
00134
00135 bool isFullRange();
00136 void setFullRange();
00137
00138 virtual bool updateData(Table *t, const QString& colName);
00139 virtual void loadData();
00140 void enableSpeedMode();
00141
00143 int tableRow(int point);
00144
00145 void remove();
00146
00159 virtual QString plotAssociation();
00160 virtual void updateColumnNames(const QString& oldName, const QString& newName, bool updateTableName);
00161
00163 QList<DataCurve *> errorBarsList(){return d_error_bars;};
00165 void addErrorBars(DataCurve *c){if (c) d_error_bars << c;};
00167 void removeErrorBars(DataCurve *c);
00169 void clearErrorBars();
00171 void clearLabels();
00172
00173 void setVisible(bool on);
00174
00175 bool selectedLabels(const QPoint& pos);
00176 bool hasSelectedLabels();
00177 void setLabelsSelected(bool on = true);
00178
00179 void moveLabels(const QPoint& pos);
00180 void updateLabelsPosition();
00181
00182 protected:
00183 bool validCurveType();
00184 void loadLabels();
00185
00187 QList <DataCurve *> d_error_bars;
00189 Table *d_table;
00191
00192
00193
00194 QString d_x_column;
00195
00196 int d_start_row;
00197 int d_end_row;
00198
00200 QString d_labels_column;
00201
00203 QList <PlotMarker *> d_labels_list;
00205 double d_click_pos_x, d_click_pos_y;
00206
00207 QColor d_labels_color;
00208 QFont d_labels_font;
00209 double d_labels_angle;
00210 bool d_white_out_labels;
00211 int d_labels_align, d_labels_x_offset, d_labels_y_offset;
00213 PlotMarker *d_selected_label;
00214 };
00215
00216 class PlotMarker: public QwtPlotMarker
00217 {
00218 public:
00219 PlotMarker(int index, double angle);
00220
00221 int index(){return d_index;};
00222 void setIndex(int i){d_index = i;};
00223
00224 double angle(){return d_angle;};
00225 void setAngle(double a){d_angle = a;};
00226
00227 double xLabelOffset(){return d_label_x_offset;};
00228 double yLabelOffset(){return d_label_y_offset;};
00229 void setLabelOffset(double xOffset, double yOffset){d_label_x_offset = xOffset; d_label_y_offset = yOffset;};
00230
00231 protected:
00233 void draw(QPainter *p, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRect &r) const;
00234
00235 int d_index;
00236 double d_angle;
00238 double d_label_x_offset;
00240 double d_label_y_offset;
00241 };
00242 #endif