[vtkusers] interaction test using two renderwindow

Jinyoung Hwang hwangjinyoung at gmail.com
Tue May 18 02:48:28 EDT 2010


Hi folks,

I'm trying to test the synchronization of two renderwindows.
I first made two renderwindow using vtkRenderWindow.
Then, below callback funcion is used when left mouse button is clicked.


---
in Main():
renderWindowInteractor->AddObserver(vtkCommand::LeftButtonPressEvent,
callback, 1.0);
---

---
callback function:

static void interaction_test(vtkObject* obj, unsigned long, void*, void*)
{
vtkRenderWindowInteractor *iren =
vtkRenderWindowInteractor::SafeDownCast(obj);
if(iren && iren->GetRepeatCount()) {
cout << "Double Click";
    }

cout<< "----" << endl;

vtkCollectionSimpleIterator si;

vtkSmartPointer<vtkRendererCollection> renc =
vtkSmartPointer<vtkRendererCollection>::New();
renc = renderWindowInteractor2->GetRenderWindow()->GetRenderers();
renc->InitTraversal(si);
 vtkSmartPointer<vtkRenderer> ren1 = vtkSmartPointer<vtkRenderer>::New();
ren1 = ren->GetFirstRenderer();

vtkSmartPointer<vtkRenderer> ren2 = vtkSmartPointer<vtkRenderer>::New();
ren2 = ren->GetNextRenderer(si);

vtkMatrix4x4 *trmat1 =
firstren->GetActiveCamera()->GetViewTransformMatrix();
  cout << trmat1->GetElement(0,0) << " " << trmat1->GetElement(0,1)<< " " <<
trmat1->GetElement(0,2)<< " " << trmat1->GetElement(0,3) << endl;
  cout << trmat1->GetElement(1,0) << " "<< trmat1->GetElement(1,1)<< " " <<
trmat1->GetElement(1,2)<< " " << trmat1->GetElement(1,3) << endl;
  cout << trmat1->GetElement(2,0) << " "<< trmat1->GetElement(2,1)<< " " <<
trmat1->GetElement(2,2)<< " " << trmat1->GetElement(2,3) << endl;
  cout << trmat1->GetElement(3,0) << " "<< trmat1->GetElement(3,1)<< " " <<
trmat1->GetElement(3,2)<< " " << trmat1->GetElement(3,3) << endl;

vtkMatrix4x4 *trmat2 =
secondren->GetActiveCamera()->GetViewTransformMatrix();
  cout << trmat2->GetElement(0,0) << " " << trmat2->GetElement(0,1)<< " " <<
trmat2->GetElement(0,2)<< " " << trmat2->GetElement(0,3) << endl;
  cout << trmat2->GetElement(1,0) << " "<< trmat2->GetElement(1,1)<< " " <<
trmat2->GetElement(1,2)<< " " << trmat2->GetElement(1,3) << endl;
  cout << trmat2->GetElement(2,0) << " "<< trmat2->GetElement(2,1)<< " " <<
trmat2->GetElement(2,2)<< " " << trmat2->GetElement(2,3) << endl;
  cout << trmat2->GetElement(3,0) << " "<< trmat2->GetElement(3,1)<< " " <<
trmat2->GetElement(3,2)<< " " << trmat2->GetElement(3,3) << endl;
}

At this code, when I control the mouse in renderwindow A, I can obtain the
information of renderwindow B.
However, I cannot get the information of renderwindow A.
Two vtkMatrix4x4 instances showed same results.
How to get trmat1 of renderwindow A and trmat2 of renderwindow B?

regards,

JY
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100518/69b4ac9a/attachment.htm>


More information about the vtkusers mailing list