62 #include "ColorStack.hh" 142 return Vec4uc (0, 0, 0, 0);
150 currentNode_ = currentNode_->
pushIndex (_idx);
158 currentNode_ = currentNode_->
popIndex ();
165 std::vector<unsigned int> rv(0);
166 if (initialized_ && !error_)
168 unsigned int idx = translator_.
color2index (_rgba);
169 if (idx >= root_->startIndex () && idx < root_->endIndex ())
170 root_->colorToStack (rv, idx);
181 return translator_.
max_index () - currentNode_->endIndex ();
193 return currentNode_->colorIndex ();
209 startIdx_ = endIdx_ = parent_->endIndex ();
211 startIdx_ = endIdx_ = 1;
216 ColorStack::Node::~Node ()
218 for (std::vector<Node *>::iterator it = nodes_.begin (); it != nodes_.end(); ++it)
229 if (colorStartIdx_ == 0 && translator_->
max_index () > endIdx_ + _idx)
231 colorStartIdx_ = endIdx_;
232 endIdx_ = colorEndIdx_ = colorStartIdx_ + _idx;
242 if (colorStartIdx_ && colorStartIdx_ + _idx < colorEndIdx_)
254 if (colorStartIdx_ && colorStartIdx_ + _idx < colorEndIdx_)
256 _rgba = translator_->
index2color(colorStartIdx_ + _idx);
267 nodes_.push_back (n);
275 parent_->endIdx_ = endIdx_;
281 void ColorStack::Node::colorToStack (std::vector<unsigned int> &_stack,
unsigned int _index)
283 if (_index >= colorStartIdx_ && _index < colorEndIdx_)
285 _stack.push_back (_index - colorStartIdx_);
289 for (std::vector<Node *>::iterator it = nodes_.begin (); it != nodes_.end(); ++it)
292 if (_index >= n->startIndex () && _index < n->endIndex ())
293 n->colorToStack (_stack, _index);
296 _stack.push_back (index_);
bool getIndexColor(unsigned int _idx, Vec4uc &_rgba) const
gets the color instead of setting it directly
Node * pushIndex(unsigned int _idx)
creates a new node the stack (like glPushName)
Vec4uc getIndexColor(unsigned int _idx)
gets the color instead of setting it directly
void glColor(const Vec3f &_v)
Wrapper: glColor for Vec3f.
void initialize()
init (takes current GL context/ like glInitNames (); glPushName (0))
void popIndex()
pops the current node from the stack (like glPopName)
unsigned int freeIndicies() const
returns maximal available index count
unsigned int currentIndex() const
returns the current color index
bool setMaximumIndex(unsigned int _idx)
sets the maximum index number used in current node
void setIndex(unsigned int _idx)
sets the current color the given index (like glLoadName)
void initialize()
init (takes current GL context)
void pushIndex(unsigned int _idx)
creates a new node the stack (like glPushName)
VectorT< unsigned char, 4 > Vec4uc
Namespace providing different geometric functions concerning angles.
Vec4uc index2color(unsigned int _idx) const
index -> color (one buffer)
ColorStack()
Default constructor.
std::vector< unsigned int > colorToStack(Vec4uc _rgba) const
converts the given color to index values on the stack
bool setMaximumIndex(unsigned int _idx)
sets the maximum index number used in current node
Node * popIndex()
pops the current node from the stack (like glPopName)
unsigned int max_index() const
returns maximal convertable index
bool setIndex(unsigned int _idx) const
sets the current color the given index (like glLoadName)
int color2index(Vec4uc _rgba) const
color -> index (one buffer)