source: projectionDesigner/trunk/projdesigner/include/Channel.h @ 149

Last change on this file since 149 was 4, checked in by Torben Dannhauer, 15 years ago
File size: 10.2 KB
RevLine 
[4]1// -*- mode:c++ -*-
2#ifndef _CHANNEL_H_
3#define _CHANNEL_H_
4
5#include <QtXml>
6#include <QtOpenGL>
7
8#include "interfaces.h"
9#include "Frustum.h"
10#include "Screen.h"
11
12class QGLPixelBuffer;
13
14namespace projection
15{
16class ProjectionModel;
17class Warp;
18
19//! Channel draw mode
20enum CHANNEL_DRAWMODE
21{
22    CHANNEL_DRAWMODE_DESIGN_DISTORTIONMAP,  //!< Draw distortion map for designing.
23    CHANNEL_DRAWMODE_EXPORT_DISTORTIONMAP,  //!< Draw distortion map for exporting.
24    CHANNEL_DRAWMODE_DESIGN_BLENDMAP,       //!< Draw blend map for designing.
25    CHANNEL_DRAWMODE_EXPORT_BLENDMAP        //!< Draw blend map for exporting.
26};
27
28/**
29 * Channel class. It contains projector and view data.
30 */
31class Channel : public QObject
32{
33    Q_OBJECT
34
35public:
36
37    /**
38     * Constructor.
39     *
40     * @param pModel Projection model.
41     */
42    Channel(ProjectionModel* pModel);
43
44    /**
45     * Destructor.
46     */
47    virtual ~Channel();
48
49    /**
50     * Render the scene to a texture.
51     */
52    void renderSceneToViewBuffer();
53
54    /**
55     * Render the screen viewing from the projector.
56     */
57    void draw(CHANNEL_DRAWMODE drawMode);
58
59    /**
60     * Draw projector and view frustum shape objects.
61     *
62     * @param bSelected True to draw with selection highlight.
63     */
64    void drawFrustums(bool bSelected=false);
65
66    /**
67     * Set channel name.
68     *
69     * @param name Name of the channel.
70     */
71    void setName(const QString& name);
72
73    /**
74     * Retrieve name of the channel.
75     */
76    QString getName() const;
77
78    /**
79     * Show or hide the name of the channel in the projector view.
80     *
81     * @param bShow True to show the name of the channel, false to hide.
82     */
83    void setOverlayName(bool bShow);
84
85    /**
86     * Check whether the name of the channel is shown or not.
87     *
88     * @return True if the name of the channel.
89     */
90    bool getOverlayName() const;
91
92    /**
93     * Set host name of the remote host PC to show this channel.
94     *
95     * @param hostName Host name of the remote host PC.
96     */
97    void setRemoteHostName(const QString& hostName);
98
99    /**
100     * Retrieve host name of the remote host PC to show this channel.
101     *
102     * @return Host name of the remote host PC.
103     */
104    QString getRemoteHostName() const;
105
106    /**
107     * Enable or disable the full-screen mode at remote host PC.
108     *
109     * @param bFullScreen True to display this channel in full-screen mode at remote host PC.
110     */
111    void setRemoteFullScreen(bool bFullScreen);
112
113    /**
114     * Check whether this channel is full-screen or not at remote host PC.
115     *
116     * @return True to display this channel in full-screen mode at remote host PC.
117     */
118    bool getRemoteFullScreen() const;
119
120    /**
121     * Screen index for multi-monitor remote host PC.
122     *
123     * @param screenIndex Screen index to display this channel.
124     */
125    void setRemoteScreen(int screenIndex);
126
127    /**
128     * Retrieve screen index for multi-monitor remote host PC.
129     *
130     * @return Screen index to display this channel.
131     */
132    int  getRemoteScreen() const;
133
134    /**
135     * Set file name of image to overlay in the projection window.
136     *
137     * @param fileName File name to overlay in the projection window
138     */
139    void setOverlayImageFileName(const QString& fileName);
140
141    /**
142     * Retrieve file name of image  to overlay in the projection window.
143     *
144     * @return File name to overlay in the projection window
145     */
146    QString getOverlayImageFileName() const;
147
148    /**
149     * Retrieve projector frustum object.
150     *
151     * @return Projector frustum object.
152     */
153    ProjectorData* getProjector();
154
155    /**
156     * Retrieve view frustum object.
157     *
158     * @return View frustum object.
159     */
160    Frustum* getView();
161
162        void setProjector(ProjectorInterface *projector_interface=NULL, const QString& projector_name="");
163        void setProjector(const QString& projector_fullname);
164
165    /**
166     * Show or hide the projected scene in DesignView.
167     *
168     * @param bShow True to display the projected scene in DesignView.
169     */
170    void setShowProjectedScene(bool bShow);
171
172    /**
173     * Check whether the projected scene is shown in DesignView.
174     *
175     * @return True if the projected scene is shown in DesignView.
176     */
177    bool getShowProjectedScene() const;
178
179    /**
180     * Show projector window of this channel.
181     */
182    void showProjectorWindow();
183
184    /**
185     * Fit the view frustum to projection area on the screen surface.
186     *
187     * @return True if successfully fitted.
188     */
189    bool fitView();
190
191    /**
192     * Retrieve the rendered view texture object ID.
193     *
194     * @return Rendered view texture object ID.
195     */
196    unsigned int getViewTexture();
197
198    /**
199     * Reconstruct the off-screen buffer.
200     */
201    void reconstructBuffer();
202
203    /**
204     * Retrieve distortion warp class instance.
205     *
206     * @return Distortion warp class instance.
207     */
208    Warp* getDistWarp() const;
209
210    /**
211     * Retrieve blending warp class instance.
212     *
213     * @return Blending warp class instance.
214     */
215    Warp* getBlendWarp() const;
216
217    /**
218     * Retrieve the current (distortion / blending) warp class instance.
219     *
220     * @return Current (distortion / blending) warp class instance.
221     */
222    Warp* getCurrentWarp() const;
223
224    /**
225     * Enable or disable distortion warping.
226     *
227     * @param bEnabled True to enable the distortion warping, false to disable.
228     */
229    void setDistWarpEnabled(bool bEnabled);
230
231    /**
232     * Check whether the distortion warping is enabled or not.
233     *
234     * @return True if the distortion warping is enabled.
235     */
236    bool getDistWarpEnabled() const;
237
238    /**
239     * Discard the off-screen buffer object for warping.
240     */
241    void clearWarpBuffer();
242
243    /**
244     * Set blending factor of the specified channel for exporting a blend map.
245     *
246     * @param name Name of channel to set blending factor.
247     * @param factor Blending factor (0.0-1.0).
248     */
249    void setBlendFactor(const QString& name, float factor);
250
251    /**
252     * Retrieve the blending factor of the specified channel.
253     *
254     * @param name Name of channel to retrieve the blending factor.
255     * @return Blending factor of the specified channel.
256     */
257    float getBlendFactor(const QString& name) const;
258
259    /**
260     * Export projection settings to file.
261     *
262     * @param fileName File name of the projection settings to save.
263     * @return True if successfully exported.
264     */
265    bool exportDataset(const QString& fileName);
266
267    /**
268     * Assignment operator.
269     *
270     * @param chan Assignment source channel.
271     */
272    Channel& operator=(const Channel& chan);
273
274        void setProjectorTransformMatrix(const TransformMatrix& matrix);
275        TransformMatrix& getProjectorTransformMatrix(void); // <-- not const because of TransformMatrix::getMatrix() that should be const!
276        void setViewProjectionMatrix(const ProjectionMatrix& matrix);
277        void setViewTransformMatrix(const TransformMatrix& matrix);
278
279    /**
280     * Restore the channel data from XML data.
281     *
282     * @param element Parent XML element of the channel data.
283     */
284    bool initFromDOMElement(const QDomElement& element, const QString& version);
285
286    /**
287     * Store the current channel data as XML data.
288     *
289     * @param name XML node name of the data.
290     * @param doc XML document to store the data.
291     * @return Current channel data as XML data.
292     */
293    QDomElement domElement(const QString& name, QDomDocument& doc) const;
294
295public slots:
296
297    /**
298     * Called when channel, projector or view frustum is changed.
299     * Always render the scene to the off-screen buffer...
300     */
301    void updateData();
302
303        void updatePluginData(const ProjectorData& data);
304
305private:
306
307    /**
308     * Retrieve (or create if not exist) off-screen buffer object for warping.
309     *
310     * @return Off-screen buffer object for warping.
311     */
312    QGLPixelBuffer* getWarpBuffer();
313
314    /**
315     * Replace pre-defined keyword in file name pattern.
316     *
317     * @param pattern File name pattern.
318     * @return File name pattern whose keywords replaced.
319     */
320    QString replaceKeywordInFileName(const QString& pattern);
321
322private:
323
324    QString m_name;                 //!< Channel name.
325
326    bool    m_bOverlayName;         //!< True to show the channel name.
327    QString m_overlayImageFileName; //!< File name of image to overlay in the projection window.
328    GLuint  m_overlayImageTexIndex; //!< Texture object index of the image to overlay in the projection window.
329    int     m_overlayImageWidth;    //!< Width of image to overlay in the projection window.
330    int     m_overlayImageHeight;   //!< Height of image to overlay in the projection window.
331
332    bool    m_bShowProjectedScene;  //!< True to display the projected scene in DesignView.
333
334    QString m_remoteHostName;       //!< Remote host name to display this channel.
335    bool    m_bRemoteFullScreen;    //!< True to display this channel in full-screen mode at remote host PC.
336    int     m_remoteScreen;         //!< Screen index for multi-monitor remote host PC.
337
338    Frustum m_projector;            //!< Projector settings.
339    Frustum m_view;                 //!< View settings.
340
341    QGLPixelBuffer* m_pWarpBuffer;  //!< Off-screen buffer for distortion map warping.
342    unsigned int m_warpTextureID;   //!< Distortion warping texture object index.
343
344    Warp* m_pDistWarp;              //!< Distortion map warping.
345    bool m_bDistWarpEnabled;        //!< True to enable the distortion map warping.
346
347    Warp* m_pBlendWarp;             //!< Blend map warping.
348
349    QMap<QString, float> m_blendFactors;    //!< Blend factors for exporting a blend map.
350
351    QGLPixelBuffer* m_pSceneBuffer; //!< Off-screen buffer for rendering the scene.
352    unsigned int m_sceneTextureID;  //!< Scene rendered texture object index.
353
354    ProjectionModel* m_pModel;      //!< Projection model.
355
356    TransformMatrix m_projectorTransformMatrix;      //!< Transform matrix of the frustum.
357        ProjectorData *m_projectorData;
358};
359
360};
361
362#endif // _CHANNEL_H_
Note: See TracBrowser for help on using the repository browser.