diff options
| -rw-r--r-- | openscad.pro | 2 | ||||
| -rw-r--r-- | src/CsgInfo.h | 6 | ||||
| -rw-r--r-- | src/GLView.cc | 41 | ||||
| -rw-r--r-- | src/GLView.h | 54 | ||||
| -rw-r--r-- | src/OffscreenView.cc | 6 | ||||
| -rw-r--r-- | src/OffscreenView.h | 6 | ||||
| -rw-r--r-- | src/QGLView.h | 10 | ||||
| -rw-r--r-- | src/export_png.cc | 10 | ||||
| -rw-r--r-- | src/mainwin.cc | 3 | ||||
| -rw-r--r-- | src/qglview.cc | 8 | 
10 files changed, 116 insertions, 30 deletions
| diff --git a/openscad.pro b/openscad.pro index c0995c6..18d9dae 100644 --- a/openscad.pro +++ b/openscad.pro @@ -180,6 +180,7 @@ HEADERS += src/version_check.h \             src/CGAL_renderer.h \             src/OGL_helper.h \             src/QGLView.h \ +           src/GLView.h \             src/MainWindow.h \             src/Preferences.h \             src/OpenCSGWarningDialog.h \ @@ -285,6 +286,7 @@ SOURCES += src/version_check.cc \             src/OpenCSGWarningDialog.cc \             src/editor.cc \             src/qglview.cc \ +           src/GLView.cc \             \             src/builtin.cc \             src/export.cc \ 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 ¢er); // +	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 ¢er); // +	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); | 
