Implement interaciton paths for labels.

This commit is contained in:
2018-04-30 13:40:12 +02:00
parent 4f370a4bbd
commit c434c2b62c
5 changed files with 45 additions and 7 deletions

View File

@@ -1,22 +1,27 @@
#include <GL/gl.h>
#include "LabelVisualisation.hpp"
#include "glutils.hpp"
#include "RenderingState.hpp"
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);
for (auto i = 0u; i < nodeLabels.size(); ++i) {
glPushMatrix();
glTranslatef(nodePositions_[3 * i], nodePositions_[3 * i + 1], nodePositions_[3 * i + 2]);
if constexpr (alphaEnabled()) {
glColor4fv(colorBuffer[i].data());
} else {
glColor3fv(colorBuffer[i].data());
}
setGlColor(colorBuffer[i]);
renderText(nodeLabels[i]);
glPopMatrix();
}
@@ -32,6 +37,7 @@ LabelVisualisation::LabelVisualisation(const std::vector<float> &positions, cons
auto nodeInserter = std::back_inserter(nodePositions_);
// First, determine all nodes elegible to be rendered.
for (auto i = 0u; i < limit; ++i) {
if (prevData[i] < DISPLAY_LIMIT) {
continue;
@@ -42,5 +48,19 @@ LabelVisualisation::LabelVisualisation(const std::vector<float> &positions, cons
nodeLabels.emplace_back(labels[i]);
}
// Now fix the points for the interaction paths.
nodeIndices.reserve(2 * nodeLabels.size());
for (auto i = 0u; i < nodeLabels.size(); ++i) {
nodeIndices.push_back(i);
nodeIndices.push_back(i + nodeLabels.size());
}
// Make sure the end positions exist.
std::copy_n(nodePositions_.begin(), nodePositions_.size(), nodeInserter);
for (auto i = nodePositions_.size() / 2; i < nodePositions_.size(); i += 3) {
nodePositions_[i] = LAYER_X_OFFSET;
}
patchTransparancy();
}