Dear Fabian,<br><br>As you suggested, I think you have to split your code in at least two functions. The first one will initialize you data, while the second will modify only the object 'PointCloudColors'. You don't need to save the configuration of the camera as you won't reset any part of the rendering pipeline. You will modify only the input. So by calling for example 'PointCloudRenderWindow->Render();' in the second function, VTK will check for you if something changed and then will update the rendering. <br>
<br>Moreover, I don't see any Qt objects in your code. With Qt and a QVTKWidget, you won't have to use the last three lines (at least, I never used them). You have some example on the wiki to use VTK with Qt: <a href="http://www.vtk.org/Wiki/VTK/Examples/Cxx#Qt">http://www.vtk.org/Wiki/VTK/Examples/Cxx#Qt</a><br>
<br>Arnaud<br><br><div class="gmail_quote">On Mon, Oct 29, 2012 at 2:29 PM, Fabian <span dir="ltr"><<a href="mailto:fabian-richter@gmx.de" target="_blank">fabian-richter@gmx.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello Arnaud BARRE,<br>
<br>
thanks for Your answer.<br>
<br>
My code looks like this (my pointcloud is a list already processed in the<br>
vector called 'Data'):<br>
<br>
My Code wrote<br>
> void PCV_VTKOps::PCV_Visualize(std::vector<br>
> <STRUCT_7Values><br>
> Data)<br>
> {<br>
> int i;<br>
> PickedPoints.clear();<br>
><br>
> //general vtk declarations<br>
> vtkSmartPointer<br>
> <vtkRenderer><br>
> PointCloudRenderer = vtkSmartPointer<br>
> <vtkRenderer><br>
> ::New();<br>
> vtkSmartPointer<br>
> <vtkRenderWindow><br>
> PointCloudRenderWindow = vtkSmartPointer<br>
> <vtkRenderWindow><br>
> ::New();<br>
> vtkSmartPointer<br>
> <vtkRenderWindowInteractor><br>
> PointCloudrenderWindowInteractor = vtkSmartPointer<br>
> <vtkRenderWindowInteractor><br>
> ::New();<br>
> vtkSmartPointer<br>
> <PCV_VTKPickPoints><br>
> style = vtkSmartPointer<br>
> <PCV_VTKPickPoints><br>
> ::New();<br>
> vtkSmartPointer<br>
> <vtkBMPReader><br>
> BackgroundTextureReader = vtkSmartPointer<br>
> <vtkBMPReader><br>
> ::New();<br>
> vtkSmartPointer<br>
> <vtkTexture><br>
> BackgroundTexture = vtkSmartPointer<br>
> <vtkTexture><br>
> ::New();<br>
> vtkSmartPointer<br>
> <vtkInteractorStyleTrackballCamera><br>
> style2 = vtkSmartPointer<br>
> <vtkInteractorStyleTrackballCamera><br>
> ::New();<br>
> vtkSmartPointer<br>
> <vtkWindowToImageFilter><br>
> PointCloudToImageFilter = vtkSmartPointer<br>
> <vtkWindowToImageFilter><br>
> ::New();<br>
> vtkSmartPointer<br>
> <vtkBMPWriter><br>
> PointCloudToImageWriter = vtkSmartPointer<br>
> <vtkBMPWriter><br>
> ::New();<br>
><br>
> vtkCamera *PointCloudRendererCamera;<br>
><br>
> //vtkDeclarations PointCloud<br>
> vtkSmartPointer<br>
> <vtkUnsignedCharArray><br>
> PointCloudColors = vtkSmartPointer<br>
> <vtkUnsignedCharArray><br>
> ::New();<br>
> vtkSmartPointer<br>
> <vtkPoints><br>
> PointCloudPoints = vtkSmartPointer<br>
> <vtkPoints><br>
> ::New();<br>
> vtkSmartPointer<br>
> <vtkPolyData><br>
> PointsPolydata = vtkSmartPointer<br>
> <vtkPolyData><br>
> ::New();<br>
> vtkSmartPointer<br>
> <vtkPolyData><br>
> PointCloudPolyData = vtkSmartPointer<br>
> <vtkPolyData><br>
> ::New();<br>
> vtkSmartPointer<br>
> <vtkVertexGlyphFilter><br>
> PointCloudVertexFilter = vtkSmartPointer<br>
> <vtkVertexGlyphFilter><br>
> ::New();<br>
> vtkSmartPointer<br>
> <vtkPolyDataMapper><br>
> PointCloudMapper = vtkSmartPointer<br>
> <vtkPolyDataMapper><br>
> ::New();<br>
> vtkSmartPointer<br>
> <vtkActor><br>
> PointCloudActor = vtkSmartPointer<br>
> <vtkActor><br>
> ::New();<br>
><br>
> PointCloudColors -> SetNumberOfComponents(3);<br>
> unsigned char Color[3] = {0, 0, 0};<br>
><br>
><br>
><br>
> for (i = 0; i < (int) Data.size(); i++)<br>
> {<br>
> if(VTKPARMS.ColorMode == 1)<br>
> {<br>
> Color[0] = Data[i].R;<br>
> Color[1] = Data[i].G;<br>
> Color[2] = Data[i].B;<br>
> }<br>
> PointCloudColors -> InsertNextTupleValue(Color);<br>
> PointCloudPoints -> InsertNextPoint(Data[i].x,Data[i].y,Data[i].z);<br>
> }<br>
><br>
> PointsPolydata -> SetPoints(PointCloudPoints);<br>
> PointCloudVertexFilter -><br>
> SetInputConnection(PointsPolydata->GetProducerPort());<br>
> PointCloudVertexFilter -> Update();<br>
> PointCloudPolyData -><br>
> ShallowCopy(PointCloudVertexFilter->GetOutput());<br>
> PointCloudPolyData -> GetPointData()->SetScalars(PointCloudColors);<br>
><br>
> //Visualization<br>
> PointCloudMapper -><br>
> SetInputConnection(PointCloudPolyData->GetProducerPort());<br>
> PointCloudActor -> SetMapper(PointCloudMapper);<br>
> PointCloudActor -> GetProperty()->SetPointSize(VTKPARMS.PointSize);<br>
><br>
> PointCloudRenderer -> AddActor(PointCloudActor);<br>
><br>
> BackgroundTextureReader -> SetFileName<br>
> ("C:\\PunktWolkenTest\\VTKBACKGROUND.bmp");<br>
> BackgroundTexture -><br>
> SetInputConnection(BackgroundTextureReader->GetOutputPort());<br>
><br>
> PointCloudRenderer->SetBackgroundTexture(BackgroundTexture);<br>
> PointCloudRenderer->TexturedBackgroundOn();<br>
><br>
> PointCloudRenderWindow -> AddRenderer(PointCloudRenderer);<br>
><br>
><br>
> PointCloudrenderWindowInteractor -><br>
> SetRenderWindow(PointCloudRenderWindow);<br>
><br>
> VTKPARMS.QTRenderer = PointCloudRenderer;<br>
> VTKPARMS.QTRenderWindow = PointCloudRenderWindow;<br>
><br>
><br>
> PointCloudRenderWindow -> Render();<br>
> PointCloudrenderWindowInteractor -> Start();<br>
> PointCloudRenderWindow -> Finalize();<br>
><br>
> }<br>
<br>
But I am not sure if my question is more about structure. What this function<br>
does is basically take the points, process the pipeline and put the Renderer<br>
and RenderWindow somewhere where I can put it into a QVTKWidget.<br>
<br>
Now I am afraid, that 'sorting points out' (because they have a special<br>
color value) would mean that I need to walk through the whole pipeline<br>
again. I know how to connect the QTSlider, but I dont know, if my function<br>
allows to interact with it after it run through.<br>
<br>
I thought about reorganising the function in case it needs to be called<br>
every time when the slider is moved. In that case I would save the VTKcamera<br>
somehow, filter the pointcloud before it gets visualized and swap the<br>
RenderWindows in the QVTKWidget (if possible).<br>
<br>
Would You think this to be better?<br>
<br>
THANKS ALOT,<br>
Fabian<br>
<br>
<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://vtk.1045678.n5.nabble.com/Change-Objects-in-active-vtkRenderWindow-using-QT-tp5716830p5716869.html" target="_blank">http://vtk.1045678.n5.nabble.com/Change-Objects-in-active-vtkRenderWindow-using-QT-tp5716830p5716869.html</a><br>
<div class="HOEnZb"><div class="h5">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>
</div></div></blockquote></div><br>