<p dir="ltr">Den 17 feb. 2017 8:36 fm skrev "Elvis Stansvik" <<a href="mailto:elvis.stansvik@orexplore.com">elvis.stansvik@orexplore.com</a>>:<br>
><br>
> Den 14 feb. 2017 7:56 fm skrev "Elvis Stansvik" <<a href="mailto:elvis.stansvik@orexplore.com">elvis.stansvik@orexplore.com</a>>:<br>
> ><br>
> > I realized that this is maybe a mail more suited for the developer<br>
> > list, so sending it here.<br>
><br>
> It would be great if some dev could just confirm that they see the same crash in master.<br>
><br>
> 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).<br>
><br>
> 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.</p>
<p dir="ltr">s/where the color plot area/where the opacity plot area starts/</p>
<p dir="ltr">><br>
> Elvis<br>
><br>
> ><br>
> > Elvis<br>
> ><br>
> > 2017-02-12 12:30 GMT+01:00 Elvis Stansvik <<a href="mailto:elvis.stansvik@orexplore.com">elvis.stansvik@orexplore.com</a>>:<br>
> > > Hi all,<br>
> > ><br>
> > > In the test case below, I'm trying to get the bounding rect of a vtkAxis in<br>
> > > a vtkChartXY, but I'm getting a crash in the call to GetBoundingRect with<br>
> > > the following backtrace:<br>
> > ><br>
> > > #0  vtkOpenGLContextDevice2D::ComputeStringBounds (this=this@entry=0x689ea0,<br>
> > > string=..., bounds=bounds@entry=0x7fffffffcda0)<br>
> > >     at<br>
> > > /buildbot/vtk7-builder/build/Rendering/ContextOpenGL2/vtkOpenGLContextDevice2D.cxx:1755<br>
> > > #1  0x00007ffff78454f1 in vtkOpenGLContextDevice2D::ComputeStringBounds<br>
> > > (this=0x689ea0, string=..., bounds=0x7fffffffcda0)<br>
> > >     at<br>
> > > /buildbot/vtk7-builder/build/Rendering/ContextOpenGL2/vtkOpenGLContextDevice2D.cxx:1626<br>
> > > #2  0x00007ffff6f2722d in vtkContext2D::ComputeStringBounds<br>
> > > (this=this@entry=0x67e3f0, string=..., bounds=bounds@entry=0x7fffffffcda0)<br>
> > > at /buildbot/vtk7-builder/build/Rendering/Context2D/vtkContext2D.cxx:645<br>
> > > #3  0x00007ffff7ab4b28 in vtkAxis::GetBoundingRect (this=0x671490,<br>
> > > painter=0x67e3f0) at<br>
> > > /buildbot/vtk7-builder/build/Charts/Core/vtkAxis.cxx:990<br>
> > > #4  0x0000000000402ab1 in main (argc=1, argv=0x7fffffffd038) at<br>
> > > /home/estan/testcrash/main.cpp:50<br>
> > ><br>
> > > The reason seems to be that the render window (RenderWindow member) of<br>
> > > vtkOpenGLContextDevice2D is NULL at that point (!).<br>
> > ><br>
> > > Am I using the GetBoundingRect API in the wrong way somehow? How can I get<br>
> > > the computed bounding rect for a vtkAxis?<br>
> > ><br>
> > > Thanks in advance,<br>
> > > Elvis<br>
> > ><br>
> > > main.cpp:<br>
> > ><br>
> > > #include <vtkAxis.h><br>
> > > #include <vtkChartXY.h><br>
> > > #include <vtkContextScene.h><br>
> > > #include <vtkContextView.h><br>
> > > #include <vtkFloatArray.h><br>
> > > #include <vtkNew.h><br>
> > > #include <vtkPlot.h><br>
> > > #include <vtkRenderer.h><br>
> > > #include <vtkRenderWindow.h><br>
> > > #include <vtkRenderWindowInteractor.h><br>
> > > #include <vtkTable.h><br>
> > ><br>
> > > int main(int argc, char *argv[]) {<br>
> > >     vtkNew<vtkRenderer> renderer;<br>
> > ><br>
> > >     vtkNew<vtkRenderWindow> window;<br>
> > >     window->AddRenderer(renderer.Get());<br>
> > ><br>
> > >     vtkNew<vtkRenderWindowInteractor> interactor;<br>
> > >     interactor->SetRenderWindow(window.Get());<br>
> > ><br>
> > >     vtkNew<vtkChartXY> chart;<br>
> > ><br>
> > >     vtkNew<vtkTable> table;<br>
> > >     vtkNew<vtkFloatArray> xArray;<br>
> > >     xArray->SetName("X Axis");<br>
> > >     table->AddColumn(xArray.Get());<br>
> > >     vtkNew<vtkFloatArray> yArray;<br>
> > >     yArray->SetName("Y Axis");<br>
> > >     table->AddColumn(yArray.Get());<br>
> > >     table->SetNumberOfRows(2);<br>
> > >     table->SetValue(0, 0, 0);<br>
> > >     table->SetValue(0, 1, 0);<br>
> > >     table->SetValue(1, 0, 1);<br>
> > >     table->SetValue(1, 1, 1);<br>
> > ><br>
> > >     auto linePlot = chart->AddPlot(vtkChart::LINE);<br>
> > >     linePlot->SetInputData(table.Get(), 0, 1);<br>
> > ><br>
> > >     vtkNew<vtkContextView> view;<br>
> > >     view->GetScene()->AddItem(chart.Get());<br>
> > >     view->SetRenderWindow(window.Get());<br>
> > >     view->SetInteractor(interactor.Get());<br>
> > ><br>
> > >     window->Render();<br>
> > ><br>
> > >     // Get bounding rect of the left axis<br>
> > >     auto leftAxis = chart->GetAxis(vtkAxis::LEFT);<br>
> > >     leftAxis->Update();<br>
> > >     auto rect = leftAxis->GetBoundingRect(view->GetContext());<br>
> > ><br>
> > >     interactor->Start();<br>
> > ><br>
> > >     return 0;<br>
> > > }<br>
> > ><br>
> > ><br>
> > > CMakeLists.txt:<br>
> > ><br>
> > > cmake_minimum_required(VERSION 3.1)<br>
> > ><br>
> > > project(TestCase)<br>
> > ><br>
> > > set(CMAKE_CXX_STANDARD 11)<br>
> > > set(CMAKE_CXX_STANDARD_REQUIRED ON)<br>
> > ><br>
> > > find_package(VTK COMPONENTS<br>
> > >     vtkChartsCore<br>
> > >     vtkCommonCore<br>
> > >     vtkInteractionStyle<br>
> > >     vtkRenderingContext2D<br>
> > >     vtkRenderingContextOpenGL2<br>
> > >     vtkRenderingCore<br>
> > >     vtkRenderingFreeType<br>
> > >     vtkRenderingOpenGL2<br>
> > >     vtkViewsContext2D<br>
> > > )<br>
> > ><br>
> > > add_executable(TestCase main.cpp)<br>
> > ><br>
> > > target_link_libraries(TestCase PUBLIC<br>
> > >     vtkChartsCore<br>
> > >     vtkCommonCore<br>
> > >     vtkInteractionStyle<br>
> > >     vtkRenderingContext2D<br>
> > >     vtkRenderingContextOpenGL2<br>
> > >     vtkRenderingCore<br>
> > >     vtkRenderingFreeType<br>
> > >     vtkRenderingOpenGL2<br>
> > >     vtkViewsContext2D<br>
> > > )<br>
> > ><br>
> > > target_include_directories(TestCase PUBLIC<br>
> > >     ${VTK_INCLUDE_DIRS}<br>
> > > )<br>
> > ><br>
> > ><br>
> > > target_compile_definitions(TestCase PUBLIC<br>
> > >     ${VTK_DEFINITIONS}<br>
> > > )<br></p>