Main Page | Class Hierarchy | Compound List | File List | Compound Members

object.h

00001 /***************************************************************************
00002                            object.h
00003                            -------------------
00004     copyright            : (C) 2004 by Jos van den Oever
00005     email                : jos@vandenoever.info
00006  ***************************************************************************/
00007 
00008 /***************************************************************************
00009  *                                                                         *
00010  *   This program is free software; you can redistribute it and/or modify  *
00011  *   it under the terms of the GNU General Public License as published by  *
00012  *   the Free Software Foundation; either version 2 of the License, or     *
00013  *   (at your option) any later version.                                   *
00014  *                                                                         *
00015  ***************************************************************************/
00016 
00017 #ifndef OBJECT_H
00018 #define OBJECT_H
00019 
00020 #include <qwidget.h>
00021 #include <qwmatrix.h>
00022 #include <qpixmap.h>
00023 #include <vector>
00024 #include <map>
00025 #include <list>
00026 
00027 #include "side.h"
00028 #include "matrix3d.h"
00029 
00030 using namespace std;
00031 class QPicture;
00032 
00033 /* this class implements an object that can be rotate by dragging over it with
00034    the mouse */
00035 class Object : public QWidget {
00036 Q_OBJECT
00037 public:
00038         Object(QWidget *, const char *name="");
00039         void addSide(const Side &);
00040         Side &getSide(short i);
00041         const Side &getSide(short i) const;
00042         bool hasPicture(const QPicture *p1, short i) const;
00043         void reset();
00044         void saveOrientation();
00045         void animateToSavedOrientation();
00046         void stopAnimation();
00047         void setPicture(short i, const QPicture *p);
00048         void setOrient(double t, double p, double r);
00049 public slots:
00050         void rotateX(double);
00051         void rotateY(double);
00052         void rotateZ(double);
00053 private slots:
00054         void animationStep();
00055 protected:
00056         void paintEvent(QPaintEvent *);
00057         void mouseMoveEvent ( QMouseEvent * e );
00058         void mousePressEvent(QMouseEvent *e);
00059         void mouseReleaseEvent(QMouseEvent *e);
00060         void resizeEvent ( QResizeEvent * );
00061         void updateMatrices();
00062 private:
00063         short elements;
00064         int lastX, lastY;
00065         bool firstMouseEvent;
00066         bool changed;
00067         bool grabbing;
00068         bool movedSinceMousePress;
00069         double scaling;
00070         double maxdist;
00071         bool animate;
00072 
00073         Matrix3D m;
00074         QPixmap buffer;
00075         list<pair<Side, short> > sides;
00076 signals:
00077         void animationFinished();
00078         void rotatedX(double);
00079         void rotatedY(double);
00080         void rotatedZ(double);
00081         void rotated();
00082 };
00083 
00084 #endif

Generated on Thu Jan 15 23:13:57 2004 for CubeTest by doxygen 1.3.2