|
4 | 4 | // voir fichier /etc/printcap : liste des imprimantes
|
5 | 5 |
|
6 | 6 | #include <QtVtk/QtVTKPrintHelper.h>
|
| 7 | +#include <QtVtk/QtVtk.h> |
7 | 8 | #include <QtUtil/QtMessageBox.h>
|
8 | 9 |
|
9 | 10 | #include <TkUtil/Exception.h>
|
@@ -305,8 +306,7 @@ void QtVTKPrintHelper::printToFile (vtkRenderWindow& window, const string& fileN
|
305 | 306 | if ((string::npos == dotPos) || (string::npos == fileName.length ( ) - 1))
|
306 | 307 | {
|
307 | 308 | UTF8String error (charset);
|
308 |
| - error << "Impossibilité de déterminer le format du fichier à " |
309 |
| - << "partir de son extension.\n" |
| 309 | + error << "Impossibilité de déterminer le format du fichier à partir de son extension.\n" |
310 | 310 | << "Extensions possibles : "
|
311 | 311 | << ".ps .eps .jpg .jpeg .bmp .png .pnm .tiff .pdf";
|
312 | 312 | throw Exception (error);
|
@@ -340,36 +340,39 @@ void QtVTKPrintHelper::printToFile (vtkRenderWindow& window, const string& fileN
|
340 | 340 | } // EPS ou PDF
|
341 | 341 |
|
342 | 342 | // V 7.14.7 : on s'assure que la copie du buffer graphique pourra fonctionner, à savoir qu'on fonctionne sur une
|
343 |
| - // machine aveccarte graphique, ou, à défaut, pas sur une machine virtuelle : |
| 343 | + // machine avec carte graphique, ou, à défaut, pas sur une machine virtuelle : |
344 | 344 | static bool first = true;
|
345 | 345 | static bool useHard = true;
|
346 |
| - if (true == first) |
| 346 | + if (true == QtVtk::forceSoftwarePrinter) |
347 | 347 | {
|
348 |
| - const string glVendor ((const char*)glGetString (GL_VENDOR)); // NVIDIA, ATI, Intel, ... |
349 |
| - const string glRenderer ((const char*)glGetString (GL_RENDERER)); // Quattro, Mesa DRI Intel, ... |
350 |
| - if ((true == glVendor.empty ( )) || (true == glRenderer.empty ( ))) |
351 |
| - useHard = false; |
352 |
| - if (NULL != strcasestr (glRenderer.c_str ( ), "llvmpipe")) |
353 |
| - useHard = false; |
354 |
| - if (false == useHard) // Pas de hard détecté, par sécurité on fait une impression offscreen : |
355 |
| - cout << "Absence de carte graphique détectée, les impressions dans un fichier seront effectuées en rendu logiciel par sécurité." << endl; |
356 |
| - else |
| 348 | + if (true == first) |
357 | 349 | {
|
358 |
| - if (true == MachineData::isVirtualMachine ( )) |
359 |
| - { |
| 350 | + const string glVendor ((const char*)glGetString (GL_VENDOR)); // NVIDIA, ATI, Intel, ... |
| 351 | + const string glRenderer ((const char*)glGetString (GL_RENDERER)); // Quattro, Mesa DRI Intel, ... |
| 352 | + if ((true == glVendor.empty ( )) || (true == glRenderer.empty ( ))) |
360 | 353 | useHard = false;
|
361 |
| - cout << "Machine virtuelle détectée, les impressions dans un fichier seront effectuées en rendu logiciel par sécurité." << endl; |
362 |
| - } // if (true == MachineData::isVirtualMachine ( )) |
363 |
| - } // else if (false == useHard) |
364 |
| - first = false; |
365 |
| - } // if (true == first) |
366 |
| - |
367 |
| - if (false == useHard) |
| 354 | + if (NULL != strcasestr (glRenderer.c_str ( ), "llvmpipe")) |
| 355 | + useHard = false; |
| 356 | + if (false == useHard) // Pas de hard détecté, par sécurité on fait une impression offscreen : |
| 357 | + cout << "Absence de carte graphique détectée, les impressions dans un fichier seront effectuées en rendu logiciel par sécurité." << endl; |
| 358 | + else |
| 359 | + { |
| 360 | + if (true == MachineData::isVirtualMachine ( )) |
| 361 | + { |
| 362 | + useHard = false; |
| 363 | + cout << "Machine virtuelle détectée, les impressions dans un fichier seront effectuées en rendu logiciel par sécurité." << endl; |
| 364 | + } // if (true == MachineData::isVirtualMachine ( )) |
| 365 | + } // else if (false == useHard) |
| 366 | + first = false; |
| 367 | + } // if (true == first) |
| 368 | + } // if (true == QtVtk::forceSoftwarePrinter) |
| 369 | + |
| 370 | + if ((true == QtVtk::forceSoftwarePrinter) || (false == useHard)) |
368 | 371 | {
|
369 | 372 | printToFile (window, fileName, window.GetSize ( )[0], window.GetSize ( )[1]);
|
370 | 373 | return;
|
371 |
| - } // if (false == useHard) |
372 |
| - |
| 374 | + } // if ((true == QtVtk::forceSoftwarePrinter) || (false == useHard)) |
| 375 | + |
373 | 376 | // Impression raster : on passe par un image.
|
374 | 377 | vtkWindowToImageFilter* windowToImageFilter = vtkWindowToImageFilter::New ( );
|
375 | 378 | vtkImageWriter* writer = createWriter (fileName);
|
|
0 commit comments