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 QString saveToString(const QString& geometry, bool = false);
00244 QString saveAsTemplate(const QString& geometryInfo);
00245
00246 void zoomChanged(double);
00247 void rotationChanged(double, double, double);
00248 void scaleChanged(double, double, double);
00249 void shiftChanged(double, double, double);
00250
00252
00253 void setDataColors(const QColor& cMax, const QColor& cMin);
00254
00255 void changeTransparency(double t);
00256 void setTransparency(double t);
00257 double transparency(){return alpha;};
00258
00259 QColor minDataColor();
00260 QColor maxDataColor();
00261 QColor meshColor(){return meshCol;};
00262 QColor axesColor(){return axesCol;};
00263 QColor labelColor(){return labelsCol;};
00264 QColor numColor(){return numCol;};
00265 QColor bgColor(){return bgCol;};
00266 QColor gridColor(){return gridCol;};
00267
00268 QString colorMap(){return color_map;};
00269 void setDataColorMap(const QString& fileName);
00270 bool openColorMap(ColorVector& cv, QString fname);
00271
00272 void setMeshColor(const QColor&);
00273 void setAxesColor(const QColor&);
00274 void setNumbersColor(const QColor&);
00275 void setLabelsColor(const QColor&);
00276 void setBackgroundColor(const QColor&);
00277 void setGridColor(const QColor&);
00278
00279 void setColors(const QStringList& colors);
00281
00283
00284 QFont titleFont(){return titleFnt;};
00285 void setTitleFont(const QFont& font);
00286 QString plotTitle(){return title;};
00287 QColor titleColor(){return titleCol;};
00288 void setTitle(const QStringList& lst);
00289 void setTitle(const QString& s, const QColor& color = QColor(Qt::black), const QFont& font = QFont());
00291
00293
00294 void setResolution(int r);
00295 int resolution(){return sp->resolution();};
00297
00299
00300 void showColorLegend(bool show = true);
00301 bool isLegendOn(){return legendOn;};
00303
00304 void setOptions(bool legend, int r, int dist);
00305 void setOptions(const QStringList& lst);
00306 void update();
00307
00309
00310 double barsRadius();
00311 void setBarRadius(double rad);
00313
00315
00316 double pointsSize(){return d_point_size;};
00317 bool smoothPoints(){return d_smooth_points;};
00318 void setDotOptions(double size, bool smooth);
00319
00320 bool smoothCrossHair(){return crossHairSmooth;};
00321 bool boxedCrossHair(){return crossHairBoxed;};
00322 double crossHairRadius(){return crossHairRad;};
00323 double crossHairLinewidth(){return crossHairLineWidth;};
00324 void setCrossOptions(double rad, double linewidth, bool smooth, bool boxed);
00325 void setCrossStyle();
00326
00327 double coneRadius(){return conesRad;};
00328 int coneQuality(){return conesQuality;};
00329 void setConeOptions(double rad, int quality);
00330 void setConeStyle();
00331
00332 PointStyle pointType(){return pointStyle;};
00334
00335 Table* table(){return d_table;};
00336 void showWorksheet();
00337 void setPlotAssociation(const QString& s){plotAssociation = s;};
00338
00339 void setAntialiasing(bool smooth = true);
00340 bool antialiasing(){return sp->smoothDataMesh();};
00341
00343 void rotate();
00344 void animate(bool on = true);
00345 bool isAnimated(){return d_timer->isActive();};
00346
00347 void findBestLayout();
00348 bool autoscale(){return d_autoscale;};
00350 void setAutoscale(bool on = true){d_autoscale = on;};
00351
00352 signals:
00353 void showOptionsDialog();
00354 void modified();
00355
00356 private:
00358 int animation_redraw_wait;
00360 QString color_map;
00361
00362 QTimer *d_timer;
00363 QString title, plotAssociation;
00364 QStringList labels;
00365 QFont titleFnt;
00366 bool legendOn, d_autoscale;
00367 QVector<int> scaleType;
00368 QColor axesCol,labelsCol,titleCol,meshCol,bgCol,numCol,gridCol;
00370 QColor fromColor, toColor;
00371 int labelsDist, legendMajorTicks;
00372 bool ignoreFonts;
00373 Qwt3D::StandardColor* col_;
00374 double barsRad, alpha, d_point_size, crossHairRad, crossHairLineWidth, conesRad;
00376 bool d_smooth_points;
00377 bool crossHairSmooth, crossHairBoxed;
00378 int conesQuality;
00379 PointStyle pointStyle;
00380 Table *d_table;
00381 Matrix *d_matrix;
00382 Qwt3D::SurfacePlot* sp;
00383 UserFunction *d_func;
00384 UserParametricSurface *d_surface;
00385 Qwt3D::PLOTSTYLE style_;
00386 };
00387
00389 class UserFunction : public Function
00390 {
00391 public:
00392 UserFunction(const QString& s, SurfacePlot& pw);
00393
00394 double operator()(double x, double y);
00395 QString function(){return formula;};
00396
00397 unsigned int rows(){return d_rows;};
00398 unsigned int columns(){return d_columns;};
00399 void setMesh (unsigned int columns, unsigned int rows);
00400
00401 private:
00402 QString formula;
00403 unsigned int d_rows, d_columns;
00404 };
00405
00407 class UserParametricSurface : public ParametricSurface
00408 {
00409 public:
00410 UserParametricSurface(const QString& xFormula, const QString& yFormula,
00411 const QString& zFormula, SurfacePlot& pw);
00412 Triple operator()(double u, double v);
00413
00414 unsigned int rows(){return d_rows;};
00415 unsigned int columns(){return d_columns;};
00416 void setMesh (unsigned int columns, unsigned int rows);
00417
00418 bool uPeriodic(){return d_u_periodic;};
00419 bool vPeriodic(){return d_v_periodic;};
00420 void setPeriodic (bool u, bool v);
00421
00422 double uStart(){return d_ul;};
00423 double uEnd(){return d_ur;};
00424 double vStart(){return d_vl;};
00425 double vEnd(){return d_vr;};
00426 void setDomain(double ul, double ur, double vl, double vr);
00427
00428 QString xFormula(){return d_x_formula;};
00429 QString yFormula(){return d_y_formula;};
00430 QString zFormula(){return d_z_formula;};
00431
00432 private:
00433 QString d_x_formula, d_y_formula, d_z_formula;
00434 unsigned int d_rows, d_columns;
00435 bool d_u_periodic, d_v_periodic;
00436 double d_ul, d_ur, d_vl, d_vr;
00437 };
00438 #endif // Plot3D_H