#ifndef __DEFAULT_PROJECTOR_DATA_H__ #define __DEFAULT_PROJECTOR_DATA_H__ // Includes Projection Designer headers #include /** * Implementation of the DefaultProjectorWidget class. * * This class is where the projector is really implemented. Attributes are the * frustum parameters. Methods allow you to draw the frustum either *from* the * frustum as from a different point of view, in order to *see* the frustum. * */ class DefaultPluginData: public ProjectorData { public: /** * Default constructor fot the DefaultPluginData. * */ DefaultPluginData (ProjectorInterface* plugin, float fov=30.f, float aspectRatio=4.f/3.f, float near=0.1f, float far=100.f, float offaxisX=0.f, float offaxisY=0.f); /** * Copy constructor fot the DefaultPluginData. * */ DefaultPluginData (const DefaultPluginData& data): ProjectorData(data) {copy_from(data);} /** * Destructor fot the DefaultPluginData. * */ ~DefaultPluginData (); /** * Implements the copy from other datas. * * This method is used by the copy constructor. * * @param data The source data. * * @return true if the copy is ok, false otherwise. The copy can fail if * ProjectorData is not a DefaultPluginData. * * @seealso is_equal_to * */ bool copy_from(const ProjectorData& data); /** * Implements the egality-test with other datas. * * This could be an operator==. * * @param data The data to test with. * * @return true if the data are equal, false otherwise. The test can fail if * the data have different parameters, but also it ProjectorData is * not a DefaultPluginData. * * @seealso copy_from * */ bool is_equal_to(const ProjectorData& data) const; /** * Draws the frustum (a truncated pyramid). * * This method draws the frustum from outside. If the frustum is selected, * the lines are a little bigger. * * @param bSelected true if the frustum is selected. * */ void draw(bool bSelected); /** * Begins the draw through the frustum. * * The draw must end with a endDraw(). * * This is the same than glFrustum(), with some glPush...() before. * * @seealso endDraw * */ void beginDraw(void); /** * Ends the draw through the frustum. * * Must be used each time a draw through the projector has begun with a * beginDraw(). * * This is the same than some glPop...(). * * @seealso beginDraw * */ void endDraw(void); /** * Begins the projection. * * The projection must end with a endProjection(). * * This is the same than glFrustum(), without anything else. * beginDraw and beginProjection are quite close and it is perhaps to merge * them, but for the moment, to respect the Projection Designer * implementation, it will be let like this. * * endProjection is not implemented here because it does nothing more than * the ProjectorData::endProjection(). * */ void beginProjection(void); /** * Sets the field of view. * * @param fov The new field of view. * */ void setFov(float fov) {m_fov=fov;} /** * Gets the field of view. * * @return The field of view of the projector. * */ float fov() const {return m_fov;} /** * Sets the aspect ratio. * * @param aspectRatio The new aspect ratio. * */ void setAspectRatio(float aspectRatio) {m_aspectRatio=aspectRatio;} /** * Gets the aspect ratio. * * @return The aspect ratio of the projector. * */ float aspectRatio() const {return m_aspectRatio;} /** * Sets the near distance of the frustum. * * @param nearDist The new near distance of the frustum. * */ void setNearDist(float nearDist) {m_nearDist=nearDist;} /** * Gets the near distance of the frustum. * * @return The near distance of the frustum. * */ float nearDist() const {return m_nearDist;} /** * Sets the far distance of the frustum. * * @param farDist The new far distance of the frustum. * */ void setFarDist(float farDist) {m_farDist=farDist;} /** * Gets the far distance of the frustum. * * @return The far distance of the frustum. * */ float farDist() const {return m_farDist;} /** * Sets the off-axis X of the frustum. * * @param offaxisX The new off-axis X of the frustum. * */ void setOffaxisX(float offaxisX) {m_offaxisX=offaxisX;} /** * Gets the off-axis X of the frustum. * * @return The off-axis X of the frustum. * */ float offaxisX() const {return m_offaxisX;} /** * Sets the off-axis Y of the frustum. * * @param offaxisY The new off-axis Y of the frustum. * */ void setOffaxisY(float offaxisY) {m_offaxisY=offaxisY;} /** * Gets the off-axis Y of the frustum. * * @return The off-axis Y of the frustum. * */ float offaxisY() const {return m_offaxisY;} /** * Sets the visible distance of the frustum. * * @param visibleFar The new visible distance of the frustum. * */ void setVisibleFar(float visibleFar) {m_visibleFar=visibleFar;} /** * Gets the visible distance of the frustum. * * @return The visible distance of the frustum. * */ float visibleFar() const {return m_visibleFar;} /** * Loads the frustum from a QDomElement. * * @param element The QDomElement to read from. * */ void initFromDOMElement(const QDomElement& element); /** * Writes the frustum in a QDomDocument. * * @param name The name of the element. * @param doc The document whom belongs the element. * * @return The QDomElement to add. * */ QDomElement domElement(const QString& name, QDomDocument& doc) const; /** * Gets the name of projector type, stored in g_projector_name. * * @return The name of projector type, stored in g_projector_name. * */ const QString& projector(void) const {return g_projector_name;} /// Public static const projector name. static const QString g_projector_name; private: /// Field of view of the frustum. float m_fov; /// Aspect ratio of the frustum. float m_aspectRatio; /// Near distance of the frustum. float m_nearDist; /// Far distance of the frustum. float m_farDist; /// Off-axis X of the frustum. float m_offaxisX; /// Off-axis Y of the frustum. float m_offaxisY; /// Visible far of the frustum. float m_visibleFar; }; #endif // __DEFAULT_PROJECTOR_DATA_H__