ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
contourwidgetobserver.cpp
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
9 
10 #include <vtkContourRepresentation.h>
11 #include <vtkContourWidget.h>
12 #include <vtkPolyData.h>
13 
14 namespace VtkUtils {
15 
17  : AbstractWidgetObserver(parent) {
19 }
20 
21 void ContourWidgetObserver::Execute(vtkObject* caller,
22  unsigned long eventId,
23  void* callData) {
24  Q_UNUSED(eventId)
25  Q_UNUSED(callData)
26 
27  vtkContourWidget* widget = reinterpret_cast<vtkContourWidget*>(caller);
28  if (widget) {
29  vtkContourRepresentation* rep = vtkContourRepresentation::SafeDownCast(
30  widget->GetRepresentation());
31  vtkPolyData* pd = rep->GetContourRepresentationAsPolyData();
32  if (pd) {
33  m_polyData->DeepCopy(pd);
34  emit dataChanged(m_polyData);
35  }
36  }
37 }
38 
39 } // namespace VtkUtils
ContourWidgetObserver(QObject *parent=nullptr)
void Execute(vtkObject *caller, unsigned long eventId, void *callData)
vtkSmartPointer< vtkPolyData > m_polyData
void dataChanged(vtkPolyData *data)