15 template<
typename TPlot,
typename TCoord>
18 static constexpr bool is_double = std::is_same_v<TCoord,double>;
19 static constexpr bool is_uint64 = std::is_same_v<TCoord,uint64_t>;
26 if constexpr (is_double) {
29 ret = nduplot_add_sample (plot,
x,
y);
32 return error_guard (ret, -1);
39 if constexpr (is_double) {
42 ret = nduplot_set_sample (plot,
x,
y);
44 return error_guard (ret, -1);
51 if constexpr (is_double) {
57 return error_guard (ret, -1);
64 static_assert (is_double || is_uint64,
"PlotBase must be parameterized with either 'double' or 'uint64_t' types");
65 if constexpr (is_double) {
66 static_assert (std::is_same_v<TPlot, ncdplot>,
"ncdplot must be used for a plot using double coordinates");
68 static_assert (std::is_same_v<TPlot, ncuplot>,
"ncuplot must be used for a plot using uint64_t coordinates");
71 ensure_valid_plane (plane);
74 throw invalid_argument (
"Invalid Plane object passed in 'plane'. Widgets must not reuse the same plane.");
79 if constexpr (is_uint64) {
86 throw init_error (
"Notcurses failed to create a new plot");
88 take_plane_ownership (plane);
93 if (!is_notcurses_stopped ()) {
94 if constexpr (is_double) {
bool is_valid() const noexcept
TPlot * get_plot() const noexcept
bool add_sample(uint64_t x, TCoord y) const NOEXCEPT_MAYBE
bool sample(uint64_t x, TCoord *y) const NOEXCEPT_MAYBE
bool set_sample(uint64_t x, TCoord y) const NOEXCEPT_MAYBE
PlotBase(Plane *plane, const ncplot_options *opts, TCoord miny=0, TCoord maxy=0)
static ncplot_options default_options
PlotD(Plane const *plane, const ncplot_options *opts=nullptr)
PlotD(Plane const &plane, const ncplot_options *opts=nullptr)
PlotD(Plane &plane, const ncplot_options *opts=nullptr)
PlotD(Plane *plane, const ncplot_options *opts=nullptr)
Plane * get_plane() const noexcept
static ncplot_options default_options
PlotU(Plane const &plane, const ncplot_options *opts=nullptr)
PlotU(Plane *plane, const ncplot_options *opts=nullptr)
PlotU(Plane const *plane, const ncplot_options *opts=nullptr)
PlotU(Plane &plane, const ncplot_options *opts=nullptr)
Plane * get_plane() const noexcept
const struct ncplane_options * opts
int ncdplot_add_sample(ncdplot *n, uint64_t x, double y)
void ncuplot_destroy(ncuplot *n)
ncuplot * ncuplot_create(ncplane *n, const ncplot_options *opts, uint64_t miny, uint64_t maxy)
int ncdplot_set_sample(ncdplot *n, uint64_t x, double y)
void ncdplot_destroy(ncdplot *n)
ncdplot * ncdplot_create(ncplane *n, const ncplot_options *opts, double miny, double maxy)
int ncdplot_sample(const ncdplot *n, uint64_t x, double *y)
int ncuplot_sample(const ncuplot *n, uint64_t x, uint64_t *y)