<div dir="ltr">Try<br><br>contourWidget->SetInteractor(renderWindow->GetInteractor());<br><br>Jothy<br><br><div class="gmail_quote">On Tue, Nov 22, 2011 at 1:08 PM, Xavius <span dir="ltr"><<a href="mailto:xavierelf@gmail.com">xavierelf@gmail.com</a>></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've tried to use vtkContourWidget as shown in examples and found that it<br>
doesn't work with QVTKWidget.<br>
Here is a sample code:<br>
<br>
/<br>
QVTKWidget *widget = new QVTKWidget;<br>
setCentralWidget(widget);<br>
vtkSmartPointer<vtkRenderer> renderer = vtkSmartPointer<vtkRenderer>::New();<br>
vtkRenderWindow *renderWindow = widget->GetRenderWindow();<br>
renderWindow->AddRenderer(renderer);<br>
<br>
QVTKInteractor *interactor = QVTKInteractor::New()<br>
interactor->SetRenderWindow(renderWindow);<br>
<br>
renderer->SetBackground(0.1, 0.2, 0.4);<br>
renderWindow->SetSize(600, 600);<br>
<br>
vtkSmartPointer<vtkOrientedGlyphContourRepresentation> contourRep =<br>
vtkSmartPointer<vtkOrientedGlyphContourRepresentation>::New();<br>
contourRep->GetLinesProperty()->SetColor(1, 0, 0); //set color to red<br>
<br>
vtkSmartPointer<vtkContourWidget> contourWidget =<br>
vtkSmartPointer<vtkContourWidget>::New();<br>
contourWidget->SetInteractor(interactor);<br>
contourWidget->SetRepresentation(contourRep);<br>
contourWidget->On();<br>
<br>
vtkSmartPointer<vtkPolyData> pd = vtkSmartPointer<vtkPolyData>::New();<br>
vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();<br>
vtkSmartPointer<vtkCellArray> lines =<br>
vtkSmartPointer<vtkCellArray>::New();<br>
vtkIdType* lineIndices = new vtkIdType[21];<br>
for (int i = 0; i< 20; i++)<br>
{<br>
const double angle = 2.0*vtkMath::Pi()*i/20.0;<br>
points->InsertPoint(static_cast<vtkIdType>(i), 0.1*cos(angle),<br>
0.1*sin(angle), 0.0 );<br>
lineIndices[i] = static_cast<vtkIdType>(i);<br>
}<br>
<br>
lineIndices[20] = 0;<br>
lines->InsertNextCell(21,lineIndices);<br>
delete [] lineIndices;<br>
pd->SetPoints(points);<br>
pd->SetLines(lines);<br>
<br>
contourWidget->Initialize(pd);<br>
contourWidget->Render();<br>
renderer->ResetCamera();<br>
renderWindow->Render();<br>
<br>
interactor->Initialize();<br>
/<br>
<br>
Please help me! What I'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>