------------------------------------------------------------------------------
| 36 | |
| 37 | //------------------------------------------------------------------------------ |
| 38 | void vtkOpenGLGL2PSExporter::WriteData() |
| 39 | { |
| 40 | // Open file: |
| 41 | if (this->FilePrefix == nullptr) |
| 42 | { |
| 43 | vtkErrorMacro(<< "Please specify a file prefix to use"); |
| 44 | return; |
| 45 | } |
| 46 | |
| 47 | std::ostringstream fname; |
| 48 | fname << this->FilePrefix << "." << this->GetFileExtension(); |
| 49 | if (this->Compress && this->FileFormat != PDF_FILE) |
| 50 | { |
| 51 | fname << ".gz"; |
| 52 | } |
| 53 | FILE* file = vtksys::SystemTools::Fopen(fname.str(), "wb"); |
| 54 | if (!file) |
| 55 | { |
| 56 | vtkErrorMacro("Unable to open file: " << fname.str()); |
| 57 | return; |
| 58 | } |
| 59 | |
| 60 | // Setup information that GL2PS will need to export the scene: |
| 61 | std::string title = (this->Title && this->Title[0]) ? this->Title : "VTK GL2PS Export"; |
| 62 | GLint options = static_cast<GLint>(this->GetGL2PSOptions()); |
| 63 | GLint sort = static_cast<GLint>(this->GetGL2PSSort()); |
| 64 | GLint format = static_cast<GLint>(this->GetGL2PSFormat()); |
| 65 | const int* winsize = this->RenderWindow->GetSize(); |
| 66 | GLint viewport[4] = { 0, 0, static_cast<GLint>(winsize[0]), static_cast<GLint>(winsize[1]) }; |
| 67 | |
| 68 | // Setup helper class: |
| 69 | vtkNew<vtkOpenGLGL2PSHelper> gl2ps; |
| 70 | gl2ps->SetInstance(gl2ps); |
| 71 | gl2ps->SetTextAsPath(this->TextAsPath); |
| 72 | gl2ps->SetRenderWindow(this->RenderWindow); |
| 73 | |
| 74 | // Grab the image background: |
| 75 | vtkNew<vtkImageData> background; |
| 76 | if (!this->RasterizeBackground(background)) |
| 77 | { |
| 78 | vtkErrorMacro("Error rasterizing background image. Exported image may be " |
| 79 | "incorrect."); |
| 80 | background->Initialize(); |
| 81 | // Continue with export. |
| 82 | } |
| 83 | |
| 84 | // Fixup options for no-opengl-context GL2PS rendering (we don't use the |
| 85 | // context since we inject all geometry manually): |
| 86 | options |= GL2PS_NO_OPENGL_CONTEXT | GL2PS_NO_BLENDING; |
| 87 | // Print warning if the user requested no background -- we always draw it. |
| 88 | if ((options & GL2PS_DRAW_BACKGROUND) == GL2PS_NONE) |
| 89 | { |
| 90 | vtkWarningMacro("Ignoring DrawBackground=false setting. The background is " |
| 91 | "always drawn on the OpenGL2 backend for GL2PS exports."); |
| 92 | } |
| 93 | // Turn the option off -- we don't want GL2PS drawing the background, it |
| 94 | // comes from the raster image we draw in the image. |
| 95 | options &= ~GL2PS_DRAW_BACKGROUND; |
nothing calls this directly
no test coverage detected