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