trase
trase::Drawable Class Referenceabstract

Base class for drawable objects in a figure. More...

#include <Drawable.hpp>

Inheritance diagram for trase::Drawable:
Collaboration diagram for trase::Drawable:

Public Member Functions

 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
 

Protected Attributes

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

Base class for drawable objects in a figure.

A figure consists of a tree structure of Drawable objects, with the Figure object at the top of the tree. Each Drawable in the tree has a parent Drawable and zero or more child Drawables.

Each Drawable is given a size as a ratio of its parents size, so that resizing of the entire tree can be done easily.

Each Drawable also has a set of times at which animation frames are defined and, given a time, can calculate where this time sits in the list of frames

Finally, each Drawable has functions for drawing itself, given a Backend as a templated argument. These are overridden in derived classes (but can't be virtual as they are templated on the Backend type). Instead, each draw function is implemented in a header file ending in *Draw.hpp (e.g. AxisDraw.hpp), and included when compiling each Backend

Constructor & Destructor Documentation

◆ Drawable()

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

Parameters
parentthe parent object
area_of_parentthe drawable area assigned to this Drawable as a ratio of the parent size

Member Function Documentation

◆ get_frame_info()

const FrameInfo & trase::Drawable::get_frame_info ( ) const

returns the current FrameInfo

See also
update_frame_info()

◆ update_frame_info()

void trase::Drawable::update_frame_info ( float  time)

fills out m_frame_info using a given time

See also
get_frame_info()

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