<div dir="ltr">Try<br><br>contourWidget-&gt;SetInteractor(renderWindow-&gt;GetInteractor());<br><br>Jothy<br><br><div class="gmail_quote">On Tue, Nov 22, 2011 at 1:08 PM, Xavius <span dir="ltr">&lt;<a href="mailto:xavierelf@gmail.com">xavierelf@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hi all!<br>
I&#39;ve tried to use vtkContourWidget as shown in examples and found that it<br>
doesn&#39;t work with QVTKWidget.<br>
Here is a sample code:<br>
<br>
/<br>
QVTKWidget *widget = new QVTKWidget;<br>
setCentralWidget(widget);<br>
vtkSmartPointer&lt;vtkRenderer&gt; renderer = vtkSmartPointer&lt;vtkRenderer&gt;::New();<br>
  vtkRenderWindow *renderWindow = widget-&gt;GetRenderWindow();<br>
  renderWindow-&gt;AddRenderer(renderer);<br>
<br>
  QVTKInteractor *interactor = QVTKInteractor::New()<br>
  interactor-&gt;SetRenderWindow(renderWindow);<br>
<br>
  renderer-&gt;SetBackground(0.1, 0.2, 0.4);<br>
  renderWindow-&gt;SetSize(600, 600);<br>
<br>
  vtkSmartPointer&lt;vtkOrientedGlyphContourRepresentation&gt; contourRep =<br>
      vtkSmartPointer&lt;vtkOrientedGlyphContourRepresentation&gt;::New();<br>
  contourRep-&gt;GetLinesProperty()-&gt;SetColor(1, 0, 0); //set color to red<br>
<br>
  vtkSmartPointer&lt;vtkContourWidget&gt; contourWidget =<br>
      vtkSmartPointer&lt;vtkContourWidget&gt;::New();<br>
  contourWidget-&gt;SetInteractor(interactor);<br>
  contourWidget-&gt;SetRepresentation(contourRep);<br>
  contourWidget-&gt;On();<br>
<br>
  vtkSmartPointer&lt;vtkPolyData&gt; pd = vtkSmartPointer&lt;vtkPolyData&gt;::New();<br>
  vtkSmartPointer&lt;vtkPoints&gt; points = vtkSmartPointer&lt;vtkPoints&gt;::New();<br>
  vtkSmartPointer&lt;vtkCellArray&gt; lines =<br>
vtkSmartPointer&lt;vtkCellArray&gt;::New();<br>
  vtkIdType* lineIndices = new vtkIdType[21];<br>
  for (int i = 0; i&lt; 20; i++)<br>
    {<br>
    const double angle = 2.0*vtkMath::Pi()*i/20.0;<br>
    points-&gt;InsertPoint(static_cast&lt;vtkIdType&gt;(i), 0.1*cos(angle),<br>
                        0.1*sin(angle), 0.0 );<br>
    lineIndices[i] = static_cast&lt;vtkIdType&gt;(i);<br>
    }<br>
<br>
  lineIndices[20] = 0;<br>
  lines-&gt;InsertNextCell(21,lineIndices);<br>
  delete [] lineIndices;<br>
  pd-&gt;SetPoints(points);<br>
  pd-&gt;SetLines(lines);<br>
<br>
  contourWidget-&gt;Initialize(pd);<br>
  contourWidget-&gt;Render();<br>
  renderer-&gt;ResetCamera();<br>
  renderWindow-&gt;Render();<br>
<br>
  interactor-&gt;Initialize();<br>
/<br>
<br>
Please help me! What I&#39;m doing wrong? The same code outside QVTKWidget works<br>
flawless.<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
View this message in context: <a href="http://vtk.1045678.n5.nabble.com/Problem-with-vtkContourWidget-and-QVTKWidget-tp5013481p5013481.html" target="_blank">http://vtk.1045678.n5.nabble.com/Problem-with-vtkContourWidget-and-QVTKWidget-tp5013481p5013481.html</a><br>

Sent from the VTK - Users mailing list archive at Nabble.com.<br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
</font></span></blockquote></div><br><br clear="all"><br>-- <br><div dir="ltr">Jothy<br></div><br>
</div>