source: projectionDesigner/trunk/projdesigner/include/Scene.h @ 373

Last change on this file since 373 was 4, checked in by Torben Dannhauer, 15 years ago
File size: 6.6 KB
Line 
1#ifndef _SCENE_H_
2#define _SCENE_H_
3
4#pragma warning(disable: 4003)
5#include "gmtl/gmtl.h"
6#include "math/TransformMatrix.h"
7
8#include "interfaces.h"
9
10namespace projection
11{
12class ProjectionModel;
13
14/**
15 * Scene class.
16 */
17class Scene : public QObject
18{
19    Q_OBJECT
20
21public:
22
23    /**
24     * Constructor.
25     *
26     * @param pModel Projection model.
27     */
28    Scene(ProjectionModel* pModel);
29
30    /**
31     * Destructor.
32     */
33    virtual ~Scene();
34
35    /**
36     * Retrieve Projection model.
37     *
38     * @return Projection model.
39     */
40    ProjectionModel* getModel() const;
41
42    /**
43     * Retrieve name of the scene content.
44     *
45     * @param index Index of the scene content.
46     * @return Name of the scene content.
47     */
48    QString getContentName(int index) const;
49
50    /**
51     * Retrieve the number of the scene content.
52     *
53     * @return Number of the scene content.
54     */
55    unsigned int getNumContents() const;
56
57    /**
58     * Retrieve scene content object.
59     *
60     * @param shapeName Name of the scene content object.
61     * @return Scene content object.
62     */
63    SceneContent* getContent(const QString& contentName) const;
64
65    /**
66     * Select scene content by name.
67     *
68     * @param contentName Name of the scene content to select.
69     */
70    void setCurrentContent(const QString& contentName);
71
72    /**
73     * Retrieve the name of the current scene content.
74     *
75     * @return Name of the current scene content.
76     */
77    QString getCurrentContentName() const;
78
79    /**
80     * Retrieve current scene content object.
81     *
82     * @return Current scene content object.
83     */
84    SceneContent* getCurrentContent() const;
85
86    /**
87     * Retrieve viewpoint center of the scene viewer.
88     *
89     * @return Viewpoint center.
90     */
91    gmtl::Vec3f getCameraCenter() const { return m_cameraCenter; }
92
93    /**
94     * Retrieve viewpoint rotation of the scene viewer.
95     *
96     * @return Viewpoint rotation.
97     */
98    gmtl::Quatf getCameraRotation() const { return m_cameraRot; }
99
100    /**
101     * Retrieve viewpoint distance of the scene viewer.
102     *
103     * @return Viewpoint distance from trackball center.
104     */
105    float getCameraDistance() const { return m_cameraDistance; }
106
107    /**
108     * Retrieve viewpoint matrix of the scene viewer.
109     *
110     * @return Viewpoint matrix.
111     */
112    gmtl::Matrix44f getCameraMatrix() const;
113
114    /**
115     * Put the camera at the center of the scene.
116     */
117    void centerView();
118
119    /**
120     * Set camera to view all the scene.
121     */
122    void viewAll();
123
124    /**
125     * Set transform matrix of the scene.
126     *
127     * @param matrix Transform matrix of the scene.
128     */
129    void setMatrix(const TransformMatrix& matrix);
130
131    /**
132     * Retrieve transform matrix of the scene.
133     *
134     * @param Transform matrix of the scene.
135     */
136    const TransformMatrix& getMatrix() const { return m_transformMatrix; }
137
138    /**
139     * Draw the scene content.
140     */
141    void draw();
142
143    /**
144     * Show or hide the scene content in design view.
145     *
146     * @param bShowInDesignView True to show the scene content in design view.
147     */
148    void setShowInDesignView(bool bShowInDesignView);
149
150    /**
151     * Check whether the scene content is shown in design view.
152     *
153     * @return True if the scene content is shown in design view.
154     */
155    bool getShowInDesignView() { return m_bShowInDesignView; }
156
157    /**
158     * Set size of the scene for SceneViewer.
159     *
160     * @param size Size of the scene.
161     */
162    void setSize(float size);
163
164    /**
165     * Retrieve size of the scene.
166     *
167     * @return Size of the scene.
168     */
169    float getSize() const;
170
171    /**
172     * Show or hide a grid frame with the scene content.
173     *
174     * @param bShowGrid True to show a grid frame, false to hide.
175     */
176    void setShowGrid(bool bShowGrid);
177
178    /**
179     * Check whether the grid frame is shown or not.
180     *
181     * @return True if the grid frame is shown.
182     */
183    bool getShowGrid() { return m_bShowGrid; }
184
185    /**
186     * Set size of the grid frame.
187     *
188     * @param gridSize Size of the grid frame.
189     */
190    void setGridSize(float gridSize);
191
192    /**
193     * Retrieve the size of the grid frame.
194     *
195     * @return Size of the grid frame.
196     */
197    float getGridSize() { return m_gridSize; }
198
199    /**
200     * Notify to redraw the screen.
201     */
202    void notifyRedraw();
203
204    /**
205     * Restore the scene content from XML data.
206     *
207     * @param element Parent XML element of the scene content data.
208     */
209    bool initFromDOMElement(const QDomElement& element);
210
211    /**
212     * Store the current scene content as XML data.
213     *
214     * @param name XML node name of the data.
215     * @param doc XML document to store the data.
216     * @return Current scene content data as XML data.
217     */
218    QDomElement domElement(const QString& name, QDomDocument& doc) const;
219
220        /**
221         * Reset the scene.
222         */
223        void reset();
224
225public slots:
226
227    /**
228     * Set viewpoint of the scene viewer.
229     *
230     * @param data Viewpoint as XML data.
231     */
232    void setCameraViewpoint(const QString& data);
233
234    /**
235     * Set viewpoint of the scene viewer.
236     *
237     * @param distance Viewpoint rotation.
238     * @param distance Viewpoint center.
239     * @param distance Viewpoint distance from trackball center.
240     */
241    void setCameraViewpoint(const gmtl::Vec3f& center, const gmtl::Quatf& rot, float distance);
242
243    /**
244     * Update the scene content.
245     *
246     * @param content Scene content from the widget.
247     */
248        void updateSceneContent(const SceneContent& content);
249
250protected:
251
252    TransformMatrix m_transformMatrix;  //!< Transform matrix of the scene.
253    gmtl::Vec3f m_cameraCenter;         //!< View point center.
254    gmtl::Quatf m_cameraRot;            //!< View point rotation.
255    float m_cameraDistance;             //!< View point distance from trackball center.
256    bool m_bShowInDesignView;           //!< True if the scene content is shown in design view.
257    float m_size;                       //!< Size of the scene.
258    bool m_bShowGrid;                   //!< True if the grid frame is shown.
259    float m_gridSize;                   //!< Size of the grid frame.
260
261        QList<SceneContent*> m_pContents;   //!< Scene content objects.
262    SceneContent* m_pCurrentContent;    //!< Current scene content object.
263
264    ProjectionModel* m_pModel;          //!< Projection model.
265};
266
267}; // projection
268
269#endif // _SCENE_H_
Note: See TracBrowser for help on using the repository browser.