From 916e3cbf8071425f7f200b4de5d6a0da3694febd Mon Sep 17 00:00:00 2001 From: strange Date: Thu, 18 Feb 2010 16:45:46 -0700 Subject: [PATCH] Implemented a VisualizationRequest system to determine if data should be used. In essence, a VisualizationRequest is nought more than a wrapper around a pair of Timestamps . . . --- gui/src/session/Visualization.h | 4 ++++ gui/src/session/VisualizationData.h | 4 ++++ gui/src/session/VisualizationRequest.cpp | 1 + gui/src/session/VisualizationRequest.h | 17 +++++++++++++++++ gui/src/session/VisualizationThread.cpp | 6 ++++-- gui/src/session/VisualizationThread.h | 4 +++- 6 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 gui/src/session/VisualizationRequest.cpp create mode 100644 gui/src/session/VisualizationRequest.h diff --git a/gui/src/session/Visualization.h b/gui/src/session/Visualization.h index 02be030..29c5f13 100644 --- a/gui/src/session/Visualization.h +++ b/gui/src/session/Visualization.h @@ -5,11 +5,13 @@ #include #include "VisualizationThread.h" +#include "VisualizationRequest.h" class Visualization : public QWidget { Q_OBJECT private: VisualizationThread *v_thread; QImage *current_image; + VisualizationRequest *current_request; protected: virtual VisualizationThread *create_v_thread(DataThread *data_thread) { data_thread = data_thread; return NULL; } @@ -20,6 +22,8 @@ protected: virtual void paintEvent(QPaintEvent *event); private slots: void update_image(QImage *image); +signals: + void visualization_request(VisualizationRequest *request); }; #endif diff --git a/gui/src/session/VisualizationData.h b/gui/src/session/VisualizationData.h index 5afc004..80a31d6 100644 --- a/gui/src/session/VisualizationData.h +++ b/gui/src/session/VisualizationData.h @@ -1,10 +1,14 @@ #ifndef AESALON_GUI_SESSION_VISUALIZATION_DATA_H #define AESALON_GUI_SESSION_VISUALIZATION_DATA_H +#include "VisualizationRequest.h" + class VisualizationData { public: VisualizationData(); virtual ~VisualizationData(); + + virtual bool is_within(VisualizationRequest *request) const = 0; }; #endif diff --git a/gui/src/session/VisualizationRequest.cpp b/gui/src/session/VisualizationRequest.cpp new file mode 100644 index 0000000..d0ebfdd --- /dev/null +++ b/gui/src/session/VisualizationRequest.cpp @@ -0,0 +1 @@ +#include "VisualizationRequest.h" diff --git a/gui/src/session/VisualizationRequest.h b/gui/src/session/VisualizationRequest.h new file mode 100644 index 0000000..b01eb29 --- /dev/null +++ b/gui/src/session/VisualizationRequest.h @@ -0,0 +1,17 @@ +#ifndef AESALON_GUI_SESSION_VISUALIZATION_REQUEST_H +#define AESALON_GUI_SESSION_VISUALIZATION_REQUEST_H + +#include "storage/Timestamp.h" +#include "DataRequest.h" + +class VisualizationRequest { +private: + Timestamp from, to; +public: + VisualizationRequest(const Timestamp &from, const Timestamp &to) : from(from), to(to) {} + + const Timestamp &get_from() const { return from; } + const Timestamp &get_to() const { return to; } +}; + +#endif diff --git a/gui/src/session/VisualizationThread.cpp b/gui/src/session/VisualizationThread.cpp index bc738d9..ee49c93 100644 --- a/gui/src/session/VisualizationThread.cpp +++ b/gui/src/session/VisualizationThread.cpp @@ -18,6 +18,7 @@ void VisualizationThread::run() { DataRequest *request = get_request_queue()->pop_request(); VisualizationData *data = request->create_data(); v_data.append(data); + if(!current_request || data->is_within(current_request)) { /* then draw the data. */ } } msleep(50); } @@ -27,6 +28,7 @@ void VisualizationThread::send_request(DataRequest *request) { data_thread->get_request_queue()->push_request(request); } -void VisualizationThread::render(const Timestamp &from, const Timestamp &to) { - +void VisualizationThread::update_request(VisualizationRequest *new_request) { + current_request = new_request; + /* TODO: actually request the data in here . . . */ } diff --git a/gui/src/session/VisualizationThread.h b/gui/src/session/VisualizationThread.h index 7d6f9ef..6607b7e 100644 --- a/gui/src/session/VisualizationThread.h +++ b/gui/src/session/VisualizationThread.h @@ -5,6 +5,7 @@ #include #include +#include "VisualizationRequest.h" #include "DataRequestQueue.h" #include "storage/Timestamp.h" @@ -13,6 +14,7 @@ private: DataThread *data_thread; DataRequestQueue *request_queue; QList v_data; + VisualizationRequest *current_request; public: VisualizationThread(DataThread *data_thread, QObject *parent = 0); virtual ~VisualizationThread(); @@ -22,7 +24,7 @@ protected: virtual void run(); void send_request(DataRequest *request); public slots: - void render(const Timestamp &from, const Timestamp &to); + void update_request(VisualizationRequest *new_request); signals: void replace_image(QImage *new_image); }; -- 2.11.4.GIT