<div style="font-family:ËÎÌå;font-size:medium;color:#0000FF;;"><DIV>hi,</DIV>
<DIV> I wanna use QScrollBar and QSpinBox to respond with the slice image(axial,coronal,sagittal) of a volume in QVTKWidget.</DIV>
<DIV>So i wrote a ScrollBarCallback class .The code is as follows:</DIV>
<DIV>class ScrollBarCallback: public vtkCommand<BR>{<BR>public:<BR> static ScrollBarCallback *New()<BR> {return new ScrollBarCallback();};</DIV>
<DIV> ScrollBarCallback()<BR> {<BR> this->ScrollBar=0;<BR> this->Qinteractor=0;<BR> this->ImagePlaneWidget=0;</DIV>
<DIV> };<BR> void SetScrollBar(QScrollBar *scollbar)<BR> {<BR> this->ScrollBar=scollbar;</DIV>
<DIV> };<BR> QScrollBar *GetScrollBar()<BR> {<BR> return this->ScrollBar;<BR> };<BR> void SetInteractor(QVTKInteractor *interactor)<BR> {<BR> <BR> this->Qinteractor = interactor;<BR> };</DIV>
<DIV> QVTKInteractor *GetInteractor() <BR> {<BR> return this->Qinteractor;<BR> };</DIV>
<DIV> void SetImagePlaneWidget(vtkImagePlaneWidget *imageplane)<BR> {<BR> this->ImagePlaneWidget=imageplane;<BR> };<BR>vtkImagePlaneWidget *GetImagePlaneWidget()<BR>{<BR> return this->ImagePlaneWidget;<BR>};</DIV>
<DIV>virtual void Execute(vtkObject *, unsigned long event , void* )</DIV>
<DIV>{<BR> QScrollBar * slider=this->GetScrollBar();<BR> QVTKInteractor *interactor=this->GetInteractor();<BR> vtkImagePlaneWidget *imageplane= this->GetImagePlaneWidget();<BR> imageplane->SetInteractor(interactor);<BR> imageplane->SetSliceIndex(slider->value());</DIV>
<DIV> interactor->Start();</DIV>
<DIV>};</DIV>
<DIV>private:</DIV>
<DIV> QScrollBar *ScrollBar;<BR> QVTKInteractor *Qinteractor;<BR> vtkImagePlaneWidget *ImagePlaneWidget;</DIV>
<DIV> </DIV>
<DIV>};</DIV>
<DIV> </DIV>
<DIV>GUI4::GUI4()<BR>{<BR> this->setupUi(this);</DIV>
<DIV> renwin = vtkRenderWindow::New();<BR> renwin->StereoCapableWindowOn();</DIV>
<DIV> qVTK2->SetUseTDx(true);<BR> qVTK2->SetRenderWindow(renwin);<BR> renwin->Delete();</DIV>
<DIV> QVTKInteractor *iren2=qVTK2->GetInteractor();</DIV>
<DIV> iren2->SetInteractorStyle(iren->GetInteractorStyle());</DIV>
<DIV> Ren2 = vtkRenderer::New();<BR> qVTK2->GetRenderWindow()->AddRenderer(Ren2);</DIV>
<DIV> ...........</DIV>
<DIV> ...........</DIV>
<DIV> ...........</DIV>
<DIV>vtkProperty* ipwProp = vtkProperty::New();</DIV>
<DIV>vtkImagePlaneWidget* ipw = vtkImagePlaneWidget::New();</DIV>
<DIV> </DIV>
<DIV>ipw->SetKeyPressActivationValue('x');<BR> ipw->RestrictPlaneToVolumeOn();<BR> ipw->GetPlaneProperty()->SetColor(1,0,0);<BR> ipw->SetTexturePlaneProperty(ipwProp);<BR> ipw->SetResliceInterpolateToNearestNeighbour();<BR> ipw->SetInput(reader->GetOutput());<BR> ipw->SetPlaneOrientationToYAxes();<BR> ipw->SetSliceIndex(30);<BR> ipw->DisplayTextOn();</DIV>
<DIV> </DIV>
<DIV> vtkLookupTable *table2 =vtkLookupTable::New();<BR> table2->SetRange(0, 2000); </DIV>
<DIV> table2->SetValueRange(0.0, 1.0); <BR> table2->SetSaturationRange(0.0, 0.0); <BR> table2->SetRampToLinear();<BR> table2->Build();</DIV>
<DIV> vtkImageMapToColors *colorMap = vtkImageMapToColors::New();<BR> colorMap->SetInput(ipw->GetResliceOutput());<BR> colorMap->SetLookupTable(table2);</DIV>
<DIV> vtkImageActor *actor2 =vtkImageActor::New();<BR> actor2->SetInput(colorMap->GetOutput());</DIV>
<DIV> Ren2->AddActor(actor2); </DIV>
<DIV> QObject::connect(spinBox_2,SIGNAL(valueChanged(int)),verticalScrollBar_2,SLOT(setValue(int)));<BR> QObject::connect(verticalScrollBar_2,SIGNAL(valueChanged(int)),spinBox_2,SLOT(setValue(int)));<BR> verticalScrollBar_2->setValue(ipw->GetSliceIndex());</DIV>
<DIV> </DIV>
<DIV> ScrollBarCallback *callback=ScrollBarCallback::New();<BR> callback->SetScrollBar(verticalScrollBar_2);<BR> callback->SetImagePlaneWidget(ipw);<BR> callback->SetInteractor(iren2);</DIV>
<DIV><BR> iren2->GetInteractorStyle()->AddObserver(vtkCommand::InteractionEvent,callback);<BR> iren2->Start();<BR>...............</DIV>
<DIV>...............</DIV>
<DIV>...............</DIV>
<DIV> </DIV>
<DIV> When i used this ScrollBarCallback class, QVTKInteractor showed:</DIV>
<DIV> QVTKInteractor (02A60E78): QVTKInteractor cannot control the event loop.And the scrollbar can not control the the slice(setsliceindex()) . </DIV>
<DIV> I did not know which code was wrong,or maybe i should use vtkEventQtSlotConnect. I just did a try,using </DIV>
<DIV>vtkEventQtSlotConnect::Connect(imageplane->SetSliceIndex(int),vtkCommand::NoEvent,slider,SIGNAL(valueChanged(int)));</DIV>
<DIV>it also didn't work,maybe it was wrong.</DIV>
<DIV> </DIV>
<DIV>I was confused for more than a month.</DIV>
<DIV>Thanks for your advice and help. </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV></div>