[vtk-developers] Crash in vtkOpenGLContextDevice2D::ComputeStringBounds when getting bounding rect of vtkAxis

Elvis Stansvik elvis.stansvik at orexplore.com
Fri Feb 17 02:36:09 EST 2017


Den 14 feb. 2017 7:56 fm skrev "Elvis Stansvik" <
elvis.stansvik at orexplore.com>:
>
> I realized that this is maybe a mail more suited for the developer
> list, so sending it here.

It would be great if some dev could just confirm that they see the same
crash in master.

Perhaps GetBoundingRect was never meant to be made public? If so, I'm
looking for a way to map context scene coordinates to screen coordinates
(or alternatively, some other way of getting the pixel width of an axis).

My use case is that I have an opacity/color editor setup similar to that in
ParaView, but I want an Y axis on the opacity editor, and to get the color
widget underneath aligned properly, I need the X screen coordinate where
the color plot area, since it's no longer 0, but shifted to the right by
the left axis.

Elvis

>
> Elvis
>
> 2017-02-12 12:30 GMT+01:00 Elvis Stansvik <elvis.stansvik at orexplore.com>:
> > Hi all,
> >
> > In the test case below, I'm trying to get the bounding rect of a
vtkAxis in
> > a vtkChartXY, but I'm getting a crash in the call to GetBoundingRect
with
> > the following backtrace:
> >
> > #0  vtkOpenGLContextDevice2D::ComputeStringBounds (this=this at entry
=0x689ea0,
> > string=..., bounds=bounds at entry=0x7fffffffcda0)
> >     at
> >
/buildbot/vtk7-builder/build/Rendering/ContextOpenGL2/vtkOpenGLContextDevice2D.cxx:1755
> > #1  0x00007ffff78454f1 in vtkOpenGLContextDevice2D::ComputeStringBounds
> > (this=0x689ea0, string=..., bounds=0x7fffffffcda0)
> >     at
> >
/buildbot/vtk7-builder/build/Rendering/ContextOpenGL2/vtkOpenGLContextDevice2D.cxx:1626
> > #2  0x00007ffff6f2722d in vtkContext2D::ComputeStringBounds
> > (this=this at entry=0x67e3f0, string=..., bounds=bounds at entry
=0x7fffffffcda0)
> > at /buildbot/vtk7-builder/build/Rendering/Context2D/vtkContext2D.cxx:645
> > #3  0x00007ffff7ab4b28 in vtkAxis::GetBoundingRect (this=0x671490,
> > painter=0x67e3f0) at
> > /buildbot/vtk7-builder/build/Charts/Core/vtkAxis.cxx:990
> > #4  0x0000000000402ab1 in main (argc=1, argv=0x7fffffffd038) at
> > /home/estan/testcrash/main.cpp:50
> >
> > The reason seems to be that the render window (RenderWindow member) of
> > vtkOpenGLContextDevice2D is NULL at that point (!).
> >
> > Am I using the GetBoundingRect API in the wrong way somehow? How can I
get
> > the computed bounding rect for a vtkAxis?
> >
> > Thanks in advance,
> > Elvis
> >
> > main.cpp:
> >
> > #include <vtkAxis.h>
> > #include <vtkChartXY.h>
> > #include <vtkContextScene.h>
> > #include <vtkContextView.h>
> > #include <vtkFloatArray.h>
> > #include <vtkNew.h>
> > #include <vtkPlot.h>
> > #include <vtkRenderer.h>
> > #include <vtkRenderWindow.h>
> > #include <vtkRenderWindowInteractor.h>
> > #include <vtkTable.h>
> >
> > int main(int argc, char *argv[]) {
> >     vtkNew<vtkRenderer> renderer;
> >
> >     vtkNew<vtkRenderWindow> window;
> >     window->AddRenderer(renderer.Get());
> >
> >     vtkNew<vtkRenderWindowInteractor> interactor;
> >     interactor->SetRenderWindow(window.Get());
> >
> >     vtkNew<vtkChartXY> chart;
> >
> >     vtkNew<vtkTable> table;
> >     vtkNew<vtkFloatArray> xArray;
> >     xArray->SetName("X Axis");
> >     table->AddColumn(xArray.Get());
> >     vtkNew<vtkFloatArray> yArray;
> >     yArray->SetName("Y Axis");
> >     table->AddColumn(yArray.Get());
> >     table->SetNumberOfRows(2);
> >     table->SetValue(0, 0, 0);
> >     table->SetValue(0, 1, 0);
> >     table->SetValue(1, 0, 1);
> >     table->SetValue(1, 1, 1);
> >
> >     auto linePlot = chart->AddPlot(vtkChart::LINE);
> >     linePlot->SetInputData(table.Get(), 0, 1);
> >
> >     vtkNew<vtkContextView> view;
> >     view->GetScene()->AddItem(chart.Get());
> >     view->SetRenderWindow(window.Get());
> >     view->SetInteractor(interactor.Get());
> >
> >     window->Render();
> >
> >     // Get bounding rect of the left axis
> >     auto leftAxis = chart->GetAxis(vtkAxis::LEFT);
> >     leftAxis->Update();
> >     auto rect = leftAxis->GetBoundingRect(view->GetContext());
> >
> >     interactor->Start();
> >
> >     return 0;
> > }
> >
> >
> > CMakeLists.txt:
> >
> > cmake_minimum_required(VERSION 3.1)
> >
> > project(TestCase)
> >
> > set(CMAKE_CXX_STANDARD 11)
> > set(CMAKE_CXX_STANDARD_REQUIRED ON)
> >
> > find_package(VTK COMPONENTS
> >     vtkChartsCore
> >     vtkCommonCore
> >     vtkInteractionStyle
> >     vtkRenderingContext2D
> >     vtkRenderingContextOpenGL2
> >     vtkRenderingCore
> >     vtkRenderingFreeType
> >     vtkRenderingOpenGL2
> >     vtkViewsContext2D
> > )
> >
> > add_executable(TestCase main.cpp)
> >
> > target_link_libraries(TestCase PUBLIC
> >     vtkChartsCore
> >     vtkCommonCore
> >     vtkInteractionStyle
> >     vtkRenderingContext2D
> >     vtkRenderingContextOpenGL2
> >     vtkRenderingCore
> >     vtkRenderingFreeType
> >     vtkRenderingOpenGL2
> >     vtkViewsContext2D
> > )
> >
> > target_include_directories(TestCase PUBLIC
> >     ${VTK_INCLUDE_DIRS}
> > )
> >
> >
> > target_compile_definitions(TestCase PUBLIC
> >     ${VTK_DEFINITIONS}
> > )
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20170217/7adae2b5/attachment.html>


More information about the vtk-developers mailing list