Skip to content

Version 8.6.0. By default, all prints are made in soft rendering. #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmake/version.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
#

set (QT_VTK_MAJOR_VERSION "8")
set (QT_VTK_MINOR_VERSION "5")
set (QT_VTK_RELEASE_VERSION "1")
set (QT_VTK_MINOR_VERSION "6")
set (QT_VTK_RELEASE_VERSION "0")
set (QT_VTK_VERSION ${QT_VTK_MAJOR_VERSION}.${QT_VTK_MINOR_VERSION}.${QT_VTK_RELEASE_VERSION})


51 changes: 27 additions & 24 deletions src/QtVtk/QtVTKPrintHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// voir fichier /etc/printcap : liste des imprimantes

#include <QtVtk/QtVTKPrintHelper.h>
#include <QtVtk/QtVtk.h>
#include <QtUtil/QtMessageBox.h>

#include <TkUtil/Exception.h>
Expand Down Expand Up @@ -305,8 +306,7 @@ void QtVTKPrintHelper::printToFile (vtkRenderWindow& window, const string& fileN
if ((string::npos == dotPos) || (string::npos == fileName.length ( ) - 1))
{
UTF8String error (charset);
error << "Impossibilité de déterminer le format du fichier à "
<< "partir de son extension.\n"
error << "Impossibilité de déterminer le format du fichier à partir de son extension.\n"
<< "Extensions possibles : "
<< ".ps .eps .jpg .jpeg .bmp .png .pnm .tiff .pdf";
throw Exception (error);
Expand Down Expand Up @@ -340,36 +340,39 @@ void QtVTKPrintHelper::printToFile (vtkRenderWindow& window, const string& fileN
} // EPS ou PDF

// V 7.14.7 : on s'assure que la copie du buffer graphique pourra fonctionner, à savoir qu'on fonctionne sur une
// machine aveccarte graphique, ou, à défaut, pas sur une machine virtuelle :
// machine avec carte graphique, ou, à défaut, pas sur une machine virtuelle :
static bool first = true;
static bool useHard = true;
if (true == first)
if (true == QtVtk::forceSoftwarePrinter)
{
const string glVendor ((const char*)glGetString (GL_VENDOR)); // NVIDIA, ATI, Intel, ...
const string glRenderer ((const char*)glGetString (GL_RENDERER)); // Quattro, Mesa DRI Intel, ...
if ((true == glVendor.empty ( )) || (true == glRenderer.empty ( )))
useHard = false;
if (NULL != strcasestr (glRenderer.c_str ( ), "llvmpipe"))
useHard = false;
if (false == useHard) // Pas de hard détecté, par sécurité on fait une impression offscreen :
cout << "Absence de carte graphique détectée, les impressions dans un fichier seront effectuées en rendu logiciel par sécurité." << endl;
else
if (true == first)
{
if (true == MachineData::isVirtualMachine ( ))
{
const string glVendor ((const char*)glGetString (GL_VENDOR)); // NVIDIA, ATI, Intel, ...
const string glRenderer ((const char*)glGetString (GL_RENDERER)); // Quattro, Mesa DRI Intel, ...
if ((true == glVendor.empty ( )) || (true == glRenderer.empty ( )))
useHard = false;
cout << "Machine virtuelle détectée, les impressions dans un fichier seront effectuées en rendu logiciel par sécurité." << endl;
} // if (true == MachineData::isVirtualMachine ( ))
} // else if (false == useHard)
first = false;
} // if (true == first)

if (false == useHard)
if (NULL != strcasestr (glRenderer.c_str ( ), "llvmpipe"))
useHard = false;
if (false == useHard) // Pas de hard détecté, par sécurité on fait une impression offscreen :
cout << "Absence de carte graphique détectée, les impressions dans un fichier seront effectuées en rendu logiciel par sécurité." << endl;
else
{
if (true == MachineData::isVirtualMachine ( ))
{
useHard = false;
cout << "Machine virtuelle détectée, les impressions dans un fichier seront effectuées en rendu logiciel par sécurité." << endl;
} // if (true == MachineData::isVirtualMachine ( ))
} // else if (false == useHard)
first = false;
} // if (true == first)
} // if (true == QtVtk::forceSoftwarePrinter)

if ((true == QtVtk::forceSoftwarePrinter) || (false == useHard))
{
printToFile (window, fileName, window.GetSize ( )[0], window.GetSize ( )[1]);
return;
} // if (false == useHard)
} // if ((true == QtVtk::forceSoftwarePrinter) || (false == useHard))

// Impression raster : on passe par un image.
vtkWindowToImageFilter* windowToImageFilter = vtkWindowToImageFilter::New ( );
vtkImageWriter* writer = createWriter (fileName);
Expand Down
4 changes: 3 additions & 1 deletion src/QtVtk/QtVtk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ static vtkSmartPointer<vtkHardwareSelector> hardwareSelector;
static vtkSmartPointer<vtkRenderWindow> hardwareSelectionWindow;
static vtkSmartPointer<vtkRenderer> hardwareSelectionRenderer;

bool QtVtk::forceSoftwarePrinter = true; // v 8.6.0


QtVtk::QtVtk ( )
Expand Down Expand Up @@ -44,8 +45,9 @@ QtVtk::~QtVtk ( )
} // QtVtk::~QtVtk


void QtVtk::initialize ( )
void QtVtk::initialize (bool softwarePrinter)
{
forceSoftwarePrinter = softwarePrinter; // v 8.6.0
// Q_INIT_RESOURCE (QtVtk);

/* if (0 != QApplication::desktop ( ))
Expand Down
15 changes: 13 additions & 2 deletions src/QtVtk/public/QtVtk/QtVtk.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,12 @@ class QtVtk
public :

/**
* Initialisation des services..
* Initialisation des services.
* @param forceSoftwarePrinter : true si on force des impressions n'utilisant pas le buffer de la fenêtre Open GL. Les impressions sont plus lentes et coûteuses
* en mémoire, mais le rendu "hard" dysfonctionne dans certaines configurations, voire peut planter une station ou session de machine virtuelle. Vaut true
* par défaut.
*/
static void initialize ( );
static void initialize (bool forceSoftwarePrinter = true);

/**
* Arrêts des services.
Expand Down Expand Up @@ -65,6 +68,14 @@ class QtVtk
static vtkRenderer& getHardwareSelectionRenderer ( );


/** true si on force des impressions n'utilisant pas le buffer de la fenêtre Open GL. Les impressions sont plus lentes et coûteuses
* en mémoire, mais le rendu "hard" dysfonctionne dans certaines configurations, voire peut planter une station ou session de machine virtuelle.
* Vaut true par défaut.
* @since 8.6.0
*/
static bool forceSoftwarePrinter;


private :

/**
Expand Down
7 changes: 7 additions & 0 deletions versions.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
A FAIRE : tester le vtkIntersectionPolyDataFilter de VTK 7, voir si de base il propose les services attendus (Inner, ...).

Version 8.6.0 : 22/11/24
===============

Par défaut les impressions sont toutes faites en rendu soft. En effet, le rendu hard est très dégradé dans des configurations récentes,
et peut planter une session effectuées dans une machine virtuelle.


Version 8.5.1 : 14/06/24
===============

Expand Down