[vtkusers] How to intercept Window Size Change Event

Xiaofeng Z xf10036 at hotmail.com
Fri Apr 23 11:20:08 EDT 2010


Thanks John, I'll try.

Xiaofeng

--------------------------------------------------
From: "John Drescher" <drescherjm at gmail.com>
Sent: Friday, March 26, 2010 11:00 AM
To: "Darshan Pai" <darshanpai at gmail.com>
Cc: "Xiaofeng Z" <xf10036 at hotmail.com>; "VTK" <vtkusers at vtk.org>
Subject: Re: [vtkusers] How to intercept Window Size Change Event

>> 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