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 GRAPH3D_H
00030 #define GRAPH3D_H
00031
00032 #include <qwt3d_surfaceplot.h>
00033 #include <qwt3d_function.h>
00034 #include <qwt3d_parametricsurface.h>
00035
00036 #include <QTimer>
00037 #include <QVector>
00038 #include <QEvent>
00039
00040 #include "../Table.h"
00041 #include "../matrix/Matrix.h"
00042
00043 using namespace Qwt3D;
00044
00045 class UserFunction;
00046 class UserParametricSurface;
00047
00058 class Graph3D: public MdiSubWindow
00059 {
00060 Q_OBJECT
00061
00062 public:
00063 Graph3D (const QString& label, ApplicationWindow* parent, const char* name=0, Qt::WFlags f=0);
00064 ~Graph3D();
00065
00066 enum PlotType{Scatter = 0, Trajectory = 1, Bars = 2, Ribbon = 3};
00067 enum PointStyle{None = 0, Dots = 1, VerticalBars = 2, HairCross = 3, Cones = 4};
00068
00069 public slots:
00070 void copy(Graph3D* g);
00071 void initPlot();
00072 void initCoord();
00073 void addFunction(const QString& s, double xl, double xr, double yl,
00074 double yr, double zl, double zr, int columns, int rows);
00075 void addParametricSurface(const QString& xFormula, const QString& yFormula,
00076 const QString& zFormula, double ul, double ur, double vl, double vr,
00077 int columns, int rows, bool uPeriodic, bool vPeriodic);
00078 void insertNewData(Table* table, const QString& colName);
00079
00080 Matrix * matrix(){return d_matrix;};
00081 void addMatrixData(Matrix* m);
00082 void addMatrixData(Matrix* m,double xl,double xr,double yl,double yr,double zl,double zr);
00083 void updateMatrixData(Matrix* m);
00084
00085 void addData(Table* table,const QString& xColName,const QString& yColName);
00086 void addData(Table* table,const QString& xColName,const QString& yColName,
00087 double xl, double xr, double yl, double yr, double zl, double zr);
00088 void addData(Table* table, int xCol, int yCol, int zCol, int type = 0);
00089 void loadData(Table* table, int xCol, int yCol, int zCol,
00090 double xl=0.0, double xr=0.0, double yl=0.0, double yr=0.0, double zl=0.0, double zr=0.0);
00091
00092 void clearData();
00093 bool hasData(){return sp->hasData();};
00094
00095 void updateData(Table* table);
00096 void updateDataXY(Table* table, int xCol, int yCol);
00097
00098 void changeDataColumn(Table* table, const QString& colName, int type = 0);
00099
00101
00102 UserParametricSurface *parametricSurface(){return d_surface;};
00104
00106
00107 UserFunction* userFunction(){return d_func;};
00108 QString formula();
00110
00112
00113 bool eventFilter(QObject *object, QEvent *e);
00114 void resizeEvent (QResizeEvent *);
00115 void scaleFonts(double factor);
00116 void setIgnoreFonts(bool ok){ignoreFonts = ok;};
00118
00120
00121 void setFramed();
00122 void setBoxed();
00123 void setNoAxes();
00124 bool isOrthogonal(){return sp->ortho();};
00125 void setOrthogonal(bool on = true){sp->setOrtho(on);};
00126
00127 QStringList axesLabels(){return labels;};
00128 void setAxesLabels(const QStringList& lst);
00129 void resetAxesLabels();
00130
00131 void setXAxisLabel(const QString&);
00132 void setYAxisLabel(const QString&);
00133 void setZAxisLabel(const QString&);
00134
00135 QFont xAxisLabelFont();
00136 QFont yAxisLabelFont();
00137 QFont zAxisLabelFont();
00138
00139 void setXAxisLabelFont(const QFont& fnt);
00140 void setYAxisLabelFont(const QFont& fnt);
00141 void setZAxisLabelFont(const QFont& fnt);
00142
00143 void setXAxisLabelFont(const QStringList& lst);
00144 void setYAxisLabelFont(const QStringList& lst);
00145 void setZAxisLabelFont(const QStringList& lst);
00146
00147 QFont numbersFont();
00148 void setNumbersFont(const QFont& font);
00149 void setNumbersFont(const QStringList& lst);
00150
00151 double xStart();
00152 double xStop();
00153 double yStart();
00154 double yStop();
00155 double zStart();
00156 double zStop();
00157 QStringList scaleLimits();
00158 void updateScale(int axis, const QStringList& options);
00159 void setScales(double xl, double xr, double yl, double yr, double zl, double zr);
00160 void updateScales(double xl, double xr, double yl, double yr,
00161 double zl, double zr, int xcol, int ycol);
00162 void updateScalesFromMatrix(double xl,double xr,double yl,double yr,double zl,double zr);
00163
00164 QStringList scaleTicks();
00165 void setTicks(const QStringList& options);
00166
00167 void setXAxisTickLength(double majorLength, double minorLength);
00168 void setYAxisTickLength(double majorLength, double minorLength);
00169 void setZAxisTickLength(double majorLength, double minorLength);
00170
00171 void setAxisTickLength(int axis, double majorLength, double minorLength);
00172 void setLabelsDistance(int val);
00173 int labelsDistance(){return labelsDist;};
00174
00175 QStringList axisTickLengths();
00176 void setTickLengths(const QStringList& lst);
00178
00180
00181 void setPolygonStyle();
00182 void setHiddenLineStyle();
00183 void setWireframeStyle();
00184 void setFilledMeshStyle();
00185 void setDotStyle();
00186 void setBarStyle();
00187 void setFloorData();
00188 void setFloorIsolines();
00189 void setEmptyFloor();
00190
00191 void setMeshLineWidth(double lw);
00192 double meshLineWidth(){return sp->meshLineWidth();};
00194
00196
00197 int grids();
00198 void setGrid(Qwt3D::SIDE s, bool b);
00199 void setGrid(int grids);
00200
00201 void setLeftGrid(bool b = true);
00202 void setRightGrid(bool b = true);
00203 void setCeilGrid(bool b = true);
00204 void setFloorGrid(bool b = true);
00205 void setFrontGrid(bool b = true);
00206 void setBackGrid(bool b = true);
00208
00209 void setStyle(const QStringList& st);
00210 void customPlotStyle(int style);
00211 void resetNonEmptyStyle();
00212
00213 void setRotation(double xVal,double yVal,double zVal);
00214 void setScale(double xVal,double yVal,double zVal);
00215 void setShift(double xVal,double yVal,double zVal);
00216
00217 double xRotation(){return sp->xRotation();};
00218 double yRotation(){return sp->yRotation();};
00219 double zRotation(){return sp->zRotation();};
00220
00221 double xScale(){return sp->xScale();};
00222 double yScale(){return sp->yScale();};
00223 double zScale(){return sp->zScale();};
00224
00225 double xShift(){return sp->xShift();};
00226 double yShift(){return sp->yShift();};
00227 double zShift(){return sp->zShift();};
00228
00229 double zoom(){return sp->zoom();};
00230 void setZoom(double val);
00231
00232 Qwt3D::PLOTSTYLE plotStyle();
00233 Qwt3D::FLOORSTYLE floorStyle();
00234 Qwt3D::COORDSTYLE coordStyle();
00235
00236 void print();
00237 void copyImage();
00238 void exportImage(const QString& fileName, int quality = 100, bool transparent = false);
00239 void exportPDF(const QString& fileName);
00240 void exportVector(const QString& fileName);
00241 void exportToFile(const QString& fileName);
00242
00243 void save(const QString& fn, const QString& geometry, bool = false);
00244
00245 void zoomChanged(double);
00246 void rotationChanged(double, double, double);
00247 void scaleChanged(double, double, double);
00248 void shiftChanged(double, double, double);
00249
00251
00252 void setDataColors(const QColor& cMax, const QColor& cMin);
00253
00254 void changeTransparency(double t);
00255 void setTransparency(double t);
00256 double transparency(){return alpha;};
00257
00258 QColor minDataColor();
00259 QColor maxDataColor();
00260 QColor meshColor(){return meshCol;};
00261 QColor axesColor(){return axesCol;};
00262 QColor labelColor(){return labelsCol;};
00263 QColor numColor(){return numCol;};
00264 QColor bgColor(){return bgCol;};
00265 QColor gridColor(){return gridCol;};
00266
00267 QString colorMap(){return color_map;};
00268 void setDataColorMap(const QString& fileName);
00269 bool openColorMap(ColorVector& cv, QString fname);
00270
00271 void setMeshColor(const QColor&);
00272 void setAxesColor(const QColor&);
00273 void setNumbersColor(const QColor&);
00274 void setLabelsColor(const QColor&);
00275 void setBackgroundColor(const QColor&);
00276 void setGridColor(const QColor&);
00277
00278 void setColors(const QStringList& colors);
00280
00282
00283 QFont titleFont(){return titleFnt;};
00284 void setTitleFont(const QFont& font);
00285 QString plotTitle(){return title;};
00286 QColor titleColor(){return titleCol;};
00287 void setTitle(const QStringList& lst);
00288 void setTitle(const QString& s, const QColor& color = QColor(Qt::black), const QFont& font = QFont());
00290
00292
00293 void setResolution(int r);
00294 int resolution(){return sp->resolution();};
00296
00298
00299 void showColorLegend(bool show = true);
00300 bool isLegendOn(){return legendOn;};
00302
00303 void setOptions(bool legend, int r, int dist);
00304 void setOptions(const QStringList& lst);
00305 void update();
00306
00308
00309 double barsRadius();
00310 void setBarRadius(double rad);
00312
00314
00315 double pointsSize(){return d_point_size;};
00316 bool smoothPoints(){return d_smooth_points;};
00317 void setDotOptions(double size, bool smooth);
00318
00319 bool smoothCrossHair(){return crossHairSmooth;};
00320 bool boxedCrossHair(){return crossHairBoxed;};
00321 double crossHairRadius(){return crossHairRad;};
00322 double crossHairLinewidth(){return crossHairLineWidth;};
00323 void setCrossOptions(double rad, double linewidth, bool smooth, bool boxed);
00324 void setCrossStyle();
00325
00326 double coneRadius(){return conesRad;};
00327 int coneQuality(){return conesQuality;};
00328 void setConeOptions(double rad, int quality);
00329 void setConeStyle();
00330
00331 PointStyle pointType(){return pointStyle;};
00333
00334 Table* table(){return d_table;};
00335 void showWorksheet();
00336 void setPlotAssociation(const QString& s){plotAssociation = s;};
00337
00338 void setAntialiasing(bool smooth = true);
00339 bool antialiasing(){return sp->smoothDataMesh();};
00340
00342 void rotate();
00343 void animate(bool on = true);
00344 bool isAnimated(){return d_timer->isActive();};
00345
00346 void findBestLayout();
00347 bool autoscale(){return d_autoscale;};
00349 void setAutoscale(bool on = true){d_autoscale = on;};
00350
00351 signals:
00352 void showOptionsDialog();
00353 void modified();
00354
00355 private:
00357 int animation_redraw_wait;
00359 QString color_map;
00360
00361 QTimer *d_timer;
00362 QString title, plotAssociation;
00363 QStringList labels;
00364 QFont titleFnt;
00365 bool legendOn, d_autoscale;
00366 QVector<int> scaleType;
00367 QColor axesCol,labelsCol,titleCol,meshCol,bgCol,numCol,gridCol;
00369 QColor fromColor, toColor;
00370 int labelsDist, legendMajorTicks;
00371 bool ignoreFonts;
00372 Qwt3D::StandardColor* col_;
00373 double barsRad, alpha, d_point_size, crossHairRad, crossHairLineWidth, conesRad;
00375 bool d_smooth_points;
00376 bool crossHairSmooth, crossHairBoxed;
00377 int conesQuality;
00378 PointStyle pointStyle;
00379 Table *d_table;
00380 Matrix *d_matrix;
00381 Qwt3D::SurfacePlot* sp;
00382 UserFunction *d_func;
00383 UserParametricSurface *d_surface;
00384 Qwt3D::PLOTSTYLE style_;
00385 };
00386
00388 class UserFunction : public Function
00389 {
00390 public:
00391 UserFunction(const QString& s, SurfacePlot& pw);
00392
00393 double operator()(double x, double y);
00394 QString function(){return formula;};
00395
00396 unsigned int rows(){return d_rows;};
00397 unsigned int columns(){return d_columns;};
00398 void setMesh (unsigned int columns, unsigned int rows);
00399
00400 private:
00401 QString formula;
00402 unsigned int d_rows, d_columns;
00403 };
00404
00406 class UserParametricSurface : public ParametricSurface
00407 {
00408 public:
00409 UserParametricSurface(const QString& xFormula, const QString& yFormula,
00410 const QString& zFormula, SurfacePlot& pw);
00411 Triple operator()(double u, double v);
00412
00413 unsigned int rows(){return d_rows;};
00414 unsigned int columns(){return d_columns;};
00415 void setMesh (unsigned int columns, unsigned int rows);
00416
00417 bool uPeriodic(){return d_u_periodic;};
00418 bool vPeriodic(){return d_v_periodic;};
00419 void setPeriodic (bool u, bool v);
00420
00421 double uStart(){return d_ul;};
00422 double uEnd(){return d_ur;};
00423 double vStart(){return d_vl;};
00424 double vEnd(){return d_vr;};
00425 void setDomain(double ul, double ur, double vl, double vr);
00426
00427 QString xFormula(){return d_x_formula;};
00428 QString yFormula(){return d_y_formula;};
00429 QString zFormula(){return d_z_formula;};
00430
00431 private:
00432 QString d_x_formula, d_y_formula, d_z_formula;
00433 unsigned int d_rows, d_columns;
00434 bool d_u_periodic, d_v_periodic;
00435 double d_ul, d_ur, d_vl, d_vr;
00436 };
00437 #endif // Plot3D_H