// -*- mode:c++ -*- #ifndef _CHANNEL_H_ #define _CHANNEL_H_ #include #include #include "interfaces.h" #include "Frustum.h" #include "Screen.h" class QGLPixelBuffer; namespace projection { class ProjectionModel; class Warp; //! Channel draw mode enum CHANNEL_DRAWMODE { CHANNEL_DRAWMODE_DESIGN_DISTORTIONMAP, //!< Draw distortion map for designing. CHANNEL_DRAWMODE_EXPORT_DISTORTIONMAP, //!< Draw distortion map for exporting. CHANNEL_DRAWMODE_DESIGN_BLENDMAP, //!< Draw blend map for designing. CHANNEL_DRAWMODE_EXPORT_BLENDMAP //!< Draw blend map for exporting. }; /** * Channel class. It contains projector and view data. */ class Channel : public QObject { Q_OBJECT public: /** * Constructor. * * @param pModel Projection model. */ Channel(ProjectionModel* pModel); /** * Destructor. */ virtual ~Channel(); /** * Render the scene to a texture. */ void renderSceneToViewBuffer(); /** * Render the screen viewing from the projector. */ void draw(CHANNEL_DRAWMODE drawMode); /** * Draw projector and view frustum shape objects. * * @param bSelected True to draw with selection highlight. */ void drawFrustums(bool bSelected=false); /** * Set channel name. * * @param name Name of the channel. */ void setName(const QString& name); /** * Retrieve name of the channel. */ QString getName() const; /** * Show or hide the name of the channel in the projector view. * * @param bShow True to show the name of the channel, false to hide. */ void setOverlayName(bool bShow); /** * Check whether the name of the channel is shown or not. * * @return True if the name of the channel. */ bool getOverlayName() const; /** * Set host name of the remote host PC to show this channel. * * @param hostName Host name of the remote host PC. */ void setRemoteHostName(const QString& hostName); /** * Retrieve host name of the remote host PC to show this channel. * * @return Host name of the remote host PC. */ QString getRemoteHostName() const; /** * Enable or disable the full-screen mode at remote host PC. * * @param bFullScreen True to display this channel in full-screen mode at remote host PC. */ void setRemoteFullScreen(bool bFullScreen); /** * Check whether this channel is full-screen or not at remote host PC. * * @return True to display this channel in full-screen mode at remote host PC. */ bool getRemoteFullScreen() const; /** * Screen index for multi-monitor remote host PC. * * @param screenIndex Screen index to display this channel. */ void setRemoteScreen(int screenIndex); /** * Retrieve screen index for multi-monitor remote host PC. * * @return Screen index to display this channel. */ int getRemoteScreen() const; /** * Set file name of image to overlay in the projection window. * * @param fileName File name to overlay in the projection window */ void setOverlayImageFileName(const QString& fileName); /** * Retrieve file name of image to overlay in the projection window. * * @return File name to overlay in the projection window */ QString getOverlayImageFileName() const; /** * Retrieve projector frustum object. * * @return Projector frustum object. */ ProjectorData* getProjector(); /** * Retrieve view frustum object. * * @return View frustum object. */ Frustum* getView(); void setProjector(ProjectorInterface *projector_interface=NULL, const QString& projector_name=""); void setProjector(const QString& projector_fullname); /** * Show or hide the projected scene in DesignView. * * @param bShow True to display the projected scene in DesignView. */ void setShowProjectedScene(bool bShow); /** * Check whether the projected scene is shown in DesignView. * * @return True if the projected scene is shown in DesignView. */ bool getShowProjectedScene() const; /** * Show projector window of this channel. */ void showProjectorWindow(); /** * Fit the view frustum to projection area on the screen surface. * * @return True if successfully fitted. */ bool fitView(); /** * Retrieve the rendered view texture object ID. * * @return Rendered view texture object ID. */ unsigned int getViewTexture(); /** * Reconstruct the off-screen buffer. */ void reconstructBuffer(); /** * Retrieve distortion warp class instance. * * @return Distortion warp class instance. */ Warp* getDistWarp() const; /** * Retrieve blending warp class instance. * * @return Blending warp class instance. */ Warp* getBlendWarp() const; /** * Retrieve the current (distortion / blending) warp class instance. * * @return Current (distortion / blending) warp class instance. */ Warp* getCurrentWarp() const; /** * Enable or disable distortion warping. * * @param bEnabled True to enable the distortion warping, false to disable. */ void setDistWarpEnabled(bool bEnabled); /** * Check whether the distortion warping is enabled or not. * * @return True if the distortion warping is enabled. */ bool getDistWarpEnabled() const; /** * Discard the off-screen buffer object for warping. */ void clearWarpBuffer(); /** * Set blending factor of the specified channel for exporting a blend map. * * @param name Name of channel to set blending factor. * @param factor Blending factor (0.0-1.0). */ void setBlendFactor(const QString& name, float factor); /** * Retrieve the blending factor of the specified channel. * * @param name Name of channel to retrieve the blending factor. * @return Blending factor of the specified channel. */ float getBlendFactor(const QString& name) const; /** * Export projection settings to file. * * @param fileName File name of the projection settings to save. * @return True if successfully exported. */ bool exportDataset(const QString& fileName); /** * Assignment operator. * * @param chan Assignment source channel. */ Channel& operator=(const Channel& chan); void setProjectorTransformMatrix(const TransformMatrix& matrix); TransformMatrix& getProjectorTransformMatrix(void); // <-- not const because of TransformMatrix::getMatrix() that should be const! void setViewProjectionMatrix(const ProjectionMatrix& matrix); void setViewTransformMatrix(const TransformMatrix& matrix); /** * Restore the channel data from XML data. * * @param element Parent XML element of the channel data. */ bool initFromDOMElement(const QDomElement& element, const QString& version); /** * Store the current channel data as XML data. * * @param name XML node name of the data. * @param doc XML document to store the data. * @return Current channel data as XML data. */ QDomElement domElement(const QString& name, QDomDocument& doc) const; public slots: /** * Called when channel, projector or view frustum is changed. * Always render the scene to the off-screen buffer... */ void updateData(); void updatePluginData(const ProjectorData& data); private: /** * Retrieve (or create if not exist) off-screen buffer object for warping. * * @return Off-screen buffer object for warping. */ QGLPixelBuffer* getWarpBuffer(); /** * Replace pre-defined keyword in file name pattern. * * @param pattern File name pattern. * @return File name pattern whose keywords replaced. */ QString replaceKeywordInFileName(const QString& pattern); private: QString m_name; //!< Channel name. bool m_bOverlayName; //!< True to show the channel name. QString m_overlayImageFileName; //!< File name of image to overlay in the projection window. GLuint m_overlayImageTexIndex; //!< Texture object index of the image to overlay in the projection window. int m_overlayImageWidth; //!< Width of image to overlay in the projection window. int m_overlayImageHeight; //!< Height of image to overlay in the projection window. bool m_bShowProjectedScene; //!< True to display the projected scene in DesignView. QString m_remoteHostName; //!< Remote host name to display this channel. bool m_bRemoteFullScreen; //!< True to display this channel in full-screen mode at remote host PC. int m_remoteScreen; //!< Screen index for multi-monitor remote host PC. Frustum m_projector; //!< Projector settings. Frustum m_view; //!< View settings. QGLPixelBuffer* m_pWarpBuffer; //!< Off-screen buffer for distortion map warping. unsigned int m_warpTextureID; //!< Distortion warping texture object index. Warp* m_pDistWarp; //!< Distortion map warping. bool m_bDistWarpEnabled; //!< True to enable the distortion map warping. Warp* m_pBlendWarp; //!< Blend map warping. QMap m_blendFactors; //!< Blend factors for exporting a blend map. QGLPixelBuffer* m_pSceneBuffer; //!< Off-screen buffer for rendering the scene. unsigned int m_sceneTextureID; //!< Scene rendered texture object index. ProjectionModel* m_pModel; //!< Projection model. TransformMatrix m_projectorTransformMatrix; //!< Transform matrix of the frustum. ProjectorData *m_projectorData; }; }; #endif // _CHANNEL_H_