Commit 0c46f805 authored by Emmanuel Promayon's avatar Emmanuel Promayon

UPDATED RendererWidget compatibility with VTK8: now using QVTKOpenGLNativeWidget

Basic replacement, requires testing...
parent afacf897
......@@ -96,24 +96,24 @@
namespace camitk {
//--------------- Picking Interactor ---------------------------------------
vtkInstantiatorNewMacro(vtkInteractorStylePick);
//----------------------- Picking Interactor -----------------------
vtkStandardNewMacro(vtkInteractorStylePick);
//--------------------------------------------------------------------------
//----------------------- constructor -----------------------
vtkInteractorStylePick::vtkInteractorStylePick() {
this->areaPicking = false;
this->startPosition[0] = this->startPosition[1] = 0;
this->endPosition[0] = this->endPosition[1] = 0;
this->moving = 0;
this->pixelArray = vtkSmartPointer<vtkUnsignedCharArray>::New();
areaPicking = false;
startPosition[0] = startPosition[1] = 0;
endPosition[0] = endPosition[1] = 0;
moving = 0;
pixelArray = vtkSmartPointer<vtkUnsignedCharArray>::New();
}
//--------------------------------------------------------------------------
//----------------------- SetAreaPicking ------------------------
void vtkInteractorStylePick::SetAreaPicking(bool b) {
this->areaPicking = b;
}
//--------------------------------------------------------------------------
//----------------------- OnLeftButtonDown -----------------------
void vtkInteractorStylePick::OnLeftButtonDown() {
if (!this->Interactor) {
return;
......@@ -150,7 +150,7 @@ void vtkInteractorStylePick::OnLeftButtonDown() {
}
}
//--------------------------------------------------------------------------
//------------------------------- OnMouseMove -------------------------------
void vtkInteractorStylePick::OnMouseMove() {
if (!this->Interactor || !this->moving) {
return;
......@@ -185,7 +185,7 @@ void vtkInteractorStylePick::OnMouseMove() {
}
}
//--------------------------------------------------------------------------
// ------------------------------- OnLeftButtonUp -------------------------------
void vtkInteractorStylePick::OnLeftButtonUp() {
if (!this->Interactor || !this->moving) {
return;
......@@ -201,7 +201,7 @@ void vtkInteractorStylePick::OnLeftButtonUp() {
this->moving = 0;
}
//--------------------------------------------------------------------------
// ------------------------------- RedrawRubberBand -------------------------------
void vtkInteractorStylePick::RedrawRubberBand() {
//update the rubber band on the screen
int* size = this->Interactor->GetRenderWindow()->GetSize();
......@@ -272,7 +272,7 @@ void vtkInteractorStylePick::RedrawRubberBand() {
tmpPixelArray->Delete();
}
//--------------------------------------------------------------------------
// ------------------------------- Pick -------------------------------
void vtkInteractorStylePick::Pick() {
//find rubber band lower left, upper right and center
double rbcenter[3];
......@@ -354,7 +354,7 @@ void vtkInteractorStylePick::Pick() {
this->Interactor->Render();
}
//--------------------------------------------------------------------------
// ------------------------------- PrintSelf -------------------------------
void vtkInteractorStylePick::PrintSelf(ostream& os, vtkIndent indent) {
this->Superclass::PrintSelf(os, indent);
}
......@@ -366,9 +366,12 @@ QMap <RendererWidget::ScreenshotFormat, RendererWidget::ScreenshotFormatInfo*> s
#if VTK_MAJOR_VERSION == 6
RendererWidget::RendererWidget(QWidget* parent, ControlMode mode) : QVTKWidget2(parent) {
#elif VTK_MAJOR_VERSION == 7 || VTK_MAJOR_VERSION == 8
#elif VTK_MAJOR_VERSION == 7
RendererWidget::RendererWidget(QWidget* parent, ControlMode mode) : QVTKWidget(parent) {
#elif VTK_MAJOR_VERSION == 8
RendererWidget::RendererWidget(QWidget* parent, ControlMode mode) : QVTKOpenGLNativeWidget(parent) {
#else
#error "Invalid VTK version: not (yet) supported."
#endif
......@@ -447,7 +450,7 @@ RendererWidget::RendererWidget(QWidget* parent, ControlMode mode) : QVTKWidget(p
newFormat.setStencilBufferSize(context()->format().stencilBufferSize());
context()->setFormat(newFormat);
}
#elif VTK_MAJOR_VERSION == 7 || VTK_MAJOR_VERSION == 8
#elif VTK_MAJOR_VERSION == 7
auto window = windowHandle();
if (window != nullptr) {
......@@ -468,6 +471,8 @@ RendererWidget::RendererWidget(QWidget* parent, ControlMode mode) : QVTKWidget(p
// fmt.setStereo(1);
// fmt.setStencilBufferSize(8);
// QSurfaceFormat::setDefaultFormat(fmt);
#elif VTK_MAJOR_VERSION == 8
#else
#error "Invalid VTK version: not (yet) supported."
#endif
......@@ -1394,9 +1399,11 @@ void RendererWidget::mousePressEvent(QMouseEvent* event) {
#if VTK_MAJOR_VERSION == 6
QVTKWidget2::mousePressEvent(event);
#elif VTK_MAJOR_VERSION == 7 || VTK_MAJOR_VERSION == 8
#elif VTK_MAJOR_VERSION == 7
QVTKWidget::mousePressEvent(event);
#elif VTK_MAJOR_VERSION == 8
QVTKOpenGLNativeWidget::mousePressEvent(event);
#else
#error "Invalid VTK version: not (yet) supported."
#endif
......@@ -1408,43 +1415,17 @@ void RendererWidget::mouseReleaseEvent(QMouseEvent* event) {
#if VTK_MAJOR_VERSION == 6
QVTKWidget2::mouseReleaseEvent(event);
#elif VTK_MAJOR_VERSION == 7 || VTK_MAJOR_VERSION == 8
#elif VTK_MAJOR_VERSION == 7
QVTKWidget::mouseReleaseEvent(event);
#elif VTK_MAJOR_VERSION == 8
QVTKOpenGLNativeWidget::mouseReleaseEvent(event);
#else
#error "Invalid VTK version: not (yet) supported."
#endif
endPicking();
}
//---------------------------- slotLeftClick ---------------------------------
// void RendererWidget::leftClick() {
// // Ctrl+Left click
// if (QApplication::keyboardModifiers() == Qt::ControlModifier) {
// // divert the left button press event, so that it won't
// // have any effect on the scene while continuously allow picking
// // if (!pickingDiverter) {
// // pickingDiverter = true;
// // interactorStyle->AddObserver(vtkCommand::MouseMoveEvent, pickingButtonDiverter);
// // }
// //
// // // do the picking action
// // pick();
// startPicking();
// pickInteractorStyle->OnLeftButtonDown();
// }
// }
//---------------------------- slotLeftRelease ---------------------------------
// void RendererWidget::leftRelease() {
//
// }
//---------------------------- slotRightClick ---------------------------------
// void RendererWidget::rightClick() {
// emit rightButtonPressed();
// }
// --------------------- mouseMoveEvent ----------------------------------
void RendererWidget::mouseMoveEvent(QMouseEvent* event) {
if (QApplication::keyboardModifiers() == Qt::ControlModifier && QApplication::mouseButtons() == Qt::LeftButton) {
......@@ -1457,9 +1438,12 @@ void RendererWidget::mouseMoveEvent(QMouseEvent* event) {
#if VTK_MAJOR_VERSION == 6
QVTKWidget2::mouseMoveEvent(event);
#elif VTK_MAJOR_VERSION == 7 || VTK_MAJOR_VERSION == 8
#elif VTK_MAJOR_VERSION == 7
QVTKWidget::mouseMoveEvent(event);
#elif VTK_MAJOR_VERSION == 8
QVTKOpenGLNativeWidget::mouseMoveEvent(event);
#else
#error "Invalid VTK version: not (yet) supported."
#endif
......
......@@ -41,13 +41,17 @@
// additional needed headers for QVTKWidget2
#include <vtkGenericOpenGLRenderWindow.h>
#elif VTK_MAJOR_VERSION == 7 || VTK_MAJOR_VERSION == 8
#elif VTK_MAJOR_VERSION == 7
#include <QVTKWidget.h>
// additional needed headers for QVTKWidget
#include <QWindow>
#elif VTK_MAJOR_VERSION == 8
#include <QVTKOpenGLNativeWidget.h>
#else
#error "Invalid VTK version: not (yet) supported."
// for VTK8, check for instance https://www.slicer.org/wiki/Documentation/Labs/Qt5-and-VTK8#Qt5:_QVTKOpenGLWidget
#endif
#include <vtkSmartPointer.h>
......@@ -139,9 +143,12 @@ namespace camitk {
#if VTK_MAJOR_VERSION == 6
class CAMITK_API RendererWidget : public QVTKWidget2 {
#elif VTK_MAJOR_VERSION == 7 || VTK_MAJOR_VERSION == 8
#elif VTK_MAJOR_VERSION == 7
class CAMITK_API RendererWidget : public QVTKWidget {
#elif VTK_MAJOR_VERSION == 8
class CAMITK_API RendererWidget : public QVTKOpenGLNativeWidget {
#else
#error "Invalid VTK version: not (yet) supported."
#endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment