notcurses/include/ncpp/Plot.hh
Marek Habersack 28976dfef2 [C++] Sync API changes
Been a while, but here goes, sync to the latest API changes.

Added:

  * Direct:   cursor_{up,left,right,down} (`ncdirect_cursor_{up,left,right,down}`)
  * Plane: constructors to use `ncplane_bound`
  * Plane: reparent (`ncplane_reparent`)
  * Plot: definition of `default_options`

Changed:

  * Plane (breaking): the `*gradient*` functions now return `int`
  * Plane (breaking): `polyfill` returns `int`
  * Plane (breaking): `stain` returns `int`
  * Plane (breaking): `blit_bgrx` takes `const void*` for `data`
  * Plane (breaking): `blit_rgba` takes `const void*` for `data`
  * Plot: `plot_optons` -> `ncplot_options`
  * Plot (breaking): `{add,set}_sample` now return `bool`
2020-04-11 20:44:25 -04:00

68 lines
1.4 KiB
C++

#ifndef __NCPP_PLOT_HH
#define __NCPP_PLOT_HH
#include <notcurses/notcurses.h>
#include "Root.hh"
#include "NCAlign.hh"
namespace ncpp
{
class Plane;
class NCPP_API_EXPORT Plot : public Root
{
public:
static ncplot_options default_options;
public:
explicit Plot (Plane *plane, const ncplot_options *opts = nullptr)
: Plot (reinterpret_cast<ncplane*>(plane), opts)
{}
explicit Plot (Plane const* plane, const ncplot_options *opts = nullptr)
: Plot (const_cast<Plane*>(plane), opts)
{}
explicit Plot (Plane &plane, const ncplot_options *opts = nullptr)
: Plot (reinterpret_cast<ncplane*>(&plane), opts)
{}
explicit Plot (Plane const& plane, const ncplot_options *opts = nullptr)
: Plot (const_cast<Plane*>(&plane), opts)
{}
explicit Plot (ncplane *plane, const ncplot_options *opts = nullptr)
{
if (plane == nullptr)
throw invalid_argument ("'plane' must be a valid pointer");
plot = ncplot_create (plane, opts == nullptr ? &default_options : opts);
if (plot == nullptr)
throw init_error ("notcurses failed to create a new plot");
}
~Plot ()
{
if (!is_notcurses_stopped ())
ncplot_destroy (plot);
}
bool add_sample(uint64_t x, uint64_t y)
{
return ncplot_add_sample (plot, x, y) >= 0;
}
bool set_sample(uint64_t x, uint64_t y)
{
return ncplot_set_sample (plot, x, y) >= 0;
}
Plane* get_plane () const noexcept;
private:
ncplot *plot;
};
}
#endif