[vtkusers] How to intercept Window Size Change Event

Sebastian Gatzka sebastian.gatzka at stud.tu-darmstadt.de
Thu Apr 8 03:47:08 EDT 2010


This is interesting for me too.
When adding an observer on the render window, how can I limit the window 
size to a minimim value inside the callback function?

Am 27.03.2010 00:00, schrieb Xiaofeng Z:
> 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
>>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at 
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at: 
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100408/b1877b40/attachment.htm>


More information about the vtkusers mailing list