00001 /*!@file NeovisionII/ChipValidator/ChipValidatorQt.qt.H Simple GUI to validate chips */ 00002 00003 // //////////////////////////////////////////////////////////////////// // 00004 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2000-2005 // 00005 // by the 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: Laurent Itti 00034 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/Apps/BorderWatch/ChipValidatorQt.qt.H $ 00035 // $Id: ChipValidatorQt.qt.H 13059 2010-03-26 08:14:32Z itti $ 00036 // 00037 00038 #ifndef NEOVISIONII_CHIPVALIDATORQT_QT_H_DEFINED 00039 #define NEOVISIONII_CHIPVALIDATORQT_QT_H_DEFINED 00040 00041 #include <QtGui/QWidget> 00042 #include <QtGui/QLabel> 00043 #include <QtGui/QMouseEvent> 00044 class QGridLayout; 00045 class QApplication; 00046 00047 #include <vector> 00048 #include <string> 00049 00050 #include "Image/Image.H" 00051 #include "Image/PixelsTypes.H" 00052 00053 class ChipQLabel; // defined below 00054 00055 // ###################################################################### 00056 //! Simple struct for each chip 00057 struct ChipData { 00058 Image<PixRGB<byte> > image; 00059 std::string file; 00060 bool positive; 00061 }; 00062 00063 // ###################################################################### 00064 //! Simple GUI to display and browse BorderWatch results 00065 class ChipValidatorQt : public QWidget 00066 { 00067 Q_OBJECT 00068 00069 public: 00070 //! Constructor 00071 ChipValidatorQt(QApplication *qapp, std::vector<ChipData>& chipvec, const Dims& griddims, QWidget* parent = 0); 00072 00073 //! Destructor 00074 virtual ~ChipValidatorQt(); 00075 00076 //! A chip was clicked 00077 void chipClicked(const uint idx); 00078 00079 protected slots: 00080 void pageChanged(const int idx); 00081 00082 private: 00083 std::vector<ChipData>& itsChipVec; 00084 Dims itsGridDims; 00085 std::vector<ChipQLabel*> itsChipLabels; 00086 uint itsPage; 00087 QLabel *itsStatusLabel; 00088 00089 //! display an image in a chip 00090 void setChipImage(const uint idx); 00091 }; 00092 00093 00094 // ###################################################################### 00095 //! a clickable QLabel 00096 class ChipQLabel : public QLabel { 00097 00098 Q_OBJECT 00099 00100 public: 00101 ChipQLabel(const uint grididx, ChipValidatorQt *master, Qt::WindowFlags flags = 0) : 00102 QLabel(master, flags), itsGridIdx(grididx), itsMaster(master) 00103 { setMouseTracking(true); } 00104 00105 virtual ~ChipQLabel() { } 00106 00107 //! Override to catch button presses 00108 virtual void mousePressEvent(QMouseEvent *eve) 00109 { if (eve->button() == Qt::LeftButton) itsMaster->chipClicked(itsGridIdx); } 00110 00111 private: 00112 const uint itsGridIdx; 00113 ChipValidatorQt *itsMaster; 00114 }; 00115 00116 // ###################################################################### 00117 /* So things look consistent in everyone's emacs... */ 00118 /* Local Variables: */ 00119 /* mode: c++ */ 00120 /* indent-tabs-mode: nil */ 00121 /* End: */ 00122 00123 #endif // NEOVISIONII_CHIPVALIDATORQT_QT_H_DEFINED