Implement an option to choose path color. Refs #1.
This commit is contained in:
@@ -72,7 +72,7 @@ void ActivityAnimation::draw(float timeScale)
|
||||
glDrawArrays(GL_POINTS, 0, bufferLength / 3);
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
if (RenderingState::instance().renderInteractionPaths()) {
|
||||
glColor4f(1, 1, 1, 0.1);
|
||||
glColor4fv(RenderingState::instance().pathColor().data());
|
||||
glVertexPointer(3, GL_FLOAT, 0, startingPos.data());
|
||||
glDrawElements(GL_LINES, lineIndices.size(), GL_UNSIGNED_INT, lineIndices.data());
|
||||
checkGLErrors();
|
||||
|
||||
@@ -41,7 +41,7 @@ static void check_file(const char *filename)
|
||||
* @param targetColor
|
||||
* @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] == '#') {
|
||||
// Attempt to parse #RRGGBBAA
|
||||
@@ -176,3 +176,8 @@ Options::Options() noexcept :
|
||||
dumpPath(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
const Color &Options::pathColor() const
|
||||
{
|
||||
return pathColor_;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "utils.hpp"
|
||||
#include "PNGDumper.hpp"
|
||||
|
||||
namespace fmri {
|
||||
@@ -18,13 +19,14 @@ namespace fmri {
|
||||
const string& model() const;
|
||||
const string& weights() const;
|
||||
const string& means() const;
|
||||
const Color& pathColor() const;
|
||||
std::optional<vector<string>> labels() const;
|
||||
std::optional<fmri::PNGDumper> imageDumper() const;
|
||||
|
||||
const vector<string>& inputs() const;
|
||||
|
||||
private:
|
||||
std::array<float, 4> pathColor_;
|
||||
Color pathColor_;
|
||||
string modelPath;
|
||||
string weightsPath;
|
||||
string meansPath;
|
||||
|
||||
@@ -322,3 +322,13 @@ bool RenderingState::renderInteractionPaths() const
|
||||
{
|
||||
return options.renderInteractionPaths;
|
||||
}
|
||||
|
||||
void RenderingState::loadOptions(const Options &options)
|
||||
{
|
||||
this->options.pathColor = options.pathColor();
|
||||
}
|
||||
|
||||
const Color &RenderingState::pathColor() const
|
||||
{
|
||||
return options.pathColor;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "LayerData.hpp"
|
||||
#include "LayerVisualisation.hpp"
|
||||
#include "Animation.hpp"
|
||||
#include "Options.hpp"
|
||||
|
||||
namespace fmri
|
||||
{
|
||||
@@ -39,11 +40,18 @@ namespace fmri
|
||||
void render(float time) const;
|
||||
|
||||
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.
|
||||
*/
|
||||
bool renderActivatedOnly() const;
|
||||
bool renderInteractionPaths() const;
|
||||
const Color& pathColor() const;
|
||||
|
||||
static RenderingState& instance();
|
||||
|
||||
@@ -55,6 +63,7 @@ namespace fmri
|
||||
bool renderInteractions = true;
|
||||
bool activatedOnly = false;
|
||||
bool renderInteractionPaths = false;
|
||||
Color pathColor;
|
||||
} options;
|
||||
std::array<float, 3> pos;
|
||||
std::array<float, 2> angle;
|
||||
|
||||
@@ -60,6 +60,7 @@ int main(int argc, char *argv[])
|
||||
// Prepare data for simulations
|
||||
Options options = Options::parse(argc, argv);
|
||||
loadSimulationData(options);
|
||||
RenderingState::instance().loadOptions(options);
|
||||
|
||||
// Register callbacks
|
||||
glutReshapeFunc(changeWindowSize);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <cassert>
|
||||
#include <cmath>
|
||||
#include <fstream>
|
||||
@@ -16,6 +17,8 @@ namespace fmri
|
||||
{
|
||||
typedef float DType;
|
||||
|
||||
typedef std::array<float, 4> Color;
|
||||
|
||||
/**
|
||||
* The distance between layers in the visualisation.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user