[prev in list] [next in list] [prev in thread] [next in thread]
List: vtkusers
Subject: Re: [vtkusers] simple QVTKWidget resize issue
From: Larry Kellogg <lkellogg19 () hotmail ! com>
Date: 2012-07-30 19:42:34
Message-ID: SNT110-W65B991EA04BBFB8C147832CAC60 () phx ! gbl
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
Unfortunately I'm using parallel projection, and
SetUseHorizontalViewAngle () only works with perspective displays.
Larry
> From: clinton@elemtech.com
> To: vtkusers@vtk.org
> Date: Mon, 30 Jul 2012 12:40:55 -0600
> CC: lkellogg19@hotmail.com
> Subject: Re: [vtkusers] simple QVTKWidget resize issue
>
> 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
> _______________________________________________
> 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
[Attachment #5 (text/html)]
<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>
Unfortunately I'm using parallel projection, and
SetUseHorizontalViewAngle () only works with perspective \
displays.<div><br></div><div>Larry<br><br><div><div \
id="SkyDrivePlaceholder"></div>> From: clinton@elemtech.com<br>> To: \
vtkusers@vtk.org<br>> Date: Mon, 30 Jul 2012 12:40:55 -0600<br>> CC: \
lkellogg19@hotmail.com<br>> Subject: Re: [vtkusers] simple QVTKWidget resize \
issue<br>> <br>> On Sunday, July 29, 2012 12:55:28 AM Larry Kellogg \
wrote:<br>> > Hi Everyone,<br>> > I'm having a simple problem, but I \
can't find a solution.<br>> > In my application when I shrink the window \
vertically, vtk automatically<br>> > scales the view so that everything remains \
centered as it was. But when I<br>> > shrink the window horizontally, nothing \
is resized and the model which used<br>> > to be centered nicely is now cut off \
on the sides.<br>> > <br>> > Is there a way to get QVTKWidget or a render \
window to resize the display<br>> > when the window is resized in both the \
vertical and horizontal directions. <br>> > If VTK doesn't have a way to do \
this, does anybody have any good<br>> > suggestions on how I could implement \
this myself? Thanks,<br>> <br>> You can add a callback and register it <br>> \
StartRenderCallback = vtkCallbackCommand::New();<br>> \
StartRenderCallback->SetCallback(MyView::StartRender);<br>> \
RenderWindow->AddObserver(vtkCommand::StartEvent, StartRenderCallback);<br>> \
<br>> ...<br>> <br>> And in your callback, switch between using the \
horizonal view angle depending <br>> on the window size.<br>> <br>> void \
MyView::StartRender(vtkObject* caller, <br>> unsigned long, \
void* clientdata, void*)<br>> {<br>> vtkRenderWindow* win = \
vtkRenderWindow::SafeDownCast(caller);<br>> vtkRenderer* ren ....<br>> \
<br>> // update the view angle<br>> int horiz_view = win->GetSize()[0] \
< win->GetSize()[1];<br>> \
ren->GetActiveCamera()->SetUseHorizontalViewAngle(horiz_view);<br>> \
}<br>> <br>> But perhaps this kind of thing can be added to VTK, with a flag to \
switch <br>> beween vertical, horizontal or both.<br>> <br>> -- <br>> \
Clinton Stimpson<br>> Elemental Technologies, Inc<br>> Computational Simulation \
Software, LLC<br>> www.csimsoft.com<br>> \
_______________________________________________<br>> Powered by \
www.kitware.com<br>> <br>> Visit other Kitware open-source projects at \
http://www.kitware.com/opensource/opensource.html<br>> <br>> Please keep \
messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ<br>> \
<br>> Follow this link to subscribe/unsubscribe:<br>> \
http://www.vtk.org/mailman/listinfo/vtkusers<br></div></div> </div></body> \
</html>
_______________________________________________
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
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic