summaryrefslogtreecommitdiff
path: root/src/GLView.h
diff options
context:
space:
mode:
authordonbright <hugh.m.bright@gmail.com>2013-03-05 23:47:14 (GMT)
committerdonbright <hugh.m.bright@gmail.com>2013-03-05 23:47:14 (GMT)
commit42f21c3a0850083d245aa3ac346a53e876f0679e (patch)
treefacf41750e0fe27cc4cdaf352c9c8e687011d103 /src/GLView.h
parent422c668dcb538f181683ae51305bf8d3404f48d6 (diff)
parent4734172c3a16cc06b09e4d2131aa8e380bd0f226 (diff)
Merge pull request #288 from openscad/issue11_2
Issue11 2
Diffstat (limited to 'src/GLView.h')
-rw-r--r--src/GLView.h132
1 files changed, 59 insertions, 73 deletions
diff --git a/src/GLView.h b/src/GLView.h
index 5552e4b..165c634 100644
--- a/src/GLView.h
+++ b/src/GLView.h
@@ -1,95 +1,81 @@
#ifndef GLVIEW_H_
#define GLVIEW_H_
-#include "system-gl.h"
-#include <QGLWidget>
-#include <QLabel>
+/* GLView: A basic OpenGL rectangle for rendering images.
-class GLView : public QGLWidget
-{
- Q_OBJECT
- Q_PROPERTY(bool showFaces READ showFaces WRITE setShowFaces);
- Q_PROPERTY(bool showEdges READ showEdges WRITE setShowEdges);
- Q_PROPERTY(bool showAxes READ showAxes WRITE setShowAxes);
- Q_PROPERTY(bool showCrosshairs READ showCrosshairs WRITE setShowCrosshairs);
- Q_PROPERTY(bool orthoMode READ orthoMode WRITE setOrthoMode);
+This class is inherited by:
-public:
- GLView(QWidget *parent = NULL);
- GLView(const QGLFormat & format, QWidget *parent = NULL);
- void setRenderer(class Renderer* r);
-#ifdef ENABLE_OPENCSG
- bool hasOpenCSGSupport() { return this->opencsg_support; }
-#endif
- // Properties
- bool showFaces() const { return this->showfaces; }
- void setShowFaces(bool enabled) { this->showfaces = enabled; }
- bool showEdges() const { return this->showedges; }
- void setShowEdges(bool enabled) { this->showedges = enabled; }
- bool showAxes() const { return this->showaxes; }
- void setShowAxes(bool enabled) { this->showaxes = enabled; }
- bool showCrosshairs() const { return this->showcrosshairs; }
- void setShowCrosshairs(bool enabled) { this->showcrosshairs = enabled; }
- bool orthoMode() const { return this->orthomode; }
- void setOrthoMode(bool enabled) { this->orthomode = enabled; }
- const QString &getRendererInfo() const { return this->rendererInfo; }
+*QGLview - for Qt GUI
+*OffscreenView - for offscreen rendering, in tests and from command-line
-public:
- QLabel *statusLabel;
- double object_rot_x;
- double object_rot_y;
- double object_rot_z;
- double object_trans_x;
- double object_trans_y;
- double object_trans_z;
- GLint shaderinfo[11];
+The view assumes either a Gimbal Camera (rotation,translation,distance)
+or Vector Camera (eye,center/target) is being used. See Camera.h. The
+cameras are not kept in sync.
-#ifdef ENABLE_OPENCSG
- bool opencsg_support;
- int opencsg_id;
+QGLView only uses GimbalCamera while OffscreenView can use either one.
+Some actions (showCrossHairs) only work properly on Gimbal Camera.
+
+*/
+
+#include <Eigen/Core>
+#include <Eigen/Geometry>
+#include <string>
+#ifndef _MSC_VER
+#include <stdint.h>
#endif
+#include "system-gl.h"
+#include <iostream>
+#include "renderer.h"
+#include "Camera.h"
-private:
- void init();
- Renderer *renderer;
+class GLView
+{
+public:
+ GLView();
+ void setRenderer(Renderer* r);
- QString rendererInfo;
+ void initializeGL();
+ void resizeGL(int w, int h);
+ virtual void paintGL();
- bool showfaces;
- bool showedges;
- bool showaxes;
- bool showcrosshairs;
- bool orthomode;
+ void setCamera( Camera &cam );
- double viewer_distance;
+ void setupGimbalCamPerspective();
+ void setupGimbalCamOrtho(double distance, bool offset=false);
+ void gimbalCamPaintGL();
- double w_h_ratio;
+ void setupVectorCamPerspective();
+ void setupVectorCamOrtho(bool offset=false);
+ void vectorCamPaintGL();
- bool mouse_drag_active;
- QPoint last_mouse;
+ void showCrosshairs();
+ void showAxes();
+ void showSmallaxes();
- void keyPressEvent(QKeyEvent *event);
- void wheelEvent(QWheelEvent *event);
- void mousePressEvent(QMouseEvent *event);
- void mouseMoveEvent(QMouseEvent *event);
- void mouseReleaseEvent(QMouseEvent *event);
+ virtual bool save(const char *filename) = 0;
+ virtual std::string getRendererInfo() const = 0;
- void initializeGL();
- void resizeGL(int w, int h);
- void setupPerspective();
- void setupOrtho(double distance,bool offset=false);
- void paintGL();
- void normalizeAngle(GLdouble& angle);
+ Renderer *renderer;
+ Camera cam;
+ double far_far_away;
+ size_t width;
+ size_t height;
+ double w_h_ratio;
+ bool orthomode;
+ bool showaxes;
+ bool showfaces;
+ bool showedges;
+ bool showcrosshairs;
#ifdef ENABLE_OPENCSG
- bool is_opencsg_capable;
- bool has_shaders;
-private slots:
- void display_opencsg_warning();
+ GLint shaderinfo[11];
+ bool is_opencsg_capable;
+ bool has_shaders;
+ void enable_opencsg_shaders();
+ virtual void display_opencsg_warning() = 0;
+ bool opencsg_support;
+ int opencsg_id;
#endif
-
-signals:
- void doAnimateUpdate();
};
#endif
contact: Jan Huwald // Impressum