source: projectionDesigner/trunk/projdesignerplugins/defaultplugin/DefaultTeapotSceneContent.h @ 373

Last change on this file since 373 was 4, checked in by Torben Dannhauer, 15 years ago
File size: 4.2 KB
Line 
1#ifndef __DEFAULT_TEAPOT_SCENE_CONTENT_H__
2#define __DEFAULT_TEAPOT_SCENE_CONTENT_H__
3
4// Includes system headers
5#include <stdlib.h>
6#include <GL/glut.h>
7
8// Includes Projection Designer headers
9#include <projdesigner/include/interfaces.h>
10
11
12/**
13 * This class implements the contents of the teapot scene of the default plugin.
14 *
15 * The teapot is a basic scene content. It only has 2 parameters, which are the
16 * flag that determine if the teapot will be drawn using solid or wireframe
17 * representation, and the width of the lines for the wireframe representation.
18 *
19 */
20class DefaultTeapotSceneContent: public SceneContent
21{
22
23public:
24
25
26    /**
27     * Default constructor
28     *
29     */
30    DefaultTeapotSceneContent (SceneInterface* plugin);
31
32
33    /**
34     * Copy constructor.
35     *
36     * Uses copy_from() to make the copy.
37     *
38     */
39    DefaultTeapotSceneContent (const DefaultTeapotSceneContent& data): SceneContent(data) {copy_from(data);}
40
41
42    /**
43     * Destructor.
44     *
45     */
46    ~DefaultTeapotSceneContent ();
47
48
49    /**
50     * Implements the copy from other contents.
51     *
52     * This method is used by the copy constructor.
53     *
54     * @param content The source content to copy from.
55     *
56     * @return true if the copy is ok, false otherwise. The copy can fail if
57     *         SceneContent is not a DefaultTeapotSceneContent.
58     *
59     * @seealso is_equal_to
60     *
61     */
62    bool copy_from(const SceneContent& content);
63
64
65    /**
66     * Implements the egality-test with other contents.
67     *
68     * This could be an operator==.
69     *
70     * @param content The content to compare with.
71     *
72     * @return true if the content are equal, false otherwise. The test can
73     *         fail if the contents have different parameters, but also it
74     *         SceneContent is not a DefaultTeapotSceneContent.
75     *
76     * @seealso copy_from
77     *
78     */
79    bool is_equal_to(const SceneContent& content) const;
80
81
82    /**
83     * Draws the teapot.
84     *
85     * @param glWidget The QGLWidget that own the OpenGL context.
86     * @param cameraMatrix The camera matrix that must be use.
87     *
88     */
89    void draw(QGLWidget* glWidget, const float* cameraMatrix);
90
91
92    /**
93     * Resets the teapot.
94     *
95     * This is a pure virtual method of SceneContent.
96     * This one does nothing.
97     *
98     */
99    void reset (void) {}
100
101
102    /**
103     * Gets the wireframe flag of the teapot.
104     *
105     * @return The wireframe flag of the teapot.
106     *
107     */
108    bool wireframe(void) const {return m_bWireframe;}
109
110
111    /**
112     * Sets the wireframe flag of the teapot.
113     *
114     * @param wireframe The new wireframe flag of the teapot.
115     *
116     */
117    void setWireframe(bool wireframe) {m_bWireframe=wireframe;}
118
119
120    /**
121     * Gets the width of the lines of the teapot.
122     *
123     * @return The width of the lines of the teapot.
124     *
125     */
126    int width(void) const {return m_iWidth;}
127
128
129    /**
130     * Sets the width of the lines of the teapot.
131     *
132     * @param width The new width of the lines of the teapot.
133     *
134     */
135    void setWidth(int width) {m_iWidth=width;}
136
137
138    /**
139     * Loads the teapot from a QDomElement.
140     *
141     * @param element The QDomElement to read from.
142     *
143     */
144    void initFromDOMElement(const QDomElement& element);
145
146
147    /**
148     * Writes the teapot in a QDomDocument.
149     *
150     * @param name The name of the element.
151     * @param doc The document whom belongs the element.
152     *
153     * @return The QDomElement to add.
154     *
155     */
156    QDomElement domElement(const QString& name, QDomDocument& doc) const;
157
158
159    /**
160     * Gets the name of teapot scene type, stored in g_scene_name.
161     *
162     * @return The name of teapot scene type, stored in g_scene_name.
163     *
164     */
165    const QString& scene_name(void) const {return g_scene_name;}
166
167
168    /// Public static const scene name for the teapot scene.
169    static const QString g_scene_name;
170
171
172private:
173
174
175    /// The wireframe flag.
176    /// true means that the teapot will be draw in wireframe.
177    /// false means that a solid teapot will be drawn.
178    int m_bWireframe;
179
180
181    /// Width of the lines of the teapot.
182    /// The width is specified in pixels.
183    int m_iWidth;
184
185};
186
187
188#endif // __DEFAULT_TEAPOT_SCENE_CONTENT_H__
Note: See TracBrowser for help on using the repository browser.