diff options
| -rw-r--r-- | glview.cc | 9 | ||||
| -rw-r--r-- | mainwin.cc | 24 | ||||
| -rw-r--r-- | openscad.h | 7 | 
3 files changed, 35 insertions, 5 deletions
| @@ -35,6 +35,8 @@ GLView::GLView(QWidget *parent) : QGLWidget(parent)  	last_mouse_x = 0;  	last_mouse_y = 0; +	orthomode = false; +  	renderfunc = NULL;  	renderfunc_vp = NULL; @@ -168,7 +170,12 @@ void GLView::paintGL()  	glMatrixMode(GL_PROJECTION);  	glLoadIdentity(); -	glFrustum(-w_h_ratio, +w_h_ratio, -(1/w_h_ratio), +(1/w_h_ratio), +10.0, +FAR_FAR_AWAY); +	if (orthomode) +		glOrtho(-w_h_ratio*viewer_distance/10, +w_h_ratio*viewer_distance/10, +				-(1/w_h_ratio)*viewer_distance/10, +(1/w_h_ratio)*viewer_distance/10, +				-FAR_FAR_AWAY, +FAR_FAR_AWAY); +	else +		glFrustum(-w_h_ratio, +w_h_ratio, -(1/w_h_ratio), +(1/w_h_ratio), +10.0, +FAR_FAR_AWAY);  	gluLookAt(0.0, -viewer_distance, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0);  	glMatrixMode(GL_MODELVIEW); @@ -172,9 +172,12 @@ MainWindow::MainWindow(const char *filename)  		menu->addAction("Front", this, SLOT(viewAngleFront()));  		menu->addAction("Back", this, SLOT(viewAngleBack()));  		menu->addAction("Diagonal", this, SLOT(viewAngleDiagonal())); +  		menu->addSeparator(); -		menu->addAction("Perspective"); -		menu->addAction("Orthogonal"); +		actViewPerspective = menu->addAction("Perspective", this, SLOT(viewPerspective())); +		actViewPerspective->setCheckable(true); +		actViewOrthogonal = menu->addAction("Orthogonal", this, SLOT(viewOrthogonal())); +		actViewOrthogonal->setCheckable(true);  	}  	console->setReadOnly(true); @@ -205,6 +208,7 @@ MainWindow::MainWindow(const char *filename)  #else  	viewModeThrownTogether();  #endif +	viewPerspective();  	setCentralWidget(s1);  	current_win = NULL; @@ -1173,3 +1177,19 @@ void MainWindow::viewAngleDiagonal()  	screen->updateGL();  } +void MainWindow::viewPerspective() +{ +	actViewPerspective->setChecked(true); +	actViewOrthogonal->setChecked(false); +	screen->orthomode = false; +	screen->updateGL(); +} + +void MainWindow::viewOrthogonal() +{ +	actViewPerspective->setChecked(false); +	actViewOrthogonal->setChecked(true); +	screen->orthomode = true; +	screen->updateGL(); +} + @@ -644,6 +644,7 @@ public:  	void (*renderfunc)(void*);  	void *renderfunc_vp; +	bool orthomode;  	double viewer_distance;  	double object_rot_y;  	double object_rot_z; @@ -751,6 +752,8 @@ public:  	QAction *actViewModeThrownTogether;  	QAction *actViewModeShowEdges;  	QAction *actViewModeAnimate; +	QAction *actViewPerspective; +	QAction *actViewOrthogonal;  	void viewModeActionsUncheck();  private slots: @@ -764,8 +767,6 @@ private slots:  	void viewModeThrownTogether();  	void viewModeShowEdges();  	void viewModeAnimate(); - -private slots:  	void viewAngleTop();  	void viewAngleBottom();  	void viewAngleLeft(); @@ -773,6 +774,8 @@ private slots:  	void viewAngleFront();  	void viewAngleBack();  	void viewAngleDiagonal(); +	void viewPerspective(); +	void viewOrthogonal();  };  extern AbstractModule *parse(const char *text, int debug); | 
