Classes | Namespaces | Modules | Typedefs | Enumerations | Enumerator | Functions | Variables

Vector Graphics Engine

vgfx is the Vector Graphics Engine. More...

Collaboration diagram for Vector Graphics Engine:


class  vgfx::Drawer
 Clients must implement this if they want to draw. More...
class  vgfx::Request
 used to easily construct vgfx Requests More...
struct  vgfx::visit_result_t
 hit detection results More...
class  vgfx::Primitive
 the base class from which all vector graphics objects inherit. More...
class  vgfx::ObjectMap
 an ObjectMap is a physical manifestation of a vector graphics 2D area. More...
struct  vgfx::init_primitive_t
struct  vgfx::init_point_t
struct  vgfx::init_bezier_t
struct  vgfx::init_rect_t
struct  vgfx::init_line_t
struct  vgfx::init_dxdy_t
struct  vgfx::init_quad_t
struct  vgfx::init_text_t


namespace  vgfx


 vgfx Request Format

This is a description of the vector graphics engine request format.


typedef point2d_t< float > vgfx::point_t
typedef rect2d_t< float > vgfx::rect_t
typedef bool(* vgfx::callback_t )(void *context, visit_result_t &result)


enum  vgfx::eHitDetect {
  vgfx::eHit_Overlap = 1,
  vgfx::eHit_Contained = 2,
  vgfx::eHit_Always = 3,
  vgfx::eHit_Invalid = 0

hit detection results



void vgfx::visit_result_t::clear (void) throw ()
virtual vgfx::Primitive::~Primitive (void) throw ()
virtual long vgfx::Primitive::getRefCount (void) const throw ()
virtual void vgfx::Primitive::incrementRefCount (void) throw ()
virtual void vgfx::Primitive::decrementRefCount (void) throw ()
virtual const char * vgfx::Primitive::getID (void) const throw ()
virtual void vgfx::Primitive::setID (const char *id)
virtual const char * vgfx::Primitive::getType (void) const =0 throw ()
virtual void vgfx::Primitive::persist (std::ostream &stream) const =0
virtual void vgfx::Primitive::listContainers (const VecString &path, VecString &ids) const
virtual bool vgfx::Primitive::doesContainerExist (const VecString &path) const
virtual bool vgfx::Primitive::canCreateContainer (const VecString &path) const
virtual void vgfx::Primitive::removeContainer (const VecString &path)
virtual void vgfx::Primitive::getContainerDictionary (const VecString &path, dictionary_t &data) const
virtual void vgfx::Primitive::setContainerDictionary (const VecString &path, const dictionary_t &data)
virtual void vgfx::Primitive::recalcBoundingRect (const char *tag_path, Drawer *drawer, const xform_2d_t &T)=0
virtual bool vgfx::Primitive::getBoundingRect (rect_t &r) const =0 throw ()
virtual bool vgfx::Primitive::getPrimitive (const char *tag_path, const xform_2d_t &T, visit_result_t &vr)
virtual void vgfx::Primitive::draw (Drawer *drawer, const rect_t &r_pix, const xform_2d_t &T)=0
 draw this primitive and all children, recursively
virtual bool vgfx::Primitive::visit (const rect_t &r, const xform_2d_t &T, const char *tag_path, callback_t callback, void *context, eHitDetect hit)
static smart_ptr< Primitive > vgfx::Primitive::create (const char *type, const dictionary_t &data)
virtual long vgfx::ObjectMap::size (void) const =0 throw ()
virtual void vgfx::ObjectMap::newObjectID (const char *prefix, std::string &id)=0
virtual void vgfx::ObjectMap::addObject (smart_ptr< Primitive > &primitive)=0
virtual Primitive * vgfx::ObjectMap::findObject (const char *ID) const =0 throw ()
virtual smart_ptr< Primitive > vgfx::ObjectMap::removeObject (const char *ID)=0
static smart_ptr< ObjectMap > vgfx::ObjectMap::create (void)
bool vgfx::processRequest (ObjectMap *map,std::istream &stream,bool single_transaction,std::string &undo_request,std::string &diagnostic)
 Request that an ObjectMap be updated with the given request.
void vgfx::invokeFunction (Primitive *in_function, ObjectMap *map, const dictionary_t &in_params, std::ostream &out)
Primitive * vgfx::addFunctionFromPath (ObjectMap *map, const char *path)
void vgfx::setScript (ObjectMap *map, const char *parent_id, const char *script_id, const objtree::property_set_t &pset_def, std::ostream &stream, std::string &root)
void vgfx::updateScriptParameters (ObjectMap *map, const char *parent_id, const objtree::property_set_t &pset, std::ostream &stream)
void vgfx::resizeScript (ObjectMap *map, const char *parent_id, float width, float height, std::ostream &stream)
template<class T >
std::string vgfx::getStringValue (const T &t)
void vgfx::init_point_from_data (const dictionary_t &data, init_point_t &)
smart_ptr< Primitive > vgfx::create_point (const init_point_t &)
void vgfx::init_bezier_from_data (const dictionary_t &data, init_bezier_t &init)
smart_ptr< Primitive > vgfx::create_bezier (const init_bezier_t &init)
void vgfx::init_rect_from_data (const dictionary_t &data, init_rect_t &init)
smart_ptr< Primitive > vgfx::create_rect (const init_rect_t &init)
void vgfx::init_line_from_data (const dictionary_t &data, init_line_t &init)
smart_ptr< Primitive > vgfx::create_line (const init_line_t &init)
void vgfx::init_dxdy_from_data (const dictionary_t &data, init_dxdy_t &)
smart_ptr< Primitive > vgfx::create_dxdy (const init_dxdy_t &)
void vgfx::init_quad_from_data (const dictionary_t &data, init_quad_t &init)
smart_ptr< Primitive > vgfx::create_quad (const init_quad_t &init)
smart_ptr< Primitive > vgfx::parseGroup (std::istream &stream, ObjectMap *map)
smart_ptr< Primitive > vgfx::parseFunction (std::istream &stream, ObjectMap *map)
void vgfx::init_text_from_data (const dictionary_t &data, init_text_t &init)
smart_ptr< Primitive > vgfx::create_text (const init_text_t &init)


Primitive * vgfx::visit_result_t::p
const char * vgfx::visit_result_t::tag_path
xform_2d_t vgfx::visit_result_t::T
long vgfx::Primitive::m_refcount
std::string vgfx::Primitive::m_id
float vgfx::init_point_t::y0
bool vgfx::init_rect_t::fill
float vgfx::init_line_t::y0
float vgfx::init_line_t::x1
float vgfx::init_line_t::y1
float vgfx::init_dxdy_t::dy

enum  vgfx::eBrushAttribute {
  vgfx::eBrush_PenColor = 1,
  vgfx::eBrush_FillColor = 2,
  vgfx::eBrush_PenThickness = 3,
  vgfx::eBrush_Font = 50,
  vgfx::eBrush_TextFlags = 60,
  vgfx::eBrush_Invalid = 0

Detailed Description

vgfx is the Vector Graphics Engine.

It exists to represent the logical model of nested, transformed 2D shapes.

The library is heavily optimized for two use cases:

In particular, the library doesn't try to be particularly fast on writes. It is more concerned with correctness (of course), and with constructing a rollback request for internal and external use.

Because any write operation returns a corresponding rollback request, it is easy for calling applications to set up an undo/redo stack.

The request language is intended to be human-readable and easy for applications to generate on the fly. Think of something like SQL updates.

Queries are focused on either lookups by object ID, or lookups based on a 2D rectangle. Reads (queries) are intended to be fast so the engine can be used in a real-time rendering application.

Typical client usage is:

If you want to draw any of this:

Keep in mind: an ObjectMap isn't actually a canvas! Think of it as a big registry of objects which you can look up by name (ID). And objects can reference each other by their IDs.

To draw something, you have to provide an object to draw. Typically an application will create a bunch of objects in the ObjectMap, and then put everything visible under a known root group object. For display, the application will call draw() on the root group object. (To do this, the application will have to create an object that implements the Drawer interface, and then call vgfx::Primitive::draw() on the root group object).

Other descriptions of vgfx (mostly for search engines):

Typedef Documentation

typedef point2d_t<float> vgfx::point_t

Definition at line 116 of file vgfx.h.

typedef rect2d_t<float> vgfx::rect_t

Definition at line 117 of file vgfx.h.

typedef bool(* vgfx::callback_t)(void *context,visit_result_t &result)

Definition at line 151 of file vgfx.h.

Enumeration Type Documentation


Definition at line 46 of file vgfx/drawer.h.

hit detection results

  • rects overlap at all
  • counts as a hit only if contained
  • ignore rect, always hit

Definition at line 124 of file vgfx.h.

Function Documentation

void vgfx::visit_result_t::clear ( void   )  throw () [inline, inherited]

Definition at line 138 of file vgfx.h.

vgfx::Primitive::~Primitive ( void   )  throw () [virtual, inherited]

Definition at line 53 of file vgfx.cpp.

virtual long vgfx::Primitive::getRefCount ( void   )  const throw () [inline, virtual, inherited]

Definition at line 163 of file vgfx.h.

virtual void vgfx::Primitive::incrementRefCount ( void   )  throw () [inline, virtual, inherited]

Definition at line 164 of file vgfx.h.

virtual void vgfx::Primitive::decrementRefCount ( void   )  throw () [inline, virtual, inherited]

Definition at line 169 of file vgfx.h.

const char * vgfx::Primitive::getID ( void   )  const throw () [virtual, inherited]

Definition at line 64 of file vgfx.cpp.

void vgfx::Primitive::setID ( const char *  id  )  [virtual, inherited]

Definition at line 75 of file vgfx.cpp.

virtual const char* vgfx::Primitive::getType ( void   )  const throw () [pure virtual, inherited]
virtual void vgfx::Primitive::persist ( std::ostream &  stream  )  const [pure virtual, inherited]
void vgfx::Primitive::listContainers ( const VecString path,
VecString ids 
) const [virtual, inherited]

Definition at line 87 of file vgfx.cpp.

bool vgfx::Primitive::doesContainerExist ( const VecString path  )  const [virtual, inherited]

Definition at line 101 of file vgfx.cpp.

bool vgfx::Primitive::canCreateContainer ( const VecString path  )  const [virtual, inherited]

Definition at line 113 of file vgfx.cpp.

void vgfx::Primitive::removeContainer ( const VecString path  )  [virtual, inherited]

Definition at line 125 of file vgfx.cpp.

void vgfx::Primitive::getContainerDictionary ( const VecString path,
dictionary_t data 
) const [virtual, inherited]

Definition at line 138 of file vgfx.cpp.

void vgfx::Primitive::setContainerDictionary ( const VecString path,
const dictionary_t data 
) [virtual, inherited]

Definition at line 153 of file vgfx.cpp.

virtual void vgfx::Primitive::recalcBoundingRect ( const char *  tag_path,
Drawer drawer,
const xform_2d_t T 
) [pure virtual, inherited]
virtual bool vgfx::Primitive::getBoundingRect ( rect_t r  )  const throw () [pure virtual, inherited]
bool vgfx::Primitive::getPrimitive ( const char *  tag_path,
const xform_2d_t T,
visit_result_t vr 
) [virtual, inherited]

Definition at line 181 of file vgfx.cpp.

void vgfx::Primitive::draw ( Drawer drawer,
const rect_t r_pix,
const xform_2d_t T 
) [pure virtual, inherited]

draw this primitive and all children, recursively

Definition at line 167 of file vgfx.cpp.

bool vgfx::Primitive::visit ( const rect_t r,
const xform_2d_t T,
const char *  tag_path,
callback_t  callback,
void *  context,
eHitDetect  hit 
) [virtual, inherited]

Definition at line 200 of file vgfx.cpp.

smart_ptr< Primitive > vgfx::Primitive::create ( const char *  type,
const dictionary_t data 
) [static, inherited]

Definition at line 244 of file vgfx.cpp.

virtual long vgfx::ObjectMap::size ( void   )  const throw () [pure virtual, inherited]
virtual void vgfx::ObjectMap::newObjectID ( const char *  prefix,
std::string &  id 
) [pure virtual, inherited]
virtual void vgfx::ObjectMap::addObject ( smart_ptr< Primitive > &  primitive  )  [pure virtual, inherited]
virtual Primitive* vgfx::ObjectMap::findObject ( const char *  ID  )  const throw () [pure virtual, inherited]
virtual smart_ptr<Primitive> vgfx::ObjectMap::removeObject ( const char *  ID  )  [pure virtual, inherited]
smart_ptr< ObjectMap > vgfx::ObjectMap::create ( void   )  [static, inherited]

Definition at line 275 of file object_map.cpp.

bool vgfx::processRequest ( ObjectMap *  map,
std::istream &  stream,
bool  single_transaction,
std::string &  undo_request,
std::string &  diagnostic 

Request that an ObjectMap be updated with the given request.

Returns false on failure.

map ObjectMap upon which the request will act.
stream Input text stream containing request. See vgfx Request Format.
single_transaction If true, the request will be handled as an atomic operation and an undo request will be returned. If false, there is no rollback of partial commits. Use true unless you have good reason otherwise.
undo_request On output, this contains a request which will undo the original input request. Handy for undo/redo stacks.
diagnostic If the return value is false, this string will contain some details on output which may be helpful in tracking down what failed.
void vgfx::invokeFunction ( Primitive *  in_function,
ObjectMap *  map,
const dictionary_t in_params,
std::ostream &  out 
Primitive * vgfx::addFunctionFromPath ( ObjectMap *  map,
const char *  path 
void vgfx::setScript ( ObjectMap *  map,
const char *  parent_id,
const char *  script_id,
const objtree::property_set_t pset_def,
std::ostream &  stream,
std::string &  root 
void vgfx::updateScriptParameters ( ObjectMap *  map,
const char *  parent_id,
const objtree::property_set_t pset,
std::ostream &  stream 
void vgfx::resizeScript ( ObjectMap *  map,
const char *  parent_id,
float  width,
float  height,
std::ostream &  stream 
template<class T >
std::string vgfx::getStringValue ( const T &  t  ) 

Definition at line 326 of file vgfx.h.

void vgfx::init_point_from_data ( const dictionary_t data,
init_point_t &   
smart_ptr<Primitive> vgfx::create_point ( const init_point_t &   ) 
void vgfx::init_bezier_from_data ( const dictionary_t data,
init_bezier_t &  init 
smart_ptr< Primitive > vgfx::create_bezier ( const init_bezier_t &  init  ) 
void vgfx::init_rect_from_data ( const dictionary_t data,
init_rect_t &  init 
smart_ptr< Primitive > vgfx::create_rect ( const init_rect_t &  init  ) 
void vgfx::init_line_from_data ( const dictionary_t data,
init_line_t &  init 
smart_ptr< Primitive > vgfx::create_line ( const init_line_t &  init  ) 
void vgfx::init_dxdy_from_data ( const dictionary_t data,
init_dxdy_t &   
smart_ptr<Primitive> vgfx::create_dxdy ( const init_dxdy_t &   ) 
void vgfx::init_quad_from_data ( const dictionary_t data,
init_quad_t &  init 
smart_ptr< Primitive > vgfx::create_quad ( const init_quad_t &  init  ) 
smart_ptr< Primitive > vgfx::parseGroup ( std::istream &  stream,
ObjectMap *  map 
smart_ptr< Primitive > vgfx::parseFunction ( std::istream &  stream,
ObjectMap *  map 
void vgfx::init_text_from_data ( const dictionary_t data,
init_text_t &  init 
smart_ptr< Primitive > vgfx::create_text ( const init_text_t &  init  ) 

Variable Documentation

Primitive* vgfx::visit_result_t::p [inherited]

Definition at line 145 of file vgfx.h.

const char* vgfx::visit_result_t::tag_path [inherited]

Definition at line 146 of file vgfx.h.

Definition at line 147 of file vgfx.h.

long vgfx::Primitive::m_refcount [private, inherited]

Definition at line 216 of file vgfx.h.

std::string vgfx::Primitive::m_id [private, inherited]

Definition at line 217 of file vgfx.h.

float vgfx::init_point_t::y0 [inherited]

Definition at line 357 of file vgfx.h.

bool vgfx::init_rect_t::fill [inherited]

Definition at line 378 of file vgfx.h.

float vgfx::init_line_t::y0 [inherited]

Definition at line 389 of file vgfx.h.

float vgfx::init_line_t::x1 [inherited]

Definition at line 390 of file vgfx.h.

float vgfx::init_line_t::y1 [inherited]

Definition at line 391 of file vgfx.h.

float vgfx::init_dxdy_t::dy [inherited]

Definition at line 402 of file vgfx.h.