// -*- C++ -*- namespace Hurricane { /*! \class CellImage * \brief Widget to generate Image files. * * * \section secImageBasicUsage 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 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): \code 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; } \endcode * * * \section secImageConfiguration Configuration Variables * * The CellImage reads the following configuration variables for * it's defaults settings (they are located in \c misc.conf, for * the system-wide settings). * * * * \section secImageImplDetails 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 \c 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 * \c "Image.Coriolis". */ /*! \function CellImage::CellImage(QWidget* parent=NULL); * Construct a CellImage window no screen CellWidget is actually bound. */ /*! \function CellImage::~CellImage(); * Destructor. */ /*! \function void CellImage::setScreenCellWidget(CellWidget* screenCellWidget); * Bind the CellImage to the screen CellWidget \c screenCellWidget. * It is those contents that will be printed. */ /*! \function void CellImage::setMode(int mode); * Sets the display mode, that is the resolution that will be used. * Two modes are availables: * */ /*! \function QImage* CellImage::toImage(unsigned int flags=0); * \param flags Control some tweaks. * * \return A newly allocated QImage displaying the contents of the bound * \c screenCellWidget. The deletion of the QImage is left to caller. * * Availables flags: * */ /*! \enum CellImage::Flags * Some flags to tweak the image display. */ /*! \var CellImage::Flags CellImage::ShowScale; * Adds a false color scale at the bottom of the image. * Useful if you draw a density map for instance. */ }