Skip to content
Snippets Groups Projects
Unverified Commit 98cc67c4 authored by Dmitri Naumov's avatar Dmitri Naumov Committed by GitHub
Browse files

Merge pull request #2432 from endJunction/UseQVtkOpenGlWidget

Use QVtkOpenGLWidget
parents 5fc667ab e539de27
No related branches found
No related tags found
No related merge requests found
...@@ -20,19 +20,22 @@ ...@@ -20,19 +20,22 @@
#include "VtkCustomInteractorStyle.h" #include "VtkCustomInteractorStyle.h"
#include "VtkPickCallback.h" #include "VtkPickCallback.h"
#include <vtkAxesActor.h>
#include <vtkCamera.h> #include <vtkCamera.h>
#include <vtkCellPicker.h> #include <vtkCellPicker.h>
#include <vtkRenderWindow.h>
#include <vtkRenderer.h>
#include <vtkSmartPointer.h>
#include <vtkAxesActor.h>
#include <vtkCommand.h> #include <vtkCommand.h>
#include <vtkGenericOpenGLRenderWindow.h>
#include <vtkInteractorStyleRubberBandZoom.h> #include <vtkInteractorStyleRubberBandZoom.h>
#include <vtkInteractorStyleSwitch.h> #include <vtkInteractorStyleSwitch.h>
#include <vtkMath.h> #include <vtkMath.h>
#include <vtkNew.h>
#include <vtkOrientationMarkerWidget.h> #include <vtkOrientationMarkerWidget.h>
#include <vtkPNGWriter.h> #include <vtkPNGWriter.h>
#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkSmartPointer.h>
#include <vtkSmartPointer.h> #include <vtkSmartPointer.h>
#include <vtkWindowToImageFilter.h> #include <vtkWindowToImageFilter.h>
...@@ -49,30 +52,31 @@ VisualizationWidget::VisualizationWidget(QWidget* parent /*= 0*/) ...@@ -49,30 +52,31 @@ VisualizationWidget::VisualizationWidget(QWidget* parent /*= 0*/)
{ {
this->setupUi(this); this->setupUi(this);
vtkNew<vtkRenderer> ren;
_vtkRender = ren;
vtkNew<vtkGenericOpenGLRenderWindow> renderWindow;
vtkWidget->SetRenderWindow(renderWindow);
vtkWidget->GetRenderWindow()->AddRenderer(ren);
_interactorStyle = VtkCustomInteractorStyle::New(); _interactorStyle = VtkCustomInteractorStyle::New();
vtkWidget->GetRenderWindow()->GetInteractor()->SetInteractorStyle(_interactorStyle); renderWindow->GetInteractor()->SetInteractorStyle(_interactorStyle);
_interactorStyle->SetDefaultRenderer(ren);
_vtkPickCallback = VtkPickCallback::New(); _vtkPickCallback = VtkPickCallback::New();
vtkSmartPointer<vtkCellPicker> picker = vtkSmartPointer<vtkCellPicker>::New(); vtkSmartPointer<vtkCellPicker> picker = vtkSmartPointer<vtkCellPicker>::New();
picker->AddObserver(vtkCommand::EndPickEvent, _vtkPickCallback); picker->AddObserver(vtkCommand::EndPickEvent, _vtkPickCallback);
vtkWidget->GetRenderWindow()->GetInteractor()->SetPicker(picker); renderWindow->GetInteractor()->SetPicker(picker);
vtkSmartPointer<vtkRenderWindow> renderWindow = vtkWidget->GetRenderWindow();
renderWindow->StereoCapableWindowOn();
renderWindow->SetStereoTypeToCrystalEyes();
_vtkRender = vtkRenderer::New();
renderWindow->AddRenderer(_vtkRender);
_interactorStyle->SetDefaultRenderer(_vtkRender);
QSettings settings; QSettings settings;
_vtkRender->SetBackground(0.0,0.0,0.0); ren->SetBackground(0.0,0.0,0.0);
// Create an orientation marker using vtkAxesActor // Create an orientation marker using vtkAxesActor
vtkSmartPointer<vtkAxesActor> axesActor = vtkSmartPointer<vtkAxesActor>::New(); vtkSmartPointer<vtkAxesActor> axesActor = vtkSmartPointer<vtkAxesActor>::New();
_markerWidget = vtkOrientationMarkerWidget::New(); _markerWidget = vtkOrientationMarkerWidget::New();
_markerWidget->SetOrientationMarker(axesActor); _markerWidget->SetOrientationMarker(axesActor);
_markerWidget->SetInteractor(vtkWidget->GetRenderWindow()->GetInteractor()); _markerWidget->SetInteractor(renderWindow->GetInteractor());
_markerWidget->EnabledOn(); _markerWidget->EnabledOn();
_markerWidget->InteractiveOff(); _markerWidget->InteractiveOff();
...@@ -88,7 +92,6 @@ VisualizationWidget::~VisualizationWidget() ...@@ -88,7 +92,6 @@ VisualizationWidget::~VisualizationWidget()
_vtkPickCallback->Delete(); _vtkPickCallback->Delete();
_interactorStyle->Delete(); _interactorStyle->Delete();
_markerWidget->Delete(); _markerWidget->Delete();
_vtkRender->Delete();
} }
VtkCustomInteractorStyle* VisualizationWidget::interactorStyle() const VtkCustomInteractorStyle* VisualizationWidget::interactorStyle() const
......
...@@ -535,7 +535,7 @@ ...@@ -535,7 +535,7 @@
</layout> </layout>
</item> </item>
<item> <item>
<widget class="QVTKWidget" name="vtkWidget" native="true"> <widget class="QVTKOpenGLWidget" name="vtkWidget" native="true">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding"> <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch> <horstretch>0</horstretch>
...@@ -548,9 +548,9 @@ ...@@ -548,9 +548,9 @@
</widget> </widget>
<customwidgets> <customwidgets>
<customwidget> <customwidget>
<class>QVTKWidget</class> <class>QVTKOpenGLWidget</class>
<extends>QWidget</extends> <extends>QWidget</extends>
<header>QVTKWidget.h</header> <header>QVTKOpenGLWidget.h</header>
</customwidget> </customwidget>
</customwidgets> </customwidgets>
<resources> <resources>
......
#include "mainwindow.h" #include "mainwindow.h"
#include <QApplication> #include <QApplication>
#include <QSurfaceFormat>
#include <QVTKOpenGLWidget.h>
#include <logog/include/logog.hpp> #include <logog/include/logog.hpp>
#include <memory> #include <memory>
...@@ -23,6 +25,9 @@ int main(int argc, char* argv[]) ...@@ -23,6 +25,9 @@ int main(int argc, char* argv[])
InitializeSdkObjects(lSdkManager, lScene); InitializeSdkObjects(lSdkManager, lScene);
#endif #endif
// needed to ensure appropriate OpenGL context is created for VTK rendering.
QSurfaceFormat::setDefaultFormat(QVTKOpenGLWidget::defaultFormat());
auto myOutputWindow = vtkSmartPointer<VtkConsoleOutputWindow>::New(); auto myOutputWindow = vtkSmartPointer<VtkConsoleOutputWindow>::New();
vtkOutputWindow::SetInstance(myOutputWindow); vtkOutputWindow::SetInstance(myOutputWindow);
......
...@@ -141,6 +141,7 @@ ...@@ -141,6 +141,7 @@
- added custom VTK filter to represent raster data as point clouds. [#2121](https://github.com/ufz/ogs/pull/2121) - added custom VTK filter to represent raster data as point clouds. [#2121](https://github.com/ufz/ogs/pull/2121)
- geometrical points can now be converted into station points. [#2369](https://github.com/ufz/ogs/pull/2369) - geometrical points can now be converted into station points. [#2369](https://github.com/ufz/ogs/pull/2369)
- fixed issue with geometrical surfaces not being loaded correctly. [#2388](https://github.com/ufz/ogs/pull/2388) - fixed issue with geometrical surfaces not being loaded correctly. [#2388](https://github.com/ufz/ogs/pull/2388)
- Replace deprecated QVTKWidget with QVTKOpenGLWidget [#2432](https://github.com/ufz/ogs/pull/2432)
### Other notable code changes ### Other notable code changes
......
...@@ -210,7 +210,7 @@ pipeline { ...@@ -210,7 +210,7 @@ pipeline {
post { post {
always { always {
recordIssues enabledForFailure: true, filters: [ recordIssues enabledForFailure: true, filters: [
excludeFile('.*qrc_icons\\.cpp.*'), excludeMessage('.*QVTKWidget.*'), excludeFile('.*qrc_icons\\.cpp.*'),
excludeMessage('.*tmpnam.*')], excludeMessage('.*tmpnam.*')],
tools: [gcc4(name: 'GCC-GUI', id: 'gcc4-gui', tools: [gcc4(name: 'GCC-GUI', id: 'gcc4-gui',
pattern: 'build/build*.log')], pattern: 'build/build*.log')],
......
...@@ -91,7 +91,6 @@ if(APPLE) ...@@ -91,7 +91,6 @@ if(APPLE)
endif() endif()
if(MSVC) if(MSVC)
set(CONAN_IMPORTS ${CONAN_IMPORTS} "bin, *.dll* -> ./bin") set(CONAN_IMPORTS ${CONAN_IMPORTS} "bin, *.dll* -> ./bin")
set(CONAN_IMPORTS ${CONAN_IMPORTS} "plugins/platforms, *.dll* -> ./bin/platforms")
endif() endif()
if(UNIX AND NOT APPLE) if(UNIX AND NOT APPLE)
set(CONAN_IMPORTS ${CONAN_IMPORTS} "lib, *.so* -> ./lib") set(CONAN_IMPORTS ${CONAN_IMPORTS} "lib, *.so* -> ./lib")
......
...@@ -27,8 +27,8 @@ endif() ...@@ -27,8 +27,8 @@ endif()
if(OGS_BUILD_GUI) if(OGS_BUILD_GUI)
install_qt5_plugin("Qt5::QCocoaIntegrationPlugin" QT_PLUGINS) install_qt5_plugin("Qt5::QCocoaIntegrationPlugin" QT_PLUGINS)
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/qt.conf" file(WRITE "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/qt.conf"
"[Paths]\nPlugins = ../${_qt_plugin_dir}\n") "[Paths]\nPlugins = ../${_qt_plugin_dir}\n")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/qt.conf" install(FILES "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/qt.conf"
DESTINATION bin COMPONENT ogs_gui) DESTINATION bin COMPONENT ogs_gui)
endif() endif()
...@@ -75,6 +75,7 @@ macro(install_qt5_plugin _qt_plugin_name _qt_plugins_var) ...@@ -75,6 +75,7 @@ macro(install_qt5_plugin _qt_plugin_name _qt_plugins_var)
set(_qt_plugin_dir "plugins") set(_qt_plugin_dir "plugins")
endif() endif()
set(_qt_plugin_dest "${_qt_plugin_dir}/${_qt_plugin_type}") set(_qt_plugin_dest "${_qt_plugin_dir}/${_qt_plugin_type}")
file(COPY "${_qt_plugin_path}" DESTINATION "${_qt_plugin_dest}")
install(FILES "${_qt_plugin_path}" install(FILES "${_qt_plugin_path}"
DESTINATION "${_qt_plugin_dest}" DESTINATION "${_qt_plugin_dest}"
${COMPONENT}) ${COMPONENT})
......
...@@ -29,8 +29,8 @@ endif() ...@@ -29,8 +29,8 @@ endif()
if(OGS_BUILD_GUI) if(OGS_BUILD_GUI)
install_qt5_plugin("Qt5::QWindowsIntegrationPlugin" QT_PLUGINS) install_qt5_plugin("Qt5::QWindowsIntegrationPlugin" QT_PLUGINS)
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/qt.conf" file(WRITE "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/qt.conf"
"[Paths]\nPlugins = ../${_qt_plugin_dir}\n") "[Paths]\nPlugins = ../${_qt_plugin_dir}\n")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/qt.conf" install(FILES "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/qt.conf"
DESTINATION bin COMPONENT ogs_gui) DESTINATION bin COMPONENT ogs_gui)
endif() endif()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment