00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
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
00034
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