CIvfBufferSelection Class Reference

#include <ivf/IvfBufferSelection.h>

Inheritance diagram for CIvfBufferSelection:

CIvfBase CIvfRefCountBase CIvfRTTIBase List of all members.

Public Member Functions

 CIvfBufferSelection ()
virtual ~CIvfBufferSelection ()
 IvfClassInfo ("CIvfBufferSelection", CIvfBase)
int pick (int x, int y)
void update ()
void setComposite (CIvfComposite *composite)
CIvfCompositegetComposite ()
void setView (CIvfView *view)
CIvfViewgetView ()
CIvfShapegetSelectedShape ()
int getSize ()
CIvfShapegetSelectedShape (int idx)
CIvfSelectedShapesVector & getSelectedShapes ()

Detailed Description

Buffer selection class

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();
                }
        }
Author:
Jonas Lindemann
Examples:

selection.cpp.

Definition at line 101 of file IvfBufferSelection.h.


Constructor & Destructor Documentation

CIvfBufferSelection::CIvfBufferSelection  ) 
 

CIvfBufferSelection constructor

virtual CIvfBufferSelection::~CIvfBufferSelection  )  [virtual]
 

CIvfBufferSelection destructor


Member Function Documentation

CIvfComposite* CIvfBufferSelection::getComposite  ) 
 

Returns the composite with objects used in the selection

CIvfShape* CIvfBufferSelection::getSelectedShape int  idx  ) 
 

Returns the specified selected shape.

Returns NULL if no object is selected or the selection operation failed.

CIvfShape* CIvfBufferSelection::getSelectedShape  ) 
 

Returns the topmost selected shape.

Returns NULL if no object is selected or the selection operation failed.

CIvfSelectedShapesVector& CIvfBufferSelection::getSelectedShapes  ) 
 

Returns selected shapes

Returns a STL vector of the selected shapes.

int CIvfBufferSelection::getSize  ) 
 

Return the total number of selected shapes

CIvfView* CIvfBufferSelection::getView  ) 
 

Returns view used for selection (required)

int CIvfBufferSelection::pick int  x,
int  y
 

Initiates a object selection

This method can only be used when a valid OpenGL context exists.

Parameters:
x - x position of mouse cursor in current viewport
y - y position of mouse cursor in current viewport
Returns:
number of object "hits"

void CIvfBufferSelection::setComposite CIvfComposite composite  ) 
 

Sets the objects used in the selection operation (required)

This method also calls the update() method for updating the object selection list.

See also:
update

void CIvfBufferSelection::setView CIvfView view  ) 
 

Sets the view used for selection (required)

void CIvfBufferSelection::update  ) 
 

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.


The documentation for this class was generated from the following file:
Generated on Fri Sep 1 15:36:49 2006 for Interactive Visualisation Framework - Ivf++ by  doxygen 1.4.6-NO