source: projectionDesigner/trunk/projdesigner/include/Screen.h @ 322

Last change on this file since 322 was 4, checked in by Torben Dannhauer, 15 years ago
File size: 5.9 KB
Line 
1#ifndef _SCREEN_H_
2#define _SCREEN_H_
3
4#include "math/TransformMatrix.h"
5
6//! Projection image source.
7enum PROJECT_SOURCE
8{
9        PROJECT_SOURCE_NONE = 0,            //!< Draw the screen only.
10        PROJECT_SOURCE_PROJECTORAREA,       //!< Projected area of the projector.
11        PROJECT_SOURCE_VIEWAREA,            //!< View area of the channel.
12        PROJECT_SOURCE_SCENE,               //!< Scene viewed from the center.
13        PROJECT_SOURCE_EXPORT_DISTORTION,   //!< Color encoded distortion, green and blue channels (internal use only).
14        PROJECT_SOURCE_EXPORT_DISTORTION_R, //!< Color encoded distortion, red channel (internal use only).
15        PROJECT_SOURCE_EXPORT_BLENDING      //!< Edge blend intensity (internal use only).
16};
17
18namespace projection
19{
20class ScreenShape;
21class Channel;
22class ProjectionModel;
23
24/**
25 * Screen class.
26 */
27class Screen : public QObject
28{
29        Q_OBJECT
30
31public:
32
33    /**
34     * Constructor. Screen data / rendering class.
35     *
36     * @param Projection model.
37     */
38    Screen(ProjectionModel* pModel);
39
40    /**
41     * Destructor.
42     */
43    virtual ~Screen();
44
45        /**
46     * Returns a Pointer to the Projection Model.
47     *
48     * @return Pointer to the ProjectionModel
49     */
50        ProjectionModel* getProjectionModel(){return m_pModel;}
51
52    /**
53     * Set transform matrix of the screen.
54     *
55     * @param matrix Transform matrix of the screen.
56     */
57    void setMatrix(const TransformMatrix& matrix);
58
59    /**
60     * Retrieve the transform matrix of the screen.
61     *
62     * @return Transform matrix of the screen.
63     */
64    TransformMatrix getMatrix() const { return m_transformMatrix; }
65
66    /**
67     * Retrieve name of the screen shape.
68     *
69     * @param index Index of the screen shape.
70     * @return Name of the screen shape.
71     */
72        QString getShapeName(int index) const;
73
74    /**
75     * Retrieve the number of the screen shapes.
76     *
77     * @return Number of the screen shapes.
78     */
79    unsigned int getNumShapes() const;
80
81    /**
82     * Retrieve screen shape object.
83     *
84     * @param shapeName Name of the screen shape.
85     * @return Screen shape object.
86     */
87    ScreenShape* getShape(const QString& shapeName) const;
88
89    /**
90     * Select screen shape by name.
91     *
92     * @param shapeName Name of the screen shape to select.
93     */
94        void setCurrentShape(const QString& shapeName);
95
96    /**
97     * Retrieve the name of the current srceen shape.
98     *
99     * @return Name of the current screen shape.
100     */
101    QString getCurrentShapeName() const;
102
103    /**
104     * Retrieve the current screen shape object.
105     *
106     * @return Current screen shape object.
107     */
108    ScreenShape* getCurrentShape() const;
109
110    /**
111     * Retrive the radius of the current screen.
112     *
113     * @return Radius of the current screen.
114     */
115    float getSize() const;
116
117    /**
118     * Show or hide the wire frame mesh of the screen.
119     *
120     * @param bShowFrame True to show the wire frame mesh.
121     */
122        void setShowFrame(bool bShowFrame);
123
124    /**
125     * Check whether the wire frame mesh of the screen is shown or hidden.
126     *
127     * @param bShowFrame True if the wire frame mesh of the screen is shown.
128     */
129    bool getShowFrame() { return m_bShowFrame; }
130
131    /**
132     * Set line width of the wire frame mesh of the screen.
133     *
134     * @param frameLineWidth Line width of the wire frame mesh of the screen.
135     */
136        void setFrameLineWidth(float frameLineWidth);
137
138    /**
139     * Retrieve the line width of the wire frame mesh of the screen.
140     *
141     * @return Line width of the wire frame mesh of the screen.
142     */
143    bool getFrameLineWidth() { return m_frameLineWidth; }
144
145    /**
146     * Set size of the off-screen buffer.
147     *
148     * @param width Width of the off-screen buffer.
149     * @param height Height of the off-screen buffer.
150     */
151    void setBufferSize(int width, int height);
152
153    /**
154     * Retrieve the width of the off-screen buffer.
155     *
156     * @retrieve Width of the off-screen buffer.
157     */
158    int getBufferWidth() const { return m_bufferWidth; }
159
160    /**
161     * Retrieve the height of the off-screen buffer.
162     *
163     * @retrieve Height of the off-screen buffer.
164     */
165    int getBufferHeight() const { return m_bufferHeight; }
166
167    /**
168     * Draw the screen shape object with.
169     *
170     * @param bDepthMaskControl True to use glDepthMask() for blending.
171     */
172    void draw(bool bDepthMaskControl=true);
173
174    /**
175     * Draw the wire frame mesh of the screen.
176     */
177    void drawFrame();
178
179    /**
180     * Draw the screen object with projection texture image of the specified channel.
181     *
182     * @param source Projection image source to draw.
183     * @param pChannel Channel which draws for.
184     */
185    void draw(PROJECT_SOURCE source, Channel* pChannel=NULL);
186
187    /**
188     * Notify to redraw the screen.
189     */
190    void notifyRedraw();
191
192    /**
193     * Restore the screen shape from XML data.
194     *
195     * @param element Parent XML element of the screen data.
196     */
197        bool initFromDOMElement(const QDomElement& element);
198
199    /**
200     * Store the current screen shape as XML data.
201     *
202     * @param name XML node name of the data.
203     * @param doc XML document to store the data.
204     * @return Current screen data as XML data.
205     */
206        QDomElement domElement(const QString& name, QDomDocument& doc) const;
207
208        /**
209         * Reset the screen.
210        */
211    void reset();
212
213protected:
214
215        TransformMatrix m_transformMatrix;  //!< Transform matrix of the screen.
216    bool m_bShowFrame;                  //!< True if the wire frame mesh of the screen is shown.
217    float m_frameLineWidth;             //!< Line width of the wire frame mesh of the screen.
218    int m_bufferWidth;                  //!< Width of the off-screen buffer.
219    int m_bufferHeight;                 //!< Height of the off-screen buffer.
220        QList<ScreenShape*> m_pShapes;      //!< Screen shape objects.
221        ScreenShape* m_pCurrentShape;       //!< Current screen shape object.
222
223    ProjectionModel* m_pModel;          //!< Projection model.
224};
225
226}; // projection
227
228#endif // _SCREEN_H_
Note: See TracBrowser for help on using the repository browser.