[vtkusers] vtkChart in QVTKWidget

Jothy jothybasu at gmail.com
Fri Aug 12 06:39:42 EDT 2011


Now, I have managed to get it rendered in QVTKWidget, but the interaction
doesn't work.

How should I start the interactor? I tried the commented line in the below
code

// Add multiple line plots, setting the colors etc

           vtkSmartPointer<vtkChartXY> chart =

             vtkSmartPointer<vtkChartXY>::New();

           chart->GetAxis(vtkAxis::LEFT)->SetTitle("yyy");

           chart->GetAxis(vtkAxis::BOTTOM)->SetTitle("xxx");

          this->view->GetScene()->AddItem(chart);

           vtkPlot *line = chart->AddPlot(vtkChart::LINE);

           line->SetInput(table, 0, 1);

           line->SetColor(0, 255, 0, 255);

           line->SetWidth(1.0);

//           this->view->GetRenderWindow()->SetMultiSamples(0);

           this->ui->chartWidget->GetRenderWindow()->AddRenderer(this->view->GetRenderer());

//           vtkRenderWindowInteractor
*chartItr=vtkRenderWindowInteractor::New();

//           this->ui->chartWidget->GetRenderWindow()->SetInteractor(chartItr);

//           this->ui->chartWidget->GetInteractor()->Initialize();

//           this->ui->chartWidget->GetInteractor()->Start();

             this->ui->chartWidget->show();


Thanks

Jothy

On Fri, Aug 12, 2011 at 11:05 AM, Jothy <jothybasu at gmail.com> wrote:

> Hi all,
>
> I am trying to plot a 2D XY line plot using vtkChartXY by following this
> example http://www.vtk.org/Wiki/VTK/Examples/Cxx/Plotting/LinePlot.
>
> I can render using vtkRenderer and vtkRenderWindow, but I can't get it
> rendered in a QVTKWidget. How to link these two?
>
> I tried using
> QVTkWidget->GetRenderWindow()->AddRenderer(vtkContextView->GetRenderer()).
>
> Any suggestions?
>
> Thanks
>
> Jothy
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20110812/b3fc4d7a/attachment.htm>


More information about the vtkusers mailing list