Skip to content

Commit ccf4ace

Browse files
author
Charles PIGNEROL
committed
Version 8.8.3. Qt 6.10.0 / VTK 9.2.5 port. The port appears to be working fine in 9.5.2 but is not validated with Qt 6.10.0 because the graphical window is often black. Works well in Qt 6.6.1/VTK 9.2.5.
1 parent c241400 commit ccf4ace

11 files changed

+66
-73
lines changed

cmake/version.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
set (QT_VTK_MAJOR_VERSION "8")
66
set (QT_VTK_MINOR_VERSION "8")
7-
set (QT_VTK_RELEASE_VERSION "2")
7+
set (QT_VTK_RELEASE_VERSION "3")
88
set (QT_VTK_VERSION ${QT_VTK_MAJOR_VERSION}.${QT_VTK_MINOR_VERSION}.${QT_VTK_RELEASE_VERSION})
99

1010

src/QtVtk/QtVTKPrintHelper.cpp

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -364,34 +364,10 @@ void QtVTKPrintHelper::printToFile (vtkRenderWindow& window, const string& fileN
364364
} // if (1 < magnification)
365365
} // if (0 != dpi)
366366
windowToImageFilter->Update ( );
367-
#ifndef VTK_5
368367
writer->SetInputConnection (windowToImageFilter->GetOutputPort ( ));
369-
#else // VTK_5
370-
writer->SetInput (windowToImageFilter->GetOutput ( ));
371-
#endif // VTK_5
372-
writer->SetFileName (fileName.c_str ( ));
373-
#ifdef VTK_5
374-
// On force le raffraichissement total de la fenetre. En effet, si la fenetre
375-
// VTK est masquee par une autre fenetre X11 la zone masquee n'est pas
376-
// forcement raffraichie, et la zone correspondante de l'image est alors noire.
377-
window.MappedOff ( );
378-
window.MappedOn ( );
379-
#endif // VTK_5
380-
window.Render ( );
381-
#ifdef VTK_5
382-
windowToImageFilter->Modified ( );
383-
windowToImageFilter->Update ( );
384-
#endif // VTK_5
385-
writer->Write ( );
386-
/*
387-
windowToImageFilter->SetInput (&window);
388-
windowToImageFilter->Update ( );
389-
writer->SetInput (windowToImageFilter->GetOutput ( ));
390368
writer->SetFileName (fileName.c_str ( ));
391369
window.Render ( );
392370
writer->Write ( );
393-
*/
394-
395371
writer->Delete ( );
396372
windowToImageFilter->Delete ( );
397373

@@ -440,24 +416,9 @@ void QtVTKPrintHelper::printToFile (vtkRenderWindow& window, const string& fileN
440416

441417
windowToImageFilter->SetInput (rw);
442418
windowToImageFilter->Update ( );
443-
#ifndef VTK_5
444419
writer->SetInputConnection (windowToImageFilter->GetOutputPort ( ));
445-
#else // VTK_5
446-
writer->SetInput (windowToImageFilter->GetOutput ( ));
447-
#endif // VTK_5
448420
writer->SetFileName (fileName.c_str ( ));
449-
#ifdef VTK_5
450-
// On force le raffraichissement total de la fenetre. En effet, si la fenetre
451-
// VTK est masquee par une autre fenetre X11 la zone masquee n'est pas
452-
// forcement raffraichie, et la zone correspondante de l'image est alors noire.
453-
rw->MappedOff ( );
454-
rw->MappedOn ( );
455-
#endif // VTK_5
456421
rw->Render ( );
457-
#ifdef VTK_5
458-
windowToImageFilter->Modified ( );
459-
windowToImageFilter->Update ( );
460-
#endif // VTK_5
461422
writer->Write ( );
462423
writer->Delete ( );
463424
windowToImageFilter->Delete ( );

src/QtVtk/QtVtkViewDefinitionDialog.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@ QtVtkViewDefinitionDialog::QtVtkViewDefinitionDialog (
4646

4747
// Creation de l'ihm :
4848
QVBoxLayout* layout = new QVBoxLayout (this);
49+
#ifdef QT_5
4950
layout->setMargin (QtConfiguration::margin);
51+
#else // QT_5
52+
layout->setContentsMargins (QtConfiguration::margin, QtConfiguration::margin, QtConfiguration::margin, QtConfiguration::margin);
53+
#endif // QT_5
5054
layout->setSizeConstraint (QLayout::SetMinimumSize);
5155
QtGroupBox* frame = new QtGroupBox (QSTR ("Paramètres de la vue"), this, "frame");
5256
QVBoxLayout* frameLayout = new QVBoxLayout (frame);

src/QtVtk/QtVtkViewDefinitionPanel.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,11 @@ QtVtkViewDefinitionPanel::QtVtkViewDefinitionPanel (QWidget* parent, const strin
4848
// Creation de l'ihm :
4949
QVBoxLayout* layout = new QVBoxLayout (this);
5050
layout->setSpacing (QtConfiguration::spacing);
51+
#ifdef QT_5
5152
layout->setMargin (QtConfiguration::margin);
53+
#else // QT_5
54+
layout->setContentsMargins (QtConfiguration::margin, QtConfiguration::margin, QtConfiguration::margin, QtConfiguration::margin);
55+
#endif // QT_5
5256
layout->setSizeConstraint (QLayout::SetMinimumSize);
5357

5458
// Nom / Commentaire :

src/QtVtk/public/QtVtk/vtkECMIntersectionPolyDataFilter.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,7 @@
6666
* La simple réduction par homothétie du maillage suffit à rendre ce filtre
6767
* opérant ...
6868
*/
69-
#ifndef VTK_5
70-
class vtkECMIntersectionPolyDataFilter :
71-
#else // VTK_5
72-
class VTK_GRAPHICS_EXPORT vtkECMIntersectionPolyDataFilter :
73-
#endif // VTK_5
74-
public vtkPolyDataAlgorithm
69+
class vtkECMIntersectionPolyDataFilter : public vtkPolyDataAlgorithm
7570
{
7671
public:
7772

src/QtVtk/public/QtVtk/vtkPatchedDelaunay2D.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,7 @@ class vtkPointSet;
148148
#define VTK_SET_TRANSFORM_PLANE 1
149149
#define VTK_BEST_FITTING_PLANE 2
150150

151-
#ifndef VTK_5
152151
class vtkPatchedDelaunay2D : public vtkPolyDataAlgorithm // CP
153-
#else // VTK_5
154-
class VTK_GRAPHICS_EXPORT vtkPatchedDelaunay2D : public vtkPolyDataAlgorithm // CP
155-
#endif // VTK_5
156152
{
157153
public:
158154
vtkTypeMacro(vtkPatchedDelaunay2D,vtkPolyDataAlgorithm);

src/QtVtk/vtkECMIntersectionPolyDataFilter.cpp

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616

1717
#include "vtkCellArray.h"
1818
#include "vtkCellData.h"
19+
#if VTK_MAJOR_VERSION >= 9
1920
#include "vtkDelaunay2D.h"
21+
#endif // VTK_MAJOR_VERSION >= 9
2022
#include "vtkDoubleArray.h"
2123
#include "vtkInformation.h"
2224
#include "vtkInformationVector.h"
@@ -43,7 +45,9 @@
4345
// CP : new code
4446
#include <vtkIdTypeArray.h>
4547
#include <set>
48+
#if VTK_MAJOR_VERSION < 9
4649
#include <QtVtk/vtkPatchedDelaunay2D.h>
50+
#endif // VTK_MAJOR_VERSION < 9
4751
// !CP new code
4852

4953

@@ -859,17 +863,14 @@ ::SplitCell(vtkPolyData *input, vtkIdType cellId, vtkIdType *cellPts,
859863
transform->Translate(-center[0], -center[1], -center[2]);
860864

861865
// CP : new code
862-
// vtkSmartPointer< vtkDelaunay2D > del2D =
863-
// vtkSmartPointer< vtkDelaunay2D >::New();
864-
vtkSmartPointer< vtkPatchedDelaunay2D > del2D =
865-
vtkSmartPointer< vtkPatchedDelaunay2D >::New();
866+
#if VTK_MAJOR_VERSION < 9
867+
vtkSmartPointer< vtkPatchedDelaunay2D > del2D = vtkSmartPointer< vtkPatchedDelaunay2D >::New();
868+
#else
869+
vtkSmartPointer< vtkDelaunay2D > del2D = vtkSmartPointer< vtkDelaunay2D >::New();
870+
#endif // VTK_MAJOR_VERSION < 9
866871
// !CP : new code
867-
#ifndef VTK_5
868872
del2D->SetInputData (pd);
869-
#else // VTK_5
870-
del2D->SetInput(pd);
871-
#endif // VTK_5
872-
del2D->SetSource(pd);
873+
// del2D->SetSource(pd); // CP v 8.8.3
873874
del2D->SetTolerance(0.0);
874875
del2D->SetAlpha(0.0);
875876
del2D->SetOffset(10);
@@ -1395,17 +1396,11 @@ int vtkECMIntersectionPolyDataFilter::RequestData(vtkInformation* vtkNotU
13951396
// Set up new poly data for the inputs to build cells and links.
13961397
vtkSmartPointer< vtkPolyData > mesh0 = vtkSmartPointer< vtkPolyData >::New();
13971398
mesh0->DeepCopy(input0);
1398-
#ifndef VTK_5
1399-
#else // VTK_5
1400-
mesh0->SetSource(NULL);
1401-
#endif // VTK_5
1399+
// mesh0->SetSource(NULL); // CP v 8.8.3
14021400

14031401
vtkSmartPointer< vtkPolyData > mesh1 = vtkSmartPointer< vtkPolyData >::New();
14041402
mesh1->DeepCopy(input1);
1405-
#ifndef VTK_5
1406-
#else // VTK_5
1407-
mesh1->SetSource(NULL);
1408-
#endif // VTK_5
1403+
// mesh1->SetSource(NULL); // CP v 8.8.3
14091404

14101405
// Find the triangle-triangle intersections between mesh0 and mesh1
14111406
vtkSmartPointer< vtkOBBTree > obbTree0 = vtkSmartPointer< vtkOBBTree >::New();

src/QtVtk/vtkPatchedDelaunay2D.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,7 @@ vtkPatchedDelaunay2D::~vtkPatchedDelaunay2D()
6666
void vtkPatchedDelaunay2D::SetSource(vtkPolyData *input) // CP
6767
{
6868
// this->Superclass::SetInputData(1, input); // CP
69-
#ifndef VTK_5
7069
this->Superclass::SetInputData(1, input); // CP
71-
#else // VTK_5
72-
this->Superclass::SetInput(1, input); // CP
73-
#endif // VTK_5
7470
}
7571

7672
//----------------------------------------------------------------------------

src/viewpoint/QtViewPointWindow.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
#include <QtUtil/QtCoordinatesDialog.h>
1111
#include <VtkContrib/vtkTrihedron.h>
1212
#include <VtkContrib/vtkTrihedronCommand.h>
13+
#ifndef VTK_WIDGET
14+
#include <vtkGenericOpenGLRenderWindow.h>
15+
#endif // VTK_WIDGET
1316

1417
#include <QApplication>
1518
#include <QInputDialog>
@@ -48,8 +51,12 @@ void QtViewPointWindow::createGui ( )
4851
_graphicWindow->setAttribute (Qt::WA_TranslucentBackground, true); // Bonne gestion transparence
4952
setCentralWidget (_graphicWindow);
5053
_renderer = vtkRenderer::New ( );
54+
#ifndef VTK_WIDGET
55+
_renderWindow = vtkGenericOpenGLRenderWindow::New ( );
56+
#else // VTK_WIDGET
5157
_renderWindow = vtkRenderWindow::New ( );
5258
_renderWindow->Render ( ); // Pour bonne gestion transparence
59+
#endif // VTK_WIDGET
5360
_renderWindow->SetAlphaBitPlanes (1); // Bonne gestion transparence
5461
_renderWindow->SetMultiSamples (0); // Bonne gestion transparence
5562
_renderer->SetUseDepthPeeling (true); // Bonne gestion transparence
@@ -70,8 +77,8 @@ void QtViewPointWindow::createGui ( )
7077
_renderWindow->AddRenderer (trihedronRenderer);
7178
_graphicWindow->SetRenderWindow (_renderWindow);
7279
vtkInteractorStyleSwitch* interactorStyle = vtkInteractorStyleSwitch::New ( );
73-
_graphicWindow->GetInteractor ( )->SetInteractorStyle (interactorStyle);
74-
_graphicWindow->GetInteractor ( )->SetRenderWindow (_renderWindow);
80+
_graphicWindow->getInteractor ( )->SetInteractorStyle (interactorStyle);
81+
_graphicWindow->getInteractor ( )->SetRenderWindow (_renderWindow);
7582
_graphicWindow->setMinimumSize (800, 600);
7683
_graphicWindow->resize (800, 600);
7784
} // QtViewPointWindow::createGui

src/viewpoint/viewpoint.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <TkUtil/Exception.h>
1010

1111
#include <QApplication>
12+
#include <QSurfaceFormat>
1213

1314
#include <iostream>
1415

@@ -22,6 +23,22 @@ int main (int argc, char* argv[])
2223
try
2324
{
2425
QApplication* application = new QApplication (argc, argv);
26+
#if (VTK_MAJOR_VERSION >= 9)
27+
QSurfaceFormat fmt;
28+
fmt.setRenderableType(QSurfaceFormat::OpenGL);
29+
fmt.setVersion(3, 2);
30+
fmt.setProfile(QSurfaceFormat::CoreProfile);
31+
fmt.setSwapBehavior(QSurfaceFormat::DoubleBuffer);
32+
fmt.setRedBufferSize(8);
33+
fmt.setGreenBufferSize(8);
34+
fmt.setBlueBufferSize(8);
35+
fmt.setDepthBufferSize(24);
36+
fmt.setStencilBufferSize(8);
37+
fmt.setAlphaBufferSize(0);
38+
fmt.setStereo(false);
39+
fmt.setSamples(0);//vtkOpenGLRenderWindow::GetGlobalMaximumNumberOfMultiSamples());
40+
QSurfaceFormat::setDefaultFormat (fmt);
41+
#endif // #if (VTK_MAJOR_VERSION >= 9)
2542
QtVtk::initialize ( );
2643
QtViewPointWindow* mainWindow = new QtViewPointWindow ( );
2744
mainWindow->show ( );

0 commit comments

Comments
 (0)