00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef EVODATAVIEWER_H
00025 #define EVODATAVIEWER_H
00026
00027 #include "experimentsconfig.h"
00028 #include <QWidget>
00029 #include <QPixmap>
00030 #include <QTimer>
00031 #include <QListWidget>
00032 #include <QGridLayout>
00033 #include <QPushButton>
00034 #include <QFile>
00035 #include <QTextStream>
00036
00037 namespace farsa {
00038
00039
00040
00041 class FARSA_EXPERIMENTS_API DataChunk
00042 {
00043
00044
00045
00046
00047 private:
00048 QColor color;
00049 QString label;
00050 int size;
00051 double dpratio;
00052 bool visible;
00053 int index;
00054 double min, max;
00055 double maxValue;
00056
00057
00058 int style;
00059 double* data;
00060 double zeroValue;
00061 void checkMaxValue(double val);
00062
00063
00064 public:
00065 DataChunk(const QString& label, const QColor& color, int size, bool visible);
00066 ~DataChunk();
00067 void setColor(QColor color);
00068 void setData(double value);
00069 void setDataRaw(double value);
00070 void setDataRaw(int ind, double value);
00071
00072
00073 void setRange(double min, double max);
00074 void setLabel(const QString& label);
00075 void setStyle(int style);
00076 void setVisible(bool vis);
00077 bool isVisible();
00078 const QString& getLabel();
00079 QColor& getColor();
00080
00081 double getValueToDraw();
00082 double getValue(int ind);
00083 int getIndex();
00084 double linearMap( double x, double rmin, double rmax,
00085 double outMin = 0, double outMax = 1 );
00086
00087
00088 double getRangeMin();
00089 double getRangeMax();
00090 double getMaxValue();
00091 double getZeroValue();
00092 void setDPRatio(double val);
00093 double getDPRatio();
00094
00095 bool loadRawData(const QString& filename, int column);
00096
00097
00098
00099
00100 };
00101
00102 class FARSA_EXPERIMENTS_API EvoListViewer : public QWidget
00103 {
00104 Q_OBJECT
00105 public:
00106 EvoListViewer(DataChunk** dataChunks, int n, bool *nviewChange , QWidget *parent = 0);
00107 ~EvoListViewer();
00108 private slots:
00109 void okSelected();
00110 public slots:
00111 void restoreSelected();
00112 void allOnOrAllOff();
00113
00114
00115 private:
00116 int nchunks;
00117 DataChunk** dataChunks;
00118 QListWidget *listwidget;
00119 QGridLayout *layout;
00120 QPushButton* deselectAll;
00121 bool *nvchange;
00122
00123
00124
00125
00126
00127 };
00128
00129
00130
00131
00132 class FARSA_EXPERIMENTS_API EvoDataViewer : public QWidget
00133 {
00134 Q_OBJECT
00135 public:
00136
00137 EvoDataViewer(int nchunks, int chunksize, int style=0, QWidget* parent=0, Qt::WindowFlags flags=0);
00138 ~EvoDataViewer();
00139
00140 void setChunkLabel(int ch, const QString& label);
00141 void setChunkValue(int ch, double value);
00142 bool setChunkValue(const QString& name, double value);
00143 void setChunkColor(int ch, QColor color);
00144 void setCurrentStep(int step);
00145 void setStyle(int style);
00146 void setChunkRange(int ch, double mn, double mx);
00147 void setChunkProperties(int ch, double rangeMin, double rangeMax, const QString& label, QColor color, bool visible);
00148 int visibleChunks();
00149 void listVisibleChunks();
00150 void reset();
00151 private slots:
00152 void pickUnvisible();
00153 protected:
00154 void paintEvent(QPaintEvent* evt);
00155 void resizeEvent(QResizeEvent* evt);
00156 void mousePressEvent(QMouseEvent* evt);
00157 private:
00158 void updateGraphic(int ch);
00159 QPixmap* qpixmap;
00160 int dheight;
00161 int dwidth;
00162 int nchunks;
00163 int nvchunks;
00164 int chunksize;
00165 DataChunk** dataChunks;
00166 DataChunk* stepChunk;
00167 int vertical_step;
00168 int label_width;
00169 int panning_width;
00170 int style;
00171 double pickValue;
00172 int pickStep;
00173 bool pickValueVisible;
00174 int pickX, pickY;
00175 QTimer *qtimer;
00176 EvoListViewer *elw;
00177
00178 int *vchunks;
00179 public:
00180 bool nviewChange;
00181 private:
00182 void evoDataPaint();
00183
00184
00185 };
00186
00187
00188 class FARSA_EXPERIMENTS_API FitViewer : public QWidget
00189 {
00190
00191 private:
00192 DataChunk** dataChunks;
00193 int nchunks;
00194 int chunksize;
00195
00196 double fitVal[4000][3];
00197 int currentGen;
00198 int padding;
00199 double zerox, zeroy;
00200 double vmin;
00201 double vmax;
00202 double wyaxes;
00203 double xstep;
00204 int* sortedIndex;
00205 QString gtitle;
00206 QString xlabel;
00207 QString ylabel;
00208
00209 public:
00210 void setValues(int gen, double min, double average, double max);
00211 FitViewer( QWidget* parent=0, Qt::WindowFlags flags=0 );
00212 FitViewer(int nchunks, int chunkSize, QWidget* parent=0, Qt::WindowFlags flags=0);
00213 ~FitViewer();
00214 private:
00215 double getYnormValue(double val);
00216 int checkGraphRange(double val);
00217
00218 protected:
00219 void paintEvent(QPaintEvent* evt);
00220 public:
00221 void setChunkLabel(int ch, const QString &label);
00222 void setChunkProperties(int ch, const QString &label, QColor color, bool visible);
00223 void setChunkValue(int ch,int ind, double value);
00224 bool setChunkValue(const QString& name,int ind, double value);
00225 void diplayUntilStep(int st);
00226 void setLabels(const QString &title, const QString &xlabel, const QString &ylabel);
00227 bool loadRawData(int nchunk, const QString &filename, int column);
00228 void checkChunkRange(int chunk);
00229 void reset();
00230 int getCurrentGeneration();
00231 void sortchunks();
00232
00233
00234 };
00235
00236 }
00237
00238 #endif