Implement an option to choose path color. Refs #1.

This commit is contained in:
2018-04-03 16:43:23 +02:00
parent 62153d9c6d
commit f62c2859e3
7 changed files with 33 additions and 3 deletions

View File

@@ -72,7 +72,7 @@ void ActivityAnimation::draw(float timeScale)
glDrawArrays(GL_POINTS, 0, bufferLength / 3); glDrawArrays(GL_POINTS, 0, bufferLength / 3);
glDisableClientState(GL_COLOR_ARRAY); glDisableClientState(GL_COLOR_ARRAY);
if (RenderingState::instance().renderInteractionPaths()) { if (RenderingState::instance().renderInteractionPaths()) {
glColor4f(1, 1, 1, 0.1); glColor4fv(RenderingState::instance().pathColor().data());
glVertexPointer(3, GL_FLOAT, 0, startingPos.data()); glVertexPointer(3, GL_FLOAT, 0, startingPos.data());
glDrawElements(GL_LINES, lineIndices.size(), GL_UNSIGNED_INT, lineIndices.data()); glDrawElements(GL_LINES, lineIndices.size(), GL_UNSIGNED_INT, lineIndices.data());
checkGLErrors(); checkGLErrors();

View File

@@ -41,7 +41,7 @@ static void check_file(const char *filename)
* @param targetColor * @param targetColor
* @return true if the read was successful. * @return true if the read was successful.
*/ */
static bool parse_color(const char *input, std::array<float, 4> &targetColor) static bool parse_color(const char *input, Color &targetColor)
{ {
if (input[0] == '#') { if (input[0] == '#') {
// Attempt to parse #RRGGBBAA // Attempt to parse #RRGGBBAA
@@ -176,3 +176,8 @@ Options::Options() noexcept :
dumpPath(nullptr) dumpPath(nullptr)
{ {
} }
const Color &Options::pathColor() const
{
return pathColor_;
}

View File

@@ -4,6 +4,7 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include "utils.hpp"
#include "PNGDumper.hpp" #include "PNGDumper.hpp"
namespace fmri { namespace fmri {
@@ -18,13 +19,14 @@ namespace fmri {
const string& model() const; const string& model() const;
const string& weights() const; const string& weights() const;
const string& means() const; const string& means() const;
const Color& pathColor() const;
std::optional<vector<string>> labels() const; std::optional<vector<string>> labels() const;
std::optional<fmri::PNGDumper> imageDumper() const; std::optional<fmri::PNGDumper> imageDumper() const;
const vector<string>& inputs() const; const vector<string>& inputs() const;
private: private:
std::array<float, 4> pathColor_; Color pathColor_;
string modelPath; string modelPath;
string weightsPath; string weightsPath;
string meansPath; string meansPath;

View File

@@ -322,3 +322,13 @@ bool RenderingState::renderInteractionPaths() const
{ {
return options.renderInteractionPaths; return options.renderInteractionPaths;
} }
void RenderingState::loadOptions(const Options &options)
{
this->options.pathColor = options.pathColor();
}
const Color &RenderingState::pathColor() const
{
return options.pathColor;
}

View File

@@ -5,6 +5,7 @@
#include "LayerData.hpp" #include "LayerData.hpp"
#include "LayerVisualisation.hpp" #include "LayerVisualisation.hpp"
#include "Animation.hpp" #include "Animation.hpp"
#include "Options.hpp"
namespace fmri namespace fmri
{ {
@@ -39,11 +40,18 @@ namespace fmri
void render(float time) const; void render(float time) const;
void loadSimulationData(const std::map<string, LayerInfo> &info, std::vector<std::vector<LayerData>> &&data); void loadSimulationData(const std::map<string, LayerInfo> &info, std::vector<std::vector<LayerData>> &&data);
/**
* Load rendering-specific options from the given options object.
*
* @param options
*/
void loadOptions(const Options& options);
/** /**
* @return Whether the network should only render activated nodes, rather than all of them. * @return Whether the network should only render activated nodes, rather than all of them.
*/ */
bool renderActivatedOnly() const; bool renderActivatedOnly() const;
bool renderInteractionPaths() const; bool renderInteractionPaths() const;
const Color& pathColor() const;
static RenderingState& instance(); static RenderingState& instance();
@@ -55,6 +63,7 @@ namespace fmri
bool renderInteractions = true; bool renderInteractions = true;
bool activatedOnly = false; bool activatedOnly = false;
bool renderInteractionPaths = false; bool renderInteractionPaths = false;
Color pathColor;
} options; } options;
std::array<float, 3> pos; std::array<float, 3> pos;
std::array<float, 2> angle; std::array<float, 2> angle;

View File

@@ -60,6 +60,7 @@ int main(int argc, char *argv[])
// Prepare data for simulations // Prepare data for simulations
Options options = Options::parse(argc, argv); Options options = Options::parse(argc, argv);
loadSimulationData(options); loadSimulationData(options);
RenderingState::instance().loadOptions(options);
// Register callbacks // Register callbacks
glutReshapeFunc(changeWindowSize); glutReshapeFunc(changeWindowSize);

View File

@@ -1,6 +1,7 @@
#pragma once #pragma once
#include <algorithm> #include <algorithm>
#include <array>
#include <cassert> #include <cassert>
#include <cmath> #include <cmath>
#include <fstream> #include <fstream>
@@ -16,6 +17,8 @@ namespace fmri
{ {
typedef float DType; typedef float DType;
typedef std::array<float, 4> Color;
/** /**
* The distance between layers in the visualisation. * The distance between layers in the visualisation.
*/ */