ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
vtkBoxWidgetCustomCallback.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 <vtkActor.h>
11 #include <vtkBoxRepresentation.h>
12 #include <vtkBoxWidget.h>
13 #include <vtkTransform.h>
14 
16  return new vtkBoxWidgetCustomCallback;
17 }
18 
20  m_actor = actor;
21 }
22 
23 void vtkBoxWidgetCustomCallback::Execute(vtkObject *caller,
24  unsigned long,
25  void *) {
26  if (m_preview) {
27  // 将调用该回调函数的调用者caller指针,转换为vtkBoxWidget2类型对象指针
29  vtkBoxWidget::SafeDownCast(caller);
30  // vtkSmartPointer<vtkBoxWidget2>
31  // boxWidget=reinterpret_cast<vtkBoxWidget2>(caller);这样转换不可以,vtkBoxWidget可以
33  // 将boxWidget中的变换矩阵保存在t中
34  // vtkBoxRepresentation::SafeDownCast(boxWidget->GetRepresentation())->GetTransform(t);
35  boxWidget->GetTransform(t);
36  // this->m_actor->SetUserTransform(t);
37  }
38 }
virtual void Execute(vtkObject *caller, unsigned long, void *)
void SetActor(vtkSmartPointer< vtkActor > actor)
SetActor set the current vtkActor in which the actor is picked.
static vtkBoxWidgetCustomCallback * New()