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. It looks as if that code base has interaction built in and it seems to be 2d plots as well. Any comments on the vtkQtChart stuff? I haven'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. I appreciate the responses so far. It'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"><<a href="mailto:Shekhar.Chandra@sci.monash.edu.au">Shekhar.Chandra@sci.monash.edu.au</a>></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'm wrong, but I don'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 "zoom" XY Plots:<br>
<br>
//Scale<br>
plotActor->SetWidth(factor);<br>
plotActor->SetHeight(factor);<br>
//Reposition<br>
plotActor->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't seem to work either. I'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 <<a href="mailto:clinton@elemtech.com" target="_blank">clinton@elemtech.com</a> <mailto:<a href="mailto:clinton@elemtech.com" target="_blank">clinton@elemtech.com</a>>> wrote:<br>
<br>
<br>
Maybe you're just missing a<br>
renderer->ResetCamera();<br>
<br>
If you're just viewing an image, have a look at the image viewer<br>
example in VTK/Examples/GUI/Qt/ImageViewer<br>
<br>
Clint<br>
<br>
Justin Giles wrote:<br>
<br>
Ok, I added a style to my interactor in the following way:<br>
<br>
//code<br>
vtkRenderWindow *renderWindow = vtkRenderWindow::New();<br>
renderWindow->SetSize(550, 450);<br>
renderWindow->AddRenderer(renderer);<br>
vtkRenderWindowInteractor* inter = QVTKInteractor::New();<br>
renderWindow->SetInteractor(inter);<br>
vtkInteractorStyleImage* interstyle =<br>
vtkInteractorStyleImage::New();<br>
inter->SetInteractorStyle(interstyle);<br>
view->SetRenderWindow(renderWindow);<br>
//end code<br>
<br>
(where view = QVTKWidget)<br>
<br>
And, I still get the same results. Instead of a nice plot, I<br>
just get a blank white screen. Thoughts? Am I doing something<br>
wrong?<br>
<br>
Thanks,<br>
<br>
Justin<br>
<br>
On Mon, Feb 23, 2009 at 11:20 AM, Clinton Stimpson<br>
<<a href="mailto:clinton@elemtech.com" target="_blank">clinton@elemtech.com</a> <mailto:<a href="mailto:clinton@elemtech.com" target="_blank">clinton@elemtech.com</a>><br></div></div><div><div></div><div class="Wj3C7c">
<mailto:<a href="mailto:clinton@elemtech.com" target="_blank">clinton@elemtech.com</a> <mailto:<a href="mailto:clinton@elemtech.com" target="_blank">clinton@elemtech.com</a>>>> wrote:<br>
<br>
<br>
Interaction is handled by the interactor style classes.<br>
<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>
You can use an existing style, or make your own and give it<br>
to the<br>
interactor.<br>
<br>
Clint<br>
<br>
Justin Giles wrote:<br>
<br>
I am able to create a 2d plot using a QVTKWidget, however<br>
I am<br>
unable to interact with that plot. I pretty much new to VTK,<br>
so I am kind of at a loss as to how to connect the vtk<br>
interactors and Qt. I have poked around a bit and noticed a<br>
QVTKInteractor class, but anything I do with that results in<br>
my 2d plot going away to be replaced with a blank white area.<br>
Below is the code that I am using. Just as a note, this is<br>
being done in a class that extends a QMainWindow.<br>
<br>
//snippet//<br>
<br>
<br>
view = new QVTKWidget;<br>
setCentralWidget(view);<br>
<br>
int DIM = 500;<br>
vtkDataArray *dataArray1 =<br>
vtkDataArray::CreateDataArray(VTK_FLOAT);<br>
dataArray1->SetNumberOfTuples(DIM);<br>
<br>
vtkDataArray *dataArray2 =<br>
vtkDataArray::CreateDataArray(VTK_FLOAT);<br>
dataArray2->SetNumberOfTuples(DIM);<br>
<br>
int t;<br>
for (t = 0; t < DIM; t++)<br>
{<br>
float x = t;<br>
float y = vtkMath::Random(0.0f,1.0f);<br>
dataArray1->SetTuple(t, &x);<br>
dataArray2->SetTuple(t, &y);<br>
}<br>
<br>
vtkFieldData *fieldData = vtkFieldData::New();<br>
fieldData->AllocateArrays(2);<br>
fieldData->AddArray(dataArray1);<br>
fieldData->AddArray(dataArray2);<br>
<br>
vtkDataObject *dataObject = vtkDataObject::New();<br>
dataObject->SetFieldData(fieldData);<br>
<br>
vtkXYPlotActor *plot = vtkXYPlotActor::New();<br>
plot->AddDataObjectInput(dataObject);<br>
plot->SetTitle("Plot");<br>
plot->SetXTitle("X-Axis");<br>
plot->SetYTitle("Y-Axis");<br>
plot->SetXValuesToValue();<br>
plot->SetWidth(0.9);<br>
plot->SetHeight(0.9);<br>
plot->SetPosition(0.05, 0.05);<br>
plot->LegendOn();<br>
plot->PickableOff();<br>
plot->PlotCurvePointsOn();<br>
plot->PlotCurveLinesOff();<br>
<br>
plot->SetDataObjectXComponent(0, 0);<br>
plot->SetDataObjectYComponent(0, 1);<br>
plot->SetPlotColor(0, 1.0, 0.0, 0.0);<br>
plot->SetPlotLabel(0, "My Label");<br>
//plot->GetProperty()->SetColor(0.0, 0.0, 0.0);<br>
<br>
vtkRenderer *renderer = vtkRenderer::New();<br>
renderer->SetBackground(0, 0, 0);<br>
renderer->AddActor2D(plot);<br>
<br>
vtkRenderWindow *renderWindow = vtkRenderWindow::New();<br>
renderWindow->SetSize(550, 450);<br>
renderWindow->AddRenderer(renderer);<br>
// vtkRenderWindowInteractor* inter =<br>
QVTKInteractor::New();<br>
// renderWindow->SetInteractor(inter);<br>
view->SetRenderWindow(renderWindow);<br>
<br>
//end-snippet//<br>
------------------------------------------------------------------------<br>
<br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a> <<a href="http://www.kitware.com" target="_blank">http://www.kitware.com</a>><br>
<<a href="http://www.kitware.com" target="_blank">http://www.kitware.com</a>><br>
<br>
<br>
Visit other Kitware open-source projects at<br>
<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:<br>
<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>
<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>