<P>
hi<BR>
 <BR>
i have used vtkBoxWidget for scaling my volume data and it works fine except that the image and the widget and not aligned.<BR>
When i scale the volume or rotate it , it moves out of the widget.<BR>
Please suugest a solution for this.<BR>
I am including my code here<BR>
 <BR>
vtkRenderWindowInteractor *iren;<BR>
vtkVolume *vol;<BR>
vtkRenderWindow *renwin;<BR>
vtkRenderer *ren;<BR>
vtkCamera *cam;<BR>
vtkVolumeRayCastMapper *volMapper;<BR>
class vtkMyCallback : public vtkCommand<BR>
{<BR>
public:<BR>
&nbsp; static vtkMyCallback *New() <BR>
&nbsp; &nbsp; { return new vtkMyCallback; }<BR>
&nbsp; virtual void Execute(vtkObject *caller, unsigned long, void*)<BR>
&nbsp; &nbsp; {<BR>
&nbsp; &nbsp; &nbsp; vtkTransform *t = vtkTransform::New();<BR>
&nbsp; &nbsp; &nbsp; vtkBoxWidget *widget = reinterpret_cast&lt;vtkBoxWidget*&gt;(caller);<BR>
&nbsp; &nbsp; &nbsp; widget-&gt;GetTransform(t);<BR>
&nbsp; &nbsp; &nbsp; widget-&gt;GetProp3D()-&gt;SetUserTransform(t);<BR>
&nbsp; &nbsp; }<BR>
};<BR>
int main( int argc, char *argv[] )<BR>
{<BR>
 vtkImageReader *Reader = vtkImageReader::New();<BR>
&nbsp; &nbsp; &nbsp; &nbsp; Reader-&gt; SetHeaderSize (0); <BR>
&nbsp; &nbsp; &nbsp; &nbsp; Reader-&gt;SetDataExtent (0,199,0,199,0,99);<BR>
&nbsp; &nbsp; &nbsp; &nbsp; Reader-&gt;SetDataSpacing(1.0,1.0,1.0);<BR>
&nbsp; &nbsp; &nbsp; &nbsp; Reader-&gt;SetDataScalarTypeToUnsignedChar();<BR>
&nbsp; &nbsp; &nbsp; &nbsp; Reader-&gt;SetDataByteOrderToLittleEndian();<BR>
&nbsp; &nbsp; &nbsp; &nbsp; Reader-&gt;SetFileDimensionality(3);<BR>
&nbsp; &nbsp; &nbsp; &nbsp; Reader-&gt;SetFileName(&quot;d:/bym280602b&quot;);<BR>
&nbsp; &nbsp;  Reader-&gt;SetDataMask(0x7fff);<BR>
<BR>
&nbsp; &nbsp;  vtkPiecewiseFunction *oTFun =vtkPiecewiseFunction::New();<BR>
&nbsp; &nbsp; oTFun-&gt;AddSegment(32,0,255,1.0);<BR>
 vtkPiecewiseFunction *gTFun =vtkPiecewiseFunction::New();<BR>
&nbsp; &nbsp; gTFun-&gt;AddSegment(0,1.0,5,1.0);<BR>
&nbsp;  <BR>
&nbsp;  vtkVolumeProperty *volProperty = vtkVolumeProperty::New();<BR>
&nbsp; &nbsp; volProperty-&gt;SetColor(gTFun);<BR>
 volProperty-&gt;SetScalarOpacity(oTFun);<BR>
 volProperty-&gt;SetInterpolationTypeToLinear();<BR>
 volProperty-&gt;ShadeOn();<BR>
&nbsp;  <BR>
&nbsp;  vtkVolumeRayCastCompositeFunction *compositeFunction= vtkVolumeRayCastCompositeFunction::New();<BR>
 volMapper = vtkVolumeRayCastMapper::New();<BR>
&nbsp; &nbsp; volMapper-&gt;SetInput(Reader-&gt;GetOutput()); <BR>
 volMapper-&gt;SetVolumeRayCastFunction(compositeFunction);<BR>
 <BR>
 vol=vtkVolume::New();<BR>
 vol-&gt;SetMapper(volMapper);&nbsp; <BR>
 vol-&gt;SetProperty(volProperty);<BR>
<BR>
 ren=vtkRenderer::New();<BR>
&nbsp;  ren-&gt;AddVolume(vol);&nbsp;  <BR>
&nbsp;  <BR>
 <BR>
&nbsp; &nbsp; renwin=vtkRenderWindow::New();<BR>
&nbsp;  renwin-&gt;AddRenderer(ren);<BR>
&nbsp; &nbsp; renwin-&gt;SetSize(500,500);<BR>
&nbsp; &nbsp; iren=vtkRenderWindowInteractor::New();<BR>
&nbsp; &nbsp; iren-&gt;SetRenderWindow(renwin);<BR>
&nbsp; vtkInteractorStyleTrackballCamera *style = <BR>
&nbsp; &nbsp; vtkInteractorStyleTrackballCamera::New();<BR>
&nbsp; iren-&gt;SetInteractorStyle(style);<BR>
&nbsp;  vtkBoxWidget *boxWidget = vtkBoxWidget::New();<BR>
&nbsp; boxWidget-&gt;SetInteractor(iren);<BR>
&nbsp; boxWidget-&gt;SetPlaceFactor(1);<BR>
&nbsp; boxWidget-&gt;SetProp3D(vol);<BR>
&nbsp; boxWidget-&gt;PlaceWidget();<BR>
&nbsp; vtkMyCallback *callback = vtkMyCallback::New();<BR>
&nbsp; boxWidget-&gt;AddObserver(vtkCommand::InteractionEvent, callback);<BR>
 boxWidget-&gt;On();<BR>
&nbsp; iren-&gt;Initialize();<BR>
&nbsp; iren-&gt;Start();<BR>
&nbsp; <BR>
&nbsp;  return 0;<BR>
}<BR>
 <BR>

</P>
<br><br>
<A target="_blank" HREF="http://clients.rediff.com/signature/track_sig.asp"><IMG SRC="http://ads.rediff.com/RealMedia/ads/adstream_nx.cgi/www.rediffmail.com/inbox.htm@Bottom" BORDER=0 VSPACE=0 HSPACE=0 HEIGHT=74 WIDTH=496></a>