Notcurses 3.0.13
a blingful library for TUIs and character graphics
Loading...
Searching...
No Matches
PlotBase< TPlot, TCoord > Class Template Reference

#include <Plot.hh>

Inheritance diagram for PlotBase< TPlot, TCoord >:
Collaboration diagram for PlotBase< TPlot, TCoord >:

Public Member Functions

bool add_sample (uint64_t x, TCoord y) const NOEXCEPT_MAYBE
 
bool set_sample (uint64_t x, TCoord y) const NOEXCEPT_MAYBE
 
bool sample (uint64_t x, TCoord *y) const NOEXCEPT_MAYBE
 
- Public Member Functions inherited from Root
notcursesget_notcurses () const
 
NotCursesget_notcurses_cpp () const
 

Protected Member Functions

 PlotBase (Plane *plane, const ncplot_options *opts, TCoord miny=0, TCoord maxy=0)
 
 ~PlotBase ()
 
TPlotget_plot () const noexcept
 
- Protected Member Functions inherited from Widget
 Widget (NotCurses *ncinst)
 
void ensure_valid_plane (Plane *plane) const
 
void ensure_valid_plane (Plane &plane) const
 
void take_plane_ownership (Plane *plane) const
 
void take_plane_ownership (Plane &plane) const
 
- Protected Member Functions inherited from Root
 Root (NotCurses *ncinst)
 
bool is_notcurses_stopped () const noexcept
 

Additional Inherited Members

- Static Protected Member Functions inherited from Root
template<typename TRet = bool, typename TValue = int>
static TRet error_guard (TValue ret, TValue error_value)
 
template<typename TRet = bool, typename TValue = int>
static TRet error_guard_cond (TValue ret, bool error_value)
 
- Static Protected Attributes inherited from Root
static constexpr char ncpp_invalid_state_message [] = "notcurses++ is in an invalid state (already stopped?)"
 

Detailed Description

template<typename TPlot, typename TCoord>
class ncpp::PlotBase< TPlot, TCoord >

Definition at line 16 of file Plot.hh.

Constructor & Destructor Documentation

◆ PlotBase()

template<typename TPlot , typename TCoord >
PlotBase ( Plane plane,
const ncplot_options opts,
TCoord  miny = 0,
TCoord  maxy = 0 
)
inlineexplicitprotected

Definition at line 61 of file Plot.hh.

63 {
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");
67 } else {
68 static_assert (std::is_same_v<TPlot, ncuplot>, "ncuplot must be used for a plot using uint64_t coordinates");
69 }
70
71 ensure_valid_plane (plane);
72
73 if (!plane->is_valid ())
74 throw invalid_argument ("Invalid Plane object passed in 'plane'. Widgets must not reuse the same plane.");
75
76 if (opts == nullptr)
77 throw invalid_argument ("'opts' must be a valid pointer");
78
79 if constexpr (is_uint64) {
81 } else {
83 }
84
85 if (plot == nullptr)
86 throw init_error ("Notcurses failed to create a new plot");
87
89 }
static TRet error_guard(TValue ret, TValue error_value)
Definition Root.hh:39
static NotCurses * get_notcurses_cpp(const Root *o) noexcept
static ncplane * to_ncplane(const Plane *plane) noexcept
Widget(NotCurses *ncinst)
Definition Widget.hh:12
void take_plane_ownership(Plane *plane) const
Definition Widget.hh:29
void ensure_valid_plane(Plane *plane) const
Definition Widget.hh:16
const struct ncplane_options * opts
Definition notcurses.h:3483
ncuplot * ncuplot_create(ncplane *n, const ncplot_options *opts, uint64_t miny, uint64_t maxy)
Definition plot.c:647
ncdplot * ncdplot_create(ncplane *n, const ncplot_options *opts, double miny, double maxy)
Definition plot.c:690
Here is the call graph for this function:

◆ ~PlotBase()

template<typename TPlot , typename TCoord >
~PlotBase ( )
inlineprotected

Definition at line 91 of file Plot.hh.

92 {
93 if (!is_notcurses_stopped ()) {
94 if constexpr (is_double) {
95 ncdplot_destroy (plot);
96 } else {
97 ncuplot_destroy (plot);
98 }
99 }
100 }
bool is_notcurses_stopped() const noexcept
void ncuplot_destroy(ncuplot *n)
Definition plot.c:681
void ncdplot_destroy(ncdplot *n)
Definition plot.c:732
Here is the call graph for this function:

Member Function Documentation

◆ add_sample()

template<typename TPlot , typename TCoord >
bool add_sample ( uint64_t  x,
TCoord  y 
) const
inline

Definition at line 22 of file Plot.hh.

23 {
24 int ret;
25
26 if constexpr (is_double) {
27 ret = ncdplot_add_sample (plot, x, y);
28 } else {
29 ret = nduplot_add_sample (plot, x, y);
30 }
31
32 return error_guard (ret, -1);
33 }
int y
Definition notcurses.h:1905
int int x
Definition notcurses.h:1905
int ncdplot_add_sample(ncdplot *n, uint64_t x, double y)
Definition plot.c:709
Here is the call graph for this function:

◆ get_plot()

template<typename TPlot , typename TCoord >
TPlot * get_plot ( ) const
inlineprotectednoexcept

Definition at line 102 of file Plot.hh.

103 {
104 return plot;
105 }

◆ sample()

template<typename TPlot , typename TCoord >
bool sample ( uint64_t  x,
TCoord y 
) const
inline

Definition at line 47 of file Plot.hh.

48 {
49 int ret;
50
51 if constexpr (is_double) {
52 ret = ncdplot_sample (plot, x, y);
53 } else {
54 ret = ncuplot_sample (plot, x, y);
55 }
56
57 return error_guard (ret, -1);
58 }
int ncdplot_sample(const ncdplot *n, uint64_t x, double *y)
Definition plot.c:728
int ncuplot_sample(const ncuplot *n, uint64_t x, uint64_t *y)
Definition plot.c:724
Here is the call graph for this function:

◆ set_sample()

template<typename TPlot , typename TCoord >
bool set_sample ( uint64_t  x,
TCoord  y 
) const
inline

Definition at line 35 of file Plot.hh.

36 {
37 int ret;
38
39 if constexpr (is_double) {
40 ret = ncdplot_set_sample (plot, x, y);
41 } else {
42 ret = nduplot_set_sample (plot, x, y);
43 }
44 return error_guard (ret, -1);
45 }
int ncdplot_set_sample(ncdplot *n, uint64_t x, double y)
Definition plot.c:713
Here is the call graph for this function:

The documentation for this class was generated from the following file: