[vtkusers] vtkChart in QVTKWidget

Jothy jothybasu at gmail.com
Fri Aug 12 07:48:29 EDT 2011


Works with this

this->view->SetInteractor(this->ui->chartWidget->GetInteractor());

           this->ui->chartWidget->SetRenderWindow(this->view->GetRenderWindow());

           this->view->GetInteractor()->Initialize();

           this->view->GetInteractor()->Start();

Jothy



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

> 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/5c5039f2/attachment.htm>


More information about the vtkusers mailing list