[vtkusers] Initializing QVTKInteractor from within a QVTKWidget

John Drescher drescherjm at gmail.com
Fri Jun 6 18:04:48 EDT 2008


On Fri, Jun 6, 2008 at 5:57 PM, John Eke <johne at annidis.com> wrote:
> Hello People,
>
> I have written a class that sub-classes the QVTKWidget. Problem is, for some
> reason I cannot properly initialize the QVTKInteractor. Can someone please
> share a code snippet for an example of how to properly initialize an
> interactor from within this sub-class, for example using
> vtkInteractorStyleImage.
>

Although I am very new at this here is what I have (I hope this helps):

void VTK2dWidget::SetImageViewer(ISIS::ImageSliceViewer* image_view)
{
	m_pImage_view = image_view;

	if (m_pImage_view) {
		int nFirstSlice;
		int nLastSlice;

		if (m_pImage_view->GetExtent(nFirstSlice,nLastSlice)) {
			horizontalSlider->setRange(nFirstSlice,nLastSlice);
			nLastSlice -= nFirstSlice;
			if (nLastSlice > 0) {
				nLastSlice >>= 1;
				horizontalSlider->setValue(nLastSlice);
			}

			vtkRenderWindowInteractor* pInteractor =
m_pImage_view->m_RenderWindow->GetInteractor();
			if (pInteractor == NULL) {
				pInteractor = QVTKInteractor::New();
				m_pImage_view->m_RenderWindow->SetInteractor(pInteractor);
			}
			if (pInteractor) {
				vtkInteractorStyleImage * interactorStyle = vtkInteractorStyleImage::New();
				pInteractor->SetInteractorStyle( interactorStyle );
			}
			
			InitializeSlotConnections();

		}
	}
	


	qvtkWidget->SetRenderWindow(image_view->m_RenderWindow);
}



More information about the vtkusers mailing list