<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>Snippet</TITLE>
<META content="text/html; charset=ISO-8859-1" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.6001.23515">
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff text=#000000>
<DIV><FONT size=2 face=Arial>
<DIV><FONT size=2 face=Arial>
<DIV><FONT size=2 face=Arial>Hi Serge,</FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT> </DIV>
<DIV><FONT size=2 face=Arial>If it helps your sanity, I can repeat this clipping
problem in VTK 5.10 using the default interactor with QVTKWidget, which I
believe is trackball camera, and parallel projection on.</FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT> </DIV>
<DIV><FONT size=2 face=Arial>When this happens, I have a 'Fit' option which
moves the focal point of the camera to the centre of the actors and adjusts the
parallel scale to fill the view.</FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT> </DIV>
<DIV><FONT size=2 face=Arial>John.</FONT></DIV></FONT></DIV></FONT></DIV>
<BLOCKQUOTE
style="BORDER-LEFT: #000000 2px solid; PADDING-LEFT: 5px; PADDING-RIGHT: 0px; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px">
<DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV
style="FONT: 10pt arial; BACKGROUND: #e4e4e4; font-color: black"><B>From:</B>
<A title=serge@infolytica.com href="mailto:serge@infolytica.com">Serge
Lalonde</A> </DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A title=vtkusers@vtk.org
href="mailto:vtkusers@vtk.org">vtkusers@vtk.org</A> </DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Tuesday, August 20, 2013 8:12
PM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> Re: [vtkusers] Clipping problem
when panning</DIV>
<DIV><BR></DIV>Well, since I got no responses, I dug deeper and found the code
in ParaView that does the rotation and spinning around the center of the
visible actors, extracted it and put it into a
vtkInteractorStyleTrackballCamera subclass. It hasn't been extensively tested
yet, but it seems to work well.<BR><BR>Here it is in case it helps save
anybody else 3 days of work.<BR><BR><PRE style="FONT-FAMILY: Consolas; BACKGROUND: white; COLOR: black; FONT-SIZE: 13px"> <SPAN style="COLOR: green">// Our subclass of the trackball camera to change the center of rotation to be the average</SPAN>
<SPAN style="COLOR: green">// center of all visible actors instead of the center of the viewport, which always gets clipped.</SPAN>
<SPAN style="COLOR: green">// The default implementation is badly broken and doesn't look to be fixed anytime soon.</SPAN>
<SPAN style="COLOR: green">// The clipping might be fixed with the changes I submitted: <A class=moz-txt-link-freetext href="http://www.vtk.org/Bug/view.php?id=7823">http://www.vtk.org/Bug/view.php?id=7823</A></SPAN>
<SPAN style="COLOR: green">// The new rotation code was taken from ParaView. Specifically,</SPAN>
<SPAN style="COLOR: green">// - Rotate(): vtkPVTrackballRotate.cxx OnMouseMove()</SPAN>
<SPAN style="COLOR: green">// - Spin(): vtkPVTrackballRoll.cxx OnMouseMove()</SPAN>
<SPAN style="COLOR: green">// - UpdateScreenCenterOfRotation(): vtkCameraManipulator.cxx ComputeDisplayCenter()</SPAN>
<SPAN style="COLOR: blue">class</SPAN> <SPAN style="COLOR: blue">InteractorStyleTrackballCamera</SPAN>: <SPAN style="COLOR: blue">public</SPAN> <SPAN style="COLOR: blue">vtkInteractorStyleTrackballCamera</SPAN>
{
<SPAN style="COLOR: blue">public</SPAN>:
<SPAN style="COLOR: blue">static</SPAN> <SPAN style="COLOR: blue">InteractorStyleTrackballCamera</SPAN> *<SPAN style="COLOR: #880000">New</SPAN>();
<SPAN style="COLOR: #a000a0">vtkTypeMacro</SPAN>(<SPAN style="COLOR: blue">InteractorStyleTrackballCamera</SPAN>, <SPAN style="COLOR: blue">vtkInteractorStyleTrackballCamera</SPAN>);
<SPAN style="COLOR: green">// This only gets called is CurrentRenderer isn't NULL.</SPAN>
<SPAN style="COLOR: blue">virtual</SPAN> <SPAN style="COLOR: blue">void</SPAN> <SPAN style="COLOR: #880000">StartRotate</SPAN>()
{
<SPAN style="COLOR: blue">Superclass</SPAN>::<SPAN style="COLOR: #880000">StartRotate</SPAN>();
<SPAN style="COLOR: #880000">UpdateCenterOfRotation</SPAN>(<SPAN style="COLOR: navy">CurrentRenderer</SPAN>);
}
<SPAN style="COLOR: green">// This only gets called is CurrentRenderer isn't NULL.</SPAN>
<SPAN style="COLOR: blue">virtual</SPAN> <SPAN style="COLOR: blue">void</SPAN> <SPAN style="COLOR: #880000">StartSpin</SPAN>()
{
<SPAN style="COLOR: blue">Superclass</SPAN>::<SPAN style="COLOR: #880000">StartSpin</SPAN>();
<SPAN style="COLOR: #880000">UpdateCenterOfRotation</SPAN>(<SPAN style="COLOR: navy">CurrentRenderer</SPAN>);
<SPAN style="COLOR: #880000">UpdateScreenCenterOfRotation</SPAN>(<SPAN style="COLOR: navy">CurrentRenderer</SPAN>);
}
<SPAN style="COLOR: blue">virtual</SPAN> <SPAN style="COLOR: blue">void</SPAN> <SPAN style="COLOR: #880000">Rotate</SPAN>()
{
<SPAN style="COLOR: blue">if</SPAN> (<SPAN style="COLOR: navy">CurrentRenderer</SPAN> == <SPAN style="COLOR: #a000a0">NULL</SPAN>)
<SPAN style="COLOR: blue">return</SPAN>;
<SPAN style="COLOR: blue">vtkRenderer</SPAN> *<SPAN style="COLOR: navy">ren</SPAN>= <SPAN style="COLOR: navy">CurrentRenderer</SPAN>;
<SPAN style="COLOR: blue">vtkCamera</SPAN> *<SPAN style="COLOR: navy">camera</SPAN>= <SPAN style="COLOR: navy">ren</SPAN>-><SPAN style="COLOR: #880000">GetActiveCamera</SPAN>();
<SPAN style="COLOR: blue">vtkRenderWindowInteractor</SPAN> *<SPAN style="COLOR: navy">rwi</SPAN>= <SPAN style="COLOR: navy">Interactor</SPAN>;
<SPAN style="COLOR: blue">vtkTransform</SPAN> *<SPAN style="COLOR: navy">transform</SPAN>= <SPAN style="COLOR: blue">vtkTransform</SPAN>::<SPAN style="COLOR: #880000">New</SPAN>();
<SPAN style="COLOR: blue">double</SPAN> <SPAN style="COLOR: navy">scale</SPAN>= <SPAN style="COLOR: blue">vtkMath</SPAN>::<SPAN style="COLOR: #880000">Norm</SPAN>(<SPAN style="COLOR: navy">camera</SPAN>-><SPAN style="COLOR: #880000">GetPosition</SPAN>());
<SPAN style="COLOR: blue">if</SPAN> (<SPAN style="COLOR: navy">scale</SPAN> <= 0.0)
{
<SPAN style="COLOR: navy">scale</SPAN>= <SPAN style="COLOR: blue">vtkMath</SPAN>::<SPAN style="COLOR: #880000">Norm</SPAN>(<SPAN style="COLOR: navy">camera</SPAN>-><SPAN style="COLOR: #880000">GetFocalPoint</SPAN>());
<SPAN style="COLOR: blue">if</SPAN> (<SPAN style="COLOR: navy">scale</SPAN> <= 0.0)
<SPAN style="COLOR: navy">scale</SPAN>= 1.0;
}
<SPAN style="COLOR: blue">double</SPAN> *<SPAN style="COLOR: navy">temp</SPAN>= <SPAN style="COLOR: navy">camera</SPAN>-><SPAN style="COLOR: #880000">GetFocalPoint</SPAN>();
<SPAN style="COLOR: navy">camera</SPAN>-><SPAN style="COLOR: #880000">SetFocalPoint</SPAN>(<SPAN style="COLOR: navy">temp</SPAN>[0]/<SPAN style="COLOR: navy">scale</SPAN>, <SPAN style="COLOR: navy">temp</SPAN>[1]/<SPAN style="COLOR: navy">scale</SPAN>, <SPAN style="COLOR: navy">temp</SPAN>[2]/<SPAN style="COLOR: navy">scale</SPAN>);
<SPAN style="COLOR: navy">temp</SPAN>= <SPAN style="COLOR: navy">camera</SPAN>-><SPAN style="COLOR: #880000">GetPosition</SPAN>();
<SPAN style="COLOR: navy">camera</SPAN>-><SPAN style="COLOR: #880000">SetPosition</SPAN>(<SPAN style="COLOR: navy">temp</SPAN>[0]/<SPAN style="COLOR: navy">scale</SPAN>, <SPAN style="COLOR: navy">temp</SPAN>[1]/<SPAN style="COLOR: navy">scale</SPAN>, <SPAN style="COLOR: navy">temp</SPAN>[2]/<SPAN style="COLOR: navy">scale</SPAN>);
<SPAN style="COLOR: blue">double</SPAN> <SPAN style="COLOR: navy">v2</SPAN>[3];
<SPAN style="COLOR: green">// translate to center</SPAN>
<SPAN style="COLOR: navy">transform</SPAN>-><SPAN style="COLOR: #880000">Identity</SPAN>();
<SPAN style="COLOR: navy">transform</SPAN>-><SPAN style="COLOR: #880000">Translate</SPAN>(<SPAN style="COLOR: navy">m_center</SPAN>[0]/<SPAN style="COLOR: navy">scale</SPAN>, <SPAN style="COLOR: navy">m_center</SPAN>[1]/<SPAN style="COLOR: navy">scale</SPAN>, <SPAN style="COLOR: navy">m_center</SPAN>[2]/<SPAN style="COLOR: navy">scale</SPAN>);
<SPAN style="COLOR: blue">int</SPAN> <SPAN style="COLOR: navy">dx</SPAN>= <SPAN style="COLOR: navy">rwi</SPAN>-><SPAN style="COLOR: #880000">GetLastEventPosition</SPAN>()[0] - <SPAN style="COLOR: navy">rwi</SPAN>-><SPAN style="COLOR: #880000">GetEventPosition</SPAN>()[0];
<SPAN style="COLOR: blue">int</SPAN> <SPAN style="COLOR: navy">dy</SPAN>= <SPAN style="COLOR: navy">rwi</SPAN>-><SPAN style="COLOR: #880000">GetLastEventPosition</SPAN>()[1] - <SPAN style="COLOR: navy">rwi</SPAN>-><SPAN style="COLOR: #880000">GetEventPosition</SPAN>()[1];
<SPAN style="COLOR: green">// azimuth</SPAN>
<SPAN style="COLOR: navy">camera</SPAN>-><SPAN style="COLOR: #880000">OrthogonalizeViewUp</SPAN>();
<SPAN style="COLOR: blue">double</SPAN> *<SPAN style="COLOR: navy">viewUp</SPAN>= <SPAN style="COLOR: navy">camera</SPAN>-><SPAN style="COLOR: #880000">GetViewUp</SPAN>();
<SPAN style="COLOR: blue">int</SPAN> *<SPAN style="COLOR: navy">size</SPAN>= <SPAN style="COLOR: navy">ren</SPAN>-><SPAN style="COLOR: #880000">GetSize</SPAN>();
<SPAN style="COLOR: navy">transform</SPAN>-><SPAN style="COLOR: #880000">RotateWXYZ</SPAN>(360.0*<SPAN style="COLOR: navy">dx</SPAN>/<SPAN style="COLOR: navy">size</SPAN>[0], <SPAN style="COLOR: navy">viewUp</SPAN>[0], <SPAN style="COLOR: navy">viewUp</SPAN>[1], <SPAN style="COLOR: navy">viewUp</SPAN>[2]);
<SPAN style="COLOR: green">// elevation</SPAN>
<SPAN style="COLOR: blue">vtkMath</SPAN>::<SPAN style="COLOR: #880000">Cross</SPAN>(<SPAN style="COLOR: navy">camera</SPAN>-><SPAN style="COLOR: #880000">GetDirectionOfProjection</SPAN>(), <SPAN style="COLOR: navy">viewUp</SPAN>, <SPAN style="COLOR: navy">v2</SPAN>);
<SPAN style="COLOR: navy">transform</SPAN>-><SPAN style="COLOR: #880000">RotateWXYZ</SPAN>(-360.0*<SPAN style="COLOR: navy">dy</SPAN>/<SPAN style="COLOR: navy">size</SPAN>[1], <SPAN style="COLOR: navy">v2</SPAN>[0], <SPAN style="COLOR: navy">v2</SPAN>[1], <SPAN style="COLOR: navy">v2</SPAN>[2]);
<SPAN style="COLOR: green">// translate back</SPAN>
<SPAN style="COLOR: navy">transform</SPAN>-><SPAN style="COLOR: #880000">Translate</SPAN>(-<SPAN style="COLOR: navy">m_center</SPAN>[0]/<SPAN style="COLOR: navy">scale</SPAN>, -<SPAN style="COLOR: navy">m_center</SPAN>[1]/<SPAN style="COLOR: navy">scale</SPAN>, -<SPAN style="COLOR: navy">m_center</SPAN>[2]/<SPAN style="COLOR: navy">scale</SPAN>);
<SPAN style="COLOR: navy">camera</SPAN>-><SPAN style="COLOR: #880000">ApplyTransform</SPAN>(<SPAN style="COLOR: navy">transform</SPAN>);
<SPAN style="COLOR: navy">camera</SPAN>-><SPAN style="COLOR: #880000">OrthogonalizeViewUp</SPAN>();
<SPAN style="COLOR: green">// For rescale back.</SPAN>
<SPAN style="COLOR: navy">temp</SPAN>= <SPAN style="COLOR: navy">camera</SPAN>-><SPAN style="COLOR: #880000">GetFocalPoint</SPAN>();
<SPAN style="COLOR: navy">camera</SPAN>-><SPAN style="COLOR: #880000">SetFocalPoint</SPAN>(<SPAN style="COLOR: navy">temp</SPAN>[0]*<SPAN style="COLOR: navy">scale</SPAN>, <SPAN style="COLOR: navy">temp</SPAN>[1]*<SPAN style="COLOR: navy">scale</SPAN>, <SPAN style="COLOR: navy">temp</SPAN>[2]*<SPAN style="COLOR: navy">scale</SPAN>);
<SPAN style="COLOR: navy">temp</SPAN>= <SPAN style="COLOR: navy">camera</SPAN>-><SPAN style="COLOR: #880000">GetPosition</SPAN>();
<SPAN style="COLOR: navy">camera</SPAN>-><SPAN style="COLOR: #880000">SetPosition</SPAN>(<SPAN style="COLOR: navy">temp</SPAN>[0]*<SPAN style="COLOR: navy">scale</SPAN>, <SPAN style="COLOR: navy">temp</SPAN>[1]*<SPAN style="COLOR: navy">scale</SPAN>, <SPAN style="COLOR: navy">temp</SPAN>[2]*<SPAN style="COLOR: navy">scale</SPAN>);
<SPAN style="COLOR: navy">ren</SPAN>-><SPAN style="COLOR: #880000">ResetCameraClippingRange</SPAN>();
<SPAN style="COLOR: navy">rwi</SPAN>-><SPAN style="COLOR: #880000">Render</SPAN>();
<SPAN style="COLOR: navy">transform</SPAN>-><SPAN style="COLOR: #880000">Delete</SPAN>();
}
<SPAN style="COLOR: blue">virtual</SPAN> <SPAN style="COLOR: blue">void</SPAN> <SPAN style="COLOR: #880000">Spin</SPAN>()
{
<SPAN style="COLOR: blue">if</SPAN> (<SPAN style="COLOR: navy">CurrentRenderer</SPAN> == <SPAN style="COLOR: #a000a0">NULL</SPAN>)
<SPAN style="COLOR: blue">return</SPAN>;
<SPAN style="COLOR: blue">vtkRenderer</SPAN> *<SPAN style="COLOR: navy">ren</SPAN>= <SPAN style="COLOR: navy">CurrentRenderer</SPAN>;
<SPAN style="COLOR: blue">vtkCamera</SPAN> *<SPAN style="COLOR: navy">camera</SPAN>= <SPAN style="COLOR: navy">ren</SPAN>-><SPAN style="COLOR: #880000">GetActiveCamera</SPAN>();
<SPAN style="COLOR: blue">vtkRenderWindowInteractor</SPAN> *<SPAN style="COLOR: navy">rwi</SPAN>= <SPAN style="COLOR: navy">Interactor</SPAN>;
<SPAN style="COLOR: blue">double</SPAN> <SPAN style="COLOR: navy">axis</SPAN>[3];
<SPAN style="COLOR: green">// compute view vector (rotation axis)</SPAN>
<SPAN style="COLOR: blue">double</SPAN> *<SPAN style="COLOR: navy">pos</SPAN>= <SPAN style="COLOR: navy">camera</SPAN>-><SPAN style="COLOR: #880000">GetPosition</SPAN>();
<SPAN style="COLOR: blue">double</SPAN> *<SPAN style="COLOR: navy">fp</SPAN>= <SPAN style="COLOR: navy">camera</SPAN>-><SPAN style="COLOR: #880000">GetFocalPoint</SPAN>();
<SPAN style="COLOR: navy">axis</SPAN>[0]= <SPAN style="COLOR: navy">fp</SPAN>[0] - <SPAN style="COLOR: navy">pos</SPAN>[0];
<SPAN style="COLOR: navy">axis</SPAN>[1]= <SPAN style="COLOR: navy">fp</SPAN>[1] - <SPAN style="COLOR: navy">pos</SPAN>[1];
<SPAN style="COLOR: navy">axis</SPAN>[2]= <SPAN style="COLOR: navy">fp</SPAN>[2] - <SPAN style="COLOR: navy">pos</SPAN>[2];
<SPAN style="COLOR: blue">int</SPAN> <SPAN style="COLOR: navy">x1</SPAN>, <SPAN style="COLOR: navy">x2</SPAN>, <SPAN style="COLOR: navy">y1</SPAN>, <SPAN style="COLOR: navy">y2</SPAN>;
<SPAN style="COLOR: navy">x1</SPAN>= <SPAN style="COLOR: navy">rwi</SPAN>-><SPAN style="COLOR: #880000">GetLastEventPosition</SPAN>()[0] - (<SPAN style="COLOR: blue">int</SPAN>) <SPAN style="COLOR: navy">m_display_center</SPAN>[0];
<SPAN style="COLOR: navy">x2</SPAN>= <SPAN style="COLOR: navy">rwi</SPAN>-><SPAN style="COLOR: #880000">GetEventPosition</SPAN>()[0] - (<SPAN style="COLOR: blue">int</SPAN>) <SPAN style="COLOR: navy">m_display_center</SPAN>[0];
<SPAN style="COLOR: navy">y1</SPAN>= <SPAN style="COLOR: navy">rwi</SPAN>-><SPAN style="COLOR: #880000">GetLastEventPosition</SPAN>()[1] - (<SPAN style="COLOR: blue">int</SPAN>) <SPAN style="COLOR: navy">m_display_center</SPAN>[1];
<SPAN style="COLOR: navy">y2</SPAN>= <SPAN style="COLOR: navy">rwi</SPAN>-><SPAN style="COLOR: #880000">GetEventPosition</SPAN>()[1] - (<SPAN style="COLOR: blue">int</SPAN>) <SPAN style="COLOR: navy">m_display_center</SPAN>[1];
<SPAN style="COLOR: blue">if</SPAN> ((<SPAN style="COLOR: navy">x2</SPAN> == 0.0 && <SPAN style="COLOR: navy">y2</SPAN> == 0.0) || (<SPAN style="COLOR: navy">x1</SPAN> == 0.0 && <SPAN style="COLOR: navy">y1</SPAN> == 0.0))
{
<SPAN style="COLOR: green">//don't ever want to divide by zero</SPAN>
<SPAN style="COLOR: blue">return</SPAN>;
}
<SPAN style="COLOR: green">// - divide by magnitudes to get angle</SPAN>
<SPAN style="COLOR: blue">double</SPAN> <SPAN style="COLOR: navy">angle</SPAN>= <SPAN style="COLOR: blue">vtkMath</SPAN>::<SPAN style="COLOR: #880000">DegreesFromRadians</SPAN>((<SPAN style="COLOR: navy">x1</SPAN>*<SPAN style="COLOR: navy">y2</SPAN> - <SPAN style="COLOR: navy">y1</SPAN>*<SPAN style="COLOR: navy">x2</SPAN>)/(<SPAN style="COLOR: #a000a0">sqrt</SPAN>(<SPAN style="COLOR: blue">static_cast</SPAN><<SPAN style="COLOR: blue">double</SPAN>>(<SPAN style="COLOR: navy">x1</SPAN>*<SPAN style="COLOR: navy">x1</SPAN> + <SPAN style="COLOR: navy">y1</SPAN>*<SPAN style="COLOR: navy">y1</SPAN>))*<SPAN style="COLOR: #a000a0">sqrt</SPAN>(<SPAN style="COLOR: blue">static_cast</SPAN><<SPAN style="COLOR: blue">double</SPAN>>(<SPAN style="COLOR: navy">x2</SPAN>*<SPAN style="COLOR: navy">x2</SPAN> + <SPAN style="COLOR: navy">y2</SPAN>*<SPAN style="COLOR: navy">y2</SPAN>))));
<SPAN style="COLOR: green">// translate to center</SPAN>
<SPAN style="COLOR: blue">vtkTransform</SPAN> *<SPAN style="COLOR: navy">transform</SPAN>= <SPAN style="COLOR: blue">vtkTransform</SPAN>::<SPAN style="COLOR: #880000">New</SPAN>();
<SPAN style="COLOR: navy">transform</SPAN>-><SPAN style="COLOR: #880000">Identity</SPAN>();
<SPAN style="COLOR: navy">transform</SPAN>-><SPAN style="COLOR: #880000">Translate</SPAN>(<SPAN style="COLOR: navy">m_center</SPAN>[0], <SPAN style="COLOR: navy">m_center</SPAN>[1], <SPAN style="COLOR: navy">m_center</SPAN>[2]);
<SPAN style="COLOR: green">// roll</SPAN>
<SPAN style="COLOR: navy">transform</SPAN>-><SPAN style="COLOR: #880000">RotateWXYZ</SPAN>(<SPAN style="COLOR: navy">angle</SPAN>, <SPAN style="COLOR: navy">axis</SPAN>[0], <SPAN style="COLOR: navy">axis</SPAN>[1], <SPAN style="COLOR: navy">axis</SPAN>[2]);
<SPAN style="COLOR: green">// translate back</SPAN>
<SPAN style="COLOR: navy">transform</SPAN>-><SPAN style="COLOR: #880000">Translate</SPAN>(-<SPAN style="COLOR: navy">m_center</SPAN>[0], -<SPAN style="COLOR: navy">m_center</SPAN>[1], -<SPAN style="COLOR: navy">m_center</SPAN>[2]);
<SPAN style="COLOR: navy">camera</SPAN>-><SPAN style="COLOR: #880000">ApplyTransform</SPAN>(<SPAN style="COLOR: navy">transform</SPAN>);
<SPAN style="COLOR: navy">camera</SPAN>-><SPAN style="COLOR: #880000">OrthogonalizeViewUp</SPAN>();
<SPAN style="COLOR: navy">ren</SPAN>-><SPAN style="COLOR: #880000">ResetCameraClippingRange</SPAN>();
<SPAN style="COLOR: navy">rwi</SPAN>-><SPAN style="COLOR: #880000">Render</SPAN>();
<SPAN style="COLOR: navy">transform</SPAN>-><SPAN style="COLOR: #880000">Delete</SPAN>();
}
<SPAN style="COLOR: blue">protected</SPAN>:
<SPAN style="COLOR: blue">InteractorStyleTrackballCamera</SPAN>()
{
<SPAN style="COLOR: navy">m_center</SPAN>[0]= <SPAN style="COLOR: navy">m_center</SPAN>[1]= <SPAN style="COLOR: navy">m_center</SPAN>[2]= <SPAN style="COLOR: navy">m_display_center</SPAN>[0]= <SPAN style="COLOR: navy">m_display_center</SPAN>[1]= 0;
}
<SPAN style="COLOR: green">// Calculate the center of the visible actors.</SPAN>
<SPAN style="COLOR: blue">void</SPAN> <SPAN style="COLOR: #880000">UpdateCenterOfRotation</SPAN>(<SPAN style="COLOR: blue">vtkRenderer</SPAN> *<SPAN style="COLOR: navy">ren</SPAN>)
{
<SPAN style="COLOR: blue">vtkActorCollection</SPAN> *<SPAN style="COLOR: navy">actors</SPAN>= <SPAN style="COLOR: navy">ren</SPAN>-><SPAN style="COLOR: #880000">GetActors</SPAN>();
<SPAN style="COLOR: blue">vtkCollectionSimpleIterator</SPAN> <SPAN style="COLOR: navy">cookie</SPAN>;
<SPAN style="COLOR: blue">vtkActor</SPAN> *<SPAN style="COLOR: navy">actor</SPAN>;
<SPAN style="COLOR: navy">m_center</SPAN>[0]= <SPAN style="COLOR: navy">m_center</SPAN>[1]= <SPAN style="COLOR: navy">m_center</SPAN>[2]= 0;
<SPAN style="COLOR: navy">actors</SPAN>-><SPAN style="COLOR: #880000">InitTraversal</SPAN>(<SPAN style="COLOR: navy">cookie</SPAN>);
<SPAN style="COLOR: blue">while</SPAN> ((<SPAN style="COLOR: navy">actor</SPAN>= <SPAN style="COLOR: navy">actors</SPAN>-><SPAN style="COLOR: #880000">GetNextActor</SPAN>(<SPAN style="COLOR: navy">cookie</SPAN>)) != <SPAN style="COLOR: #a000a0">NULL</SPAN>)
{
<SPAN style="COLOR: blue">if</SPAN> (<SPAN style="COLOR: navy">actor</SPAN>-><SPAN style="COLOR: #880000">GetVisibility</SPAN>())
{
<SPAN style="COLOR: blue">double</SPAN> *<SPAN style="COLOR: navy">actor_center</SPAN>= <SPAN style="COLOR: navy">actor</SPAN>-><SPAN style="COLOR: #880000">GetCenter</SPAN>();
<SPAN style="COLOR: navy">m_center</SPAN>[0]+= <SPAN style="COLOR: navy">actor_center</SPAN>[0];
<SPAN style="COLOR: navy">m_center</SPAN>[1]+= <SPAN style="COLOR: navy">actor_center</SPAN>[1];
<SPAN style="COLOR: navy">m_center</SPAN>[2]+= <SPAN style="COLOR: navy">actor_center</SPAN>[2];
}
}
<SPAN style="COLOR: navy">m_center</SPAN>[0]/= <SPAN style="COLOR: navy">actors</SPAN>-><SPAN style="COLOR: #880000">GetNumberOfItems</SPAN>();
<SPAN style="COLOR: navy">m_center</SPAN>[1]/= <SPAN style="COLOR: navy">actors</SPAN>-><SPAN style="COLOR: #880000">GetNumberOfItems</SPAN>();
<SPAN style="COLOR: navy">m_center</SPAN>[2]/= <SPAN style="COLOR: navy">actors</SPAN>-><SPAN style="COLOR: #880000">GetNumberOfItems</SPAN>();
}
<SPAN style="COLOR: green">// Updates the screen center of rotation. Must be called after UpdateCenterOfRotation(),</SPAN>
<SPAN style="COLOR: blue">void</SPAN> <SPAN style="COLOR: #880000">UpdateScreenCenterOfRotation</SPAN>(<SPAN style="COLOR: blue">vtkRenderer</SPAN> *<SPAN style="COLOR: navy">ren</SPAN>)
{
<SPAN style="COLOR: blue">double</SPAN> *<SPAN style="COLOR: navy">pt</SPAN>;
<SPAN style="COLOR: green">// save the center of rotation in screen coordinates</SPAN>
<SPAN style="COLOR: navy">ren</SPAN>-><SPAN style="COLOR: #880000">SetWorldPoint</SPAN>(<SPAN style="COLOR: navy">m_center</SPAN>[0], <SPAN style="COLOR: navy">m_center</SPAN>[1], <SPAN style="COLOR: navy">m_center</SPAN>[2], 1.0);
<SPAN style="COLOR: navy">ren</SPAN>-><SPAN style="COLOR: #880000">WorldToDisplay</SPAN>();
<SPAN style="COLOR: navy">pt</SPAN>= <SPAN style="COLOR: navy">ren</SPAN>-><SPAN style="COLOR: #880000">GetDisplayPoint</SPAN>();
<SPAN style="COLOR: navy">m_display_center</SPAN>[0]= <SPAN style="COLOR: navy">pt</SPAN>[0];
<SPAN style="COLOR: navy">m_display_center</SPAN>[1]= <SPAN style="COLOR: navy">pt</SPAN>[1];
}
<SPAN style="COLOR: blue">private</SPAN>:
<SPAN style="COLOR: blue">double</SPAN> <SPAN style="COLOR: navy">m_center</SPAN>[3], <SPAN style="COLOR: green">// In model coordinates.</SPAN>
<SPAN style="COLOR: navy">m_display_center</SPAN>[2]; <SPAN style="COLOR: green">// In display coordinates.</SPAN>
};
<SPAN style="COLOR: #a000a0">vtkStandardNewMacro</SPAN>(<SPAN style="COLOR: blue">InteractorStyleTrackballCamera</SPAN>);
</PRE><BR><BR>
<DIV class=moz-cite-prefix>On 8/13/2013 8:59 AM, Serge Lalonde
wrote:<BR></DIV>
<BLOCKQUOTE cite=mid:520A2DB1.2090309@infolytica.com type="cite">I've gotten
no replies to this question. Does that mean that no one else has had this
problem?<BR><BR>Can someone please confirm that they're using panning with
vtkInteractorStyleTrackballCamera without any problems in
5.10?<BR><BR>Thanks.<BR><BR>
<DIV class=moz-cite-prefix>On 8/6/2013 10:49 AM, Serge Lalonde
wrote:<BR></DIV>
<BLOCKQUOTE cite=mid:52010CDD.7000607@infolytica.com type="cite">I tried
panning in ParaView and the clipping works properly. Is it using the
vtkInteractorStyleTrackballCamera or something else?<BR><BR>The problem is
that it looks like the rotation center is wrong after panning, causing the
model to be rotated out of the clipping range. It looks like the rotation
center is the center of the window instead of the center of the model.
Also, I have multiple actors in the scene. Could that be a
problem?<BR><BR>I'm not doing anything (that I can tell) to affect this.
Could it be a bug in VTK 5.10? If so, does anyone know of a
workaround?<BR><BR>Thanks!<BR><BR>
<DIV class=moz-cite-prefix>On 8/2/2013 3:59 PM, Serge Lalonde
wrote:<BR></DIV>
<BLOCKQUOTE cite=mid:51FC0FB4.50209@infolytica.com type="cite">I notice
that when using the vtkInteractorStyleTrackballCamera panning, I'll
subsequently see a clipping problem if I rotate the actors
afterwards.<BR>Calling ResetCameraClippingRange() on the renderer has no
effect. I'm using VTK 5.10.<BR><BR>Is there a workaround for this? It
seems like a pretty serious problem. I searched the archives without
much success for a fix for this.<BR><BR>Note: Back in October 2008 (5
years already!), when I was prototyping with VTK, I posted a fix to
vtkusers and <A class=moz-txt-link-abbreviated
href="http://www.vtk.org/bug" moz-do-not-send="true">www.vtk.org/bug</A>
for vtkRenderer and vtkCamera that fixed a similar clipping problem in
VTK 5.2. After examining the 5.10 source code, it looks like the fix was
never integrated into VTK's official code branch. The page is <A
class=moz-txt-link-freetext
href="http://www.vtk.org/Bug/view.php?id=7823"
moz-do-not-send="true">http://www.vtk.org/Bug/view.php?id=7823</A> and I
noticed that its status is expired. Other users commented in that bug
report that it fixed their problems and some even improved the fix.
<BR></BLOCKQUOTE><BR>
<DIV class=moz-signature>-- <BR><A href="http:://www.infolytica.com"
moz-do-not-send="true">www.infolytica.com </A><BR>300 Leo Pariseau, Suite
2222, Montreal, QC, Canada, H2X 4B3<BR>(514) 849-8752 x236, Fax: (514)
849-4239 </DIV><BR>
<FIELDSET class=mimeAttachmentHeader></FIELDSET> <BR><PRE wrap="">_______________________________________________
Powered by <A class=moz-txt-link-abbreviated href="http://www.kitware.com" moz-do-not-send="true">www.kitware.com</A>
Visit other Kitware open-source projects at <A class=moz-txt-link-freetext href="http://www.kitware.com/opensource/opensource.html" moz-do-not-send="true">http://www.kitware.com/opensource/opensource.html</A>
Please keep messages on-topic and check the VTK FAQ at: <A class=moz-txt-link-freetext href="http://www.vtk.org/Wiki/VTK_FAQ" moz-do-not-send="true">http://www.vtk.org/Wiki/VTK_FAQ</A>
Follow this link to subscribe/unsubscribe:
<A class=moz-txt-link-freetext href="http://www.vtk.org/mailman/listinfo/vtkusers" moz-do-not-send="true">http://www.vtk.org/mailman/listinfo/vtkusers</A>
</PRE></BLOCKQUOTE><BR>
<DIV class=moz-signature>-- <BR><A href="http:://www.infolytica.com"
moz-do-not-send="true">www.infolytica.com </A><BR>300 Leo Pariseau, Suite
2222, Montreal, QC, Canada, H2X 4B3<BR>(514) 849-8752 x236, Fax: (514)
849-4239 </DIV><BR>
<FIELDSET class=mimeAttachmentHeader></FIELDSET> <BR><PRE wrap="">_______________________________________________
Powered by <A class=moz-txt-link-abbreviated href="http://www.kitware.com">www.kitware.com</A>
Visit other Kitware open-source projects at <A class=moz-txt-link-freetext href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</A>
Please keep messages on-topic and check the VTK FAQ at: <A class=moz-txt-link-freetext href="http://www.vtk.org/Wiki/VTK_FAQ">http://www.vtk.org/Wiki/VTK_FAQ</A>
Follow this link to subscribe/unsubscribe:
<A class=moz-txt-link-freetext href="http://www.vtk.org/mailman/listinfo/vtkusers">http://www.vtk.org/mailman/listinfo/vtkusers</A>
</PRE></BLOCKQUOTE><BR>
<DIV class=moz-signature>-- <BR><A
href="http:://www.infolytica.com">www.infolytica.com </A><BR>300 Leo Pariseau,
Suite 2222, Montreal, QC, Canada, H2X 4B3<BR>(514) 849-8752 x236, Fax: (514)
849-4239 </DIV>
<P>
<HR>
<P></P>_______________________________________________<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></BLOCKQUOTE></BODY></HTML>