00001 #ifndef _IMAGE_ITEM_HPP_
00002 #define _IMAGE_ITEM_HPP_
00003
00004 #include <QObject>
00005 #include <QGraphicsItemGroup>
00006
00007 #include <image/Image.hpp>
00008 #include <string>
00009
00010 class QAction;
00011
00012 namespace jafar {
00013 namespace qdisplay {
00014
00015 class AbstractEventHandler;
00016 class Line;
00017 class Shape;
00018 class Viewer;
00019 class PolyLine;
00025 class ImageView : public QObject, public QGraphicsItemGroup {
00026 Q_OBJECT
00027 public:
00028 ImageView();
00033 ImageView(const jafar::image::Image& img);
00034
00038 ImageView(const std::string& filename);
00039
00041 ~ImageView();
00042
00043 void connectEvents();
00044 int imageWidth() const;
00045 int imageHeight() const;
00049 void setImage(const jafar::image::Image& img);
00053 void addShape(Shape* si);
00057 void removeShape(Shape* si);
00061 void addLine(Line* li);
00065 void removeLine(Line* li);
00066
00067 void addPolyLine(qdisplay::PolyLine* pl);
00068
00075 inline void setEventHandler(AbstractEventHandler* eh) { m_eventHandler = eh; }
00076
00078 void exportView( const std::string& _fileName );
00079
00080 public slots:
00081 void lutRandomize();
00082 void lutGrayscale();
00083 void lutInvertGrayscale();
00084 void lutRedHot();
00085 void exportView();
00086 void splitVertical();
00087 void splitHorizontal();
00088 void addShape();
00089 protected:
00090 void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
00091 public:
00092 QRectF boundingRect () const;
00093 void hoverMoveEvent ( QGraphicsSceneHoverEvent * event );
00094 void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
00095 private:
00096 QAction *m_lutRandomizeAction, *m_lutGrayscaleAction, *m_lutInvertGrayscaleAction, *m_lutRedHotAction, *m_exportView, * m_splitVerticalAction,*m_splitHorizontalAction,*m_addShapeAction;
00097 QImage m_image;
00098 QGraphicsPixmapItem* m_pixmapItem;
00099 double m_currentZ;
00100 AbstractEventHandler* m_eventHandler;
00101 Viewer* m_lastViewer;
00102 };
00103
00104 }
00105
00106 }
00107
00108 #endif