54 Right, |
55 Right, |
55 Free, |
56 Free, |
56 _End |
57 _End |
57 }; |
58 }; |
58 |
59 |
59 MAKE_ITERABLE_ENUM(Camera) |
|
60 |
|
61 struct CameraIcon |
60 struct CameraIcon |
62 { |
61 { |
63 QPixmap image; |
62 QPixmap image; |
64 QRect sourceRect; |
63 QRect sourceRect; |
65 QRect targetRect; |
64 QRect targetRect; |
66 QRect hitRect; |
65 QRect hitRect; |
67 Camera camera; |
66 Camera camera; |
68 }; |
67 }; |
|
68 |
|
69 MAKE_ITERABLE_ENUM(Camera) |
69 |
70 |
70 // The main renderer object, draws the brick on the screen, manages the camera and selection picking. |
71 // The main renderer object, draws the brick on the screen, manages the camera and selection picking. |
71 class GLRenderer : public QGLWidget, protected QOpenGLFunctions, public HierarchyElement |
72 class GLRenderer : public QGLWidget, protected QOpenGLFunctions, public HierarchyElement |
72 { |
73 { |
73 Q_OBJECT |
74 Q_OBJECT |
80 Camera camera() const; |
81 Camera camera() const; |
81 const CameraInfo& cameraInfo(Camera camera) const; |
82 const CameraInfo& cameraInfo(Camera camera) const; |
82 QString cameraName(Camera camera) const; |
83 QString cameraName(Camera camera) const; |
83 QByteArray capturePixels(); |
84 QByteArray capturePixels(); |
84 GLCompiler* compiler() const; |
85 GLCompiler* compiler() const; |
|
86 GLCamera& currentCamera(); |
|
87 const GLCamera& currentCamera() const; |
85 QString currentCameraName() const; |
88 QString currentCameraName() const; |
86 void drawGLScene(); |
89 void drawGLScene(); |
87 void forgetObject(LDObject* obj); |
90 void forgetObject(LDObject* obj); |
88 Axis getCameraAxis(bool y, Camera camid = (Camera) -1); |
|
89 void highlightCursorObject(); |
91 void highlightCursorObject(); |
90 void initGLData(); |
92 void initGLData(); |
91 bool isDrawOnly() const; |
93 bool isDrawOnly() const; |
92 bool isPicking() const; |
94 bool isPicking() const; |
93 Qt::KeyboardModifiers keyboardModifiers() const; |
95 Qt::KeyboardModifiers keyboardModifiers() const; |
105 void setBackground(); |
107 void setBackground(); |
106 void setCamera(Camera cam); |
108 void setCamera(Camera cam); |
107 void setDrawOnly(bool value); |
109 void setDrawOnly(bool value); |
108 void setPicking(bool a); |
110 void setPicking(bool a); |
109 QPen textPen() const; |
111 QPen textPen() const; |
110 double virtualHeight() const; |
|
111 double virtualWidth() const; |
|
112 void zoomNotch(bool inward); |
|
113 |
112 |
114 static const QPen thinBorderPen; |
113 static const QPen thinBorderPen; |
115 |
114 |
116 signals: |
115 signals: |
117 void objectHighlightingChanged(LDObject* object); |
116 void objectHighlightingChanged(LDObject* object); |
132 virtual bool freeCameraAllowed() const; |
131 virtual bool freeCameraAllowed() const; |
133 bool isDrawingSelectionScene() const; |
132 bool isDrawingSelectionScene() const; |
134 Qt::MouseButtons lastButtons() const; |
133 Qt::MouseButtons lastButtons() const; |
135 double panning (Axis ax) const; |
134 double panning (Axis ax) const; |
136 const QGenericMatrix<4, 4, GLfloat>& rotationMatrix() const; |
135 const QGenericMatrix<4, 4, GLfloat>& rotationMatrix() const; |
137 double& panning (Axis ax); |
136 double zoom(); |
138 double& zoom(); |
|
139 |
137 |
140 template<typename... Args> |
138 template<typename... Args> |
141 QString format (QString fmtstr, Args... args) |
139 QString format (QString fmtstr, Args... args) |
142 { |
140 { |
143 return ::format (fmtstr, args...); |
141 return ::format (fmtstr, args...); |
149 LDObject* m_objectAtCursor = nullptr; |
147 LDObject* m_objectAtCursor = nullptr; |
150 CameraIcon m_cameraIcons[7]; |
148 CameraIcon m_cameraIcons[7]; |
151 QTimer* m_toolTipTimer; |
149 QTimer* m_toolTipTimer; |
152 Qt::MouseButtons m_lastButtons; |
150 Qt::MouseButtons m_lastButtons; |
153 Qt::KeyboardModifiers m_currentKeyboardModifiers; |
151 Qt::KeyboardModifiers m_currentKeyboardModifiers; |
154 double m_virtualWidth; |
|
155 double m_virtualHeight; |
|
156 QGenericMatrix<4, 4, GLfloat> m_rotationMatrix; |
152 QGenericMatrix<4, 4, GLfloat> m_rotationMatrix; |
157 double m_panX[7] = {0}; |
153 GLCamera m_cameras[7]; |
158 double m_panY[7] = {0}; |
|
159 double m_zoom[7] = {30}; |
|
160 bool m_useDarkBackground = false; |
154 bool m_useDarkBackground = false; |
161 bool m_drawToolTip = false; |
155 bool m_drawToolTip = false; |
162 bool m_takingScreenCapture = false; |
156 bool m_takingScreenCapture = false; |
163 bool m_panning = false; |
157 bool m_panning = false; |
164 bool m_initialized = false; |
158 bool m_initialized = false; |