[vtkusers] Can't correctly place or size button using vtkRectangularButtonSource

msh ottffss at charter.net
Thu Apr 3 00:01:49 EDT 2008


I am trying to place a rectangular button in a render window, it should 
contain a JPEG image (vtk.jpg) that is 20x20 pixels in the rectangular 
button.  No matter what parameters I set in SetWidth(), SetHeight() the 
button is the same (huge) size (with a scaled version of the correct JPEG 
image). It is also in the center of the render window no matter what values I 
use in SetCenter().

Can anybody tell me what I am doing wrong.  The code segment is below...

	vtkJPEGReader *r=vtkJPEGReader::New();
	r->SetFileName("vtk.jpg");
	r->Update();
	vtkTexture *t=vtkTexture::New();
	t->SetInputConnection(r->GetOutputPort());
	int dims[2]={20,10};
	vtkRectangularButtonSource *bs3=vtkRectangularButtonSource::New();
	bs3->SetWidth(20.0);
	bs3->SetHeight(20.0);
	bs3->SetDepth(0.0005);
	bs3->TwoSidedOn();
	bs3->SetCenter(0.0, 0.0, 0.0);
	//bs3->SetTextureDimensions(dims);
	vtkPolyDataMapper *b3Mapper=vtkPolyDataMapper::New();
	b3Mapper->SetInputConnection(bs3->GetOutputPort());
	vtkActor *b3=vtkActor::New();
	b3->SetMapper(b3Mapper);
	b3->SetTexture(t);
	ren1->AddActor2D(b3);



More information about the vtkusers mailing list