arbeit
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

Renderable Class Reference

#include <Renderable.h>

Inheritance diagram for Renderable:

gutz::Counted VolRenBase WidgetItem AnalyticVolRen VolRenCube VolRenLit VolRenSlab EdgeWidget NodeWidget PolygonWidget SurfaceWidget List of all members.

Detailed Description

Renderable.

This is the base class, and a new effect/renderer should sub-class from it.

Please note: this object contains a gutz::Manip smart pointer, when it is constructed (by default) it creates a new manipulator (_manip). USE IT! It is generally assumed that you might want to interact with your object this is why we create one for you. If you just want to interact with your object with the least amout of effort, call setManipEventsDefault() and follow the notes on GL picking (below). If you don't override the mouse() and move() functions then events are automatically forwarded to your Manip. Apply your manip (using OpenGL) like this:

       glPushMatrix();
       {
          glMultMatrixf(_manip->getWorldTransform().m);
          /* ... draw stuff ...*/
       }
       glPopMatrix();
I usually add the "{}" around a glPush/Pop to keep the code neat and the state clear. Don't forget, if you want interaction using openGL, you have to push 2 specific unsigned int "names" on the gl-name-stack.

NOTE on GL picking (gl interaction):
There are 2 strict rules for GL style picking of renderables.
1) push the RENDERABLE_NAME on the gl name stack first
2) push your (Renderable*) pointer onto the stack as an unsigned int
Like this:

      glPushName(RENDERABLE_NAME);
      glPushName((unsigned int)(Renderable *)this);
Item 2 is actually a little tricky. You should ALWAYS cast to Renderable* before casting to unsigned int. This is VERY important if the type you are setting up is polymorphic; the "this" pointer may be incorrect when we cast to "Renderable*" in the UI. If you cast to "Renderable*" first, any ambiguity is resolved and you get the right position in the class for the cast-back in the UI

There is a third rule, but it is obvious:
3) Pop all names that you pushed onto the stack back off when you are done rendering.
Like this:

      glPopName();
      glPopName();  /// plus one pop for each additional name you added
After you are done with items 1 & 2, you can push as much onto the stack as you like (within reason), just be sure you pop it all back off (item 3).

Here is what your draw function might look like if you are using OpenGL, you want interaction, and you are using the _manip for the transformation:

     void draw(const gutz::RenderEvent &re)
     {
       glPushName(RENDERABLE_NAME); 
       glPushName((unsigned int)(Renderable *)this);
       glPushMatrix();
       {
          glMultMatrixf(_manip->getWorldTransform().m);
          /* ... draw your geometry ...*/
       }
       glPopMatrix();
       glPopName();  ///DONT FORGET THESE!!!
       glPopName();
     }

Why is this object "Counted", see gutz::Counted and gutz::SmartPtr for details on what this means.
This object really needs to be counted, since it is usualy the primary interface to renderable objects for any framework that uses them. This may be problematic in situations with polymorphisim in the hierarchy's derivation. Oh well, need to deal with this somehow, I think that this kind of baddness will be rare if you can sepparate the appearance from the behavior/data associated with a renderable object.
NOTE: Please be carefull, you need to make very sure that if a renderable pushes its name on the glName stack for GL style picking, it better have a smartptr to it somewhere, or the object that created it needs to do the reference counting, since the user interface is probably going to keep a smartptr to it too. This can lead to trouble if the user interface's smart pointer calls delete on the object because it has no references, or the objects owner deletes it. This is the classic smart pointer problem; bad things occur when we create objects on the stack, or we create objects that have automatic deletion, like non-smart pointer member variables. See gutz::SmartPtr & gutz::Counted

See also: gutz::RenderEvent, gutz::MouseEvent, gutz::MouseMoveEvent

Definition at line 125 of file Renderable.h.

DRAW!

This is the draw function.

Calling it renders the object. Pure virtual, you must override this function in a subclass.

virtual void draw (const gutz::RenderEvent &rs)=0

Draw on/off.

bool isOn () const
void setOn (bool yes)

Delete.

Does this object need to be removed from a render list? This means that the object is finished and anyone with a smart pointer to it needs to delete the smart pointer and stop using the renderable.

bool needsDelete () const
void setDelete (bool yes)

Interaction Functions

Return true if the event was for you.

By default interaction is forwarded to your protected manipulator (_manip). To use it just apply it in your draw function. However, if you don't add any events or call setManipEventsDefault(), you won't have any interaction. Override these functions in your base class to implement custom behaviors.

virtual bool key (unsigned char k, int x, int y)
virtual bool mouse (const gutz::MouseEvent &me)
virtual bool move (const gutz::MouseMoveEvent &mme)

Selected

Is this object currently selected?

virtual void setSelected (bool yes)
bool isSelected () const

Manipulator Interface

gutz::ManipgetManip () const
void setManip (gutz::Manip *const m)
void setManipEventsDefault ()
 you have to call this to enable default interaction, OR customize the manipulators events yourself.


copy/assign

 Renderable (const Renderable &r)
Renderableoperator= (const Renderable &r)

Public Member Functions

 ~Renderable ()

Protected Member Functions

 Renderable ()
 since this is a base class/interface it cannot be publicly created.

virtual void _incCount ()
 gutz::Counted interface, increment reference count by one.

virtual void _decCount ()
 gutz::Counted interface, decrement reference count by one.

virtual int _getCount () const
 gutz::Counted interface, get the current reference count.


Protected Attributes

bool _on
 is this renderable currently "render-able"?

bool _selected
 is this renderable selected?

bool _deleteMe
 does this object need to be deleted?

gutz::ManipSP _manip
 You get a manipulator free, no charge.


Friends

class SmartPtr
class SmartPtrRef


Constructor & Destructor Documentation

Renderable::~Renderable  )  [inline]
 

Definition at line 127 of file Renderable.h.

Renderable::Renderable  )  [inline, protected]
 

since this is a base class/interface it cannot be publicly created.

Only derived classes can construct this guy.

Definition at line 206 of file Renderable.h.

References _deleteMe, _manip, _on, and _selected.

Renderable::Renderable const Renderable r  )  [inline, protected]
 

Definition at line 217 of file Renderable.h.

References _manip, _on, _selected, and r.


Member Function Documentation

virtual void gutz::Counted::_decCount  )  [inline, protected, virtual, inherited]
 

gutz::Counted interface, decrement reference count by one.

Not generaly used by subclasses, mostly for collaboration with gutz::SmartPtr. Sometimes you need to call this though, see the documentation for gutz::SmartPtr

Definition at line 54 of file smartptr.h.

Referenced by TFImage::clear(), NrroImage::fBlendOverRGBA(), and Nrro::updateMinMax().

virtual int gutz::Counted::_getCount  )  const [inline, protected, virtual, inherited]
 

gutz::Counted interface, get the current reference count.

Not generaly used by subclasses, mostly for collaboration with gutz::SmartPtr.

Definition at line 58 of file smartptr.h.

virtual void gutz::Counted::_incCount  )  [inline, protected, virtual, inherited]
 

gutz::Counted interface, increment reference count by one.

Not generaly used by subclasses, mostly for collaboration with gutz::SmartPtr. Sometimes you need to call this though, see the documentation for gutz::SmartPtr

Definition at line 48 of file smartptr.h.

Referenced by TFImage::clear(), NrroImage::fBlendOverRGBA(), and Nrro::updateMinMax().

virtual void Renderable::draw const gutz::RenderEvent rs  )  [pure virtual]
 

Implemented in VolRenBase, and WidgetItem.

gutz::Manip* Renderable::getManip  )  const [inline]
 

Definition at line 184 of file Renderable.h.

References _manip.

bool Renderable::isOn  )  const [inline]
 

Definition at line 141 of file Renderable.h.

References _on.

bool Renderable::isSelected  )  const [inline]
 

Definition at line 177 of file Renderable.h.

References _selected.

virtual bool Renderable::key unsigned char  k,
int  x,
int  y
[inline, virtual]
 

Definition at line 166 of file Renderable.h.

virtual bool Renderable::mouse const gutz::MouseEvent me  )  [inline, virtual]
 

Reimplemented in WidgetItem.

Definition at line 167 of file Renderable.h.

References _manip.

virtual bool Renderable::move const gutz::MouseMoveEvent mme  )  [inline, virtual]
 

Reimplemented in WidgetItem.

Definition at line 168 of file Renderable.h.

References _manip.

bool Renderable::needsDelete  )  const [inline]
 

Definition at line 152 of file Renderable.h.

References _deleteMe.

Renderable& Renderable::operator= const Renderable r  )  [inline, protected]
 

Definition at line 225 of file Renderable.h.

References _manip, _on, and r.

Referenced by NodeWidget::operator=(), and EdgeWidget::operator=().

void Renderable::setDelete bool  yes  )  [inline]
 

Definition at line 153 of file Renderable.h.

References _deleteMe, and setOn().

void Renderable::setManip gutz::Manip *const  m  )  [inline]
 

Definition at line 185 of file Renderable.h.

References _manip.

void Renderable::setManipEventsDefault  )  [inline]
 

you have to call this to enable default interaction, OR customize the manipulators events yourself.

Definition at line 188 of file Renderable.h.

References _manip.

void Renderable::setOn bool  yes  )  [inline]
 

Definition at line 142 of file Renderable.h.

References _on.

Referenced by setDelete().

virtual void Renderable::setSelected bool  yes  )  [inline, virtual]
 

Definition at line 176 of file Renderable.h.

References _selected.


Friends And Related Function Documentation

friend class SmartPtr [friend, inherited]
 

Definition at line 40 of file smartptr.h.

Referenced by Nrro::NrroIter< T >::NrroIter().

friend class SmartPtrRef [friend, inherited]
 

Definition at line 41 of file smartptr.h.


Member Data Documentation

bool Renderable::_deleteMe [protected]
 

does this object need to be deleted?

Definition at line 237 of file Renderable.h.

Referenced by needsDelete(), Renderable(), and setDelete().

gutz::ManipSP Renderable::_manip [protected]
 

You get a manipulator free, no charge.

Definition at line 240 of file Renderable.h.

Referenced by FrameWidget::configureFrame(), GLUEdgeWidget::drawDef(), GLUNodeWidget::drawDef(), GLSurfaceWidget::drawQuad(), EdgeWidget::getEndPoint(), getManip(), SurfaceWidget::getPoint(), NodeWidget::getPoint(), NodeWidget::getPointLocal(), EdgeWidget::getStartPoint(), SurfaceWidget::intersectPlane(), mouse(), FrameWidget::mouseChild(), WidgetItem::mouseDef(), move(), FrameWidget::moveChild(), WidgetItem::moveDef(), NodeWidget::NodeWidget(), operator=(), Renderable(), EdgeWidget::setEndPoint(), setManip(), setManipEventsDefault(), WidgetItem::setParent(), SurfaceWidget::setPoint(), NodeWidget::setPoint(), NodeWidget::setPointLocal(), EdgeWidget::setStartPoint(), and FrameWidget::updateManip().

bool Renderable::_on [protected]
 

is this renderable currently "render-able"?

Definition at line 235 of file Renderable.h.

Referenced by isOn(), operator=(), Renderable(), and setOn().

bool Renderable::_selected [protected]
 

is this renderable selected?

Definition at line 236 of file Renderable.h.

Referenced by isSelected(), Renderable(), and setSelected().


The documentation for this class was generated from the following file:
Send questions, comments, and bug reports to:
jmk