MainDisplay.qt.H

00001 #ifndef MAINDISPLAY_QT_H
00002 #define MAINDISPLAY_QT_H
00003 
00004 #include <QtGui/qwidget.h>
00005 #include <QtGui/qgraphicsscene.h>
00006 #include <QtGui/qgraphicsview.h>
00007 
00008 //#include "NeovisionII/NeoAnnotate/ImageGraphicsItem.qt.H"
00009 #include "Qt4/ImageGraphicsItem.qt.H"
00010 #include "NeovisionII/NeoAnnotate/AnnotationObject.qt.H"
00011 #include "QtUtil/ImageConvert4.H"
00012 
00013 //MainDisplay is the widget which is responsible for drawing the main image as
00014 //well as the handling the drawing, moving, etc. of the object outlines
00015 class MainDisplay : public QGraphicsView
00016 {
00017   Q_OBJECT
00018 
00019   public:
00020     //! Construct the Main Display
00021     /*! Set all sorts of Qt related parameters, and preload the cursor icons */
00022     MainDisplay(QWidget *parent = 0);
00023 
00024     //! Set the background image
00025     void setImage(QImage img);
00026 
00027     //! Add a new annotation object to be displayed/maniuplated
00028     void addObject(AnnotationObject * object);
00029 
00030     //! The three ways to manipulate annotation objects
00031     /*! Which of these is the current itsActionMode will determine
00032      *  how mouse events are handled, and whether they are passed
00033      *  through to the Qt subsystem*/
00034     enum ActionMode {Edit, Add, Remove, Rotate};
00035   public slots:
00036 
00037     //! Scale our Graphics View up
00038     void zoomIn();
00039 
00040     //! Scale our Graphics View down
00041     void zoomOut();
00042 
00043     //! Set the current action mode to 'cursor' and change the mouse icon
00044     void setActionMode_Cursor();
00045 
00046     //! Set the current action mode to 'add vertex' and change the mouse icon
00047     void setActionMode_AddVertex();
00048 
00049     //! Set the current action mode to 'remove vertex' and change the mouse icon
00050     void setActionMode_RemVertex();
00051 
00052     //! Set the current action mode to 'rotate' and change the mouse icon
00053     void setActionMode_Rotate();
00054 
00055   signals:
00056     //! Emit a signal telling the Object Manager to tell the appropriate object to add a vertex
00057     void addVertex(QPointF);
00058 
00059     //! Emit a signal telling the Object Manager to tell the appropriate object to remove a vertex
00060     void removeVertex(QPointF);
00061 
00062   protected:
00063 
00064     //! Perform an action based on the current action mode
00065     void mousePressEvent(QMouseEvent * event);
00066 
00067   private:
00068     //! The Graphics Item which is responsible for drawing the background image
00069     ImageGraphicsItem *itsImageDisplay;
00070 
00071     //! This Graphics Scene holds the background image, and all annotation objects
00072     QGraphicsScene *itsScene;
00073 
00074     //! The current action mode - see mousePressEvent()
00075     ActionMode itsActionMode;
00076 
00077     //! A default cursor icon
00078     QCursor itsEditCursor;
00079     QCursor itsAddCursor;
00080     QCursor itsRemCursor;
00081     QCursor itsRotCursor;
00082 };
00083 
00084 #endif //MAINDISPLAY_QT_H
00085 
Generated on Sun May 8 08:41:02 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3