[vtkusers] saving and restoring views
Ted Christiansen
ted at caept.com
Wed May 1 10:56:29 EDT 2002
Malcolm,
Thanks for your email. The zoom factor is what is not working. The source code
is attached. Any ideas?
Ted
//////////////////////////////////////////////////////////////////////
// Save view
//////////////////////////////////////////////////////////////////////
void FEVview::SaveView(CFEvisGLView *view)
{
vtkCamera *cam = view->Renderer->GetActiveCamera();
// get view
cam->GetPosition(m_vtkposition[0], m_vtkposition[1], m_vtkposition[2]);
cam->GetFocalPoint(m_vtkfocalpoint[0], m_vtkfocalpoint[1], m_vtkfocalpoint[2]);
m_vtkviewangle = cam->GetViewAngle();
cam->GetViewUp(m_vtkviewup[0], m_vtkviewup[1], m_vtkviewup[2]);
cam->GetClippingRange(m_vtkcliprange[0], m_vtkcliprange[1]);
}
//////////////////////////////////////////////////////////////////////
// Show view
//////////////////////////////////////////////////////////////////////
void FEVview::ShowView(CFEvisGLView *view)
{
vtkCamera *cam = view->Renderer->GetActiveCamera();
// get view
cam->SetPosition(m_vtkposition[0], m_vtkposition[1], m_vtkposition[2]);
cam->SetFocalPoint(m_vtkfocalpoint[0], m_vtkfocalpoint[1], m_vtkfocalpoint[2]);
cam->SetViewAngle(m_vtkviewangle);
cam->SetViewUp(m_vtkviewup[0], m_vtkviewup[1], m_vtkviewup[2]);
cam->SetClippingRange(m_vtkcliprange[0], m_vtkcliprange[1]);
}
Malcolm Drummond wrote:
> Hi
>
> The following procs work in a Tcl script I'm running under vtk 3.2. My guess
> would be that the call to SetDistance is unnecessary and causes
> re-computation - but I haven't looked at the source code, it might be a vtk
> 4.0 thing. (btw I agree it would be a nice feature to set font sizes, for
> any overlay objects, and not have them resize. Is anyone working on this?)
>
> proc app::GetCurrentView {} {
> set cam [ren GetActiveCamera]
> set cp [$cam GetPosition]
> set fp [$cam GetFocalPoint]
> set vu [$cam GetViewUp]
> set cr [$cam GetClippingRange]
> return "{$cp} {$fp} {$vu} {$cr}"
> }
>
> proc app::SetView {view} {
> set cam [ren GetActiveCamera]
> eval $cam SetPosition [lindex $view 0];
> eval $cam SetFocalPoint [lindex $view 1];
> eval $cam SetViewUp [lindex $view 2];
> eval $cam SetClippingRange [lindex $view 3];
> $cam ComputeViewPlaneNormal;
> set lights [ren GetLights];
> $lights InitTraversal;
> set light [$lights GetNextItem];
> eval $light SetPosition [lindex $view 0];
> eval $light SetFocalPoint [lindex $view 1];
> app::Render
> }
More information about the vtkusers
mailing list