1 #include "qvtkwidget3.h" 3 #include "vtkRenderWindowInteractor.h" 4 #include "vtkInteractorStyle.h" 5 #include "vtkInteractorStyleTrackballCamera.h" 7 #include <QResizeEvent> 10 : QOpenGLWidget(parent, f)
14 format.setProfile(QSurfaceFormat::CompatibilityProfile);
19 m_connect = vtkSmartPointer<vtkEventQtSlotConnect>::New();
36 vtkGenericOpenGLRenderWindow* win = vtkGenericOpenGLRenderWindow::New();
57 m_connect->Disconnect(
m_renWin, vtkCommand::WindowIsCurrentEvent,
this, SLOT(
IsCurrent(vtkObject*,
unsigned long,
void*,
void*)));
61 m_connect->Disconnect(
m_renWin, vtkCommand::WindowIsDirectEvent,
this, SLOT(
IsDirect(vtkObject*,
unsigned long,
void*,
void*)));
74 this->
m_renWin->SetSize(this->width(), this->height());
75 this->
m_renWin->SetPosition(this->x(), this->y());
78 if(this->
m_renWin->GetInteractor() == NULL)
81 QVTKInteractor* iren = QVTKInteractor::New();
82 iren->SetUseTDx(
false);
87 vtkInteractorStyle* s = vtkInteractorStyleTrackballCamera::New();
88 iren->SetInteractorStyle(s);
95 this->
m_renWin->GetInteractor()->SetSize(this->width(), this->height());
98 m_connect->Connect(
m_renWin, vtkCommand::WindowIsCurrentEvent,
this, SLOT(
IsCurrent(vtkObject*,
unsigned long,
void*,
void*)));
102 m_connect->Connect(
m_renWin, vtkCommand::WindowIsDirectEvent,
this, SLOT(
IsDirect(vtkObject*,
unsigned long,
void*,
void*)));
120 this->
m_renWin->OpenGLInitContext();
126 vtkRenderWindowInteractor* iren =
nullptr;
128 iren = this->
m_renWin->GetInteractor();
131 if(iren ==
nullptr || !iren->GetEnabled()) {
148 if(this->
m_renWin->GetInteractor() != NULL) {
149 QResizeEvent e(QSize(w,h), QSize());
157 QWidget::moveEvent(e);
163 this->
m_renWin->SetPosition(this->x(), this->y());
192 bool* ptr =
reinterpret_cast<bool*
>(call_data);
198 int* ptr =
reinterpret_cast<int*
>(call_data);
204 int* ptr =
reinterpret_cast<int*
>(call_data);