#include <ivf/IvfBufferSelection.h>
Inheritance diagram for CIvfBufferSelection:
Public Member Functions | |
CIvfBufferSelection () | |
virtual | ~CIvfBufferSelection () |
IvfClassInfo ("CIvfBufferSelection", CIvfBase) | |
int | pick (int x, int y) |
void | update () |
void | setComposite (CIvfComposite *composite) |
CIvfComposite * | getComposite () |
void | setView (CIvfView *view) |
CIvfView * | getView () |
CIvfShape * | getSelectedShape () |
int | getSize () |
CIvfShape * | getSelectedShape (int idx) |
CIvfSelectedShapesVector & | getSelectedShapes () |
This class implements object selection using the OpenGL selection buffer. The following code shows an example of using the CIvfBufferSelection class:
void CExampleWindow::onInit(int width, int heigth) { m_camera = new CIvfCamera(); m_camera->setPosition(...); m_scene = new CIvfComposite(); ... Add some children to scene ... m_selection = new CIvfBufferSelection(); m_selection->setView(m_camera); . . . } . . . if (isLeftButtonDown()) { m_selection->pick(x, y); if (m_selection->getSelectedShape()!=NULL) { m_selection->getSelectedShape()->setHighlight(CIvfShape::HS_ON); redraw(); } else { m_scene->setHighlightChildren(CIvfShape::HS_OFF); redraw(); } } if (isRightButtonDown()) { m_selection->pick(x, y); if (m_selection->getSize()!=0) { for (i=0; i<m_selection->getSize(); i++) m_selection->getSelectedShape(i)->setHighlight(CIvfShape::HS_ON); redraw(); } else { m_scene->setHighlightChildren(CIvfShape::HS_OFF); redraw(); } }
Definition at line 101 of file IvfBufferSelection.h.
|
CIvfBufferSelection constructor |
|
CIvfBufferSelection destructor |
|
Returns the composite with objects used in the selection |
|
Returns the specified selected shape. Returns NULL if no object is selected or the selection operation failed. |
|
Returns the topmost selected shape. Returns NULL if no object is selected or the selection operation failed. |
|
Returns selected shapes Returns a STL vector of the selected shapes. |
|
Return the total number of selected shapes |
|
Returns view used for selection (required) |
|
Initiates a object selection This method can only be used when a valid OpenGL context exists.
|
|
Sets the objects used in the selection operation (required) This method also calls the update() method for updating the object selection list.
|
|
Sets the view used for selection (required) |
|
Updates object selection list Selection is implemented by giving all objects in the composite a number and storing them in the object selection list, which is used for quick object lookup. When objects are added to the composite this list must be updated with the update() method. |