Implement interaciton paths for labels.
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user