It has been a while since I last worked on Aesalon proper.
[aesalon.git] / visualizer / src / visualization / Visualization.h
blobf4c8a87a8ac2dd699402dac8b953b43050fc2a84
1 #ifndef Visualization_H
2 #define Visualization_H
4 #include <QImage>
5 #include <QMutex>
6 #include <QPainter>
8 #include "renderer/DataRange.h"
9 #include "renderer/VisualizationWrapper.h"
11 class VisualizationController;
13 class Visualization : public VisualizationWrapper {
14 public:
15 Visualization(QSize renderSize, DataRange range);
16 ~Visualization();
17 private:
18 QImage m_image;
19 DataRange m_range;
20 QPainter m_painter;
21 QMutex m_paintLock;
22 VisualizationController *m_controller;
23 public:
24 const QImage &image() const { return m_image; }
25 virtual const DataRange &range() const { return m_range; }
27 VisualizationController *controller() const { return m_controller; }
28 void setController(VisualizationController *controller) { m_controller = controller; }
29 /** Merges another visualization with this one.
30 @param other The visualization to merge with.
32 void merge(Visualization *other);
34 /** Clears the visualization of all painted data. */
35 virtual void clear();
37 /** Locks the visualization for painting. */
38 virtual void lock();
39 /** Unlocks the visualization, signifying completion of painting. */
40 virtual void unlock();
41 /** Checks if the visualization is locked for painting.
42 @return The lock status of the visualization.
44 virtual bool isLocked() const { return m_painter.isActive(); }
45 /** Re-sizes the internal QImage.
46 @param newSize The new size of the image.
48 void resize(const QSize &newSize);
50 /** Sets the pen colour. */
51 virtual void setPenColour(int r, int g, int b, int a);
53 virtual void setFillColour(int r, int g, int b, int a);
54 /** Draws a line from @a from to @a to.
55 @param from The coordinates to start the line at.
56 @param to The coordinates to end the line.
58 virtual void drawLine(DataCoord from, DataCoord to);
60 virtual void drawBox(DataRange range);
62 virtual void touch(Timestamp timestamp);
64 /** Creates a sub-visualization of this visualization, preserving the
65 mapping ratio of data units to screen units for a given range.
66 @param range The range of the sub-visualization.
67 @return The new sub-visualization.
69 Visualization *subVisualization(const DataRange &range);
71 void shift(DataCoord by);
73 void scale(qreal x, qreal y);
75 QPointF translate(const DataCoord &coord);
76 QRectF translate(const DataRange &range);
77 DataCoord translate(const QPoint &point);
78 DataRange translate(const QRect &rect);
80 DataCoord translateOffset(const QPoint &point);
81 QPointF translateOffset(const DataCoord &coord);
84 #endif