ofxOui - UI Components for OpenFrameworks

Classes | Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
ofxOui::Graph Class Reference

2D Graph Area (with virtual coordinate system) More...

#include <ofxOuiGraph.hpp>

Collaboration diagram for ofxOui::Graph:
[legend]

Classes

struct  Bounds
 Bounds of the graph space. More...
 
class  BoundsChangedEvent
 Event arguments for pan/zoom events resulting in bounds changes of the graph area. More...
 
class  Ruler
 

Public Member Functions

 Graph ()
 Default Constructor. More...
 
 ~Graph ()
 Destructor. More...
 
void drawRuler ()
 
void setupViewport ()
 
void restoreViewport ()
 
template<typename T , typename args , class ListenerClass >
void onBoundsChanged (T *owner, void(ListenerClass::*listenerMethod)(args))
 Set callback function for bounds changed events. More...
 
bool insideViewArea (ofVec2f const &pointAsPixels) const
 Checks if a point is in the view area. More...
 
bool insideGraphArea (ofVec2f const &pointAsCoord) const
 Checks if a point is in the graph area. More...
 
ofVec2f coord2pix (ofVec2f const &pointAsCoord) const
 Convert graph coordinates to pixel coordinates. More...
 
ofVec2f pix2coord (ofVec2f const &pointAsPixels) const
 Convert pixel coordinates to graph coordinates. More...
 
ofVec2f scale2view (ofVec2f const &scaleAsCoord) const
 Scale graph units to pixel units. More...
 
ofVec2f scale2graph (ofVec2f const &scaleAsPixels) const
 Scale pixel units to graph units. More...
 

Public Attributes

ofRectangle view
 View area rectangle (in pixels) More...
 
Bounds graph_area
 Bounds of the graph space. More...
 
bool iso_zoom = true
 
std::pair< bool, Rulerhorizontal_ruler = {true, {}}
 
std::pair< bool, Rulervertical_ruler = {true, {Ruler::Layout::Vertical}}
 

Protected Member Functions

void mouseScrolled (ofMouseEventArgs &e)
 

Protected Attributes

std::function< void(Graph::BoundsChangedEvent &)> bounds_changed_event_callback_
 
bool viewport_valid = false
 

Detailed Description

2D Graph Area (with virtual coordinate system)

Constructor & Destructor Documentation

§ Graph()

ofxOui::Graph::Graph ( )

Default Constructor.

§ ~Graph()

ofxOui::Graph::~Graph ( )

Destructor.

Member Function Documentation

§ coord2pix()

ofVec2f ofxOui::Graph::coord2pix ( ofVec2f const &  pointAsCoord) const

Convert graph coordinates to pixel coordinates.

Parameters
pointAsCoord2D coordinates (in graph units)
Returns
2D coordinates (in pixels)

§ drawRuler()

void ofxOui::Graph::drawRuler ( )

§ insideGraphArea()

bool ofxOui::Graph::insideGraphArea ( ofVec2f const &  pointAsCoord) const

Checks if a point is in the graph area.

Parameters
pointAsCoord2D coordinates (in graph units)
Returns
true if the point is in the graph area

§ insideViewArea()

bool ofxOui::Graph::insideViewArea ( ofVec2f const &  pointAsPixels) const

Checks if a point is in the view area.

Parameters
pointAsPixels2D coordinates (in pixels)
Returns
true if the point is in the view area

§ mouseScrolled()

void ofxOui::Graph::mouseScrolled ( ofMouseEventArgs &  e)
protected

§ onBoundsChanged()

template<typename T , typename args , class ListenerClass >
void ofxOui::Graph::onBoundsChanged ( T *  owner,
void(ListenerClass::*)(args)  listenerMethod 
)
inline

Set callback function for bounds changed events.

Parameters
ownerpointer to the owner object
listenerMethodmethod to be called on eaech event
Template Parameters
Ttype of the owner object
argsarguments of the callback function
ListenerClassclass to which the listener method belongs

§ pix2coord()

ofVec2f ofxOui::Graph::pix2coord ( ofVec2f const &  pointAsPixels) const

Convert pixel coordinates to graph coordinates.

Parameters
pointAsPixels2D coordinates (in pixels)
Returns
2D coordinates (in graph units)

§ restoreViewport()

void ofxOui::Graph::restoreViewport ( )

§ scale2graph()

ofVec2f ofxOui::Graph::scale2graph ( ofVec2f const &  scaleAsPixels) const

Scale pixel units to graph units.

Parameters
scaleAsPixelsscale in pixel units
Returns
scale in graph units

§ scale2view()

ofVec2f ofxOui::Graph::scale2view ( ofVec2f const &  scaleAsCoord) const

Scale graph units to pixel units.

Parameters
scaleAsCoordscale in graph units
Returns
scale in pixel units

§ setupViewport()

void ofxOui::Graph::setupViewport ( )

Member Data Documentation

§ bounds_changed_event_callback_

std::function<void(Graph::BoundsChangedEvent&)> ofxOui::Graph::bounds_changed_event_callback_
protected

§ graph_area

Bounds ofxOui::Graph::graph_area

Bounds of the graph space.

§ horizontal_ruler

std::pair<bool, Ruler> ofxOui::Graph::horizontal_ruler = {true, {}}

§ iso_zoom

bool ofxOui::Graph::iso_zoom = true

§ vertical_ruler

std::pair<bool, Ruler> ofxOui::Graph::vertical_ruler = {true, {Ruler::Layout::Vertical}}

§ view

ofRectangle ofxOui::Graph::view

View area rectangle (in pixels)

§ viewport_valid

bool ofxOui::Graph::viewport_valid = false
protected

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