#ifndef _SCENE_H_ #define _SCENE_H_ #pragma warning(disable: 4003) #include "gmtl/gmtl.h" #include "math/TransformMatrix.h" #include "interfaces.h" namespace projection { class ProjectionModel; /** * Scene class. */ class Scene : public QObject { Q_OBJECT public: /** * Constructor. * * @param pModel Projection model. */ Scene(ProjectionModel* pModel); /** * Destructor. */ virtual ~Scene(); /** * Retrieve Projection model. * * @return Projection model. */ ProjectionModel* getModel() const; /** * Retrieve name of the scene content. * * @param index Index of the scene content. * @return Name of the scene content. */ QString getContentName(int index) const; /** * Retrieve the number of the scene content. * * @return Number of the scene content. */ unsigned int getNumContents() const; /** * Retrieve scene content object. * * @param shapeName Name of the scene content object. * @return Scene content object. */ SceneContent* getContent(const QString& contentName) const; /** * Select scene content by name. * * @param contentName Name of the scene content to select. */ void setCurrentContent(const QString& contentName); /** * Retrieve the name of the current scene content. * * @return Name of the current scene content. */ QString getCurrentContentName() const; /** * Retrieve current scene content object. * * @return Current scene content object. */ SceneContent* getCurrentContent() const; /** * Retrieve viewpoint center of the scene viewer. * * @return Viewpoint center. */ gmtl::Vec3f getCameraCenter() const { return m_cameraCenter; } /** * Retrieve viewpoint rotation of the scene viewer. * * @return Viewpoint rotation. */ gmtl::Quatf getCameraRotation() const { return m_cameraRot; } /** * Retrieve viewpoint distance of the scene viewer. * * @return Viewpoint distance from trackball center. */ float getCameraDistance() const { return m_cameraDistance; } /** * Retrieve viewpoint matrix of the scene viewer. * * @return Viewpoint matrix. */ gmtl::Matrix44f getCameraMatrix() const; /** * Put the camera at the center of the scene. */ void centerView(); /** * Set camera to view all the scene. */ void viewAll(); /** * Set transform matrix of the scene. * * @param matrix Transform matrix of the scene. */ void setMatrix(const TransformMatrix& matrix); /** * Retrieve transform matrix of the scene. * * @param Transform matrix of the scene. */ const TransformMatrix& getMatrix() const { return m_transformMatrix; } /** * Draw the scene content. */ void draw(); /** * Show or hide the scene content in design view. * * @param bShowInDesignView True to show the scene content in design view. */ void setShowInDesignView(bool bShowInDesignView); /** * Check whether the scene content is shown in design view. * * @return True if the scene content is shown in design view. */ bool getShowInDesignView() { return m_bShowInDesignView; } /** * Set size of the scene for SceneViewer. * * @param size Size of the scene. */ void setSize(float size); /** * Retrieve size of the scene. * * @return Size of the scene. */ float getSize() const; /** * Show or hide a grid frame with the scene content. * * @param bShowGrid True to show a grid frame, false to hide. */ void setShowGrid(bool bShowGrid); /** * Check whether the grid frame is shown or not. * * @return True if the grid frame is shown. */ bool getShowGrid() { return m_bShowGrid; } /** * Set size of the grid frame. * * @param gridSize Size of the grid frame. */ void setGridSize(float gridSize); /** * Retrieve the size of the grid frame. * * @return Size of the grid frame. */ float getGridSize() { return m_gridSize; } /** * Notify to redraw the screen. */ void notifyRedraw(); /** * Restore the scene content from XML data. * * @param element Parent XML element of the scene content data. */ bool initFromDOMElement(const QDomElement& element); /** * Store the current scene content as XML data. * * @param name XML node name of the data. * @param doc XML document to store the data. * @return Current scene content data as XML data. */ QDomElement domElement(const QString& name, QDomDocument& doc) const; /** * Reset the scene. */ void reset(); public slots: /** * Set viewpoint of the scene viewer. * * @param data Viewpoint as XML data. */ void setCameraViewpoint(const QString& data); /** * Set viewpoint of the scene viewer. * * @param distance Viewpoint rotation. * @param distance Viewpoint center. * @param distance Viewpoint distance from trackball center. */ void setCameraViewpoint(const gmtl::Vec3f& center, const gmtl::Quatf& rot, float distance); /** * Update the scene content. * * @param content Scene content from the widget. */ void updateSceneContent(const SceneContent& content); protected: TransformMatrix m_transformMatrix; //!< Transform matrix of the scene. gmtl::Vec3f m_cameraCenter; //!< View point center. gmtl::Quatf m_cameraRot; //!< View point rotation. float m_cameraDistance; //!< View point distance from trackball center. bool m_bShowInDesignView; //!< True if the scene content is shown in design view. float m_size; //!< Size of the scene. bool m_bShowGrid; //!< True if the grid frame is shown. float m_gridSize; //!< Size of the grid frame. QList m_pContents; //!< Scene content objects. SceneContent* m_pCurrentContent; //!< Current scene content object. ProjectionModel* m_pModel; //!< Projection model. }; }; // projection #endif // _SCENE_H_