summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordon bright <hugh.m.bright@gmail.com>2013-02-23 21:34:06 (GMT)
committerdon bright <hugh.m.bright@gmail.com>2013-02-23 21:34:06 (GMT)
commit5389107aa684ab99701e238a7297f07b35f7d521 (patch)
tree327a51e43bcb642c849c5cfafadf8e84966c662d /src
parent4f578513a0960d4f079260922cdc86de0948099c (diff)
create GLView as parent of OffscreenView and QGLView. combine setRenderer()
Diffstat (limited to 'src')
-rw-r--r--src/CsgInfo.h6
-rw-r--r--src/GLView.cc41
-rw-r--r--src/GLView.h54
-rw-r--r--src/OffscreenView.cc6
-rw-r--r--src/OffscreenView.h6
-rw-r--r--src/QGLView.h10
-rw-r--r--src/export_png.cc10
-rw-r--r--src/mainwin.cc3
-rw-r--r--src/qglview.cc8
9 files changed, 114 insertions, 30 deletions
diff --git a/src/CsgInfo.h b/src/CsgInfo.h
index 6c3e352..889eefe 100644
--- a/src/CsgInfo.h
+++ b/src/CsgInfo.h
@@ -6,8 +6,8 @@
class CsgInfo
{
public:
- CsgInfo() { qglview = NULL; }
- OffscreenView *qglview;
+ CsgInfo() { glview = NULL; }
+ OffscreenView *glview;
};
@@ -26,7 +26,7 @@ public:
root_chain = NULL;
highlights_chain = NULL;
background_chain = NULL;
- qglview = NULL;
+ glview = NULL;
}
shared_ptr<CSGTerm> root_norm_term; // Normalized CSG products
class CSGChain *root_chain;
diff --git a/src/GLView.cc b/src/GLView.cc
new file mode 100644
index 0000000..36aa6b3
--- /dev/null
+++ b/src/GLView.cc
@@ -0,0 +1,41 @@
+#include "GLView.h"
+
+void GLView::setRenderer(class Renderer* r)
+{
+ this->renderer = r;
+}
+
+/*
+ void initializeGL(); //
+ void resizeGL(int w, int h); //
+
+ void setGimbalCamera(const Eigen::Vector3d &pos, const Eigen::Vector3d &rot, double distance); //
+ void setupGimbalPerspective(); //
+ void setupGimbalOrtho(double distance, bool offset=false); //
+
+ void setCamera(const Eigen::Vector3d &pos, const Eigen::Vector3d &center); //
+ void setupPerspective(); //
+ void setupOrtho(bool offset=false); //
+
+ void paintGL(); //
+ bool save(const char *filename); //
+ //bool save(std::ostream &output); // not implemented in qgl?
+ std::string getRendererInfo(); //
+
+ GLint shaderinfo[11]; //
+
+private:
+ Renderer *renderer;//
+ double w_h_ratio;//
+
+ bool orthomode;//
+ bool showaxes;//
+ bool showfaces;//
+ bool showedges;//
+
+ Eigen::Vector3d object_rot;//
+ Eigen::Vector3d camera_eye;//
+ Eigen::Vector3d camera_center;//
+};
+
+*/
diff --git a/src/GLView.h b/src/GLView.h
new file mode 100644
index 0000000..d6e0236
--- /dev/null
+++ b/src/GLView.h
@@ -0,0 +1,54 @@
+#ifndef GLVIEW_H_
+#define GLVIEW_H_
+
+#include <Eigen/Core>
+#include <Eigen/Geometry>
+#include <string>
+#ifndef _MSC_VER
+#include <stdint.h>
+#endif
+#include "system-gl.h"
+#include <iostream>
+#include "renderer.h"
+
+class GLView
+{
+public:
+ void setRenderer(Renderer* r);
+ Renderer *renderer = 0;
+/*
+ void initializeGL(); //
+ void resizeGL(int w, int h); //
+
+ void setGimbalCamera(const Eigen::Vector3d &pos, const Eigen::Vector3d &rot, double distance); //
+ void setupGimbalPerspective(); //
+ void setupGimbalOrtho(double distance, bool offset=false); //
+
+ void setCamera(const Eigen::Vector3d &pos, const Eigen::Vector3d &center); //
+ void setupPerspective(); //
+ void setupOrtho(bool offset=false); //
+
+ void paintGL(); //
+ bool save(const char *filename); //
+ //bool save(std::ostream &output); // not implemented in qgl?
+ std::string getRendererInfo(); //
+
+ GLint shaderinfo[11]; //
+*/
+
+
+
+/* double w_h_ratio;//
+
+ bool orthomode;//
+ bool showaxes;//
+ bool showfaces;//
+ bool showedges;//
+
+ Eigen::Vector3d object_rot;//
+ Eigen::Vector3d camera_eye;//
+ Eigen::Vector3d camera_center;//
+*/
+};
+
+#endif
diff --git a/src/OffscreenView.cc b/src/OffscreenView.cc
index 5c65bc4..da129d8 100644
--- a/src/OffscreenView.cc
+++ b/src/OffscreenView.cc
@@ -1,7 +1,6 @@
#include <GL/glew.h>
#include "OffscreenView.h"
#include "system-gl.h"
-#include "renderer.h"
#include <math.h>
#include <stdio.h>
#include <string.h>
@@ -27,11 +26,6 @@ OffscreenView::~OffscreenView()
teardown_offscreen_context(this->ctx);
}
-void OffscreenView::setRenderer(Renderer* r)
-{
- this->renderer = r;
-}
-
void OffscreenView::initializeGL()
{
glEnable(GL_DEPTH_TEST);
diff --git a/src/OffscreenView.h b/src/OffscreenView.h
index d455ee9..3414d60 100644
--- a/src/OffscreenView.h
+++ b/src/OffscreenView.h
@@ -10,13 +10,13 @@
#endif
#include "system-gl.h"
#include <iostream>
+#include "GLView.h"
-class OffscreenView
+class OffscreenView : public GLView
{
public:
OffscreenView(size_t width, size_t height); // not
~OffscreenView(); // not
- void setRenderer(class Renderer* r); //
void initializeGL(); //
void resizeGL(int w, int h); //
@@ -40,9 +40,7 @@ public:
size_t width; // not
size_t height; // not
private:
- Renderer *renderer;//
double w_h_ratio;//
-
bool orthomode;//
bool showaxes;//
bool showfaces;//
diff --git a/src/QGLView.h b/src/QGLView.h
index bc7e6d3..f617286 100644
--- a/src/QGLView.h
+++ b/src/QGLView.h
@@ -1,5 +1,5 @@
-#ifndef GLVIEW_H_
-#define GLVIEW_H_
+#ifndef QGLVIEW_H_
+#define QGLVIEW_H_
#include "system-gl.h"
#include <QGLWidget>
@@ -7,8 +7,10 @@
#include <Eigen/Core>
#include <Eigen/Geometry>
+#include "GLView.h"
+#include "renderer.h"
-class QGLView : public QGLWidget
+class QGLView : public QGLWidget, public GLView
{
Q_OBJECT
Q_PROPERTY(bool showFaces READ showFaces WRITE setShowFaces);
@@ -20,7 +22,6 @@ class QGLView : public QGLWidget
public:
QGLView(QWidget *parent = NULL);
QGLView(const QGLFormat & format, QWidget *parent = NULL);
- void setRenderer(class Renderer* r);
#ifdef ENABLE_OPENCSG
bool hasOpenCSGSupport() { return this->opencsg_support; }
#endif
@@ -55,7 +56,6 @@ public:
private:
void init();
- Renderer *renderer;
std::string rendererInfo;
diff --git a/src/export_png.cc b/src/export_png.cc
index 1a92fc9..2d6a4a2 100644
--- a/src/export_png.cc
+++ b/src/export_png.cc
@@ -14,7 +14,7 @@ void export_png_with_cgal(CGAL_Nef_polyhedron *root_N, std::ostream &output)
{
CsgInfo csgInfo;
try {
- csgInfo.qglview = new OffscreenView(512,512);
+ csgInfo.glview = new OffscreenView(512,512);
} catch (int error) {
fprintf(stderr,"Can't create OpenGL OffscreenView. Code: %i.\n", error);
return;
@@ -40,10 +40,10 @@ void export_png_with_cgal(CGAL_Nef_polyhedron *root_N, std::ostream &output)
//std::cerr << center << "\n";
//std::cerr << radius << "\n";
- csgInfo.qglview->setCamera(camerapos, center);
- csgInfo.qglview->setRenderer(&cgalRenderer);
- csgInfo.qglview->paintGL();
- csgInfo.qglview->save(output);
+ csgInfo.glview->setCamera(camerapos, center);
+ csgInfo.glview->setRenderer(&cgalRenderer);
+ csgInfo.glview->paintGL();
+ csgInfo.glview->save(output);
}
void export_png_with_opencsg(CGAL_Nef_polyhedron *root_N, std::ostream &output)
diff --git a/src/mainwin.cc b/src/mainwin.cc
index b4e1f50..54f6d37 100644
--- a/src/mainwin.cc
+++ b/src/mainwin.cc
@@ -1498,6 +1498,7 @@ void MainWindow::viewModeOpenCSG()
viewModeActionsUncheck();
viewActionOpenCSG->setChecked(true);
this->qglview->setRenderer(this->opencsgRenderer ? (Renderer *)this->opencsgRenderer : (Renderer *)this->thrownTogetherRenderer);
+ this->qglview->updateGL();
} else {
viewModeThrownTogether();
}
@@ -1522,6 +1523,7 @@ void MainWindow::viewModeCGALGrid()
viewActionCGALGrid->setChecked(true);
this->qglview->setShowFaces(false);
this->qglview->setRenderer(this->cgalRenderer);
+ this->qglview->updateGL();
}
#endif /* ENABLE_CGAL */
@@ -1531,6 +1533,7 @@ void MainWindow::viewModeThrownTogether()
viewModeActionsUncheck();
viewActionThrownTogether->setChecked(true);
this->qglview->setRenderer(this->thrownTogetherRenderer);
+ this->qglview->updateGL();
}
void MainWindow::viewModeShowEdges()
diff --git a/src/qglview.cc b/src/qglview.cc
index 0afaa4b..7b193ec 100644
--- a/src/qglview.cc
+++ b/src/qglview.cc
@@ -59,7 +59,7 @@
#define FAR_FAR_AWAY 100000.0
-QGLView::QGLView(QWidget *parent) : QGLWidget(parent), renderer(NULL)
+QGLView::QGLView(QWidget *parent) : QGLWidget(parent)
{
init();
}
@@ -113,12 +113,6 @@ void QGLView::init()
#endif
}
-void QGLView::setRenderer(Renderer *r)
-{
- this->renderer = r;
- if (r) updateGL(); // Let the last image stay, e.g. to avoid animation flickering
-}
-
void QGLView::initializeGL()
{
glEnable(GL_DEPTH_TEST);
contact: Jan Huwald // Impressum