| 62 // ============================================================================= |
62 // ============================================================================= |
| 63 class GLRenderer : public QGLWidget |
63 class GLRenderer : public QGLWidget |
| 64 { Q_OBJECT |
64 { Q_OBJECT |
| 65 |
65 |
| 66 PROPERTY (bool, drawOnly, setDrawOnly) |
66 PROPERTY (bool, drawOnly, setDrawOnly) |
| 67 PROPERTY (double, zoom, setZoom) |
|
| 68 PROPERTY (MessageManager*, msglog, setMessageLog) |
67 PROPERTY (MessageManager*, msglog, setMessageLog) |
| 69 READ_PROPERTY (bool, picking, setPicking) |
68 READ_PROPERTY (bool, picking, setPicking) |
| 70 DECLARE_PROPERTY (LDFile*, file, setFile) |
69 DECLARE_PROPERTY (LDFile*, file, setFile) |
| 71 DECLARE_PROPERTY (EditMode, editMode, setEditMode) |
70 DECLARE_PROPERTY (EditMode, editMode, setEditMode) |
| 72 |
71 |
| 94 void hardRefresh(); |
93 void hardRefresh(); |
| 95 void initGLData(); |
94 void initGLData(); |
| 96 void overlaysFromObjects(); |
95 void overlaysFromObjects(); |
| 97 void refresh(); |
96 void refresh(); |
| 98 void resetAngles(); |
97 void resetAngles(); |
| |
98 void resetAllAngles(); |
| 99 uchar* screencap (int& w, int& h); |
99 uchar* screencap (int& w, int& h); |
| 100 void setBackground(); |
100 void setBackground(); |
| 101 void setCamera (const Camera cam); |
101 void setCamera (const Camera cam); |
| 102 void setDepthValue (double depth); |
102 void setDepthValue (double depth); |
| 103 bool setupOverlay (GLRenderer::Camera cam, str file, int x, int y, int w, int h); |
103 bool setupOverlay (GLRenderer::Camera cam, str file, int x, int y, int w, int h); |
| 104 void updateOverlayObjects(); |
104 void updateOverlayObjects(); |
| 105 void zoomNotch (bool inward); |
105 void zoomNotch (bool inward); |
| 106 void zoomToFit(); |
106 void zoomToFit(); |
| |
107 void zoomAllToFit(); |
| 107 |
108 |
| 108 static void deleteLists (LDObject* obj); |
109 static void deleteLists (LDObject* obj); |
| 109 |
110 |
| 110 protected: |
111 protected: |
| 111 void contextMenuEvent (QContextMenuEvent* ev); |
112 void contextMenuEvent (QContextMenuEvent* ev); |
| 164 vertex m_rectverts[4]; |
167 vertex m_rectverts[4]; |
| 165 QColor m_bgcolor; |
168 QColor m_bgcolor; |
| 166 double m_depthValues[6]; |
169 double m_depthValues[6]; |
| 167 LDGLOverlay m_overlays[6]; |
170 LDGLOverlay m_overlays[6]; |
| 168 QList<vertex> m_knownVerts; |
171 QList<vertex> m_knownVerts; |
| 169 bool m_panning; |
|
| 170 |
172 |
| 171 void addDrawnVertex (vertex m_hoverpos); |
173 void addDrawnVertex (vertex m_hoverpos); |
| 172 void calcCameraIcons(); // Compute geometry for camera icons |
|
| 173 void clampAngle (double& angle) const; // Clamps an angle to [0, 360] |
|
| 174 void compileList (LDObject* obj, const ListType list); // Compile one of the lists of an object |
|
| 175 void compileSubObject (LDObject* obj, const GLenum gltype); // Sub-routine for object compiling |
|
| 176 void compileVertex (const vertex& vrt); // Compile a single vertex to a list |
|
| 177 vertex coordconv2_3 (const QPoint& pos2d, bool snap) const; // Convert a 2D point to a 3D point |
|
| 178 QPoint coordconv3_2 (const vertex& pos3d) const; // Convert a 3D point to a 2D point |
|
| 179 LDOverlay* findOverlayObject (Camera cam); |
174 LDOverlay* findOverlayObject (Camera cam); |
| 180 void updateRectVerts(); |
175 void updateRectVerts(); |
| 181 void pick (int mouseX, int mouseY); // Perform object selection |
|
| 182 void setObjectColor (LDObject* obj, const ListType list); // Set the color to an object list |
|
| 183 QColor getTextPen() const; // Determine which color to draw text with |
|
| 184 void getRelativeAxes (Axis& relX, Axis& relY) const; |
176 void getRelativeAxes (Axis& relX, Axis& relY) const; |
| 185 matrix getCircleDrawMatrix (double scale); |
177 matrix getCircleDrawMatrix (double scale); |
| 186 |
|
| 187 void drawBlip (QPainter& paint, QPoint pos) const; |
178 void drawBlip (QPainter& paint, QPoint pos) const; |
| 188 double circleDrawDist(int pos) const; |
179 |
| |
180 // Compute geometry for camera icons |
| |
181 void calcCameraIcons(); |
| |
182 |
| |
183 // How large is the circle we're drawing right now? |
| |
184 double circleDrawDist (int pos) const; |
| |
185 |
| |
186 // Clamps an angle to [0, 360] |
| |
187 void clampAngle (double& angle) const; |
| |
188 |
| |
189 // Compile one of the lists of an object |
| |
190 void compileList (LDObject* obj, const ListType list); |
| |
191 |
| |
192 // Sub-routine for object compiling |
| |
193 void compileSubObject (LDObject* obj, const GLenum gltype); |
| |
194 |
| |
195 // Compile a single vertex to a list |
| |
196 void compileVertex (const vertex& vrt); |
| |
197 |
| |
198 // Convert a 2D point to a 3D point |
| |
199 vertex coordconv2_3 (const QPoint& pos2d, bool snap) const; |
| |
200 |
| |
201 // Convert a 3D point to a 2D point |
| |
202 QPoint coordconv3_2 (const vertex& pos3d) const; |
| |
203 |
| |
204 // Determine which color to draw text with |
| |
205 QColor getTextPen() const; |
| |
206 |
| |
207 // Perform object selection |
| |
208 void pick (int mouseX, int mouseY); |
| |
209 |
| |
210 // Set the color to an object list |
| |
211 void setObjectColor (LDObject* obj, const ListType list); |
| |
212 |
| |
213 // Get a rotation value |
| |
214 inline double& rot (Axis ax) |
| |
215 { return |
| |
216 (ax == X) ? m_rotX[camera()] : |
| |
217 (ax == Y) ? m_rotY[camera()] : |
| |
218 m_rotZ[camera()]; |
| |
219 } |
| |
220 |
| |
221 // Get a panning value |
| |
222 inline double& pan (Axis ax) |
| |
223 { return (ax == X) ? m_panX[camera()] : m_panY[camera()]; |
| |
224 } |
| |
225 |
| |
226 // Same except const (can be used in const methods) |
| |
227 inline const double& pan (Axis ax) const |
| |
228 { return (ax == X) ? m_panX[camera()] : m_panY[camera()]; |
| |
229 } |
| |
230 |
| |
231 // Get the zoom value |
| |
232 inline double& zoom() |
| |
233 { return m_zoom[camera()]; |
| |
234 } |
| 189 |
235 |
| 190 private slots: |
236 private slots: |
| 191 void slot_toolTipTimer(); |
237 void slot_toolTipTimer(); |
| 192 }; |
238 }; |
| 193 |
239 |