-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplot.h
77 lines (61 loc) · 1.93 KB
/
plot.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// Navigating with grid and place cells in cluttered environments
// Edvardsen et al. (2020). Hippocampus, 30(3), 220-232.
//
// Licensed under the EUPL-1.2-or-later.
// Copyright (c) 2019 NTNU - Norwegian University of Science and Technology.
// Author: Vegard Edvardsen (https://github.com/evegard).
#ifndef PLOT_H_INCLUDED
#define PLOT_H_INCLUDED
#include <map>
#include <ostream>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#include "numerical.h"
class PlotComponent;
enum PlotSink { no_plot_sink, stdout_plot_sink, pipe_plot_sink };
class Plot
{
public:
void set(const char *key, const char *value);
void unset(const char *key);
void dump_to_stream(std::ostream &stream);
void set_terminal(const char *terminal);
void show();
PlotSink plot_sink = no_plot_sink;
protected:
virtual void dump_plot_commands(std::ostream &stream) = 0;
std::map<std::string, std::tuple<bool, std::string>> settings;
std::string terminal;
std::ostream *pipe = nullptr;
};
class ComponentPlot : public Plot
{
public:
PlotComponent *add_plot_component(const char *name, const char *plot_command);
protected:
void dump_plot_commands(std::ostream &stream);
std::vector<PlotComponent *> plot_components;
};
class PlotComponent : public std::stringstream
{
public:
PlotComponent(const char *name, const char *plot_command);
void reset();
const char *get_plot_command();
void dump_to_stream(std::ostream &stream);
protected:
std::string name;
std::string plot_command;
};
class MultiPlot : public Plot
{
public:
void add_plot(double x, double y, double width, double height, Plot *plot);
protected:
void dump_plot_commands(std::ostream &stream);
std::vector<std::tuple<double, double, double, double, Plot *>> plots;
};
#endif