Ok, so if I understand this correctly, with any 2d plots in VTK, you cannot interact with them unless you create your own mouse/keyboard listeners with your own custom code to do what you want?<div><br></div><div>That leads to another question......</div>
<div><br></div><div>I see a lot of vtkQtChart stuff in the source code with a few examples. &nbsp;It looks as if that code base has interaction built in and it seems to be 2d plots as well. &nbsp;Any comments on the vtkQtChart stuff? &nbsp;I haven&#39;t been able to get it to work due to a flaw in the cmake files in the GUISupport/Qt/Chart area (already filed a bug report).</div>
<div><br></div><div>Thanks for any input with this. &nbsp;I appreciate the responses so far. &nbsp;It&#39;s a big help!</div><div><br></div><div>Justin<br><br><div class="gmail_quote">On Mon, Feb 23, 2009 at 4:37 PM, Shakes <span dir="ltr">&lt;<a href="mailto:Shekhar.Chandra@sci.monash.edu.au">Shekhar.Chandra@sci.monash.edu.au</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hi Justin,<br>
<br>
Someone correct me if I&#39;m wrong, but I don&#39;t think u can interact with it as the plot is not in a 3D scene (i.e., its a not plane in a 3D scene).<br>
<br>
This is difference between vtkImageViewer and vtkImageViewer2, the latter is in a 3D scene and you can interact with it.<br>
<br>
I used the following to &quot;zoom&quot; XY Plots:<br>
<br>
//Scale<br>
plotActor-&gt;SetWidth(factor);<br>
plotActor-&gt;SetHeight(factor);<br>
//Reposition<br>
plotActor-&gt;SetPosition(pos[0]-factor*pos[0], pos[1]-factor*pos[1]);<br>
<br>
HTH<br>
Cheers<br>
Shakes<br>
<br>
Justin Giles wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="Ih2E3d">
That didn&#39;t seem to work either. &nbsp;I&#39;m trying to view a xy plot.<br>
<br>
Justin<br>
<br></div><div><div></div><div class="Wj3C7c">
On Mon, Feb 23, 2009 at 1:05 PM, Clinton Stimpson &lt;<a href="mailto:clinton@elemtech.com" target="_blank">clinton@elemtech.com</a> &lt;mailto:<a href="mailto:clinton@elemtech.com" target="_blank">clinton@elemtech.com</a>&gt;&gt; wrote:<br>

<br>
<br>
 &nbsp; &nbsp;Maybe you&#39;re just missing a<br>
 &nbsp; &nbsp;renderer-&gt;ResetCamera();<br>
<br>
 &nbsp; &nbsp;If you&#39;re just viewing an image, have a look at the image viewer<br>
 &nbsp; &nbsp;example in VTK/Examples/GUI/Qt/ImageViewer<br>
<br>
 &nbsp; &nbsp;Clint<br>
<br>
 &nbsp; &nbsp;Justin Giles wrote:<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;Ok, I added a style to my interactor in the following way:<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;//code<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; vtkRenderWindow *renderWindow = vtkRenderWindow::New();<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; renderWindow-&gt;SetSize(550, 450);<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; renderWindow-&gt;AddRenderer(renderer);<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; vtkRenderWindowInteractor* inter = QVTKInteractor::New();<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; renderWindow-&gt;SetInteractor(inter);<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; vtkInteractorStyleImage* interstyle =<br>
 &nbsp; &nbsp; &nbsp; &nbsp;vtkInteractorStyleImage::New();<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inter-&gt;SetInteractorStyle(interstyle);<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; view-&gt;SetRenderWindow(renderWindow);<br>
 &nbsp; &nbsp; &nbsp; &nbsp;//end code<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;(where view = QVTKWidget)<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;And, I still get the same results. &nbsp;Instead of a nice plot, I<br>
 &nbsp; &nbsp; &nbsp; &nbsp;just get a blank white screen. &nbsp;Thoughts? &nbsp;Am I doing something<br>
 &nbsp; &nbsp; &nbsp; &nbsp;wrong?<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;Thanks,<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;Justin<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;On Mon, Feb 23, 2009 at 11:20 AM, Clinton Stimpson<br>
 &nbsp; &nbsp; &nbsp; &nbsp;&lt;<a href="mailto:clinton@elemtech.com" target="_blank">clinton@elemtech.com</a> &lt;mailto:<a href="mailto:clinton@elemtech.com" target="_blank">clinton@elemtech.com</a>&gt;<br></div></div><div><div></div><div class="Wj3C7c">

 &nbsp; &nbsp; &nbsp; &nbsp;&lt;mailto:<a href="mailto:clinton@elemtech.com" target="_blank">clinton@elemtech.com</a> &lt;mailto:<a href="mailto:clinton@elemtech.com" target="_blank">clinton@elemtech.com</a>&gt;&gt;&gt; wrote:<br>
<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Interaction is handled by the interactor style classes.<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.vtk.org/doc/nightly/html/classvtkInteractorStyle.html" target="_blank">http://www.vtk.org/doc/nightly/html/classvtkInteractorStyle.html</a><br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; You can use an existing style, or make your own and give it<br>
 &nbsp; &nbsp; &nbsp; &nbsp;to the<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; interactor.<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Clint<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Justin Giles wrote:<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; I am able to create a 2d plot using a QVTKWidget, however<br>
 &nbsp; &nbsp; &nbsp; &nbsp;I am<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; unable to interact with that plot. &nbsp;I pretty much new to VTK,<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; so I am kind of at a loss as to how to connect the vtk<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; interactors and Qt. &nbsp;I have poked around a bit and noticed a<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; QVTKInteractor class, but anything I do with that results in<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; my 2d plot going away to be replaced with a blank white area.<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Below is the code that I am using. &nbsp;Just as a note, this is<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; being done in a class that extends a QMainWindow.<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //snippet//<br>
<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;view = new QVTKWidget;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;setCentralWidget(view);<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;int DIM = 500;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;vtkDataArray *dataArray1 =<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; vtkDataArray::CreateDataArray(VTK_FLOAT);<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;dataArray1-&gt;SetNumberOfTuples(DIM);<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;vtkDataArray *dataArray2 =<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; vtkDataArray::CreateDataArray(VTK_FLOAT);<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;dataArray2-&gt;SetNumberOfTuples(DIM);<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;int t;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;for (t = 0; t &lt; DIM; t++)<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;float x = t;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;float y = vtkMath::Random(0.0f,1.0f);<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;dataArray1-&gt;SetTuple(t, &amp;x);<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;dataArray2-&gt;SetTuple(t, &amp;y);<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;vtkFieldData *fieldData = vtkFieldData::New();<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fieldData-&gt;AllocateArrays(2);<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fieldData-&gt;AddArray(dataArray1);<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fieldData-&gt;AddArray(dataArray2);<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;vtkDataObject *dataObject = vtkDataObject::New();<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;dataObject-&gt;SetFieldData(fieldData);<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;vtkXYPlotActor *plot = vtkXYPlotActor::New();<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;plot-&gt;AddDataObjectInput(dataObject);<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;plot-&gt;SetTitle(&quot;Plot&quot;);<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;plot-&gt;SetXTitle(&quot;X-Axis&quot;);<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;plot-&gt;SetYTitle(&quot;Y-Axis&quot;);<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;plot-&gt;SetXValuesToValue();<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;plot-&gt;SetWidth(0.9);<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;plot-&gt;SetHeight(0.9);<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;plot-&gt;SetPosition(0.05, 0.05);<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;plot-&gt;LegendOn();<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;plot-&gt;PickableOff();<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;plot-&gt;PlotCurvePointsOn();<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;plot-&gt;PlotCurveLinesOff();<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;plot-&gt;SetDataObjectXComponent(0, 0);<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;plot-&gt;SetDataObjectYComponent(0, 1);<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;plot-&gt;SetPlotColor(0, 1.0, 0.0, 0.0);<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;plot-&gt;SetPlotLabel(0, &quot;My Label&quot;);<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//plot-&gt;GetProperty()-&gt;SetColor(0.0, 0.0, 0.0);<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;vtkRenderer *renderer = vtkRenderer::New();<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;renderer-&gt;SetBackground(0, 0, 0);<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;renderer-&gt;AddActor2D(plot);<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;vtkRenderWindow *renderWindow = vtkRenderWindow::New();<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;renderWindow-&gt;SetSize(550, 450);<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;renderWindow-&gt;AddRenderer(renderer);<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // &nbsp; &nbsp;vtkRenderWindowInteractor* inter =<br>
 &nbsp; &nbsp; &nbsp; &nbsp;QVTKInteractor::New();<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // &nbsp; &nbsp;renderWindow-&gt;SetInteractor(inter);<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;view-&gt;SetRenderWindow(renderWindow);<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //end-snippet//<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &nbsp; &nbsp; &nbsp; &nbsp; ------------------------------------------------------------------------<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _______________________________________________<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a> &lt;<a href="http://www.kitware.com" target="_blank">http://www.kitware.com</a>&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp;&lt;<a href="http://www.kitware.com" target="_blank">http://www.kitware.com</a>&gt;<br>
<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Visit other Kitware open-source projects at<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Please keep messages on-topic and check the VTK FAQ at:<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Follow this link to subscribe/unsubscribe:<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br>
<br>
<br>
<br>
<br>
------------------------------------------------------------------------<br>
<br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br></div></div><div class="Ih2E3d">
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></blockquote>
</blockquote></div><br></div>