[vtkusers] How to intercept Window Size Change Event

John Drescher drescherjm at gmail.com
Fri Mar 26 11:00:06 EDT 2010


> actually the VTK window is already optimized for window resize . but if you
> using GUI then all you have to do is call the SetSize() of vtkRenderWindow
>

This week I had to do this because for me its optimized in an
undesirable way. I mean the automatic scale of images is only based on
the height of the window and does not use the width as a constraint as
well. For this I added an Observe for the Modified event on the render
window.


in setupRenderWindow()
...
		vtkSmartPointer<vtkCallbackCommand> m_pModifiedCallback =
vtkSmartPointer<vtkCallbackCommand>::New();
		m_pModifiedCallback->SetCallback (WindowModifiedCallback);
		m_pModifiedCallback->SetClientData(this);

		m_pRenderWindow = vtkSmartPointer<vtkRenderWindow>::New();
		m_pRenderWindow->AddObserver(vtkCommand::ModifiedEvent,m_pModifiedCallback);
..


Now the callback:


void smImageView::smPrivate::WindowModifiedCallback( vtkObject*
caller, long unsigned int eventId, void* clientData, void* callData )
{
	smImageView::smPrivate* pSelf =
static_cast<smImageView::smPrivate*>(clientData);
	pSelf->updateCameraScaleBasedOnWindowSize();
}


Note this is a static void member function.

John



More information about the vtkusers mailing list