/**************************************************************************** Copyright (C) 2002-2006 Gilles Debunne (Gilles.Debunne@imag.fr) This file is part of the QGLViewer library. Version 2.2.4-1, released on December 12, 2006. http://artis.imag.fr/Members/Gilles.Debunne/QGLViewer libQGLViewer 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 2 of the License, or (at your option) any later version. libQGLViewer 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 libQGLViewer; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *****************************************************************************/ #include "viewer.h" #include "standardCamera.h" using namespace std; using namespace qglviewer; Viewer::Viewer(StandardCamera* nfc) { // Change the camera. Camera* c = camera(); setCamera(nfc); delete c; } // Draws a spiral void Viewer::draw() { const float nbSteps = 200.0; glBegin(GL_QUAD_STRIP); for (int i=0; iisStandard()?"Standard camera":"QGLViewer camera"; QString type = camera()->type() == Camera::PERSPECTIVE?"Perspective":"Orthogonal"; displayMessage(std + " - " + type); emit cameraChanged(); } void Viewer::keyPressEvent(QKeyEvent *e) { if (e->key() == Qt::Key_M) { // 'M' changes mode : standard or QGLViewer camera ((StandardCamera*)camera())->toggleMode(); showMessage(); } else if (e->key() == Qt::Key_T) { // 'T' changes the projection type : perspective or orthogonal if (camera()->type() == Camera::ORTHOGRAPHIC) camera()->setType(Camera::PERSPECTIVE); else camera()->setType(Camera::ORTHOGRAPHIC); showMessage(); } else QGLViewer::keyPressEvent(e); } void Viewer::wheelEvent(QWheelEvent *e) { if ((camera()->type() == Camera::ORTHOGRAPHIC) && (((StandardCamera*)camera())->isStandard()) && #if QT_VERSION >= 0x040000 (e->modifiers() & Qt::ShiftModifier)) #else (e->state() & Qt::ShiftButton)) #endif { ((StandardCamera*)camera())->changeOrthoFrustumSize(e->delta()); emit cameraChanged(); updateGL(); } else QGLViewer::wheelEvent(e); } QString Viewer::helpString() const { QString text("

S t a n d a r d C a m e r a

"); text += "An overloaded Camera class is used, that reproduces the 'standard' OpenGL settings.

"; text += "With this camera, the near and (resp. far) plane distance is set to a very small (resp. very large) value. "; text += "With the orthographic camera type, the frustum dimensions are fixed. Use Shift and the mouse wheel to change them.

"; text += "On the other hand, the QGLViewer camera fits the near and far distances to the scene radius. "; text += "Fine tuning is available using zClippingCoefficient() and zNearCoefficient(). "; text += "However, visual results do not seem to be impacted by this zBuffer fitted range.

"; text += "The QGLViewer camera also adapts the orthographic frustum dimensions to the distance to the revolveAroundPoint() to mimic a perspective camera. "; text += "Since this behavior may not be needed, this example shows how to override it.

"; text += "The second viewer displays the first one's camera to show its configuration.

"; text += "Use M to switch between 'standard' and QGLViewer camera behavior.
"; text += "Use T to switch between perspective and orthographic camera type."; return text; }