00001 /*!@file Qt/simulation.h */ 00002 00003 // //////////////////////////////////////////////////////////////////// // 00004 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2001 by the // 00005 // University of Southern California (USC) and the iLab at USC. // 00006 // See http://iLab.usc.edu for information about this project. // 00007 // //////////////////////////////////////////////////////////////////// // 00008 // Major portions of the iLab Neuromorphic Vision Toolkit are protected // 00009 // under the U.S. patent ``Computation of Intrinsic Perceptual Saliency // 00010 // in Visual Environments, and Applications'' by Christof Koch and // 00011 // Laurent Itti, California Institute of Technology, 2001 (patent // 00012 // pending; application number 09/912,225 filed July 23, 2001; see // 00013 // http://pair.uspto.gov/cgi-bin/final/home.pl for current status). // 00014 // //////////////////////////////////////////////////////////////////// // 00015 // This file is part of the iLab Neuromorphic Vision C++ Toolkit. // 00016 // // 00017 // The iLab Neuromorphic Vision C++ Toolkit is free software; you can // 00018 // redistribute it and/or modify it under the terms of the GNU General // 00019 // Public License as published by the Free Software Foundation; either // 00020 // version 2 of the License, or (at your option) any later version. // 00021 // // 00022 // The iLab Neuromorphic Vision C++ Toolkit is distributed in the hope // 00023 // that it will be useful, but WITHOUT ANY WARRANTY; without even the // 00024 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // 00025 // PURPOSE. See the GNU General Public License for more details. // 00026 // // 00027 // You should have received a copy of the GNU General Public License // 00028 // along with the iLab Neuromorphic Vision C++ Toolkit; if not, write // 00029 // to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, // 00030 // Boston, MA 02111-1307 USA. // 00031 // //////////////////////////////////////////////////////////////////// // 00032 // 00033 // Primary maintainer for this file: 00034 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/Qt/simulation.h $ 00035 // $Id: simulation.h 5796 2005-10-27 23:57:10Z rjpeters $ 00036 // 00037 00038 #include <qgl.h> 00039 00040 class iconImage 00041 { 00042 public: 00043 iconImage(){}; 00044 iconImage(int ax, int ay,int size) 00045 { 00046 x = ax; y = ay; 00047 edgeSize = size; 00048 selected = false; 00049 glx = (x - 300) * 0.01137; gly = (y - 220) * 0.01137; 00050 }; 00051 void setPosition(int ax, int ay) 00052 { 00053 x = x + ax; y = y + ay; 00054 glx = glx + GLfloat(ax) * 0.01137; 00055 gly = gly - GLfloat(ay) * 0.01137; 00056 }; 00057 iconImage operator=(const iconImage other) 00058 { 00059 iconImage temp; 00060 temp.x = other.x; 00061 temp.y = other.y; 00062 temp.glx = other.glx; 00063 temp.gly = other.gly; 00064 temp.selected = other.selected; 00065 temp.edgeSize = other.edgeSize; 00066 return temp; 00067 }; 00068 int x, y; 00069 GLfloat glx, gly; 00070 00071 int selected; 00072 int edgeSize; 00073 }; 00074 class Simulation : public QGLWidget 00075 { 00076 public: 00077 Simulation(QWidget * parent = 0, const char *name = 0); 00078 void createIcon(int num); 00079 void currentItem(int item); 00080 float getAngle(); 00081 void getCoord(int i, int &x, int &y); 00082 //void setAngle(float a); 00083 void setCoordByPix(int i, int x, int y); 00084 void setCoordByGL(int i, float glx, float gly); 00085 //void setScale(float a); 00086 void getRealPosition(int i, float &rx, float &ry); 00087 void getGLPosition(float rx, float ry, float &gx, float &gy); 00088 00089 inline void reset(){free(iconlist); sizeOfList = 0;}; 00090 inline iconImage *getList(){return iconlist;}; 00091 00092 float angle; 00093 float scale; 00094 protected: 00095 void initializeGL(); 00096 void resizeGL(int w, int h); 00097 void paintGL(); 00098 00099 void mousePressEvent(QMouseEvent *event); 00100 void mouseMoveEvent(QMouseEvent *event); 00101 //void mouseDoubleClickEvent(QMouseEvent *event); 00102 void mouseReleaseEvent(QMouseEvent *event); 00103 private: 00104 void draw(); 00105 bool right; 00106 QColor colors[7]; 00107 QPoint lastPos; 00108 QPoint dragPos; 00109 int sizeOfList; 00110 int maxX, minX, maxY, minY; 00111 iconImage *iconlist; 00112 };