[vtkusers] Axes marker not working as expected

Júlio Hoffimann julio.hoffimann at gmail.com
Sun Dec 21 21:45:48 EST 2014


I recompiled VTK in debug mode and the vtkOrientationMarkerWidget segfaults
in line 350 of vtkOrientationMarkerWidget.cxx (see screenshot).

I'm using VTK 6.2 from Git, Qt5, GCC 4.9, C++14. The current code that is
causing the segfault is:

VTKViewer::VTKViewer(QWidget *parent) : QWidget(parent){
  QVTKWidget *qvtkwidget = new QVTKWidget;
  qvtkwidget->setSizePolicy(QSizePolicy::MinimumExpanding,
                            QSizePolicy::MinimumExpanding);

  auto renderer = vtkSmartPointer<vtkRenderer>::New();

  vtkRenderWindow *renderWindow = qvtkwidget->GetRenderWindow();
  renderWindow->AddRenderer(renderer);

  auto axes = vtkSmartPointer<vtkAxesActor>::New();
  axes->SetXAxisLabelText("x");
  axes->SetYAxisLabelText("y");
  axes->SetZAxisLabelText("z");

  auto orientationMarker = vtkSmartPointer<vtkOrientationMarkerWidget>::New();
  orientationMarker->SetInteractor(qvtkwidget->GetInteractor());
  orientationMarker->SetOrientationMarker(axes);
  orientationMarker->SetEnabled(1);}

Could you please tell me why this implementation is failing?

Appreciate any help,
Júlio.

2014-12-19 14:50 GMT-08:00 Júlio Hoffimann <julio.hoffimann at gmail.com>:

> Can anyone confirm QVTKWidget is not intended to be used as a local
> variable (see code bellow)?
>
> I'm getting a runtime error whenever the mouse cursor moves over the
> QVTKWidget window.
>
> -Júlio
>
>
>>> > VTKViewer::VTKViewer(QWidget *parent) : QWidget(parent)
>>> > {
>>> >     QVTKWidget *qvtkwidget = new QVTKWidget;
>>> >
>>> >     auto axes = vtkSmartPointer<vtkAxesActor>::New();
>>> >     axes->SetXAxisLabelText("x");
>>> >     axes->SetYAxisLabelText("y");
>>> >     axes->SetZAxisLabelText("z");
>>> >
>>> >     auto orientationMarker =
>>> > vtkSmartPointer<vtkOrientationMarkerWidget>::New();
>>> >     orientationMarker->SetInteractor(qvtkwidget->GetInteractor());
>>> >     orientationMarker->SetOrientationMarker(axes);
>>> >     orientationMarker->SetEnabled(1);
>>> >
>>> >     // sphere
>>> >     auto sphereSource = vtkSmartPointer<vtkSphereSource>::New();
>>> >     sphereSource->SetCenter(8, 8, 8);
>>> >     sphereSource->SetRadius(5.0);
>>> >     auto mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
>>> >     mapper->SetInputConnection(sphereSource->GetOutputPort());
>>> >     auto actor = vtkSmartPointer<vtkActor>::New();
>>> >     actor->SetMapper(mapper);
>>> >
>>> >     auto renderer = vtkSmartPointer<vtkRenderer>::New();
>>> >     renderer->AddActor(axes);
>>> >     renderer->AddActor(actor);
>>> >
>>> >     vtkRenderWindow *renderWindow = qvtkwidget->GetRenderWindow();
>>> >     renderWindow->AddRenderer(renderer);
>>> > }
>>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20141221/d5f6720a/attachment.html>


More information about the vtkusers mailing list