source: projectionDesigner/trunk/projdesigner/include/ProjectionModel.h @ 108

Last change on this file since 108 was 4, checked in by Torben Dannhauer, 15 years ago
File size: 7.9 KB
RevLine 
[4]1#ifndef _PROJECTION_MODEL_H_
2#define _PROJECTION_MODEL_H_
3
4#include <QGLWidget>
5#include <QGLPixelBuffer>
6#include <QtXml>
7#include <QList>
8
9#include "Version.h"
10
11#include "interfaces.h"
12
13namespace projection
14{
15class Scene;
16class Screen;
17class Channel;
18class RSync;
19class Exporter;
20class GUIControler;
21
22
23
24//! Default port number.
25#define DEFAULT_PORT_NO 55555
26
27//! Design mode.
28enum DESIGN_MODE
29{
30    DESIGN_MODE_DISTORTIONMAP,  //!< Distortion map design mode.
31    DESIGN_MODE_BLENDMAP        //!< Blend map design mode.
32};
33
34/**
35 * Projection model class. It contains all projection settings.
36 */
37class ProjectionModel : public QObject
38{
39public:
40
41    /**
42     * Constructor.
43     */
44    ProjectionModel();
45
46    /**
47     * Destructor.
48     */
49    virtual ~ProjectionModel();
50
51    /**
52     * Initialize as a server.
53     *
54     * @param portNo Port number.
55     */
56    void initServer(int portNo=DEFAULT_PORT_NO);
57
58    /**
59     * Initialize as a client.
60     *
61     * @param address Client address.
62     * @param portNo Port number.
63     */
64    void initClient(const QString& address=QString::null,
65                    int portNo=DEFAULT_PORT_NO);
66
67    /**
68     * Add a new channel.
69     *
70     * @return New channel.
71     */
72    Channel* addChannel();
73
74    /**
75     * Retrieve the number of the channels.
76     *
77     * @return The number of the channels.
78     */
79    unsigned int getNumChannels() const;
80
81    /**
82     * Retrieve a channel object
83     *
84     * @param index Index of channel to retrieve.
85     * @return Channel object.
86     */
87    Channel* getChannel(int index) const;
88
89    /**
90     * Retrieve Index of the specified channel.
91     *
92     * @param pChannel Channel object.
93     * @return Index of the specified channel.
94     */
95    int getChannelIndex(Channel* pChannel) const;
96
97    /**
98     * Remove the specified channel.
99     *
100     * @param index Index of the channel to remove.
101     */
102    void removeChannel(int index);
103
104    /**
105     * Remove all channels.
106     */
107    void removeAllChannels();
108
109    /**
110     * Select a channel.
111     *
112     * @param pChannel Channel object to select.
113     */
114    void selectChannel(Channel* pChannel);
115
116    /**
117     * Retrieve the selected channel object.
118     *
119     * @return Selected channel object.
120     */
121    Channel* getSelectedChannel() const;
122
123    /**
124     * Select the previous channel.
125     */
126    void selectPreviousChannel();
127
128    /**
129     * Select the next channel.
130     */
131    void selectNextChannel();
132
133    /**
134     * Check whether any channels with the specified name is existing or not.
135     *
136     * @return True if a channel with the specified name is existing.
137     */
138    bool hasChannel(const QString& name) const;
139
140    /**
141     * Create a unique name for specified channel.
142     *
143     * @param name Candidate name of channel. It may not be a unique name.
144     * @param pChannel Channel object to give a name.
145     * @return Unique name for the specified channel.
146     */
147    QString getUniqueName(const QString& name, Channel* pChannel) const;
148
149    /**
150     * Create a projection area texture and retrieve its texture object index.
151     *
152     * @return Texture object index of the projection area texture.
153     */
154    GLuint getProjectorAreaTexture();
155
156    /**
157     * Create a view area texture and retrieve its texture object index.
158     *
159     * @return Texture object index of the view area texture.
160     */
161    GLuint getViewAreaTexture();
162
163    /**
164     * Set design mode.
165     *
166     * @param designMode Design mode.
167     */
168    void setDesignMode(DESIGN_MODE designMode);
169
170    /**
171     * Retrieve the current design mode.
172     *
173     * @param designMode Design mode.
174     */
175    DESIGN_MODE getDesignMode() const;
176
177    /**
178     * Block or unblock to update views.
179     *
180     * @param bBlock True to block updating views.
181     */
182    void setBlockUpdate(bool bBlock);
183
184    /**
185     * Check whether blocking or not update views.
186     *
187     * @return True if blocking to update views.
188     */
189    bool getBlockUpdate() const;
190
191    /**
192     * Redraw all views (DesignViewWindow and ProjectorWindows).
193     */
194    void updateViews();
195
196    /**
197     * Redraw off-screen buffer of the specified channel, then redraw all views.
198     */
199    void updateViewAndOffscreens();
200
201    /**
202     * Load projection settings from a file.
203     *
204     * @param fileName File name to load.
205     * @return True if successfully loaded.
206     */
207    bool loadFile(const QString& fileName);
208
209    /**
210     * Save the current projection settings to a file.
211     *
212     * @param fileName File name to save.
213     * @return True if successfully saved.
214     */
215    bool saveFile(const QString& fileName);
216
217    /**
218     * Restart from a new file.
219     *
220     * @return True if everything is ok.
221     */
222    bool newFile(void);
223
224    /**
225     * Restore the model from XML data.
226     *
227     * @param element Parent XML element of the model data.
228     */
229    bool initFromDOMElement(const QDomElement& element);
230
231    /**
232     * Store the current model as XML data.
233     *
234     * @param name XML node name of the data.
235     * @param doc XML document to store the data.
236     * @return Current screen data as XML data.
237     */
238    QDomElement domElement(const QString& name, QDomDocument& doc) const;
239
240    /**
241     * Restore projection settings from xml data.
242     *
243     * @param doc XML document to restore the projection settings from.
244     */
245    bool restoreSettings(QDomDocument& doc);
246
247    /**
248     * Store projection settings to xml data.
249     *
250     * @param doc XML document to store the projection settings.
251     */
252    void storeSettings(QDomDocument& doc);
253
254    /**
255     * Retrieve the scene object.
256     *
257     * @return Scene object.
258     */
259    Scene* getScene() const;
260
261    /**
262     * Retrieve the screen object.
263     *
264     * @return Screen object.
265     */
266    Screen* getScreen() const;
267
268    /**
269     * Retrieve the remote state synchronize object.
270     *
271     * @return Remote state synchronize object.
272     */
273    RSync* getRSync() const;
274
275    /**
276     * Retrieve the exporter object.
277     *
278     * @return Exporter object.
279     */
280    Exporter* getExporter() const;
281
282    /**
283     * Retrieve the GUI controler object.
284     *
285     * @return GUI controler object.
286     */
287    GUIControler* getGUI() const;
288
289    /**
290     * Set a GLWidget for the current render context.
291     *
292     * @parma pGLWidget GLWidget of the current render context.
293     */
294    void setRenderContext(QGLWidget* pGLWidget);
295
296    /**
297     * Set a P-Buffer for the current render context.
298     *
299     * @parma pPBuffer P-Buffer of the current render context.
300     */
301    void setRenderContext(QGLPixelBuffer* pPBuffer);
302
303    /**
304     * Activate the current render context.
305     */
306    void activateRenderContext();
307
308#ifdef _DEBUG
309    int m_updateViewsCount;
310    int m_updateOffscreenCount;
311#endif // _DEBUG
312
313    /// Plugins
314    static QList<ProjectorInterface*> projector_interfaces;
315    static QList<SceneInterface*> scene_interfaces;
316    static QDir pluginsDir;
317    static QStringList pluginFileNames;
318
319protected:
320
321    Scene* m_pScene;                //!< Scene object.
322    Screen* m_pScreen;              //!< Screen object.
323
324    QList<Channel*> m_pChannels;    //!< Channel objects.
325    Channel* m_pSelectedChannel;    //!< Selected channel object.
326
327    DESIGN_MODE m_designMode;       //!< Design mode.
328
329    bool m_bBlockUpdate;            //!< True if blocking to update views.
330
331    RSync* m_pRSync;                //!< Remote state synchronize object.
332    Exporter* m_pExporter;          //!< Exporter object.
333    GUIControler* m_pGUI;           //!< GUI controler object.
334
335    GLuint m_projectorAreaTexIndex; //!< Texture object index of the projection area texture.
336    GLuint m_viewAreaTexIndex;      //!< Texture object index of the view area texture.
337
338    QGLWidget* m_pGLWidget;         //!< GLWidget of the current render context.
339    QGLPixelBuffer* m_pPBuffer;     //!< GLPixelBuffer of the current render context.
340
341private:
342    void loadPlugins();
343
344};
345
346}; // projection
347
348#endif // _PROJECTION_MODEL_H_
Note: See TracBrowser for help on using the repository browser.