/**************************************************************************** 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 "eventRecorder.h" #include using namespace std; using namespace qglviewer; // Draws a spiral void Viewer::draw() { const float nbSteps = 200.0; glBegin(GL_QUAD_STRIP); for (float i=0; ikey() == Qt::Key_R) { #if QT_VERSION < 0x040000 if (e->state() & Qt::ShiftButton) #else if (e->modifiers() & Qt::ShiftModifier) #endif eventRecorder_->openReplayInterfaceWindow(); else { eventRecorder_->toggleRecording(); updateGL(); } } else QGLViewer::keyPressEvent(e); } void Viewer::setManipulatedFrame(ManipulatedFrame* fr) { #if QT_VERSION >= 300 // Qt 2.3 has problems with inherited signals. if ((manipulatedFrame()) && (manipulatedFrame() != camera()->frame())) { disconnect(manipulatedFrame(), SIGNAL(spinned()), eventRecorder(), SLOT(recordFrameState())); disconnect(manipulatedFrame(), SIGNAL(interpolated()), eventRecorder(), SLOT(recordFrameState())); } #endif QGLViewer::setManipulatedFrame(fr); #if QT_VERSION >= 300 // Qt 2.3 has problems with inherited signals. if ((manipulatedFrame()) && (manipulatedFrame() != camera()->frame())) { connect(manipulatedFrame(), SIGNAL(spinned()), eventRecorder(), SLOT(recordFrameState())); connect(manipulatedFrame(), SIGNAL(interpolated()), eventRecorder(), SLOT(recordFrameState())); } #endif } void Viewer::postDraw() { QGLViewer::postDraw(); // Red dot when EventRecorder is active if (eventRecorder_->isRecording()) { startScreenCoordinatesSystem(); glDisable(GL_LIGHTING); glDisable(GL_DEPTH_TEST); glPointSize(12.0); glColor3f(1.0, 0.0, 0.0); glBegin(GL_POINTS); glVertex2i(width()-20, 20); glEnd(); glEnable(GL_DEPTH_TEST); stopScreenCoordinatesSystem(); // restore foregroundColor qglColor(foregroundColor()); } } QString Viewer::helpString() const { QString text("

E v e n t R e c o r d e r

"); text += "An EventRecorder records all mouse and keyboard events (and more) "; text += "and is then able to replay the recorded scenario.

"; text += "Press R to strat/stop the recording.

"; text += "Press Shift+R to open the replay interface window. You can then "; text += "replay and save the scenario. You can also save snapshots during replay, "; text += "which can be used to create a movie out of your application."; return text; }