[Insight-users] Replace fltk with Qt in ApplicationModel

jiang jiang at TI . Uni-Trier . DE
Fri, 10 Oct 2003 18:14:07 +0200


Hi, all,
ApplicationModel is a very nice example application that reads dicom files
with ITK and render them with VTK. It is recommended by Luis Ibanez in
http://www . itk . org/pipermail/insight-users/2003-September/005090 . html

In this application, the user interface is fltk. I want to replace it with
Qt. Now some functions are availabel, such as read dicom files, render them
in three cross section windows and display image of difference position by
slider bar.
However, there is one interesting function that I can not realize with Qt.
It is that one user clicks in one display window, the other two windows will
display the image in the position where clicked point is slected in the
first window. My method is:
1. Add codes in void vtkQtRenderWindow::mouseReleaseEvent(QMouseEvent *me)
	ClickedPos[0]=me->pos().x();
	ClickedPos[1]=me->pos().y();
To get the mouse clicked position.

2. In ImageSliceViewer.cxx
	m_RenderWindow = new vtkQtRenderWindow(frame);//frame is where the image
displayed.
Add one function for getting clicked position for m_RenderWindow
int* ImageSliceViewer::GetClickedPos()
{
	int ClickedPos[2];
	ClickedPos[0]=m_RenderWindow->ClickedPos[0];
	ClickedPos[1]=m_RenderWindow->ClickedPos[1];

	return ClickedPos;
}

3. In InteractorObserver::Execute(vtkObject * caller, unsigned long eventId,
void *callData)
Modify code
  if( m_SliceViewer )
    {
      const int x = Fl::event_x();
      const int y = Fl::event_y();
	m_SliceViewer->SelectPoint( x, y );
    }

To
	int *pos;
	pos=new int[2];
  if( m_SliceViewer )
    {
	pos= m_SliceViewer->GetClickedPos();
    	m_SliceViewer->SelectPoint( pos[0], pos[1] );
    }


When I test it, the mouseReleaseEvent can work. But
InteractorObserver::Execute can not be invoked after mouse clicked. I tried
ApplicationModel, and when mouse click event is invoked, the
InteractorObserver::Execute will be invoked. It seems that Fl::event_x()
gets the mouse event, so InteractorObserver::Execute is invoked.
I'm a newbie for Qt. Should I do some thing in order to invoke
InteractorObserver::Execute?



Thanks a lot!

Chunyan Jiang