diff -r 2008959603c9 -r 4f226fd97826 src/glRenderer.h
--- a/src/glRenderer.h Tue Feb 14 13:37:58 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,174 +0,0 @@
-/*
- * LDForge: LDraw parts authoring CAD
- * Copyright (C) 2013 - 2017 Teemu Piippo
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#pragma once
-#include
-#include "main.h"
-#include "model.h"
-#include "glShared.h"
-#include "glcamera.h"
-
-class GLCompiler;
-class MessageManager;
-class QDialogButtonBox;
-class RadioGroup;
-class QDoubleSpinBox;
-class QSpinBox;
-class QLineEdit;
-class QTimer;
-class MagicWandMode;
-
-struct CameraInfo
-{
- CameraInfo(const CameraInfo&) = delete;
-
- int glrotate[3];
- Axis localX;
- Axis localY;
- bool negatedX;
- bool negatedY;
- bool negatedDepth; // is greater depth value closer to camera?
-};
-
-enum class Camera
-{
- Top,
- Front,
- Left,
- Bottom,
- Back,
- Right,
- Free,
- _End
-};
-
-struct CameraIcon
-{
- QPixmap image;
- QRect sourceRect;
- QRect targetRect;
- QRect hitRect;
- Camera camera;
-};
-
-MAKE_ITERABLE_ENUM(Camera)
-
-// The main renderer object, draws the brick on the screen, manages the camera and selection picking.
-class GLRenderer : public QGLWidget, protected QOpenGLFunctions, public HierarchyElement
-{
- Q_OBJECT
-
-public:
- GLRenderer(const Model* model, QWidget* parent = nullptr);
- ~GLRenderer();
-
- QColor backgroundColor() const;
- Camera camera() const;
- QByteArray capturePixels();
- GLCamera& currentCamera();
- const GLCamera& currentCamera() const;
- void drawGLScene();
- void forgetObject(LDObject* obj);
- void highlightCursorObject();
- void initGLData();
- bool isPicking() const;
- Qt::KeyboardModifiers keyboardModifiers() const;
- const Model* model() const;
- bool mouseHasMoved() const;
- QPoint const& mousePosition() const;
- QPointF const& mousePositionF() const;
- void needZoomToFit();
- LDObject* objectAtCursor() const;
- QSet pick(const QRect& range);
- LDObject* pick(int mouseX, int mouseY);
- void refresh();
- void resetAllAngles();
- void resetAngles();
- void setBackground();
- void setCamera(Camera cam);
- void setPicking(bool a);
- QPen textPen() const;
-
- static const QPen thinBorderPen;
-
-signals:
- void objectHighlightingChanged(LDObject* object);
-
-protected:
- void initializeGL();
- void keyPressEvent(QKeyEvent* event);
- void keyReleaseEvent(QKeyEvent* event);
- void leaveEvent(QEvent* event);
- void mousePressEvent(QMouseEvent* event);
- void mouseMoveEvent(QMouseEvent* ev);
- void mouseReleaseEvent(QMouseEvent* ev);
- void paintEvent(QPaintEvent*);
- void resizeGL(int w, int h);
- void wheelEvent(QWheelEvent* ev);
-
- virtual void overpaint(QPainter& painter);
- virtual bool freeCameraAllowed() const;
- bool isDrawingSelectionScene() const;
- Qt::MouseButtons lastButtons() const;
- double panning (Axis ax) const;
- const QGenericMatrix<4, 4, GLfloat>& rotationMatrix() const;
- double zoom();
-
- template
- QString format (QString fmtstr, Args... args)
- {
- return ::format (fmtstr, args...);
- }
-
-private:
- const Model* const m_model;
- GLCompiler* m_compiler;
- LDObject* m_objectAtCursor = nullptr;
- CameraIcon m_cameraIcons[7];
- QTimer* m_toolTipTimer;
- Qt::MouseButtons m_lastButtons;
- Qt::KeyboardModifiers m_currentKeyboardModifiers;
- QGenericMatrix<4, 4, GLfloat> m_rotationMatrix;
- GLCamera m_cameras[7];
- bool m_useDarkBackground = false;
- bool m_takingScreenCapture = false;
- bool m_panning = false;
- bool m_initialized = false;
- bool m_isDrawingSelectionScene = false;
- bool m_isCameraMoving = false;
- bool m_needZoomToFit = true;
- QPoint m_mousePosition;
- QPoint m_globalpos;
- QPointF m_mousePositionF;
- Camera m_camera;
- GLuint m_axeslist;
- int m_totalMouseMove;
- QColor m_backgroundColor;
- GLuint m_axesVbo;
- GLuint m_axesColorVbo;
-
- void calcCameraIcons();
- void drawVbos (VboClass surface, VboSubclass colors, GLenum type);
- void zoomToFit();
- void zoomAllToFit();
-
-private slots:
- void showCameraIconTooltip();
- void initializeAxes();
- void initializeLighting();
-};