proj home

Files   Classes   Functions   Hierarchy  

Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
gobjContainer Class Reference

Composite container of graphics objects. More...

#include <gobjbase.h>

Inheritance diagram for gobjContainer:
Inheritance graph
Collaboration diagram for gobjContainer:
Collaboration graph

Public Member Functions

void set ()
 Make the current container the container where all the global graphics is written to.
void globalpush ()
 Store the previous container and make this container the global graphics stream.
 gobjContainer ()
 Memory management enabled by default.
 gobjContainer (boolc cleanup_)
 Graphics objects optionally deleted.
 ~gobjContainer ()
 Destructor.
void nuke ()
 Empties container, deleting if cleanup is true.
boolc kill (uintc k)
 Sets vg[k] to 0.
boolc kill (gobj *const targ)
 Set vg[k] to 0.
void draw ()
 Draws vg[i].
void push (gobj *g)
 Add graphics objects to vg.
template<class T >
void pushcallback (T &data_, void(T::*fn_)())
 Add a callback function.
gobjglCallList< GLuint > * displaylistcreatenew (uint id)
 Compile the list of graphics to a display list.
void displaylist (uintc id)
 Convert this graphics list into a display list.
- Public Member Functions inherited from gobj
virtual ~gobj ()
 Destructor.

Static Public Member Functions

static void globalpop ()
 Restore the previous graphics stream.
- Static Public Member Functions inherited from gobj
static void globaldisplaylist (uintc id)
 Convert the global graphics into a display list.

Public Attributes

vector< gobj * > vg
 Public for the client to access all the graphics.
bool cleanup
 Default true to delete vg[i].

Static Public Attributes

static vector< gobjContainer * > globalvec
 Push and pop the graphic context/stream.
- Static Public Attributes inherited from gobj
static gobjContainerglobal = 0
 The graphics stream.

Detailed Description

Composite container of graphics objects.

The client adds the graphics objects to the container through push(gobj*).

Very simple pointer memory management is supported with nuke() and the destructor calling delete() on the pointers. By default it is assumed that objects pushed are contructed from new operator and are memory managed by this class.

If cleanup is set to false (explicityly or at construction time) then this class assumes the graphics pointers are managed outside of this class.

There is a global graphics pointer which is like a universal graphics stream. Clients write to the container by pushing back gobj's. This can be used to pass geometry as well as a storage place for the gobj's to be evaluated at a later date.

Definition at line 171 of file gobjbase.h.

Constructor & Destructor Documentation

gobjContainer::gobjContainer ( )

Memory management enabled by default.

Definition at line 91 of file gobjbase.cpp.

Referenced by protractor::addAxes(), and protractor::addCircles().

: cleanup(true)
{
};
gobjContainer::gobjContainer ( boolc  cleanup_)

Graphics objects optionally deleted.

Definition at line 96 of file gobjbase.cpp.

: cleanup(cleanup_)
{
}
gobjContainer::~gobjContainer ( )

Destructor.

Definition at line 117 of file gobjbase.cpp.

References nuke().

{
nuke();
}

Member Function Documentation

void gobjContainer::displaylist ( uintc  id)

Convert this graphics list into a display list.

This destroys and realizes the current geometry and is a non reversible operation. cleanup is set to true. The id is the compiled lists id.

Definition at line 44 of file gobjbase.cpp.

References cleanup, displaylistcreatenew(), nuke(), push(), and vg.

Referenced by gobj::globaldisplaylist(), quickhull2Dtest::test02(), snakesorttest::test02(), and snakesorttest::test03().

{
if (vg.empty())
return;
nuke();
cleanup=true;
push(x);
}
gobjglCallList< GLuint > * gobjContainer::displaylistcreatenew ( uint  id)

Compile the list of graphics to a display list.

The new operator called so the client owns the object.

Definition at line 18 of file gobjbase.cpp.

Referenced by displaylist().

{
GLuint listName = glGenLists(id);
new gobjglCallList<GLuint>(listName);
glNewList(listName,GL_COMPILE);
draw();
glEndList();
return gcl;
}
void gobjContainer::draw ( )
virtual

Draws vg[i].

Implements gobj.

Reimplemented in gobjContainerPrePost, tessD1draw01simplexindexes< TESS, PT >, tessD1draw01linesmulticolor< TESS, PT >, tessD1draw01lines< TESS, PT >, tessD1draw01points< TESS, PT >, pathlinesegdraw, and tessD2draw02points< TESS, PT >.

Definition at line 55 of file gobjbase.cpp.

References GOBJDEBUGCODE, and vg.

Referenced by test06::display(), menusystemtest01::display(), test05::display(), menusystemtest02::display(), menusystemtest04::display(), d2simplextest::display(), bsptree001::display(), visenv::display(), simplexD1tessapp01::display(), test07::display(), menusystemtest03::display(), test01obj< P, PD >::display(), display(), polytopesD2linkedtest::display01(), regionD2linkedtest::display01(), quickhull2Dtest::display01(), plotpolartest::display01(), tetrahedrontest::display01(), spiralindextest::display01(), helixtestscope::helixtest::display01(), maze002::display01(), maze003::display01(), triangletest::display01(), pathlinesegtest::display01(), gobjtest::display01(), diskinttest::display01(), maze004::display01(), circleD2test::display01(), boxOBBhalfspaceD2test::display01(), buttonpanel01test::display01(), maze001::display01(), menusystemtest::display01(), snakesorttest::display01(), graphicsImmediateDeferredTest::display01(), maze005::display01(), delaunaysimpleD2test::display01(), cubegui::display01(), simplexD2tessapp01::display01(), triangles3Tdisplaytest::display01(), quickhull3Dtest::display01(), display01(), menusystemtest::display02(), partitionstest::display02(), display02(), arcdraw::draw(), pathlinesegdraw::draw(), graphicsImmediateDeferred::draw(), d3tessdraw::draw(), menusystem::draw(), pointsgraph_axes_circle::draw(), gobjContainerPrePost::draw(), meshpatchtestdisplay01(), planeinttestdisplay01(), pointsurfacetestdisplay01(), gobjdebug01test::test01(), gobjdebug01test::test02(), gobjdebug01test::test03(), and graphicsImmediateDeferred::update().

{
if (vg.empty())
return;
for (uint i=0; i<vg.size(); ++i)
vg[i]->draw();
}
void gobjContainer::globalpop ( )
static

Restore the previous graphics stream.

Definition at line 8 of file gobjbase.cpp.

References globalvec.

Referenced by graphicsImmediateDeferredTestTri::graphicscreate03(), and gobjGlobal::~gobjGlobal().

{
assert(globalvec.empty()==false);
globalvec[globalvec.size()-1];
globalvec.pop_back();
}
void gobjContainer::globalpush ( )
inline

Store the previous container and make this container the global graphics stream.

Definition at line 185 of file gobjbase.h.

References gobj::global.

Referenced by gobjGlobal::gobjGlobal(), and graphicsImmediateDeferredTestTri::graphicscreate03().

{ globalvec.push_back( gobj::global); set(); }
boolc gobjContainer::kill ( uintc  k)

Sets vg[k] to 0.

Useful for mixed memory situations.

Definition at line 66 of file gobjbase.cpp.

References vg.

{
assert(k<vg.size());
if (k>=vg.size())
return false;
vg[k]=0;
return true;
}
boolc gobjContainer::kill ( gobj *const  targ)

Set vg[k] to 0.

O(N) complexity.

Definition at line 76 of file gobjbase.cpp.

References vg.

{
uint imax=vg.size();
for (uint i=0; i<imax; ++i)
{
if (vg[i]==targ)
{
vg[i]=0;
return true;
}
}
return false;
}
void gobjContainer::nuke ( )

Empties container, deleting if cleanup is true.

Definition at line 101 of file gobjbase.cpp.

References cleanup, and vg.

Referenced by pointsurface< T, G >::addsurface2D(), pointsurface< T, G >::addsurface3D(), displaylist(), test07::keyboard(), d4tessdraw::meshupdate(), pointgrid3Ddraw::update(), arcdraw::update(), cpsphere::update(), pointgrid3Dbilineardraw::update(), graphicsImmediateDeferred::update(), pointsgraph_axes_circle::update(), and ~gobjContainer().

{
if (!cleanup)
{
vg.clear();
return;
}
for (uint i=0; i<vg.size(); ++i)
{
delete vg[i];
vg[i] = 0;
}
vg.clear();
}
void gobjContainer::push ( gobj g)
inline

Add graphics objects to vg.

Definition at line 216 of file gobjbase.h.

Referenced by ruler::addAngleRuler(), protractor::addAxes(), protractor::addCircles(), protractor::addCirclesText(), plotpolar::addcrosses(), menusystem::addfont10(), menusystem::addfont10start(), menusystem::addfont12(), menusystem::addfont12start(), addpointinsidemesh(), plotpolar::addpoints(), addrandompointtomesh(), graphicsImmediateDeferredTestTri::addshape01(), graphicsImmediateDeferredTestTri::addshape02(), ruler::addStraightRuler(), pointsurface< T, G >::addsurface2D(), pointsurface< T, G >::addsurface3D(), simplexD1tessapp01::createdisplay(), d2simplextest::d2simplextest(), tetrahedrondraw< T, D >::displaybase(), tetrahedrondraw< T, D >::displayedges(), displaylist(), tetrahedrondraw< T, D >::displaywinding(), tessD2draw02points< TESS, PT >::draw(), tessD1draw01points< TESS, PT >::draw(), tessD2draw02simplexindex< TESS, PT, INDX >::draw(), writepointsobj::draw(), tessD1draw01lines< TESS, PT >::draw(), tessD2draw02multicolor< TESS, PT, INDX >::draw(), tessD1draw01linesmulticolor< TESS, PT >::draw(), writesimplicesobj::draw(), tessD1draw01simplexindexes< TESS, PT >::draw(), tessD2draw02circles< TESS, PT, INDX >::draw(), writemulticolorobj::draw(), writevoronoidiagramobj::draw(), polytopeD2tessdisp01< VPTS, VPOLY >::eval(), tessD2disp01< PT >::eval(), graphicsImmediateDeferredTestTri::graphicscreate02(), test07::keyboard(), pointsdisplay2D< T >::pointsdisplay2D(), pointsdisplay3D< T >::pointsdisplay3D(), pointsurface< T, G >::pointsurface(), pointsgraph_axes_circle::push(), graphicsImmediateDeferredSwitch::pushimmediate(), planeinttest::test01(), gobjdebug01test::test01(), pointsurfacetest::test01(), diskinttest::test01(), plotpolartest::test01(), gobjdebug01test::test02(), pointsurfacetest::test02(), simplexD2tessapp01::test02(), delaunaysimpleD2test::test02(), test02(), gobjdebug01test::test03(), pointsurfacetest::test03(), test03(), treeindexedD2test::test05(), test05(), partitionstest::test06(), pointgrid3Ddraw::update(), arcdraw::update(), cpsphere::update(), pointgrid3Dbilineardraw::update(), and writearcgeometry().

{ assert(g!=0); vg.push_back(g); }
template<class T >
void gobjContainer::pushcallback ( T data_,
void(T::*)()  fn_ 
)
inline

Add a callback function.

Definition at line 220 of file gobjbase.h.

Referenced by graphicsImmediateDeferredTestTri::graphicscreate07().

{ push(new gobjcallback<T>(data_,fn_)); }
void gobjContainer::set ( )
inline

Make the current container the container where all the global graphics is written to.

Definition at line 177 of file gobjbase.h.

References gobj::global.

Referenced by bsptree001::bsptree001(), buttonpanel01test::buttonpanel01test(), d2simplextest::d2simplextest(), visenv::defaultgraphics(), tessD2draw02multicolor< TESS, PT, INDX >::draw(), test06::eval(), test05::eval(), test07::eval(), test01obj< P, PD >::eval(), main(), maze001::maze001(), maze002::maze002(), maze003::maze003(), maze004::maze004(), maze005::maze005(), menusystemtest01::menusystemtest01(), menusystemtest02::menusystemtest02(), menusystemtest03::menusystemtest03(), menusystemtest04::menusystemtest04(), d3tessdraw::meshupdate(), openwindowresource::openwindowresource(), pathlinesegtest::pathlinesegtest(), cubegui::prog01(), simplexD1tessapp01::simplexD1tessapp01(), gobjtest::test001(), graphmisctest::test002(), gobjtest::test002(), windowscaleD2test::test002(), gobjtest::test003(), helixtestscope::helixtest::test01(), planeinttest::test01(), tetrahedrontest::test01(), pointsurfacetest::test01(), diskinttest::test01(), triangles3Tdisplaytest::test01(), plotpolartest::test01(), boxOBBhalfspaceD2test::test01(), circleD2test::test01(), menusystemtest::test01(), graphicsImmediateDeferredTest::test01(), delaunaysimpleD2test::test01(), quickhull3Dtest::test01(), test01obj< P, PD >::test01obj(), meshpatchtest::test02(), helixtestscope::helixtest::test02(), tetrahedrontest::test02(), regionD2linkedtest::test02(), polytopesD2linkedtest::test02(), quickhull2Dtest::test02(), pointsurfacetest::test02(), triangles3Tdisplaytest::test02(), diskinttest::test02(), spiralindextest::test02(), snakesorttest::test02(), graphicsImmediateDeferredTest::test02(), menusystemtest::test02(), simplexD2tessapp01::test02(), delaunaysimpleD2test::test02(), test02(), meshpatchtest::test03(), helixtestscope::helixtest::test03(), regionD2linkedtest::test03(), polytopesD2linkedtest::test03(), pointsurfacetest::test03(), diskinttest::test03(), triangles3Tdisplaytest::test03(), snakesorttest::test03(), graphicsImmediateDeferredTest::test03(), treeindexedD2test::test03(), test03(), meshpatchtest::test04(), polytopesD2linkedtest::test04(), triangles3Tdisplaytest::test04(), spiralindextest::test04(), graphicsImmediateDeferredTest::test04(), triangles3Tdisplaytest::test05(), graphicsImmediateDeferredTest::test05(), treeindexedD2test::test05(), quickhull2Dtest::test06(), graphicsImmediateDeferredTest::test06(), partitionstest::test06(), graphicsImmediateDeferredTest::test07(), and graphicsImmediateDeferred::update().

{ gobj::global = this; }

Member Data Documentation

bool gobjContainer::cleanup

Default true to delete vg[i].

Definition at line 195 of file gobjbase.h.

Referenced by displaylist(), nuke(), and gobjContainerSwitch::push().

vector< gobjContainer * > gobjContainer::globalvec
static

Push and pop the graphic context/stream.

Definition at line 181 of file gobjbase.h.

Referenced by globalpop().

vector<gobj*> gobjContainer::vg

Public for the client to access all the graphics.

Definition at line 192 of file gobjbase.h.

Referenced by displaylist(), draw(), graphicsImmediateDeferredTestTri::graphicscreate03(), kill(), nuke(), gobjContainerSwitch::nuke(), and gobjContainerSwitch::push().


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