Restore layer names.

This commit is contained in:
2018-04-23 15:39:21 +02:00
parent 03cac53d05
commit 8eb19cdb6d
5 changed files with 32 additions and 18 deletions

View File

@@ -1,7 +1,9 @@
#include <GL/gl.h>
#include "LayerVisualisation.hpp" #include "LayerVisualisation.hpp"
#include "Range.hpp" #include "Range.hpp"
#include "utils.hpp" #include "utils.hpp"
#include "RenderingState.hpp" #include "RenderingState.hpp"
#include "glutils.hpp"
const std::vector<float> &fmri::LayerVisualisation::nodePositions() const const std::vector<float> &fmri::LayerVisualisation::nodePositions() const
{ {
@@ -31,6 +33,21 @@ float fmri::LayerVisualisation::getAlpha()
return RenderingState::instance().layerAlpha(); return RenderingState::instance().layerAlpha();
} }
void fmri::LayerVisualisation::setupLayerName(std::string_view name, fmri::LayerInfo::Type type)
{
displayName = name;
displayName += ": ";
displayName += LayerInfo::nameByType(type);
}
void fmri::LayerVisualisation::drawLayerName() const
{
glColor3f(0.5, 0.5, 0.5);
renderText(displayName);
glTranslatef(0, 0, -10);
}
template<> template<>
void fmri::LayerVisualisation::initNodePositions<fmri::LayerVisualisation::Ordering::SQUARE>(size_t n, float spacing) void fmri::LayerVisualisation::initNodePositions<fmri::LayerVisualisation::Ordering::SQUARE>(size_t n, float spacing)
{ {

View File

@@ -3,6 +3,7 @@
#include <vector> #include <vector>
#include "utils.hpp" #include "utils.hpp"
#include "Drawable.hpp" #include "Drawable.hpp"
#include "LayerInfo.hpp"
namespace fmri namespace fmri
{ {
@@ -20,14 +21,15 @@ namespace fmri
virtual ~LayerVisualisation() = default; virtual ~LayerVisualisation() = default;
virtual const std::vector<float>& nodePositions() const; virtual const std::vector<float>& nodePositions() const;
void drawLayerName() const;
protected: void setupLayerName(std::string_view name, LayerInfo::Type type);
float getAlpha() override;
protected: protected:
std::vector<float> nodePositions_; std::vector<float> nodePositions_;
std::string displayName;
template<Ordering Order> template<Ordering Order>
void initNodePositions(size_t n, float spacing); void initNodePositions(size_t n, float spacing);
float getAlpha() override;
}; };
} }

View File

@@ -322,8 +322,7 @@ void RenderingState::drawLayer(float time, unsigned long i) const
auto& layer = currentData->at(i); auto& layer = currentData->at(i);
// TODO: make names available again. layer.first->drawLayerName();
// renderLayerName(currentData->at(i).name());
if (options.renderLayers) { if (options.renderLayers) {
layer.first->draw(time); layer.first->draw(time);
} }
@@ -362,17 +361,6 @@ void RenderingState::renderOverlayText() const
restorePerspectiveProjection(); restorePerspectiveProjection();
} }
void RenderingState::renderLayerName(const std::string &name) const
{
glColor3f(0.5, 0.5, 0.5);
auto layerName = name;
layerName += ": ";
//layerName += LayerInfo::nameByType(layerInfo.at(name).type());
renderText(layerName);
glTranslatef(0, 0, -10);
}
void RenderingState::handleSpecialKey(int key) void RenderingState::handleSpecialKey(int key)
{ {
if (isLoading()) { if (isLoading()) {

View File

@@ -89,7 +89,6 @@ namespace fmri
std::string debugInfo() const; std::string debugInfo() const;
void renderOverlayText() const; void renderOverlayText() const;
void renderLayerName(const std::string& name) const;
void drawLayer(float time, unsigned long i) const; void drawLayer(float time, unsigned long i) const;

View File

@@ -67,7 +67,7 @@ static EntryList deduplicate(const EntryList& entries)
return result; return result;
} }
fmri::LayerVisualisation *fmri::getVisualisationForLayer(const fmri::LayerData &data, const fmri::LayerInfo &info) static fmri::LayerVisualisation *getAppropriateLayer(const fmri::LayerData &data, const fmri::LayerInfo &info)
{ {
switch (info.type()) { switch (info.type()) {
case LayerInfo::Type::Input: case LayerInfo::Type::Input:
@@ -91,6 +91,14 @@ fmri::LayerVisualisation *fmri::getVisualisationForLayer(const fmri::LayerData &
} }
} }
fmri::LayerVisualisation *fmri::getVisualisationForLayer(const fmri::LayerData &data, const fmri::LayerInfo &info)
{
auto layer = getAppropriateLayer(data, info);
layer->setupLayerName(data.name(), info.type());
return layer;
}
static Animation *getFullyConnectedAnimation(const fmri::LayerData &prevState, const fmri::LayerInfo &layer, static Animation *getFullyConnectedAnimation(const fmri::LayerData &prevState, const fmri::LayerInfo &layer,
const vector<float> &prevPositions, const vector<float> &curPositions) const vector<float> &prevPositions, const vector<float> &curPositions)
{ {