Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Backports:SLE-15-SP6:Update
QCSXCAD
0001-Add-method-to-get-vtkRenderWindow-from-QVT...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0001-Add-method-to-get-vtkRenderWindow-from-QVTKStructure.patch of Package QCSXCAD
From e23eb773931ea5f88a08e4c67b044f50012a774b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Br=C3=BCns?= <stefan.bruens@rwth-aachen.de> Date: Fri, 25 Nov 2022 14:34:19 +0100 Subject: [PATCH] Add method to get vtkRenderWindow from QVTKStructure This allows to hide the differences between different VTK versions. --- QVTKStructure.cpp | 53 +++++++++++++++++++++++++++++------------------ QVTKStructure.h | 3 ++- export_pov.cpp | 23 ++------------------ export_x3d.cpp | 15 +------------- 4 files changed, 38 insertions(+), 56 deletions(-) diff --git a/QVTKStructure.cpp b/QVTKStructure.cpp index c06fc7f..b5a4dbb 100644 --- a/QVTKStructure.cpp +++ b/QVTKStructure.cpp @@ -27,8 +27,8 @@ #include "vtkGenericOpenGLRenderWindow.h" #else #include "QVTKWidget.h" - #endif + #include "vtkCommand.h" #include "vtkRenderWindow.h" #include "vtkRenderWindowInteractor.h" @@ -113,12 +113,12 @@ QVTKStructure::QVTKStructure() #endif ren = vtkRenderer::New(); - VTKWidget->GetRenderWindow()->AddRenderer(ren); + GetRenderWindow()->AddRenderer(ren); AddAxes(); SetBackgroundColor(255,255,255); - SetCallback(VTKWidget->GetRenderWindow()->GetInteractor()); + SetCallback(GetRenderWindow()->GetInteractor()); } QVTKStructure::~QVTKStructure() @@ -126,6 +126,19 @@ QVTKStructure::~QVTKStructure() clear(); } +QWidget* QVTKStructure::GetVTKWidget() const { + return VTKWidget; +}; + +vtkRenderWindow* QVTKStructure::GetRenderWindow() const +{ +#if VTK_MAJOR_VERSION>=9 + return VTKWidget->renderWindow(); +#else + return VTKWidget->GetRenderWindow(); +#endif +} + void QVTKStructure::AddAxes() { Axes = vtkAxesActor::New(); @@ -137,7 +150,7 @@ void QVTKStructure::AddAxes() marker->SetOrientationMarker(assembly); marker->SetViewport(0.0,0.0,0.25,0.25); - marker->SetInteractor(VTKWidget->GetRenderWindow()->GetInteractor()); + marker->SetInteractor(GetRenderWindow()->GetInteractor()); marker->SetEnabled(1); marker->InteractiveOff(); @@ -159,7 +172,7 @@ void QVTKStructure::SetBackgroundColor(int r, int g, int b) { if (ActorGridPlane[i]!=NULL) ActorGridPlane[i]->GetProperty()->SetColor(irgb); } - VTKWidget->GetRenderWindow()->GetInteractor()->Render(); + GetRenderWindow()->GetInteractor()->Render(); } void QVTKStructure::SetGeometry(ContinuousStructure *CS) @@ -277,20 +290,20 @@ void QVTKStructure::RenderGrid() void QVTKStructure::RenderGridX(int plane_pos) { RenderGridDir(0,plane_pos); - VTKWidget->GetRenderWindow()->GetInteractor()->Render(); + GetRenderWindow()->GetInteractor()->Render(); } void QVTKStructure::RenderGridY(int plane_pos) { RenderGridDir(1,plane_pos); - VTKWidget->GetRenderWindow()->GetInteractor()->Render(); + GetRenderWindow()->GetInteractor()->Render(); } void QVTKStructure::RenderGridZ(int plane_pos) { RenderGridDir(2,plane_pos); - VTKWidget->GetRenderWindow()->GetInteractor()->Render(); + GetRenderWindow()->GetInteractor()->Render(); } void QVTKStructure::RenderGridDir(int dir, unsigned int plane_pos) @@ -413,13 +426,13 @@ void QVTKStructure::SetGridOpacity(int val) { if (ActorGridPlane[i]!=NULL) ActorGridPlane[i]->GetProperty()->SetOpacity((double)val/255.0); } - VTKWidget->GetRenderWindow()->GetInteractor()->Render(); + GetRenderWindow()->GetInteractor()->Render(); } void QVTKStructure::ResetView() { ren->ResetCamera(); - VTKWidget->GetRenderWindow()->GetInteractor()->Render(); + GetRenderWindow()->GetInteractor()->Render(); } void QVTKStructure::setXY() @@ -472,7 +485,7 @@ void QVTKStructure::SetPropOpacity(unsigned int uiID, int val) if (LayerPrimitives.at(i).VTKProp!=NULL) LayerPrimitives.at(i).VTKProp->SetOpacity2All((double)val/255.0); } } - VTKWidget->GetRenderWindow()->GetInteractor()->Render(); + GetRenderWindow()->GetInteractor()->Render(); } void QVTKStructure::RenderGeometry() @@ -679,7 +692,7 @@ void QVTKStructure::RenderGeometry() } } } - VTKWidget->GetRenderWindow()->GetInteractor()->Render(); + GetRenderWindow()->GetInteractor()->Render(); } void QVTKStructure::RenderDiscMaterialModel() @@ -716,7 +729,7 @@ void QVTKStructure::RenderDiscMaterialModel() delete transform; } } - VTKWidget->GetRenderWindow()->GetInteractor()->Render(); + GetRenderWindow()->GetInteractor()->Render(); } void QVTKStructure::SetParallelProjection(bool val, bool render) @@ -725,18 +738,18 @@ void QVTKStructure::SetParallelProjection(bool val, bool render) cam->SetParallelProjection(val); if (render) - VTKWidget->GetRenderWindow()->GetInteractor()->Render(); + GetRenderWindow()->GetInteractor()->Render(); } void QVTKStructure::Set2DInteractionStyle(bool val, bool render) { if (val) - VTKWidget->GetRenderWindow()->GetInteractor()->SetInteractorStyle(vtkInteractorStyleRubberBand2DPlane::New()); + GetRenderWindow()->GetInteractor()->SetInteractorStyle(vtkInteractorStyleRubberBand2DPlane::New()); else - VTKWidget->GetRenderWindow()->GetInteractor()->SetInteractorStyle(vtkInteractorStyleTrackballCamera::New()); + GetRenderWindow()->GetInteractor()->SetInteractorStyle(vtkInteractorStyleTrackballCamera::New()); if (render) - VTKWidget->GetRenderWindow()->GetInteractor()->Render(); + GetRenderWindow()->GetInteractor()->Render(); } void QVTKStructure::SaveCamData() @@ -765,7 +778,7 @@ void QVTKStructure::RestoreCamData(bool render) Camera->Modified(); if (render) - VTKWidget->GetRenderWindow()->GetInteractor()->Render(); + GetRenderWindow()->GetInteractor()->Render(); } @@ -777,7 +790,7 @@ void QVTKStructure::ExportView2Image() return; vtkWindowToImageFilter* filter = vtkWindowToImageFilter::New(); - filter->SetInput(VTKWidget->GetRenderWindow()); + filter->SetInput(GetRenderWindow()); vtkPNGWriter* png_writer= vtkPNGWriter::New(); png_writer->SetInputConnection(filter->GetOutputPort()); @@ -885,7 +898,7 @@ void QVTKStructure::SetCallback(vtkRenderWindowInteractor *iren) cb->SetCallback(KeyPress); cb->SetClientData((void *)cbData); iren->AddObserver(vtkCommand::KeyReleaseEvent, cb); - //VTKWidget->GetRenderWindow()->GetInteractor()->AddObserver(vtkCommand::KeyReleaseEvent, cb); + //GetRenderWindow()->GetInteractor()->AddObserver(vtkCommand::KeyReleaseEvent, cb); cb->Delete(); // free(cbData); diff --git a/QVTKStructure.h b/QVTKStructure.h index 70f8bac..b04833f 100644 --- a/QVTKStructure.h +++ b/QVTKStructure.h @@ -46,7 +46,8 @@ public: QVTKStructure(); virtual ~QVTKStructure(); - QWidget* GetVTKWidget() {return (QWidget *)VTKWidget;}; + QWidget* GetVTKWidget() const; + vtkRenderWindow* GetRenderWindow() const; void AddAxes(); diff --git a/export_pov.cpp b/export_pov.cpp index 30c0943..3169020 100644 --- a/export_pov.cpp +++ b/export_pov.cpp @@ -19,13 +19,6 @@ #include <QtXml> #include "QVTKStructure.h" -#if VTK_MAJOR_VERSION>=9 - #include "QVTKOpenGLStereoWidget.h" -#elif VTK_MAJOR_VERSION==8 - #include "QVTKOpenGLWidget.h" -#else - #include "QVTKWidget.h" -#endif #include <vtkRendererCollection.h> #include <vtkRenderWindow.h> #include <vtkRenderer.h> @@ -207,13 +200,7 @@ void export_pov::export_wire( QTextStream &stream, size_t count, double *array, QString export_pov::get_camera() { -#if VTK_MAJOR_VERSION>=9 - vtkRendererCollection* collection = ((QVTKOpenGLStereoWidget*)(m_CSX->StructureVTK->GetVTKWidget()))->renderWindow()->GetRenderers(); -#elif VTK_MAJOR_VERSION==8 - vtkRendererCollection* collection = ((QVTKOpenGLWidget*)(m_CSX->StructureVTK->GetVTKWidget()))->GetRenderWindow()->GetRenderers(); -#else - vtkRendererCollection* collection = ((QVTKWidget*)(m_CSX->StructureVTK->GetVTKWidget()))->GetRenderWindow()->GetRenderers(); -#endif + vtkRendererCollection* collection = m_CSX->StructureVTK->GetRenderWindow()->GetRenderers(); vtkRenderer *r = collection->GetFirstRenderer(); if (!r) return QString(); @@ -243,13 +230,7 @@ QString export_pov::get_camera() QString export_pov::get_light() { -#if VTK_MAJOR_VERSION>=9 - vtkRendererCollection* collection = ((QVTKOpenGLStereoWidget*)(m_CSX->StructureVTK->GetVTKWidget()))->renderWindow()->GetRenderers(); -#elif VTK_MAJOR_VERSION==8 - vtkRendererCollection* collection = ((QVTKOpenGLWidget*)(m_CSX->StructureVTK->GetVTKWidget()))->GetRenderWindow()->GetRenderers(); -#else - vtkRendererCollection* collection = ((QVTKWidget*)(m_CSX->StructureVTK->GetVTKWidget()))->GetRenderWindow()->GetRenderers(); -#endif + vtkRendererCollection* collection = m_CSX->StructureVTK->GetRenderWindow()->GetRenderers(); vtkRenderer *r = collection->GetFirstRenderer(); if (!r) return QString(); diff --git a/export_x3d.cpp b/export_x3d.cpp index 802d974..1f48074 100644 --- a/export_x3d.cpp +++ b/export_x3d.cpp @@ -18,13 +18,6 @@ #include <QMessageBox> #include "QVTKStructure.h" -#if VTK_MAJOR_VERSION>=9 - #include "QVTKOpenGLStereoWidget.h" -#elif VTK_MAJOR_VERSION==8 - #include "QVTKOpenGLWidget.h" -#else - #include "QVTKWidget.h" -#endif #include <vtkRendererCollection.h> #include <vtkRenderWindow.h> #include <vtkRenderer.h> @@ -76,13 +69,7 @@ void export_X3D::save( QString filename ) export_properties( Scene, properties, Material ); // create camera -#if VTK_MAJOR_VERSION>=9 - vtkRendererCollection* collection = ((QVTKOpenGLStereoWidget*)(m_CSX->StructureVTK->GetVTKWidget()))->renderWindow()->GetRenderers(); -#elif VTK_MAJOR_VERSION==8 - vtkRendererCollection* collection = ((QVTKOpenGLWidget*)(m_CSX->StructureVTK->GetVTKWidget()))->GetRenderWindow()->GetRenderers(); -#else - vtkRendererCollection* collection = ((QVTKWidget*)(m_CSX->StructureVTK->GetVTKWidget()))->GetRenderWindow()->GetRenderers(); -#endif + vtkRendererCollection* collection = m_CSX->StructureVTK->GetRenderWindow()->GetRenderers(); vtkRenderer *r = collection->GetFirstRenderer(); if (!r) return; -- 2.38.1
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor