[vtkusers] saving and restoring views
Malcolm Drummond
malcolm at geovision.co.za
Tue Apr 9 17:16:33 EDT 2002
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
}
----- Original Message -----
From: Ted Christiansen <ted at caept.com>
To: <vtkusers at public.kitware.com>
Sent: Tuesday, April 09, 2002 9:02 PM
Subject: [vtkusers] saving and restoring views
> Hello,
>
> I am trying to save and restore a view. Everything works except for the
> zoom. Any suggestions?
>
> Ted
>
> Here is the code to save the view:
>
> vtkCamera *cam = view->Renderer->GetActiveCamera();
> // save 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]);
> m_distance = cam->GetDistance();
>
>
>
> Here is the code to show the previously saved view:
>
> vtkCamera *cam = view->Renderer->GetActiveCamera();
>
> // show 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->SetDistance(m_distance);
>
>
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at:
<http://public.kitware.com/cgi-bin/vtkfaq>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
>
>
More information about the vtkusers
mailing list