From affb3e1f7cda157acbf8a8317c4e809999aac02b Mon Sep 17 00:00:00 2001 From: Bert Peters Date: Fri, 4 May 2018 11:47:56 +0200 Subject: [PATCH] Separate drawing interactions and interaction paths. --- src/fmri/ActivityAnimation.cpp | 14 +++++++++----- src/fmri/ActivityAnimation.hpp | 5 ++--- src/fmri/Animation.cpp | 5 +++++ src/fmri/Animation.hpp | 2 ++ src/fmri/LabelVisualisation.cpp | 17 +++++++++-------- src/fmri/LabelVisualisation.hpp | 1 + src/fmri/RenderingState.cpp | 9 +++++++-- 7 files changed, 35 insertions(+), 18 deletions(-) diff --git a/src/fmri/ActivityAnimation.cpp b/src/fmri/ActivityAnimation.cpp index 6b6ac8e..235b344 100644 --- a/src/fmri/ActivityAnimation.cpp +++ b/src/fmri/ActivityAnimation.cpp @@ -60,10 +60,14 @@ void ActivityAnimation::draw(float timeScale) glVertexPointer(3, GL_FLOAT, 0, vertexBuffer.data()); glDrawArrays(GL_POINTS, 0, bufferLength / 3); glDisableClientState(GL_COLOR_ARRAY); - if (RenderingState::instance().renderInteractionPaths()) { - setGlColor(RenderingState::instance().pathColor()); - glVertexPointer(3, GL_FLOAT, 0, startingPos.data()); - glDrawElements(GL_LINES, lineIndices.size(), GL_UNSIGNED_INT, lineIndices.data()); - } + glDisableClientState(GL_VERTEX_ARRAY); +} + +void ActivityAnimation::drawPaths() +{ + glEnableClientState(GL_VERTEX_ARRAY); + setGlColor(RenderingState::instance().pathColor()); + glVertexPointer(3, GL_FLOAT, 0, startingPos.data()); + glDrawElements(GL_LINES, lineIndices.size(), GL_UNSIGNED_INT, lineIndices.data()); glDisableClientState(GL_VERTEX_ARRAY); } diff --git a/src/fmri/ActivityAnimation.hpp b/src/fmri/ActivityAnimation.hpp index 7cf4393..9a59fb0 100644 --- a/src/fmri/ActivityAnimation.hpp +++ b/src/fmri/ActivityAnimation.hpp @@ -18,10 +18,9 @@ namespace fmri ActivityAnimation( const std::vector>> &interactions, const float *aPositions, const float *bPositions); - ActivityAnimation( - const std::vector>> &interactions, - const float *aPositions, const float *bPositions, ColoringFunction coloring); + void draw(float timeScale) override; + void drawPaths() override; private: std::size_t bufferLength; diff --git a/src/fmri/Animation.cpp b/src/fmri/Animation.cpp index f665a09..43ad7c4 100644 --- a/src/fmri/Animation.cpp +++ b/src/fmri/Animation.cpp @@ -5,3 +5,8 @@ float fmri::Animation::getAlpha() { return fmri::RenderingState::instance().interactionAlpha(); } + +void fmri::Animation::drawPaths() +{ + // Default implementation does nothing. +} diff --git a/src/fmri/Animation.hpp b/src/fmri/Animation.hpp index 4e8694d..5ce25d8 100644 --- a/src/fmri/Animation.hpp +++ b/src/fmri/Animation.hpp @@ -11,6 +11,8 @@ namespace fmri public: virtual ~Animation() = default; + virtual void drawPaths(); + protected: float getAlpha() override; }; diff --git a/src/fmri/LabelVisualisation.cpp b/src/fmri/LabelVisualisation.cpp index 55f74dd..04cc762 100644 --- a/src/fmri/LabelVisualisation.cpp +++ b/src/fmri/LabelVisualisation.cpp @@ -7,14 +7,6 @@ using namespace fmri; void LabelVisualisation::draw(float) { - if (RenderingState::instance().renderInteractionPaths()) { - setGlColor(RenderingState::instance().pathColor()); - glEnableClientState(GL_VERTEX_ARRAY); - glVertexPointer(3, GL_FLOAT, 0, nodePositions_.data()); - glDrawElements(GL_LINES, nodeIndices.size(), GL_UNSIGNED_INT, nodeIndices.data()); - glDisableClientState(GL_VERTEX_ARRAY); - } - glPushMatrix(); glTranslatef(LAYER_X_OFFSET, 0, 0); @@ -64,3 +56,12 @@ LabelVisualisation::LabelVisualisation(const std::vector &positions, cons patchTransparancy(); } + +void LabelVisualisation::drawPaths() +{ + setGlColor(RenderingState::instance().pathColor()); + glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(3, GL_FLOAT, 0, nodePositions_.data()); + glDrawElements(GL_LINES, nodeIndices.size(), GL_UNSIGNED_INT, nodeIndices.data()); + glDisableClientState(GL_VERTEX_ARRAY); +} diff --git a/src/fmri/LabelVisualisation.hpp b/src/fmri/LabelVisualisation.hpp index dd84afc..4ce1a22 100644 --- a/src/fmri/LabelVisualisation.hpp +++ b/src/fmri/LabelVisualisation.hpp @@ -10,6 +10,7 @@ namespace fmri public: LabelVisualisation(const std::vector& positions, const LayerData& prevData, const std::vector& labels); void draw(float time) override; + void drawPaths() override; private: static constexpr float DISPLAY_LIMIT = 0.01; diff --git a/src/fmri/RenderingState.cpp b/src/fmri/RenderingState.cpp index 7842e4d..854e3a9 100644 --- a/src/fmri/RenderingState.cpp +++ b/src/fmri/RenderingState.cpp @@ -355,8 +355,13 @@ void RenderingState::drawLayer(float time, unsigned long i) const if (options.renderLayers) { layer.first->draw(time); } - if (options.renderInteractions && layer.second) { - layer.second->draw(time); + if (layer.second) { + if (options.renderInteractions) { + layer.second->draw(time); + } + if (options.renderInteractionPaths) { + layer.second->drawPaths(); + } } glPopMatrix();