# Hurricane Design Viewer

Public Member Functions | List of all members
Hurricane::CellPrinter Class Reference

Widget to generate PDF file. More...

Inherits QMainWindow.

## Public Member Functions
| CellPrinter (QWidget *parent=NULL)
virtual | ~CellPrinter ()
void | setScreenCellWidget (CellWidget *)
void | setMode (int mode)
void | toPdf (QPrinter *, bool imageOnly=false)

## Detailed Description

Widget to generate PDF file.

# Basic Usage

CellPrinter is a simple Qt Widget to write the contents of a CellWidget into a QPrinter. As it may uses lots of memory (due to the high-res bitmaps) it is advisable to delete it immediatly after usage. The same rendering engine is used to both display on screen and onto the printer so it is a "What You See Is What You Get" mode (except for the higher resolution). It optionaly adds a frame and a cartouche (on by default).

See also
  CellImage.

It's use is straigtforward, as shown in the example below. It consist of four steps:

1. Widget allocation.
2. Bind to a screen CellWidget (CellPrinter::setScreenCellWidget()).
3. Draw into a QPrinter (CellPrinter::toPdf()).
4. Delete the widget.

Code example (took from CellViewer):

void CellViewer::printDisplay ()
{
if (_cellWidget == NULL) return;
if (_cellWidget->getCell() == NULL) {
cerr << Warning("Unable to print, no cell loaded yet.") << endl;
return;
}
QPrinter printer( QPrinter::ScreenResolution );
printer.setPaperSize
( (QPrinter::PaperSize)Cfg::getParamEnumerate("viewer.printer.paper",0)->asInt() );
printer.setOutputFileName ( "unicorn-snapshot.pdf" );
QPrintDialog dialog ( &printer );
if ( dialog.exec() == QDialog::Accepted ) {
CellPrinter* cellPrinter = new CellPrinter();
cellPrinter->setScreenCellWidget( _cellWidget );
cellPrinter->toPdf ( &printer, false );
delete cellPrinter;
}
}

Remark: The generated PDF file are bitmaps, so they can grew very large if
  you uses paper above A2...

# Configuration Variables

The CellPrinter reads the following configuration variables for it's defaults settings (they are located in `misc.conf`, for the system-wide settings).

- `"viewer.printer.mode"`, select between the two resolution modes (Cell or Design).
- `"viewer.printer.paper"`, the output paper size, should be one value from the QPrinter::PaperSize enumeration.

# Implementation details

This widget is build as a QMainWindow (top-level) one encapsulating only a CellWidget. It is configured to never been shown thanks to the `Qt::WA_DontShowOnScreen` attribute, but all the display computations still takes place as if it actually was.

To obtain a sufficent resolution the CellPrinter/CellWidget are resized to the resolution of the printed page. For a better look select a display style with patterns of 32x32 pixels, such as `"Printer.Coriolis"`.

## Constructor & Destructor Documentation

## ◆ CellPrinter()

Hurricane::CellPrinter::CellPrinter | ( | QWidget * | parent = `NULL` | ) |

Construct a CellPrinter window no screen CellWidget is actually bound.

## ◆ ~CellPrinter()

Hurricane::CellPrinter::~CellPrinter | ( |  | ) |
| virtual

Destructor.

## Member Function Documentation

## ◆ setScreenCellWidget()

void Hurricane::CellPrinter::setScreenCellWidget | ( | CellWidget * | screenCellWidget | ) |

Bind the CellPrinter to the screen CellWidget `screenCellWidget`. It is those contents that will be printed.

## ◆ setMode()

void Hurricane::CellPrinter::setMode | ( | int | mode | ) |
| inline

Sets the display mode, that is the resolution that will be used. Two modes are availables:

- CellWidget::Res_CellMode: (approx. 150 dpi), best suited for displaying lone Cell or very small scale designs.
- CellWidget::Res_DesignMode: (approx. 300 dpi), for full fledged designs.

## ◆ toPdf()

void Hurricane::CellPrinter::toPdf | ( | QPrinter * | printer,
|  | bool | imageOnly = `false`
| ) |  |

Parameters

  printer | The QPrinter to draw into.
  imageOnly | Whether to add the frame & cartouche or not.

Perform the drawing operation on the QPrinter.

The documentation for this class was generated from the following files:

- CellPrinter.h
- CellPrinter.dox

Generated by doxygen 1.8.14 on Sun Mar 8 2020 | Return to top of page

Hurricane Design Viewer | Copyright © 2008-2016 UPMC All rights reserved