ImageHandler.h

Go to the documentation of this file.
00001 /*
00002  * The information in this file is
00003  * Copyright(c) 2007 Ball Aerospace & Technologies Corporation
00004  * and is subject to the terms and conditions of the
00005  * GNU Lesser General Public License Version 2.1
00006  * The license text is available from   
00007  * http://www.gnu.org/licenses/lgpl.html
00008  */
00009 
00010 #ifndef IMAGEHANDLER_H
00011 #define IMAGEHANDLER_H
00012 
00013 #include "MuHttpServer.h"
00014 
00015 class QBuffer;
00016 class QString;
00017 class SessionItem;
00018 
00019 /**
00020  * Publish view and layer images via HTTP
00021  */
00022 class ImageHandler : public MuHttpServer
00023 {
00024    Q_OBJECT
00025 
00026 public:
00027    /**
00028     * Construct a new ImageHandler.
00029     *
00030     * @param pParent
00031     *        Qt parent object
00032     */
00033    ImageHandler(QObject *pParent = NULL);
00034 
00035    /**
00036     * Construct a new ImageHandler.
00037     *
00038     * @param port
00039     *        TCP port where the server should listen. If this is 0, a server will
00040     *        not be started. This is used to add the ImageHandler to an existing
00041     *        server using MuHttpServer::registerPath().
00042     * @param pParent
00043     *        Qt parent object
00044     */
00045    ImageHandler(int port, QObject *pParent = NULL);
00046 
00047    /**
00048     * Destructor
00049     */
00050    ~ImageHandler();
00051 
00052    /**
00053     * Retrieve an image for a SessionItem and place the result in a buffer.
00054     *
00055     * @param pItem
00056     *        The SessionItem whose image is to be retrieved. Currently, this must be a:
00057     *            SpatialDataView or a Layer
00058     * @param buffer
00059     *        A sufficiently large buffer which will hold the resultant image.
00060     * @param format
00061     *        The format of the image data. This is anything which corresponds to
00062     *        a loaded Qt image format plugin. Common examples are: JPEG, PNG, TIFF, or BMP
00063     * @param band
00064     *        If pItem is a RasterLayer, change to this active band before grabbing the image.
00065     *        If pItem is not a RasterLayer or band is negative, this is ignored.
00066     * @param pBbox
00067     *        If this is not NULL, the bounding box as returned by SpatialDataView::getLayerImage() will be returned in this out param.
00068     * @return True if the image was successfully generated, false otherwise.
00069     */
00070    static bool getSessionItemImage(SessionItem *pItem, QBuffer &buffer, const QString &format, int band, int* pBbox = NULL);
00071 
00072 protected:
00073    /**
00074     * @copydoc MuHttpServer::getRequest()
00075     *
00076     * This method serves view and layer images. The request URL should be
00077     * the SessionItem ID of the view or layer. The file extension represents
00078     * the format of the image generated. Any image format supported by the current
00079     * build of Qt is supported. This requires at least PNG support. If no extension
00080     * is specified, PNG is assumed.
00081     */
00082    MuHttpServer::Response getRequest(const QString &uri, const QString &contentType, const QString &body,
00083       const FormValueMap &form);
00084 
00085 private:
00086    ImageHandler(const ImageHandler& rhs);
00087    ImageHandler& operator=(const ImageHandler& rhs);
00088 };
00089 
00090 #endif

Software Development Kit - Opticks 4.9.0 Build 16218