00001
00002
00008 #ifndef __CPYPLOT_HPP__
00009 #define __CPYPLOT_HPP__
00010
00011 #include <Python.h>
00012
00013 #include <string>
00014 using std::string;
00015
00016 #include <QWidget>
00017 #include <QObject>
00018
00019 #include "Matrix.h"
00020 #include "Cvals.h"
00021
00022 class QMdiSubWindow;
00023
00024 struct limit_data
00025 {
00026 Cvals * limitType;
00027 double limitMin;
00028 double limitMax;
00029 };
00030
00031
00032
00043 class plotData
00044 {
00045 public:
00046 plotData();
00047
00048 int plotType;
00049 double xmin;
00050 double xmax;
00051 double ymin;
00052 double ymax;
00053 std::string xname;
00054 std::string yname;
00055 std::string binname;
00056 std::string limitName;
00057 int nx;
00058 int ny;
00059 int type;
00060 int gridmethod;
00061 int pointSize;
00062 double limMin;
00063 double limMax;
00064 int run;
00065 int file;
00066 };
00067
00068
00080 class CPyPlot : public QWidget
00081 {
00082 Q_OBJECT
00083
00084 public:
00085 CPyPlot(QWidget * parent, string xname = "x", string yname = "y",
00086 int type = 0);
00087 virtual ~CPyPlot();
00088
00089 enum plotTypes
00090 {
00091 PLOT_SCATTER,
00092 PLOT_GRID,
00093 PLOT_RENDER,
00094 PLOT_PARTDATA
00095 };
00096
00097 static void createNewPlot(const plotData & pd);
00098
00099 virtual void calculate(Matrix<float> * thedata = 0);
00100 void plot();
00101
00102 void addLimitingValue(Cvals * limitType, double limMin, double limMax);
00103
00104 void printArguments();
00105
00106 void setRun(int run);
00107 void setFile(int file);
00108 int getRun() const;
00109 int getFile() const;
00110 int getType() const;
00111
00112 virtual string getWindowTitle();
00113 int getNumPlots() const;
00114 string getXname() const;
00115 string getYname() const;
00116
00117 void setXLimits(const double & xmin, const double & xmax);
00118 void setYLimits(const double & ymin, const double & ymax);
00119 void setLimits(const double & xmin, const double & xmax,
00120 const double & ymin, const double & ynax);
00121
00122 double getXmin() const;
00123 double getXmax() const;
00124 double getYmin() const;
00125 double getYmax() const;
00126 void xLimits(double & xmin, double & xmax);
00127 void yLimits(double & ymin, double & ymax);
00128 void limits(double & xmin, double & xmax, double & ymin, double & ymax);
00129 void setNParticles(const int & npart);
00130 int getNParticles() const;
00131
00132 string getPlotType() const;
00133 static CPyPlot * getPlotPtr(const int & num);
00134
00135 void emitsignal();
00136
00137 signals:
00138 void testsignal();
00139
00140 protected:
00141 virtual bool do_plotting();
00142
00143 static void importArray();
00144
00145 void addArgument(const string & name, const int & value);
00146 void addArgument(const string & name, const double & value);
00147 void addArgument(const string & name, const string & value);
00148 void addArgument(const string & name, PyObject * ref);
00149
00150 PyObject * getDict() const;
00151 void setPlotType(string type);
00152
00153 void resizeEvent(QResizeEvent * revent);
00154
00155 int type_;
00157 bool calculated_;
00158
00159 string plotType_;
00160 QWidget * pyWidget_;
00161 QMdiSubWindow * mdiWin_;
00163 private:
00164 static int numPlots_;
00165 static vector<CPyPlot *> plots_;
00166 static bool _arraysImported;
00167
00168 vector<struct limit_data> limitData;
00170 int run_;
00171 int file_;
00173 int number_;
00174 int _nparticles;
00176 string xname_;
00177 string yname_;
00178
00179 double xmin_;
00180 double xmax_;
00181 double ymin_;
00182 double ymax_;
00183
00184 PyObject * argDict_;
00185 };
00186
00187
00188
00189
00190
00191
00192
00199 class CPyColorPlot : public CPyPlot
00200 {
00201 public:
00202 CPyColorPlot(string xname = "x", string yname = "y",
00203 string binname = "mass",
00204 int nx = 10, int ny = 10, int type = 0,
00205 int igridmethod = 1,
00206 QWidget * myparent = 0);
00207 ~CPyColorPlot();
00208
00209 void calculate(Matrix<float> * thedata = 0);
00210 bool do_plotting();
00211
00212 Matrix<float> * getDataPtr() const;
00213 PyObject * getPyDataPtr() const;
00214
00215 string getBinname() const;
00216 int getNx() const;
00217 int getNy() const;
00218
00219
00220
00221 void setNxNy(int nx, int ny);
00222
00223
00224 private:
00225 Matrix<float> * data_;
00226 int dims_[2];
00228 PyObject * pyData_;
00230 string binname_;
00231
00232 int nx_;
00233 int ny_;
00234
00235 int igridmethod_;
00236
00237
00238 };
00239
00240
00241
00242
00243
00244
00245
00252 class CPyScatterPlot : public CPyPlot
00253 {
00254 public:
00255 CPyScatterPlot(string xname = "x", string yname = "y", int type = 0,
00256 QWidget * myparent = 0);
00257 ~CPyScatterPlot();
00258
00259 void calculate(Matrix<float> * thedata = 0);
00260
00261 bool do_plotting();
00262
00263 double getLimMin() const;
00264 double getLimMax() const;
00265
00266 string getLimitName() const;
00267 int getNumPoints() const;
00268
00269 void setLimitName(string name);
00270 void setLimitRange(double low, double high);
00271
00272 PyObject * getXDataPtr() const;
00273 PyObject * getYDataPtr() const;
00274
00275 private:
00276 int type_;
00278 int numPoints_;
00279
00280 int pointSize_;
00282 string limName_;
00283 double limMin_;
00284 double limMax_;
00285
00286 Matrix<float> * data_;
00287 PyObject * pyXData_;
00288 PyObject * pyYData_;
00289 };
00290
00291 #endif // __CPYPLOT_HPP__