KrImageTree Class Reference

The ImageTree contains all the Image Nodes. More...

#include <imagetree.h>

List of all members.

Public Types

 ALWAYS_INSIDE_BOX = 0x01
 Hit the inside of a box, even if the box is not filled.
 GET_ALL_HITS = 0x04
 Get every object hit, not just the first.
enum  { ALWAYS_INSIDE_BOX = 0x01, GET_ALL_HITS = 0x04 }

Public Member Functions

KrImNodeRoot ()
 Return the very base node of the tree. It is a KrImNode and never a more derived type.
void AddNode (KrImNode *parent, KrImNode *addMe)
 Add a ImNode to the tree.
bool DeleteNode (KrImNode *removeMe)
 Call this to delete a node and remove it from the tree.
KrImNodeFindNodeById (int id)
 Find a ImNode by its id.
KrImNodeFindNodeByName (const std::string &name)
 Find a ImNode by its name.
void HitTest (int x, int y, KrImNode *startHere, int flags, std::vector< KrImage * > *outputArray, int *windowIndex)
 Given a point -- in screen coordinates -- determine what ImageNodes are under that point.
bool CheckSiblingCollision (KrImNode *checkThis, std::vector< KrImage * > *outputArray, int window=0)
 Given a node, check if it collides with any of its own siblings.
bool CheckChildCollision (KrImNode *checkThis, KrImNode *parent, std::vector< KrImage * > *outputArray, int window=0)
 Given a node "checkThis" and a parent, check if "checkThis" collides with any of the children of the parent.
bool CheckAllCollision (KrImNode *checkThis, std::vector< KrImage * > *outputArray, int window=0)
 Given a node, check if it collides with anything in the Tree.
void Walk ()
 Flushes the cached state of the tree and makes it ready to draw.


Detailed Description

The ImageTree contains all the Image Nodes.


Member Enumeration Documentation

anonymous enum

Enumerator:
ALWAYS_INSIDE_BOX  Hit the inside of a box, even if the box is not filled.
GET_ALL_HITS  Get every object hit, not just the first.


Member Function Documentation

void KrImageTree::AddNode ( KrImNode parent,
KrImNode addMe 
)

Add a ImNode to the tree.

The parent can be specified; if not, the root will be used. The node added -- 'addMe' -- is handed over by ownership. It will be deleted when the tree is deleted or DeleteNode is called.

Node children cannot directly be added. There is no KrImNode::AddChild function for instance; everything must be added through the tree.

bool KrImageTree::CheckAllCollision ( KrImNode checkThis,
std::vector< KrImage * > *  outputArray,
int  window = 0 
)

Given a node, check if it collides with anything in the Tree.

Returns true if any collisions occur, and returns an array of everything collided with.

See KrImage::CheckCollision for a discussion of collision issues.

bool KrImageTree::CheckChildCollision ( KrImNode checkThis,
KrImNode parent,
std::vector< KrImage * > *  outputArray,
int  window = 0 
)

Given a node "checkThis" and a parent, check if "checkThis" collides with any of the children of the parent.

There does not need to be any relationship between "checkThis" and "parent".

Returns true if any collisions occur, and returns an array (outputArray) of all the KrImages collided with.

See KrImage::CheckCollision for a discussion of collision issues.

bool KrImageTree::CheckSiblingCollision ( KrImNode checkThis,
std::vector< KrImage * > *  outputArray,
int  window = 0 
)

Given a node, check if it collides with any of its own siblings.

Returns true if any collisions occur, and returns an array (outputArray) of all the KrImages collided with.

See KrImage::CheckCollision for a discussion of collision issues.

bool KrImageTree::DeleteNode ( KrImNode removeMe  ) 

Call this to delete a node and remove it from the tree.

Warning:
: DeleteNode( this ) can cause a crash. It's a temptingly useful thing, but in the case where parent objects hold on to pointers, those pointers go dangling. It's best to avoid DeleteNode( this ) usage.

void KrImageTree::HitTest ( int  x,
int  y,
KrImNode startHere,
int  flags,
std::vector< KrImage * > *  outputArray,
int *  windowIndex 
)

Given a point -- in screen coordinates -- determine what ImageNodes are under that point.

Note that only images have bounds and are drawn, so only images can be hit.

If 'startHere' is null the whole tree will be searched, else the search will cover 'startHere' and its children.

HitTest, by defualt, stops at the first non-transparent pixel it hits. There are flags to modify this behavior:


The documentation for this class was generated from the following file:
Generated on Thu Jul 20 20:45:32 2006 for Kyra by  doxygen 1.4.7