-
Notifications
You must be signed in to change notification settings - Fork 3
/
qquickvtkinteractivewidget2.cpp
82 lines (69 loc) · 2.64 KB
/
qquickvtkinteractivewidget2.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*=========================================================================
Program: Visualization Toolkit
Module: QQuickVTKInteractiveWidget2.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "qquickvtkinteractivewidget2.h"
// vtk includes
#include "vtkAbstractWidget.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkRenderer.h"
#include "vtkWidgetRepresentation.h"
//-------------------------------------------------------------------------------------------------
QQuickVTKInteractiveWidget2::QQuickVTKInteractiveWidget2(QObject* parent)
: Superclass(parent)
{
}
//-------------------------------------------------------------------------------------------------
void QQuickVTKInteractiveWidget2::setWidget(vtkAbstractWidget* w)
{
this->m_widget = w;
}
//-------------------------------------------------------------------------------------------------
vtkAbstractWidget* QQuickVTKInteractiveWidget2::widget() const
{
return this->m_widget;
}
//-------------------------------------------------------------------------------------------------
void QQuickVTKInteractiveWidget2::setEnabled(bool e)
{
if (this->m_enabled == e)
{
return;
}
this->m_enabled = e;
Q_EMIT this->enabledChanged(this->m_enabled);
}
//-------------------------------------------------------------------------------------------------
bool QQuickVTKInteractiveWidget2::enabled() const
{
return this->m_enabled;
}
//-------------------------------------------------------------------------------------------------
void QQuickVTKInteractiveWidget2::sync(vtkRenderer* ren)
{
if (!ren || !this->m_widget)
{
return;
}
auto iren = ren->GetRenderWindow()->GetInteractor();
if(m_widget /*&& m_widget->IsTypeOf("vtkCameraOrientationWidget")*/ ){
std::cout<<"Is camwidget type "<<std::endl;
vtkCameraOrientationWidget* camwidget = vtkCameraOrientationWidget::SafeDownCast(m_widget);
camwidget->SetParentRenderer(ren);
camwidget->SetEnabled(this->m_enabled);
camwidget->SetProcessEvents(this->m_enabled);
}
else{
this->m_widget->SetInteractor(iren);
this->m_widget->SetCurrentRenderer(ren);
this->m_widget->SetEnabled(this->m_enabled);
this->m_widget->SetProcessEvents(this->m_enabled);
}
}