source: projectionDesigner/trunk/projdesignerplugins/defaultplugin/DefaultProjectorData.h @ 16

Last change on this file since 16 was 4, checked in by Torben Dannhauer, 15 years ago
File size: 6.9 KB
Line 
1#ifndef __DEFAULT_PROJECTOR_DATA_H__
2#define __DEFAULT_PROJECTOR_DATA_H__
3
4// Includes Projection Designer headers
5#include <projdesigner/include/interfaces.h>
6
7
8/**
9 * Implementation of the DefaultProjectorWidget class.
10 *
11 * This class is where the projector is really implemented. Attributes are the
12 * frustum parameters. Methods allow you to draw the frustum either *from* the
13 * frustum as from a different point of view, in order to *see* the frustum.
14 *
15 */
16class DefaultPluginData: public ProjectorData
17{
18
19public:
20
21
22    /**
23     * Default constructor fot the DefaultPluginData.
24     *
25     */
26    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);
27
28
29    /**
30     * Copy constructor fot the DefaultPluginData.
31     *
32     */
33    DefaultPluginData (const DefaultPluginData& data): ProjectorData(data) {copy_from(data);}
34
35
36    /**
37     * Destructor fot the DefaultPluginData.
38     *
39     */
40    ~DefaultPluginData ();
41
42
43    /**
44     * Implements the copy from other datas.
45     *
46     * This method is used by the copy constructor.
47     *
48     * @param data The source data.
49     *
50     * @return true if the copy is ok, false otherwise. The copy can fail if
51     *         ProjectorData is not a DefaultPluginData.
52     *
53     * @seealso is_equal_to
54     *
55     */
56    bool copy_from(const ProjectorData& data);
57
58
59    /**
60     * Implements the egality-test with other datas.
61     *
62     * This could be an operator==.
63     *
64     * @param data The data to test with.
65     *
66     * @return true if the data are equal, false otherwise. The test can fail if
67     *         the data have different parameters, but also it ProjectorData is
68     *         not a DefaultPluginData.
69     *
70     * @seealso copy_from
71     *
72     */
73    bool is_equal_to(const ProjectorData& data) const;
74
75
76    /**
77     * Draws the frustum (a truncated pyramid).
78     *
79     * This method draws the frustum from outside. If the frustum is selected,
80     * the lines are a little bigger.
81     *
82     * @param bSelected true if the frustum is selected.
83     *
84     */
85    void draw(bool bSelected);
86
87
88    /**
89     * Begins the draw through the frustum.
90     *
91     * The draw must end with a endDraw().
92     *
93     * This is the same than glFrustum(), with some glPush...() before.
94     *
95     * @seealso endDraw
96     *
97     */
98    void beginDraw(void);
99
100
101    /**
102     * Ends the draw through the frustum.
103     *
104     * Must be used each time a draw through the projector has begun with a
105     * beginDraw().
106     *
107     * This is the same than some glPop...().
108     *
109     * @seealso beginDraw
110     *
111     */
112    void endDraw(void);
113
114
115    /**
116     * Begins the projection.
117     *
118     * The projection must end with a endProjection().
119     *
120     * This is the same than glFrustum(), without anything else.
121     * beginDraw and beginProjection are quite close and it is perhaps to merge
122     * them, but for the moment, to respect the Projection Designer
123     * implementation, it will be let like this.
124     *
125     * endProjection is not implemented here because it does nothing more than
126     * the ProjectorData::endProjection().
127     *
128     */
129    void beginProjection(void);
130
131
132    /**
133     * Sets the field of view.
134     *
135     * @param fov The new field of view.
136     *
137     */
138    void setFov(float fov) {m_fov=fov;}
139
140
141    /**
142     * Gets the field of view.
143     *
144     * @return The field of view of the projector.
145     *
146     */
147    float fov() const {return m_fov;}
148
149
150    /**
151     * Sets the aspect ratio.
152     *
153     * @param aspectRatio The new aspect ratio.
154     *
155     */
156    void setAspectRatio(float aspectRatio) {m_aspectRatio=aspectRatio;}
157
158
159    /**
160     * Gets the aspect ratio.
161     *
162     * @return The aspect ratio of the projector.
163     *
164     */
165    float aspectRatio() const {return m_aspectRatio;}
166
167
168    /**
169     * Sets the near distance of the frustum.
170     *
171     * @param nearDist The new near distance of the frustum.
172     *
173     */
174    void setNearDist(float nearDist) {m_nearDist=nearDist;}
175
176
177    /**
178     * Gets the near distance of the frustum.
179     *
180     * @return The near distance of the frustum.
181     *
182     */
183    float nearDist() const {return m_nearDist;}
184
185
186    /**
187     * Sets the far distance of the frustum.
188     *
189     * @param farDist The new far distance of the frustum.
190     *
191     */
192    void setFarDist(float farDist) {m_farDist=farDist;}
193
194
195    /**
196     * Gets the far distance of the frustum.
197     *
198     * @return The far distance of the frustum.
199     *
200     */
201    float farDist() const {return m_farDist;}
202
203
204    /**
205     * Sets the off-axis X of the frustum.
206     *
207     * @param offaxisX The new off-axis X of the frustum.
208     *
209     */
210    void setOffaxisX(float offaxisX) {m_offaxisX=offaxisX;}
211
212
213    /**
214     * Gets the off-axis X of the frustum.
215     *
216     * @return The off-axis X of the frustum.
217     *
218     */
219    float offaxisX() const {return m_offaxisX;}
220
221
222    /**
223     * Sets the off-axis Y of the frustum.
224     *
225     * @param offaxisY The new off-axis Y of the frustum.
226     *
227     */
228    void setOffaxisY(float offaxisY) {m_offaxisY=offaxisY;}
229
230
231    /**
232     * Gets the off-axis Y of the frustum.
233     *
234     * @return The off-axis Y of the frustum.
235     *
236     */
237    float offaxisY() const {return m_offaxisY;}
238
239
240    /**
241     * Sets the visible distance of the frustum.
242     *
243     * @param visibleFar The new visible distance of the frustum.
244     *
245     */
246    void setVisibleFar(float visibleFar) {m_visibleFar=visibleFar;}
247
248
249    /**
250     * Gets the visible distance of the frustum.
251     *
252     * @return The visible distance of the frustum.
253     *
254     */
255    float visibleFar() const {return m_visibleFar;}
256
257
258    /**
259     * Loads the frustum from a QDomElement.
260     *
261     * @param element The QDomElement to read from.
262     *
263     */
264    void initFromDOMElement(const QDomElement& element);
265
266
267    /**
268     * Writes the frustum in a QDomDocument.
269     *
270     * @param name The name of the element.
271     * @param doc The document whom belongs the element.
272     *
273     * @return The QDomElement to add.
274     *
275     */
276    QDomElement domElement(const QString& name, QDomDocument& doc) const;
277
278
279    /**
280     * Gets the name of projector type, stored in g_projector_name.
281     *
282     * @return The name of projector type, stored in g_projector_name.
283     *
284     */
285    const QString& projector(void) const {return g_projector_name;}
286
287
288    /// Public static const projector name.
289    static const QString g_projector_name;
290
291
292private:
293
294
295    /// Field of view of the frustum.
296    float m_fov;
297
298
299    /// Aspect ratio of the frustum.
300    float m_aspectRatio;
301
302
303    /// Near distance of the frustum.
304    float m_nearDist;
305
306
307    /// Far distance of the frustum.
308    float m_farDist;
309
310
311    /// Off-axis X of the frustum.
312    float m_offaxisX;
313
314
315    /// Off-axis Y of the frustum.
316    float m_offaxisY;
317
318
319    /// Visible far of the frustum.
320    float m_visibleFar;
321
322};
323
324#endif // __DEFAULT_PROJECTOR_DATA_H__
Note: See TracBrowser for help on using the repository browser.