Color nodes based on intensity.

This commit is contained in:
2017-11-16 16:21:21 +01:00
parent f1d2776fce
commit 8eba3ec063
3 changed files with 18 additions and 1 deletions

View File

@@ -102,3 +102,9 @@ GLuint fmri::compileShader(GLenum type, char const *source)
abort(); abort();
} }
} }
void ::fmri::setColorFromIntensity(float i)
{
// TODO: something more expressive.
glColor3f(i, i, i);
}

View File

@@ -33,4 +33,11 @@ namespace fmri {
* @param h new Height. * @param h new Height.
*/ */
void changeWindowSize(int w, int h); void changeWindowSize(int w, int h);
/**
* Set the current drawing color based on some intensity value.
*
* @param i The intensity.
*/
void setColorFromIntensity(float i);
} }

View File

@@ -57,7 +57,9 @@ static void render()
glPushMatrix(); glPushMatrix();
for (auto& layer : *rendererData.currentData) { for (auto& layer : *rendererData.currentData) {
glPushMatrix();
renderLayer(layer); renderLayer(layer);
glPopMatrix();
glTranslatef(-5, 0, 0); glTranslatef(-5, 0, 0);
} }
glPopMatrix(); glPopMatrix();
@@ -90,10 +92,10 @@ static void renderFlatLayer(const LayerData& data)
// Color depends on current value. // Color depends on current value.
vector<float> intensities(data.data(), data.data() + data.numEntries()); vector<float> intensities(data.data(), data.data() + data.numEntries());
rescale(intensities.begin(), intensities.end(), 0, 1); rescale(intensities.begin(), intensities.end(), 0, 1);
glColor3f(1, 1, 1);
glPushMatrix(); glPushMatrix();
for (auto i : intensities) { for (auto i : intensities) {
setColorFromIntensity(i);
drawOneParticle(); drawOneParticle();
glTranslatef(0, 0, -2); glTranslatef(0, 0, -2);
} }
@@ -118,6 +120,8 @@ static void renderLayer(const LayerData& data)
// Draw the name of the layer for reference. // Draw the name of the layer for reference.
glColor3f(0.5, 0.5, 0.5); glColor3f(0.5, 0.5, 0.5);
renderText(data.name()); renderText(data.name());
glTranslatef(0, 0, -2);
switch (shape.size()) { switch (shape.size()) {
case 4: case 4:
// TODO: implement this. // TODO: implement this.