Преглед изворни кода

Fix render window initialization

QVTKOpenGLWidget must be used with vtkGenericOpenGLRenderWindow.
This change modifies the initialization of the context view to follow the
typical usage for QVTKOpenGLWidget as presented in the documentation :
https://www.vtk.org/doc/nightly/html/classQVTKOpenGLWidget.html#details
Lucas Gandel пре 7 година
родитељ
комит
38f2a0af8b

+ 11 - 5
Libs/Visualization/VTK/Widgets/ctkVTKDiscretizableColorTransferWidget.cpp

@@ -57,12 +57,12 @@
 #include <vtkDiscretizableColorTransferFunction.h>
 #include <vtkDoubleArray.h>
 #include <vtkEventQtSlotConnect.h>
+#include <vtkGenericOpenGLRenderWindow.h>
 #include <vtkIntArray.h>
 #include <vtkImageAccumulate.h>
 #include <vtkImageData.h>
 #include <vtkPiecewiseFunction.h>
 #include <vtkRenderer.h>
-#include <vtkRenderWindow.h>
 #include <vtkScalarsToColors.h>
 #include <vtkTable.h>
 
@@ -153,12 +153,18 @@ void ctkVTKDiscretizableColorTransferWidgetPrivate::setupUi(QWidget* widget)
     vtkSmartPointer<vtkScalarsToColorsContextItem>::New();
   this->scalarsToColorsContextView = vtkSmartPointer<vtkContextView> ::New();
 
-  this->scalarsToColorsContextView->GetScene()->AddItem(
-    this->scalarsToColorsContextItem.Get());
+#if CTK_USE_QVTKOPENGLWIDGET
+  vtkSmartPointer<vtkGenericOpenGLRenderWindow> renwin =
+    vtkSmartPointer<vtkGenericOpenGLRenderWindow>::New();
+  this->ScalarsToColorsView->SetRenderWindow(renwin);
+#endif
+
+  this->scalarsToColorsContextView->SetRenderWindow(
+    this->ScalarsToColorsView->GetRenderWindow());
   this->scalarsToColorsContextView->SetInteractor(
     this->ScalarsToColorsView->GetInteractor());
-  this->ScalarsToColorsView->SetRenderWindow(
-    this->scalarsToColorsContextView->GetRenderWindow());
+  this->scalarsToColorsContextView->GetScene()->AddItem(
+    this->scalarsToColorsContextItem.Get());
 
   q->setViewBackgroundColor(QColor(49, 54, 59));