[vtkusers] Forcing a vtkCubeSource object to draw without jiggling the camera first
Steve Chall
stevec at renci.org
Wed Oct 21 17:05:14 EDT 2009
In my current project, I pick a grid cell on a vtkOpenGLImageActor, and then
I want to draw that grid cell using a colorful vtkCubeSource object. It
works beautifully -- but only after I've zoomed or rotated the camera
(translating doesn't help). If I don't zoom or rotate, the pickedPoint
never appears. After zooming or rotating -- even when I return to my
original camera position -- it always works.
What does moving the camera do that makes the vtkCubeSource immediately
appear? How can I programmatically "flip the switch" to force the
vtkCubeSource to display the first time, whatever side effect it is of the
camera motion (but not just *any* camera motion)? The rather rudimentary C
function is included below (the variables and const are globals). Thanks
for your suggestions.
I'm running VTK 5.4.2 on Ubuntu Linux version 8.04.1.
-Steve Chall
Senior Research Software Developer
Renaissance Computing Institute
Phone: 919-515-0051
Email: stevec at renci.org
void DrawPickedGridCell(int row, int col)
{
if (!pickedPoint)
{
pickedPoint = vtkCubeSource::New();
pickedPoint->SetXLength(kGridCellWidth);
pickedPoint->SetYLength(kGridCellHeight);
pickedPoint->SetZLength(0.1);
pickedPointMapper = vtkOpenGLPolyDataMapper::New();
pickedPointActor = vtkOpenGLActor::New();
pickedPointActor->GetProperty()->SetColor(1, 0, 0);
pickedPointMapper->SetInputConnection(pickedPoint->GetOutputPort());
pickedPointActor->SetMapper(pickedPointMapper);
mapRenderer->AddActor(pickedPointActor);
}
double x, y;
ComputeGridCellCenter(row, col, x, y);
pickedPoint->SetCenter(x, y, 0.1);
pickedPointCenter->SetCenter(x, y, 0.1);
}
More information about the vtkusers
mailing list