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

Pablo Hernández pablo.hernandez.cerdan at outlook.com
Mon Jul 21 06:18:14 EDT 2014


In linux it is solved if I add to the main CMakeLists.txt:
 include(${VTK_USE_FILE})
It seems like a crucial dependency, but I was able to compile with no errors in old VTK version.

I will test it in Windows soon... and hopefully end this helpful monologue.

Cheers,
Pablo
From: pablo.hernandez.cerdan at outlook.com
To: vtkusers at vtk.org
Subject: RE: Problem with QVtkWidget not rendering vktChartXY in visual studio 2013
Date: Mon, 21 Jul 2014 10:45:33 +0200




Update. It seems that the first error I was getting in Windows is in fact relevant:
"Generic Warning: In D:\Software\VTK\source.git\Rendering\Context2D\vtkContextDevice2D.cxx, line 27
Error: no override found for 'vtkContextDevice2D'."

I went back to my Linux/Ubuntu machine at work, and installed the latest VTK from 'origin/nightly-master'.
And now I am getting the pointed error, and a core dump error in exactly the same code.

I still have the working vtk version though. I installed it a couple of months ago max. It is 6.2, but I don't know how to check minor versions, or the commit from where I installed it.

I use cmake to build, and change the vtk directory (particular_build/lib/cmake/vtk-6.2) seems clean, but I have heard that it is not recommended to have multiple vtk versions installed.

Cheers,
Pablo


From: pablo.hernandez.cerdan at outlook.com
To: vtkusers at vtk.org
Subject: Problem with QVtkWidget not rendering vktChartXY in visual studio 2013
Date: Sun, 20 Jul 2014 18:12:01 +0200




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/20140721/675c17ea/attachment.html>


More information about the vtkusers mailing list