134 class GLRenderer : public QGLWidget, protected QOpenGLFunctions, public HierarchyElement |
134 class GLRenderer : public QGLWidget, protected QOpenGLFunctions, public HierarchyElement |
135 { |
135 { |
136 Q_OBJECT |
136 Q_OBJECT |
137 |
137 |
138 public: |
138 public: |
139 GLRenderer (QWidget* parent = nullptr); |
139 GLRenderer(QWidget* parent = nullptr); |
140 ~GLRenderer(); |
140 ~GLRenderer(); |
141 |
141 |
142 ECamera camera() const; |
142 ECamera camera() const; |
143 QString cameraName (ECamera camera) const; |
143 QString cameraName(ECamera camera) const; |
144 QByteArray capturePixels(); |
144 QByteArray capturePixels(); |
145 void clearOverlay(); |
145 void clearOverlay(); |
146 void compileObject (LDObject* obj); |
146 void compileObject(LDObject* obj); |
147 GLCompiler* compiler() const; |
147 GLCompiler* compiler() const; |
148 Vertex convert2dTo3d (const QPoint& pos2d, bool snap) const; |
148 Vertex convert2dTo3d(const QPoint& pos2d, bool snap) const; |
149 QPoint convert3dTo2d (const Vertex& pos3d); |
149 QPoint convert3dTo2d(const Vertex& pos3d); |
150 QString currentCameraName() const; |
150 QString currentCameraName() const; |
151 EditModeType currentEditModeType() const; |
151 EditModeType currentEditModeType() const; |
152 int depthNegateFactor() const; |
152 int depthNegateFactor() const; |
153 LDDocument* document() const; |
153 LDDocument* document() const; |
154 void drawBlip (QPainter& painter, QPointF pos, QColor color = QColor (64, 192, 0)) const; |
154 void drawBlip(QPainter& painter, QPointF pos, QColor color = QColor(64, 192, 0)) const; |
155 void drawBlipCoordinates (QPainter& painter, const Vertex& pos3d); |
155 void drawBlipCoordinates(QPainter& painter, const Vertex& pos3d); |
156 void drawBlipCoordinates (QPainter& painter, const Vertex& pos3d, QPointF pos); |
156 void drawBlipCoordinates(QPainter& painter, const Vertex& pos3d, QPointF pos); |
157 void drawGLScene(); |
157 void drawGLScene(); |
158 void forgetObject (LDObject* obj); |
158 void forgetObject(LDObject* obj); |
159 Axis getCameraAxis (bool y, ECamera camid = (ECamera) -1); |
159 Axis getCameraAxis(bool y, ECamera camid = (ECamera) -1); |
160 double getDepthValue() const; |
160 double getDepthValue() const; |
161 const LDFixedCamera& getFixedCamera (ECamera cam) const; |
161 const LDFixedCamera& getFixedCamera(ECamera cam) const; |
162 LDGLOverlay& getOverlay (int newcam); |
162 LDGLOverlay& getOverlay(int newcam); |
163 void getRelativeAxes (Axis& relX, Axis& relY) const; |
163 void getRelativeAxes(Axis& relX, Axis& relY) const; |
164 Axis getRelativeZ() const; |
164 Axis getRelativeZ() const; |
165 void hardRefresh(); |
165 void hardRefresh(); |
166 void highlightCursorObject(); |
166 void highlightCursorObject(); |
167 void initGLData(); |
167 void initGLData(); |
168 void initOverlaysFromObjects(); |
168 void initOverlaysFromObjects(); |
174 bool mouseHasMoved() const; |
174 bool mouseHasMoved() const; |
175 QPoint const& mousePosition() const; |
175 QPoint const& mousePosition() const; |
176 QPointF const& mousePositionF() const; |
176 QPointF const& mousePositionF() const; |
177 void needZoomToFit(); |
177 void needZoomToFit(); |
178 LDObject* objectAtCursor() const; |
178 LDObject* objectAtCursor() const; |
179 void pick (int mouseX, int mouseY, bool additive); |
179 void pick(int mouseX, int mouseY, bool additive); |
180 void pick (QRect const& range, bool additive); |
180 void pick(QRect const& range, bool additive); |
181 LDObject* pickOneObject (int mouseX, int mouseY); |
181 LDObject* pickOneObject(int mouseX, int mouseY); |
182 Vertex const& position3D() const; |
182 Vertex const& position3D() const; |
183 void refresh(); |
183 void refresh(); |
184 void resetAllAngles(); |
184 void resetAllAngles(); |
185 void resetAngles(); |
185 void resetAngles(); |
186 void setBackground(); |
186 void setBackground(); |
187 void setCamera (const ECamera cam); |
187 void setCamera(const ECamera cam); |
188 void setDepthValue (double depth); |
188 void setDepthValue(double depth); |
189 void setDocument (LDDocument* document); |
189 void setDocument(LDDocument* document); |
190 void setDrawOnly (bool value); |
190 void setDrawOnly(bool value); |
191 void setEditMode (EditModeType type); |
191 void setEditMode(EditModeType type); |
192 void setPicking (bool a); |
192 void setPicking(bool a); |
193 bool setupOverlay (ECamera cam, QString file, int x, int y, int w, int h); |
193 bool setupOverlay(ECamera cam, QString file, int x, int y, int w, int h); |
194 QPen textPen() const; |
194 QPen textPen() const; |
195 void updateOverlayObjects(); |
195 void updateOverlayObjects(); |
196 void zoomNotch (bool inward); |
196 void zoomNotch(bool inward); |
197 |
197 |
198 protected: |
198 protected: |
199 void contextMenuEvent (QContextMenuEvent* ev); |
199 void contextMenuEvent(QContextMenuEvent* ev); |
200 void dragEnterEvent (QDragEnterEvent* ev); |
200 void dragEnterEvent(QDragEnterEvent* ev); |
201 void dropEvent (QDropEvent* ev); |
201 void dropEvent(QDropEvent* ev); |
202 void initializeGL(); |
202 void initializeGL(); |
203 void keyPressEvent (QKeyEvent* ev); |
203 void keyPressEvent(QKeyEvent* ev); |
204 void keyReleaseEvent (QKeyEvent* ev); |
204 void keyReleaseEvent(QKeyEvent* ev); |
205 void leaveEvent (QEvent* ev); |
205 void leaveEvent(QEvent* ev); |
206 void mouseDoubleClickEvent (QMouseEvent* ev); |
206 void mouseDoubleClickEvent(QMouseEvent* ev); |
207 void mousePressEvent (QMouseEvent* ev); |
207 void mousePressEvent(QMouseEvent* ev); |
208 void mouseMoveEvent (QMouseEvent* ev); |
208 void mouseMoveEvent(QMouseEvent* ev); |
209 void mouseReleaseEvent (QMouseEvent* ev); |
209 void mouseReleaseEvent(QMouseEvent* ev); |
210 void paintEvent (QPaintEvent* ev); |
210 void paintEvent(QPaintEvent* ev); |
211 void resizeGL (int w, int h); |
211 void resizeGL(int w, int h); |
212 void wheelEvent (QWheelEvent* ev); |
212 void wheelEvent(QWheelEvent* ev); |
213 |
213 |
214 private: |
214 private: |
215 MessageManager* m_messageLog; |
215 MessageManager* m_messageLog; |
216 LDDocument* m_document; |
216 LDDocument* m_document; |
217 GLCompiler* m_compiler; |
217 GLCompiler* m_compiler; |
246 AbstractEditMode* m_currentEditMode; |
246 AbstractEditMode* m_currentEditMode; |
247 GLuint m_axesVbo; |
247 GLuint m_axesVbo; |
248 GLuint m_axesColorVbo; |
248 GLuint m_axesColorVbo; |
249 |
249 |
250 void calcCameraIcons(); |
250 void calcCameraIcons(); |
251 void clampAngle (double& angle) const; |
251 void clampAngle(double& angle) const; |
252 LDGLData& currentDocumentData() const; |
252 LDGLData& currentDocumentData() const; |
253 void drawVbos (SurfaceVboType surface, ComplementVboType colors, GLenum type); |
253 void drawVbos(SurfaceVboType surface, ComplementVboType colors, GLenum type); |
254 void doMakeCurrent(); |
254 void doMakeCurrent(); |
255 LDOverlay* findOverlayObject (ECamera cam); |
255 LDOverlay* findOverlayObject(ECamera cam); |
256 double& panning (Axis ax); |
256 double& panning(Axis ax); |
257 double panning (Axis ax) const; |
257 double panning(Axis ax) const; |
258 double& rotation (Axis ax); |
258 double& rotation(Axis ax); |
259 double& zoom(); |
259 double& zoom(); |
260 void zoomToFit(); |
260 void zoomToFit(); |
261 void zoomAllToFit(); |
261 void zoomAllToFit(); |
262 |
262 |
263 template<typename... Args> |
263 template<typename... Args> |
264 QString format (QString fmtstr, Args... args) |
264 QString format(QString fmtstr, Args... args) |
265 { |
265 { |
266 return ::format (fmtstr, args...); |
266 return ::format(fmtstr, args...); |
267 } |
267 } |
268 |
268 |
269 private slots: |
269 private slots: |
270 void slot_toolTipTimer(); |
270 void slot_toolTipTimer(); |
271 void initializeAxes(); |
271 void initializeAxes(); |