trase
trase::Axis Class Reference

An 2D axis that can contain zero or more Geometry objects. More...

#include <Axis.hpp>

Inheritance diagram for trase::Axis:
Collaboration diagram for trase::Axis:

Public Member Functions

 Axis (Drawable *parent, const bfloat2_t &area)
 create a new Axis contained in the given Figure More...
 
TRASE_DISPATCH_BACKENDS const Limitslimits () const
 returns the current Aesthetic limits
 
Limitslimits ()
 returns the current Aesthetic limits, allowing them to be set manually
 
void xlim (std::array< float, 2 > xlimits)
 a helper function to set the x Aesthetic limits manually
 
void ylim (std::array< float, 2 > ylimits)
 a helper function to set the y Aesthetic limits manually
 
void xlabel (const char *string)
 set the label on the x axis
 
void ylabel (const char *string)
 set the label on the y axis
 
void title (const char *string)
 set the title of the Axis
 
std::shared_ptr< Legendlegend ()
 show a legend identifying each Geometry in the Axis
 
std::shared_ptr< Geometrypoints (const DataWithAesthetic &data, const Transform &transform=Transform(Identity()))
 Create a new Points plot and return a shared pointer to it. More...
 
std::shared_ptr< Geometryrectangle (const DataWithAesthetic &data, const Transform &transform=Transform(Identity()))
 Create a new Rectangle plot and return a shared pointer to it. More...
 
std::shared_ptr< Geometryline (const DataWithAesthetic &data, const Transform &transform=Transform(Identity()))
 Create a new Line and return a shared pointer to it. More...
 
std::shared_ptr< Geometryhistogram (const DataWithAesthetic &data, const Transform &transform=Transform(BinX()))
 Create a new histogram and return a shared pointer to it. More...
 
std::shared_ptr< Geometryplot (int n)
 Return a shared pointer to an existing plot. More...
 
template<typename AnimatedBackend >
void draw (AnimatedBackend &backend)
 
template<typename Backend >
void draw (Backend &backend, float time)
 
template<typename Aesthetic >
float from_display (float i) const
 convert from display coordinates to data coordinates, using the given Aesthetic
 
template<typename Aesthetic >
float to_display (float i) const
 convert from data coordinates to display coordinates, using the given Aesthetic
 
void set_ticks (Vector< int, 2 > arg)
 set the number of ticks on this axis More...
 
Vector< int, 2 > get_ticks () const
 gets the number of ticks on this axis
 
- Public Member Functions inherited from trase::Drawable
 Drawable (Drawable *parent, const bfloat2_t &area_of_parent)
 constructs a Drawable under parent in the tree structure, and assigns it an drawable area given by area_of_parent More...
 
void resize (const bfloat2_t &parent_pixels)
 resize the drawable area (in raw pixels) using the parents area (in raw pixels)
 
void update_time_span (float time)
 if time is outside the current animation time span of this object then this time span is increased to include it
 
void add_frame_time (float time)
 adds a keyframe time to the animation
 
void update_frame_info (float time)
 fills out m_frame_info using a given time More...
 
const FrameInfoget_frame_info () const
 returns the current FrameInfo More...
 
const bfloat2_tpixels () const
 returns this objects drawable area in raw pixels
 
const bfloat2_tarea () const
 returns this objects drawable area as a ratio of the parents drawable area
 
bfloat2_tarea ()
 returns this objects drawable area as a ratio of the parents drawable area
 
Stylestyle () noexcept
 returns modifiable current style
 
const float & time_span () const
 returns time span of the animation
 
virtual void dispatch (BackendSVG &file, float time)=0
 
virtual void dispatch (BackendSVG &file)=0
 
template<typename AnimatedBackend >
void draw (AnimatedBackend &backend)
 draw this object using the given AnimatedBackend
 
template<typename Backend >
void draw (Backend &backend, float time)
 draw this object using the given Backend
 

Additional Inherited Members

- Protected Attributes inherited from trase::Drawable
std::vector< std::shared_ptr< Drawable > > m_children
 a list of Drawables that are children of this object
 
Drawablem_parent
 parent of this object
 
bfloat2_t m_area
 the area of this object as a ratio of its parent object
 
bfloat2_t m_pixels
 the area of this object in raw pixels (updated by resize())
 
float m_time_span
 the animation time span (see update_time_span())
 
std::vector< float > m_times
 the animation frame times (see add_frame_time())
 
FrameInfo m_frame_info
 stores information on the current draw time (see update_frame_info())
 
Style m_style
 fully styling information for each drawable
 

Detailed Description

An 2D axis that can contain zero or more Geometry objects.

Each axis stores minimum and maximum limits for each Aesthetic, these are used to both set the ticks displayed on the x and y axis, and to scale the drawn Geometry objects (how each Geometry is scaled depends on the specifics of the Geometry used). Each time a new Geometry is added to the Axis, it updates these limits using the limits of the its DataWithAestheic.

TODO: issue #87, the name of the Geometry class will probably change to Geometry in the future

An Axis can optionally contain:

  • a title
  • a label for the x axis
  • a label for the y axis
  • a legend that identifies each Geometry

Constructor & Destructor Documentation

◆ Axis()

trase::Axis::Axis ( Drawable parent,
const bfloat2_t area 
)

create a new Axis contained in the given Figure

Parameters
figurethe parent object
areathe drawable area assigned to this Drawable as a ratio of the parent size

Member Function Documentation

◆ histogram()

std::shared_ptr< Geometry > trase::Axis::histogram ( const DataWithAesthetic data,
const Transform transform = Transform(BinX()) 
)

Create a new histogram and return a shared pointer to it.

Parameters
datathe DataWithAesthetic dataset to use
transform(optional) the transform to apply
Returns
shared pointer to the new plot

◆ line()

std::shared_ptr< Geometry > trase::Axis::line ( const DataWithAesthetic data,
const Transform transform = Transform(Identity()) 
)

Create a new Line and return a shared pointer to it.

Parameters
datathe DataWithAesthetic dataset to use
transform(optional) the transform to apply
Returns
shared pointer to the new plot

◆ plot()

std::shared_ptr< Geometry > trase::Axis::plot ( int  n)

Return a shared pointer to an existing plot.

Throws std::out_of_range exception if out of range.

Parameters
nthe plot to return
Returns
a shared pointer to the nth plot

◆ points()

std::shared_ptr< Geometry > trase::Axis::points ( const DataWithAesthetic data,
const Transform transform = Transform(Identity()) 
)

Create a new Points plot and return a shared pointer to it.

Parameters
datathe DataWithAesthetic dataset to use
transform(optional) the transform to apply
Returns
shared pointer to the new plot

◆ rectangle()

std::shared_ptr< Geometry > trase::Axis::rectangle ( const DataWithAesthetic data,
const Transform transform = Transform(Identity()) 
)

Create a new Rectangle plot and return a shared pointer to it.

Parameters
datathe DataWithAesthetic dataset to use
transform(optional) the transform to apply
Returns
shared pointer to the new plot

◆ set_ticks()

void trase::Axis::set_ticks ( Vector< int, 2 >  arg)
inline

set the number of ticks on this axis

Parameters
arga length 2 int vector with the requested number of ticks along each axis (i.e. [x_ticks,y_ticks]). Setting the number of ticks on either axis to zero uses the default number of ticks

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