poolimage.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #ifndef QT_POOL_IMAGE_H_DEFINED
00039 #define QT_POOL_IMAGE_H_DEFINED
00040
00041 #ifdef INVT_HAVE_QT3
00042
00043 #include <qgl.h>
00044
00045 class iconImage
00046 {
00047 public:
00048 iconImage(){};
00049 iconImage(int ax, int ay,int size)
00050 {
00051 x = ax; y = ay;
00052 edgeSize = size;
00053 selected = false;
00054 glx = (x - 300) * 0.01137; gly = (y - 220) * 0.01137;
00055 };
00056 void setPosition(int ax, int ay)
00057 {
00058 x = x + ax; y = y + ay;
00059 glx = glx + GLfloat(ax) * 0.01137;
00060 gly = gly - GLfloat(ay) * 0.01137;
00061 };
00062 iconImage operator=(const iconImage other)
00063 {
00064 iconImage temp;
00065 temp.x = other.x;
00066 temp.y = other.y;
00067 temp.glx = other.glx;
00068 temp.gly = other.gly;
00069 temp.selected = other.selected;
00070 temp.edgeSize = other.edgeSize;
00071 return temp;
00072 };
00073 int x, y;
00074 GLfloat glx, gly;
00075
00076 int selected;
00077 int edgeSize;
00078 };
00079 class PoolImage : public QGLWidget
00080 {
00081 public:
00082 PoolImage(QWidget * parent = 0, const char *name = 0);
00083 void createIcon(int num);
00084 void currentItem(int item);
00085 float getAngle();
00086 void getCoord(int i, int &x, int &y);
00087
00088 void setCoordByPix(int i, int x, int y);
00089 void setCoordByGL(int i, float glx, float gly);
00090
00091 void getRealPosition(int i, float &rx, float &ry);
00092 void getGLPosition(float rx, float ry, float &gx, float &gy);
00093
00094 inline void reset(){free(iconlist); sizeOfList = 0;};
00095 inline iconImage *getList(){return iconlist;};
00096
00097 float angle;
00098 float scale;
00099 protected:
00100 void initializeGL();
00101 void resizeGL(int w, int h);
00102 void paintGL();
00103
00104 void mousePressEvent(QMouseEvent *event);
00105 void mouseMoveEvent(QMouseEvent *event);
00106 void mouseDoubleClickEvent(QMouseEvent *event);
00107 void mouseReleaseEvent(QMouseEvent *event);
00108 private:
00109 void draw();
00110 bool right;
00111 QColor colors[7];
00112 QPoint lastPos;
00113 QPoint dragPos;
00114 int sizeOfList;
00115 int maxX, minX, maxY, minY;
00116 iconImage *iconlist;
00117 };
00118
00119 #endif // INVT_HAVE_QT3
00120
00121 #endif // QT_POOL_IMAGE_H_DEFINED
00122
00123
00124
00125
00126
00127
00128
00129