# Hurricane Design Viewer

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

Widget to generate Image files. More...

Inherits QMainWindow.

## Public Types
enum | Flags { ShowScale =0x0001 }

## Public Member Functions
| CellImage (QWidget *parent=NULL)
virtual | ~CellImage ()
void | setScreenCellWidget (CellWidget *)
void | setMode (int mode)
QImage * | toImage (unsigned int flags=0)

## Detailed Description

Widget to generate Image files.

# Basic Usage

CellImage is a simple Qt Widget to write the contents of a CellWidget into a QImage. 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 image so it is a "What You See Is What You Get" mode (except for the higher resolution).

See also
  CellPrinter.

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

1. Widget allocation.
2. Bind to a screen CellWidget (CellImage::setScreenCellWidget()).
3. Draw into a QImage (CellImage::toImage()).
4. Delete the widget.
5. Save the QImage or do whatever you want with it.
6. Delete the QImage.

Code example (took from CellViewer):

void CellViewer::imageDisplay ()
{
if (_cellWidget == NULL) return;
if (_cellWidget->getCell() == NULL) {
cerr << Warning("Unable to save to image, no cell loaded yet.") << endl;
return;
}
CellImage* cellImage = new CellImage();
cellImage->setScreenCellWidget( _cellWidget );
QImage* image = cellImage->toImage(0);
delete cellImage;
char workingDirectory [1024];
getcwd ( workingDirectory, 1024 );
QString filePath = QFileDialog::getSaveFileName ( this
, tr("Save Image as ...")
, workingDirectory
, tr("Image (*.png)")
);
image->save ( filePath, "png" );
delete image;
}

# Configuration Variables

The CellImage 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).

# 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.

The CellImage returns a newly allocated QImage, it is the responsability of the caller to delete it after usage.

To obtain a sufficent resolution the CellImage/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 `"Image.Coriolis"`.

## Member Enumeration Documentation

## ◆ Flags

enum Hurricane::CellImage::Flags

Some flags to tweak the image display.

Enumerator
ShowScale | Adds a false color scale at the bottom of the image. Useful if you draw a density map for instance.

## Constructor & Destructor Documentation

## ◆ CellImage()

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

Construct a CellImage window no screen CellWidget is actually bound.

## ◆ ~CellImage()

Hurricane::CellImage::~CellImage | ( |  | ) |
| virtual

Destructor.

## Member Function Documentation

## ◆ setScreenCellWidget()

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

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

## ◆ setMode()

void Hurricane::CellImage::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.

## ◆ toImage()

QImage * Hurricane::CellImage::toImage | ( | unsigned int | flags = `0` | ) |

Parameters

  flags | Control some tweaks.

Returns
  A newly allocated QImage displaying the contents of the bound `screenCellWidget`. The deletion of the QImage is left to caller.

Availables flags:

- ShowScale: display a false color scale at the bottom of the image. Useful if you draw a density map for instance.

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

- CellImage.h
- CellImage.dox

Generated by doxygen 1.8.14 on Tue Jul 21 2020 | Return to top of page

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