[vtkusers] simple QVTKWidget resize issue
Clinton Stimpson
clinton at elemtech.com
Mon Jul 30 14:40:55 EDT 2012
On Sunday, July 29, 2012 12:55:28 AM Larry Kellogg wrote:
> Hi Everyone,
> I'm having a simple problem, but I can't find a solution.
> In my application when I shrink the window vertically, vtk automatically
> scales the view so that everything remains centered as it was. But when I
> shrink the window horizontally, nothing is resized and the model which used
> to be centered nicely is now cut off on the sides.
>
> Is there a way to get QVTKWidget or a render window to resize the display
> when the window is resized in both the vertical and horizontal directions.
> If VTK doesn't have a way to do this, does anybody have any good
> suggestions on how I could implement this myself? Thanks,
You can add a callback and register it
StartRenderCallback = vtkCallbackCommand::New();
StartRenderCallback->SetCallback(MyView::StartRender);
RenderWindow->AddObserver(vtkCommand::StartEvent, StartRenderCallback);
...
And in your callback, switch between using the horizonal view angle depending
on the window size.
void MyView::StartRender(vtkObject* caller,
unsigned long, void* clientdata, void*)
{
vtkRenderWindow* win = vtkRenderWindow::SafeDownCast(caller);
vtkRenderer* ren ....
// update the view angle
int horiz_view = win->GetSize()[0] < win->GetSize()[1];
ren->GetActiveCamera()->SetUseHorizontalViewAngle(horiz_view);
}
But perhaps this kind of thing can be added to VTK, with a flag to switch
beween vertical, horizontal or both.
--
Clinton Stimpson
Elemental Technologies, Inc
Computational Simulation Software, LLC
www.csimsoft.com
More information about the vtkusers
mailing list