101 panY[i] = 0.0; |
101 panY[i] = 0.0; |
102 } |
102 } |
103 } |
103 } |
104 }; |
104 }; |
105 |
105 |
|
106 enum ECamera |
|
107 { |
|
108 ETopCamera, |
|
109 EFrontCamera, |
|
110 ELeftCamera, |
|
111 EBottomCamera, |
|
112 EBackCamera, |
|
113 ERightCamera, |
|
114 EFreeCamera, |
|
115 |
|
116 ENumCameras, |
|
117 EFirstCamera = ETopCamera |
|
118 }; |
|
119 |
|
120 NUMERIC_ENUM_OPERATORS (ECamera) |
|
121 |
106 // ============================================================================= |
122 // ============================================================================= |
107 // The main renderer object, draws the brick on the screen, manages the camera |
123 // The main renderer object, draws the brick on the screen, manages the camera |
108 // and selection picking. The instance of GLRenderer is accessible as |
124 // and selection picking. The instance of GLRenderer is accessible as |
109 // g_win->R() |
125 // g_win->R() |
110 // |
126 // |
111 class GLRenderer : public QGLWidget |
127 class GLRenderer : public QGLWidget |
112 { |
128 { |
113 public: |
129 public: |
114 enum EFixedCamera |
|
115 { |
|
116 ETopCamera, |
|
117 EFrontCamera, |
|
118 ELeftCamera, |
|
119 EBottomCamera, |
|
120 EBackCamera, |
|
121 ERightCamera, |
|
122 EFreeCamera |
|
123 }; |
|
124 |
|
125 enum ListType |
|
126 { |
|
127 NormalList, |
|
128 PickList, |
|
129 BFCFrontList, |
|
130 BFCBackList |
|
131 }; |
|
132 |
|
133 // CameraIcon::img is a heap-allocated QPixmap because otherwise it gets |
130 // CameraIcon::img is a heap-allocated QPixmap because otherwise it gets |
134 // initialized before program gets to main() and constructs a QApplication |
131 // initialized before program gets to main() and constructs a QApplication |
135 // and Qt doesn't like that. |
132 // and Qt doesn't like that. |
136 struct CameraIcon |
133 struct CameraIcon |
137 { |
134 { |
138 QPixmap* img; |
135 QPixmap* img; |
139 QRect srcRect, |
136 QRect srcRect, |
140 destRect, |
137 destRect, |
141 selRect; |
138 selRect; |
142 EFixedCamera cam; |
139 ECamera cam; |
143 }; |
140 }; |
144 |
141 |
145 Q_OBJECT |
142 Q_OBJECT |
146 PROPERTY (public, bool, isDrawOnly, setDrawOnly, STOCK_WRITE) |
143 PROPERTY (public, bool, isDrawOnly, setDrawOnly, STOCK_WRITE) |
147 PROPERTY (public, MessageManager*, messageLog, setMessageLog, STOCK_WRITE) |
144 PROPERTY (public, MessageManager*, messageLog, setMessageLog, STOCK_WRITE) |
154 |
151 |
155 public: |
152 public: |
156 GLRenderer (QWidget* parent = null); |
153 GLRenderer (QWidget* parent = null); |
157 ~GLRenderer(); |
154 ~GLRenderer(); |
158 |
155 |
159 inline EFixedCamera camera() const |
156 inline ECamera camera() const |
160 { |
157 { |
161 return m_camera; |
158 return m_camera; |
162 } |
159 } |
163 |
160 |
164 void clearOverlay(); |
161 void clearOverlay(); |
165 void compileObject (LDObject* obj); |
162 void compileObject (LDObject* obj); |
166 void drawGLScene(); |
163 void drawGLScene(); |
167 void endDraw (bool accept); |
164 void endDraw (bool accept); |
168 void forgetObject (LDObject* obj); |
165 void forgetObject (LDObject* obj); |
169 Axis getCameraAxis (bool y, EFixedCamera camid = (EFixedCamera) - 1); |
166 Axis getCameraAxis (bool y, ECamera camid = (ECamera) -1); |
170 const char* getCameraName() const; |
167 const char* getCameraName() const; |
171 double getDepthValue() const; |
168 double getDepthValue() const; |
172 LDGLOverlay& getOverlay (int newcam); |
169 LDGLOverlay& getOverlay (int newcam); |
173 uchar* getScreencap (int& w, int& h); |
170 uchar* getScreencap (int& w, int& h); |
174 void hardRefresh(); |
171 void hardRefresh(); |
177 void needZoomToFit(); |
174 void needZoomToFit(); |
178 void refresh(); |
175 void refresh(); |
179 void resetAngles(); |
176 void resetAngles(); |
180 void resetAllAngles(); |
177 void resetAllAngles(); |
181 void setBackground(); |
178 void setBackground(); |
182 void setCamera (const EFixedCamera cam); |
179 void setCamera (const ECamera cam); |
183 void setDepthValue (double depth); |
180 void setDepthValue (double depth); |
184 bool setupOverlay (EFixedCamera cam, String file, int x, int y, int w, int h); |
181 bool setupOverlay (ECamera cam, String file, int x, int y, int w, int h); |
185 void updateOverlayObjects(); |
182 void updateOverlayObjects(); |
186 void zoomNotch (bool inward); |
183 void zoomNotch (bool inward); |
187 |
184 |
188 static QColor getMainColor(); |
185 static QColor getMainColor(); |
189 void highlightCursorObject(); |
186 void highlightCursorObject(); |
231 bool m_rectdraw; |
228 bool m_rectdraw; |
232 Vertex m_rectverts[4]; |
229 Vertex m_rectverts[4]; |
233 QColor m_bgcolor; |
230 QColor m_bgcolor; |
234 |
231 |
235 void addDrawnVertex (Vertex m_hoverpos); |
232 void addDrawnVertex (Vertex m_hoverpos); |
236 LDOverlay* findOverlayObject (EFixedCamera cam); |
233 LDOverlay* findOverlayObject (ECamera cam); |
237 void updateRectVerts(); |
234 void updateRectVerts(); |
238 void getRelativeAxes (Axis& relX, Axis& relY) const; |
235 void getRelativeAxes (Axis& relX, Axis& relY) const; |
239 Axis getRelativeZ() const; |
236 Axis getRelativeZ() const; |
240 Matrix getCircleDrawMatrix (double scale); |
237 Matrix getCircleDrawMatrix (double scale); |
241 void drawBlip (QPainter& paint, QPoint pos) const; |
238 void drawBlip (QPainter& paint, QPoint pos) const; |
307 private slots: |
304 private slots: |
308 void slot_toolTipTimer(); |
305 void slot_toolTipTimer(); |
309 void initializeAxes(); |
306 void initializeAxes(); |
310 }; |
307 }; |
311 |
308 |
312 // Alias for short namespaces |
|
313 typedef GLRenderer GL; |
|
314 |
|
315 static const GLRenderer::ListType g_glListTypes[] = |
|
316 { |
|
317 GL::NormalList, |
|
318 GL::PickList, |
|
319 GL::BFCFrontList, |
|
320 GL::BFCBackList, |
|
321 }; |
|
322 |
|
323 extern const GL::EFixedCamera g_Cameras[7]; |
|
324 extern const char* g_CameraNames[7]; |
309 extern const char* g_CameraNames[7]; |