[vtkusers] Problem with QVtkWidget not rendering vktChartXY in visual studio 2013

Pablo Hernández pablo.hernandez.cerdan at outlook.com
Sun Jul 20 12:12:01 EDT 2014


Hey there,
I am developing in Linux using gcc 4.8, but this weekend I tried to compile in Windows7 using visual studio 2013 (v120).
The code use QT with the QVtkWidget.

The code works properly in my Linux setup, but it does not render one of the two qtvtkwidget I have. Basically I get a white background where the widget should be, and it corrupts a little bit when resizing.
This widget shows 3 vtkChartXY in the same scene of a qvtkWidget.
I got three warning/errors but no crashing. And I can interact and render the other QtVtkWidget.
First:
"Generic Warning: In D:\Software\VTK\source.git\Rendering\Context2D\vtkContextDevice2D.cxx, line 27
Error: no override found for 'vtkContextDevice2D'."
I have no idea if this one is relevant to be honest. 
Second:
"First-chance exception at 0x01E07B28 in VTKNodesEdgesEXE.exe: 0xC0000005: Access violation reading location 0x00000000."
Debugging this, it points to the render pipeline of the qtvtkWidget, specifically:
vtkContextActor.cxx
// Renders an actor2D's property and then it's mapper.
int vtkContextActor::RenderOverlay(vtkViewport* viewport)
  // Pass the viewport details onto the context device.
  int size[2];
  size[0] = view_viewport_pixels.width();
  size[1] = view_viewport_pixels.height();
  vtkRecti viewportRect(actual_viewport_pixels.x() - view_viewport_pixels.x(),
                        actual_viewport_pixels.y() - view_viewport_pixels.y(),
                        actual_viewport_pixels.width(),
                        actual_viewport_pixels.height());
 //(Breakpoint here:)
this->Context->GetDevice()->SetViewportSize(vtkVector2i(size));

And I also get:
"QWidget::repaint: Recursive repaint detected"

I write down my code where the errors are happening, just in case...  It compiles all right in gcc, so not sure if there is something wrong with it, or I am just messing up the setup in Windows. Any hint or point to a direction to solve this is really appreciated. Or even any suggestion to improve my question being more specific is welcome.

Cheers,
Pablo

CODE:

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
//First qtvtkwidget setup:
...
...
...
    // Multiple histogram in same qvtkWidget:


    histoView =  vtkSmartPointer<vtkContextView>::New();
    histoView->SetInteractor(ui->widgetHisto->GetInteractor());
    ui->widgetHisto->SetRenderWindow(histoView->GetRenderWindow());
    histoView->GetRenderer()->SetBackground(0.0,0.0,0.0);


    //ui->widgetHisto->resize(550,720);
   // for (int i=0 ; i<1 ; i++){
    int i = 0; // For simplicity.
    auto histoChart = vtkSmartPointer<HistogramChart>::New();

    histoView->GetScene()->AddItem(histoChart);


    //Create table for chart.
    vtkNew<vtkTable> table;
    vtkNew<vtkIntArray> xArray ;
    table->AddColumn(xArray.GetPointer());
    vtkNew<vtkIntArray> yArray;
    table->AddColumn(yArray.GetPointer());


    std::string histo_str ;
    std::vector<int> histo_data;


    //int xRenwinSize = ui->widgetHisto->size().width();
    //int yRenwinSize = ui->widgetHisto->size().height();


    xArray->SetName("Leng-Axis");
    yArray->SetName("Distance btwn Nodes");
    histo_str = file_root + ".hdis";
    histo_data = graph.readHistogram(histo_str);
    histoData.push_back(histo_data);
    histoChart->SetAutoSize(true);
    //histoChart->SetSize(vtkRectf(0.0, 2.0*yRenwinSize/3.0, xRenwinSize, yRenwinSize/3.0));


    size_t histo_size = histoData[i].size();
    table->SetNumberOfRows(histo_size);
    for (std::size_t j = 0; j < histo_size; j++){
        yArray->SetValue(j,histoData[i][j]);
        xArray->SetValue(j,j);
    }
    histoChart->GetAxis(vtkAxis::BOTTOM)->SetRange(0, histo_size);
    auto plot = histoChart->AddPlot(vtkChart::LINE) ;
    plot->SetInputData(table.GetPointer(), 0 , 1);


    ui->widgetHisto->GetInteractor()->Initialize();}

And the main: 
int main (int argc, char **argv)
{



    QApplication app(argc, argv);
    app.setApplicationName("VTK-QT Graph");
    MainWindow mainWin;


    mainWin.show();
    app.exec();


}

 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20140720/266c9e31/attachment-0001.html>


More information about the vtkusers mailing list