VTK
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes
vtkHardwareSelector Class Reference

manager for OpenGL-based selection. More...

#include <vtkHardwareSelector.h>

Inheritance diagram for vtkHardwareSelector:
Inheritance graph
[legend]
Collaboration diagram for vtkHardwareSelector:
Collaboration graph
[legend]

List of all members.

Classes

struct  PixelInformation

Public Types

enum  PassTypes {
  PROCESS_PASS, ACTOR_PASS, COMPOSITE_INDEX_PASS, ID_LOW24,
  ID_MID24, ID_HIGH16, MAX_KNOWN_PASS = ID_HIGH16, MIN_KNOWN_PASS = PROCESS_PASS
}
typedef vtkObject Superclass

Public Member Functions

virtual int IsA (const char *type)
vtkHardwareSelectorNewInstance () const
void PrintSelf (ostream &os, vtkIndent indent)
vtkSelectionSelect ()
void RenderCompositeIndex (unsigned int index)
void RenderAttributeId (vtkIdType attribid)
void RenderProcessId (unsigned int processid)
int Render (vtkRenderer *renderer, vtkProp **propArray, int propArrayCount)
vtkPropGetPropFromID (int id)
void SetRenderer (vtkRenderer *)
virtual vtkRendererGetRenderer ()
virtual void SetArea (unsigned int, unsigned int, unsigned int, unsigned int)
virtual void SetArea (unsigned int[4])
virtual unsigned intGetArea ()
virtual void GetArea (unsigned int &, unsigned int &, unsigned int &, unsigned int &)
virtual void GetArea (unsigned int[4])
virtual void SetFieldAssociation (int)
virtual int GetFieldAssociation ()
virtual void SetUseProcessIdFromData (bool)
virtual bool GetUseProcessIdFromData ()
virtual bool CaptureBuffers ()
PixelInformation GetPixelInformation (unsigned int display_position[2])
PixelInformation GetPixelInformation (unsigned int display_position[2], int maxDist)
void ClearBuffers ()
bool GetPixelInformation (unsigned int display_position[2], int &processId, vtkIdType &attrId, vtkProp *&prop)
bool GetPixelInformation (unsigned int display_position[2], int &processId, vtkIdType &attrId, vtkProp *&prop, int maxDist)
void BeginRenderProp ()
void EndRenderProp ()
virtual void SetProcessID (int)
virtual int GetProcessID ()
virtual int GetCurrentPass ()
virtual vtkSelectionGenerateSelection ()
virtual vtkSelectionGenerateSelection (unsigned int r[4])
virtual vtkSelectionGenerateSelection (unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2)
virtual vtkSelectionGeneratePolygonSelection (int *polygonPoints, vtkIdType count)

Static Public Member Functions

static vtkHardwareSelectorNew ()
static int IsTypeOf (const char *type)
static vtkHardwareSelectorSafeDownCast (vtkObjectBase *o)

Protected Member Functions

virtual vtkObjectBaseNewInstanceInternal () const
 vtkHardwareSelector ()
 ~vtkHardwareSelector ()
int Convert (unsigned long offset, unsigned char *pb)
vtkIdType GetID (int low24, int mid24, int high16)
virtual bool PassRequired (int pass)
bool IsPropHit (int propid)
virtual void BeginSelection ()
virtual void EndSelection ()
void SavePixelBuffer (int passNo)
void BuildPropHitList (unsigned char *rgbData)
int Convert (unsigned int pos[2], unsigned char *pb)
int Convert (int xx, int yy, unsigned char *pb)
virtual int GetPropID (int idx, vtkProp *vtkNotUsed(prop))

Static Protected Member Functions

static void Convert (int id, float tcoord[3])

Protected Attributes

unsigned char * PixBuffer [10]
int ProcessID
int CurrentPass
int InPropRender
vtkRendererRenderer
unsigned int Area [4]
int FieldAssociation
bool UseProcessIdFromData
vtkIdType MaxAttributeId
void ReleasePixBuffers ()

Detailed Description

manager for OpenGL-based selection.

vtkHardwareSelector is a helper that orchestrates color buffer based selection. This relies on OpenGL. vtkHardwareSelector can be used to select visible cells or points within a given rectangle of the RenderWindow. To use it, call in order:

Limitations: Antialiasing will break this class. If your graphics card settings force their use this class will return invalid results.

Currently only cells from PolyDataMappers can be selected from. When vtkRenderer::Selector is non-null vtkPainterPolyDataMapper uses the vtkHardwareSelectionPolyDataPainter which make appropriate calls to BeginRenderProp(), EndRenderProp(), RenderProcessId(), RenderAttributeId() to render colors correctly. Until alternatives to vtkHardwareSelectionPolyDataPainter exist that can do a similar coloration of other vtkDataSet types, only polygonal data can be selected. If you need to select other data types, consider using vtkDataSetMapper and turning on it's PassThroughCellIds feature, or using vtkFrustumExtractor.

Only Opaque geometry in Actors is selected from. Assemblies and LODMappers are not currently supported.

During selection, visible datasets that can not be selected from are temporarily hidden so as not to produce invalid indices from their colors.

See also:
vtkIdentColoredPainter
Tests:
vtkHardwareSelector (Tests)

Definition at line 74 of file vtkHardwareSelector.h.


Member Typedef Documentation

Reimplemented from vtkObject.

Reimplemented in vtkPHardwareSelector.

Definition at line 98 of file vtkHardwareSelector.h.


Member Enumeration Documentation

Enumerator:
PROCESS_PASS 
ACTOR_PASS 
COMPOSITE_INDEX_PASS 
ID_LOW24 
ID_MID24 
ID_HIGH16 
MAX_KNOWN_PASS 
MIN_KNOWN_PASS 

Definition at line 232 of file vtkHardwareSelector.h.


Constructor & Destructor Documentation


Member Function Documentation

Create an object with Debug turned off, modified time initialized to zero, and reference counting on.

Reimplemented from vtkObject.

Reimplemented in vtkPHardwareSelector.

static int vtkHardwareSelector::IsTypeOf ( const char *  name) [static]

Return 1 if this class type is the same type of (or a subclass of) the named class. Returns 0 otherwise. This method works in combination with vtkTypeMacro found in vtkSetGet.h.

Reimplemented from vtkObject.

Reimplemented in vtkPHardwareSelector.

virtual int vtkHardwareSelector::IsA ( const char *  name) [virtual]

Return 1 if this class is the same type of (or a subclass of) the named class. Returns 0 otherwise. This method works in combination with vtkTypeMacro found in vtkSetGet.h.

Reimplemented from vtkObject.

Reimplemented in vtkPHardwareSelector.

Reimplemented from vtkObject.

Reimplemented in vtkPHardwareSelector.

virtual vtkObjectBase* vtkHardwareSelector::NewInstanceInternal ( ) const [protected, virtual]

Reimplemented from vtkObject.

Reimplemented in vtkPHardwareSelector.

Reimplemented from vtkObject.

Reimplemented in vtkPHardwareSelector.

void vtkHardwareSelector::PrintSelf ( ostream &  os,
vtkIndent  indent 
) [virtual]

Methods invoked by print to print information about the object including superclasses. Typically not called by the user (use Print() instead) but used in the hierarchical print process to combine the output of several classes.

Reimplemented from vtkObject.

Reimplemented in vtkPHardwareSelector.

Get/Set the renderer to perform the selection on.

Get/Set the renderer to perform the selection on.

virtual void vtkHardwareSelector::SetArea ( unsigned  int,
unsigned  int,
unsigned  int,
unsigned  int 
) [virtual]

Get/Set the area to select as (xmin, ymin, xmax, ymax).

virtual void vtkHardwareSelector::SetArea ( unsigned  int[4]) [virtual]

Get/Set the area to select as (xmin, ymin, xmax, ymax).

virtual unsigned int* vtkHardwareSelector::GetArea ( ) [virtual]

Get/Set the area to select as (xmin, ymin, xmax, ymax).

virtual void vtkHardwareSelector::GetArea ( unsigned int ,
unsigned int ,
unsigned int ,
unsigned int  
) [virtual]

Get/Set the area to select as (xmin, ymin, xmax, ymax).

virtual void vtkHardwareSelector::GetArea ( unsigned  int[4]) [virtual]

Get/Set the area to select as (xmin, ymin, xmax, ymax).

virtual void vtkHardwareSelector::SetFieldAssociation ( int  ) [virtual]

Set the field type to select. Valid values are

Set the field type to select. Valid values are

virtual void vtkHardwareSelector::SetUseProcessIdFromData ( bool  ) [virtual]

In some parallel rendering setups, the process id for elements must be obtained from the data itself, rather than the rendering process' id. In that case, set this flag to ON (default OFF).

In some parallel rendering setups, the process id for elements must be obtained from the data itself, rather than the rendering process' id. In that case, set this flag to ON (default OFF).

Perform the selection. Returns a new instance of vtkSelection containing the selection on success.

virtual bool vtkHardwareSelector::CaptureBuffers ( ) [virtual]

It is possible to use the vtkHardwareSelector for a custom picking. (Look at vtkScenePicker). In that case instead of Select() on can use CaptureBuffers() to render the selection buffers and then get information about pixel locations suing GetPixelInformation(). Use ClearBuffers() to clear buffers after one's done with the scene. The optional final parameter maxDist will look for a cell within the specified number of pixels from display_position.

Reimplemented in vtkPHardwareSelector.

PixelInformation vtkHardwareSelector::GetPixelInformation ( unsigned int  display_position[2]) [inline]

It is possible to use the vtkHardwareSelector for a custom picking. (Look at vtkScenePicker). In that case instead of Select() on can use CaptureBuffers() to render the selection buffers and then get information about pixel locations suing GetPixelInformation(). Use ClearBuffers() to clear buffers after one's done with the scene. The optional final parameter maxDist will look for a cell within the specified number of pixels from display_position.

Definition at line 146 of file vtkHardwareSelector.h.

PixelInformation vtkHardwareSelector::GetPixelInformation ( unsigned int  display_position[2],
int  maxDist 
)

It is possible to use the vtkHardwareSelector for a custom picking. (Look at vtkScenePicker). In that case instead of Select() on can use CaptureBuffers() to render the selection buffers and then get information about pixel locations suing GetPixelInformation(). Use ClearBuffers() to clear buffers after one's done with the scene. The optional final parameter maxDist will look for a cell within the specified number of pixels from display_position.

It is possible to use the vtkHardwareSelector for a custom picking. (Look at vtkScenePicker). In that case instead of Select() on can use CaptureBuffers() to render the selection buffers and then get information about pixel locations suing GetPixelInformation(). Use ClearBuffers() to clear buffers after one's done with the scene. The optional final parameter maxDist will look for a cell within the specified number of pixels from display_position.

Definition at line 150 of file vtkHardwareSelector.h.

bool vtkHardwareSelector::GetPixelInformation ( unsigned int  display_position[2],
int processId,
vtkIdType attrId,
vtkProp *&  prop 
)
bool vtkHardwareSelector::GetPixelInformation ( unsigned int  display_position[2],
int processId,
vtkIdType attrId,
vtkProp *&  prop,
int  maxDist 
)

Called by any vtkMapper or vtkProp subclass to render a composite-index. Currently indices >= 0xffffff are not supported.

Called by any vtkMapper or vtkProp subclass to render an attribute's id.

void vtkHardwareSelector::RenderProcessId ( unsigned int  processid)

Called by any vtkMapper or subclass to render process id. This has any effect when this->UseProcessIdFromData is true.

int vtkHardwareSelector::Render ( vtkRenderer renderer,
vtkProp **  propArray,
int  propArrayCount 
)

Called by vtkRenderer to render the selection pass. Returns the number of props rendered.

Called by the mapper (vtkHardwareSelectionPolyDataPainter) before and after rendering each prop.

Called by the mapper (vtkHardwareSelectionPolyDataPainter) before and after rendering each prop.

virtual void vtkHardwareSelector::SetProcessID ( int  ) [virtual]

Get/Set the process id. If process id < 0 (default -1), then the PROCESS_PASS is not rendered.

virtual int vtkHardwareSelector::GetProcessID ( ) [virtual]

Get/Set the process id. If process id < 0 (default -1), then the PROCESS_PASS is not rendered.

Get the current pass number.

virtual vtkSelection* vtkHardwareSelector::GenerateSelection ( ) [inline, virtual]

Generates the vtkSelection from pixel buffers. Requires that CaptureBuffers() has already been called. Optionally you may pass a screen region (xmin, ymin, xmax, ymax) to generate a selection from. The region must be a subregion of the region specified by SetArea(), otherwise it will be clipped to that region.

Definition at line 209 of file vtkHardwareSelector.h.

virtual vtkSelection* vtkHardwareSelector::GenerateSelection ( unsigned int  r[4]) [inline, virtual]

Generates the vtkSelection from pixel buffers. Requires that CaptureBuffers() has already been called. Optionally you may pass a screen region (xmin, ymin, xmax, ymax) to generate a selection from. The region must be a subregion of the region specified by SetArea(), otherwise it will be clipped to that region.

Definition at line 211 of file vtkHardwareSelector.h.

virtual vtkSelection* vtkHardwareSelector::GenerateSelection ( unsigned int  x1,
unsigned int  y1,
unsigned int  x2,
unsigned int  y2 
) [virtual]

Generates the vtkSelection from pixel buffers. Requires that CaptureBuffers() has already been called. Optionally you may pass a screen region (xmin, ymin, xmax, ymax) to generate a selection from. The region must be a subregion of the region specified by SetArea(), otherwise it will be clipped to that region.

virtual vtkSelection* vtkHardwareSelector::GeneratePolygonSelection ( int polygonPoints,
vtkIdType  count 
) [virtual]

Generates the vtkSelection from pixel buffers. Same as GenerateSelection, except this one use a polygon, instead of a rectangle region, and select elements inside the polygon. NOTE: The CaptureBuffers() needs to be called first.

returns the prop associated with a ID. This is valid only until ReleasePixBuffers() gets called.

static void vtkHardwareSelector::Convert ( int  id,
float  tcoord[3] 
) [inline, static, protected]

Definition at line 247 of file vtkHardwareSelector.h.

int vtkHardwareSelector::Convert ( unsigned long  offset,
unsigned char *  pb 
) [inline, protected]

Definition at line 254 of file vtkHardwareSelector.h.

int vtkHardwareSelector::Convert ( unsigned int  pos[2],
unsigned char *  pb 
) [inline, protected]

pos must be relative to the lower-left corner of this->Area.

Definition at line 277 of file vtkHardwareSelector.h.

int vtkHardwareSelector::Convert ( int  xx,
int  yy,
unsigned char *  pb 
) [inline, protected]

pos must be relative to the lower-left corner of this->Area.

Definition at line 279 of file vtkHardwareSelector.h.

vtkIdType vtkHardwareSelector::GetID ( int  low24,
int  mid24,
int  high16 
) [inline, protected]

Definition at line 300 of file vtkHardwareSelector.h.

virtual bool vtkHardwareSelector::PassRequired ( int  pass) [protected, virtual]

Returns is the pass indicated is needed.

bool vtkHardwareSelector::IsPropHit ( int  propid) [protected]

After the ACTOR_PASS this return true or false depending upon whether the prop was hit in the ACTOR_PASS. This makes it possible to skip props that are not involved in the selection after the first pass.

virtual int vtkHardwareSelector::GetPropID ( int  idx,
vtkProp vtkNotUsedprop 
) [inline, protected, virtual]

Return a unique ID for the prop.

Definition at line 321 of file vtkHardwareSelector.h.

virtual void vtkHardwareSelector::BeginSelection ( ) [protected, virtual]
virtual void vtkHardwareSelector::EndSelection ( ) [protected, virtual]
void vtkHardwareSelector::SavePixelBuffer ( int  passNo) [protected]
void vtkHardwareSelector::BuildPropHitList ( unsigned char *  rgbData) [protected]

Clears all pixel buffers.


Member Data Documentation

Clears all pixel buffers.

Definition at line 334 of file vtkHardwareSelector.h.

unsigned int vtkHardwareSelector::Area[4] [protected]

Clears all pixel buffers.

Definition at line 335 of file vtkHardwareSelector.h.

Clears all pixel buffers.

Definition at line 336 of file vtkHardwareSelector.h.

Clears all pixel buffers.

Definition at line 337 of file vtkHardwareSelector.h.

Clears all pixel buffers.

Definition at line 338 of file vtkHardwareSelector.h.

unsigned char* vtkHardwareSelector::PixBuffer[10] [protected]

Definition at line 342 of file vtkHardwareSelector.h.

Definition at line 343 of file vtkHardwareSelector.h.

Definition at line 344 of file vtkHardwareSelector.h.

Definition at line 345 of file vtkHardwareSelector.h.


The documentation for this class was generated from the following file: