Added plotting screen
This commit is contained in:
parent
d0de17afa1
commit
74c34370e2
7 changed files with 152 additions and 5 deletions
27
include/Signal.hpp
Normal file
27
include/Signal.hpp
Normal file
|
@ -0,0 +1,27 @@
|
|||
#pragma once
|
||||
|
||||
#include <complex>
|
||||
#include <deque>
|
||||
|
||||
typedef std::complex<double> CmplxDouble;
|
||||
|
||||
typedef struct {
|
||||
double t;
|
||||
CmplxDouble val;
|
||||
bool valid = true;
|
||||
} Sample;
|
||||
|
||||
static const Sample invalidSample{ 0.f, 0.f, false };
|
||||
|
||||
class Signal
|
||||
{
|
||||
public:
|
||||
Signal() = default;
|
||||
~Signal() = default;
|
||||
|
||||
friend Signal& operator<<(Signal& sig, const Sample& sample);
|
||||
friend Signal& operator>>(Signal& sig, Sample& sample);
|
||||
|
||||
private:
|
||||
std::deque<Sample> buffer;
|
||||
};
|
29
include/screens/PlotScreen.hpp
Normal file
29
include/screens/PlotScreen.hpp
Normal file
|
@ -0,0 +1,29 @@
|
|||
#pragma once
|
||||
#include <mutex>
|
||||
#include <vector>
|
||||
#include <SDL.h>
|
||||
#include "../Screen.hpp"
|
||||
#include "Signal.hpp"
|
||||
|
||||
typedef struct {
|
||||
double x, y, w, h;
|
||||
} fRect;
|
||||
|
||||
class PlotScreen : public Screen
|
||||
{
|
||||
public:
|
||||
PlotScreen(SDL_Renderer* renderer, Signal* dataSource,
|
||||
int x, int y, int w, int h,
|
||||
double minX, double minY, double maxX, double maxY);
|
||||
~PlotScreen();
|
||||
|
||||
void Update() override;
|
||||
void Render(SDL_Renderer* renderer) override;
|
||||
|
||||
private:
|
||||
void SignalToSampleList(std::vector<Sample>& container, uint32_t maxSamples = 0);
|
||||
void SampleListToPointList(const std::vector<Sample>& source, std::vector<SDL_Point>& container);
|
||||
|
||||
fRect plotRect;
|
||||
Signal* dataSource;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue