00001 #ifndef H_LAYER_STREAMLINES
00002 #define H_LAYER_STREAMLINES
00003
00004 #include "Layer.h"
00005 #include <QPointF>
00006 #include <QColor>
00007 #include <queue>
00008
00009 class Grid;
00010
00011 class Streamline
00012 {
00013 public:
00014 Streamline();
00015 ~Streamline();
00016
00017 std::queue<QPointF> seedPoints;
00018
00019 private:
00020
00021 };
00022
00023 class SPointF : public QPointF
00024 {
00025 public:
00026 SPointF();
00027 SPointF(QPointF p, QColor color, double texIntensity, double width);
00028 ~SPointF();
00029
00030 QColor color;
00031 double texIntensity;
00032 double width;
00033 };
00034
00035 class LayerStreamlines : public Layer
00036 {
00037 Q_OBJECT
00038
00039 public:
00040 LayerStreamlines();
00041 ~LayerStreamlines();
00042
00043 void setWidget(QWidget *widget);
00044
00045 void draw(const DrawInfo &drawInfo);
00046 std::list<SPointF> genStreamline(QPointF start);
00047
00048 public slots:
00049 void setFlowData(FlowData *flowData);
00050 void setSize(const QSize &size);
00051 void drawImage();
00052 void updateImage();
00053 void autoUpdateImage();
00054
00055 void setEulerMethod();
00056 void setRungeKuttaMethod();
00057 void setStepSize(double size);
00058 void setLineWidth(int width);
00059 void setDSep(double dSep);
00060 void setDTest(double dTest);
00061 void toggleGlyphMapping(bool val);
00062 void setGlyphSize(int size);
00063 void toggleTexture(bool val);
00064 void setTextureLength(int length);
00065 void toggleTapering(bool val);
00066 void toggleAutoUpdate(bool val);
00067
00068
00069 private:
00070 QPainter* initImageAndPainter();
00071 void invalidate();
00072 void calculate();
00073 void clearStreamlinesQueue();
00074 void addSeedPoints(QPointF p, Vector3 vec);
00075 double calcThicknessCoef(double d);
00076 double textureFunction(int x);
00077 QPen updatePen(SPointF point);
00078 QPainterPath getPath(std::vector<QPointF> points);
00079 QImage image;
00080 Grid* grid;
00081 std::queue<Streamline*> streamlineQueue;
00082 Streamline* curStreamline;
00083 std::vector<std::list<SPointF>> paths;
00084 QPointF nextPos(Vector3 vec, QPointF curPos, bool forward);
00085 double stepSize, lineWidth, dSep, dTest, glyphSize, textureLength;
00086 int integrationMethod;
00087 bool autoUpdate, activeGlyph, activeTexture, activeTapering;
00088 };
00089
00090 class Grid
00091 {
00092 public:
00093 Grid(float aspect, double dSep, double dTest, double StepSize);
00094 ~Grid();
00095 bool add(QPointF samplePoint, double* smallestDist);
00096 void toIgnore(QPointF samplePoint);
00097 void startNewStreamline();
00098 bool canAdd(QPointF samplePoint, double* smallestDist = 0);
00099
00100 int queueMaxSize;
00101
00102 private:
00103 bool addWithoutQueue(QPointF samplePoint, double* smallestDist);
00104 int getIndex(QPointF samplePoint);
00105 std::vector<QPointF>* data;
00106 std::queue<QPointF> ignoredData;
00107 double dSep, dTest, stepSize, aspect;
00108 QSize gridSize;
00109 };
00110
00111 #endif // H_LAYER_STREAMLINES