00001 #ifndef _QDISPLAY_VIEWER_H_
00002 #define _QDISPLAY_VIEWER_H_
00003
00004 #include <QGraphicsView>
00005 #include <QStatusBar>
00006 #include <QGraphicsSceneMouseEvent>
00007 #include <QKeyEvent>
00008 #include <QMap>
00009
00010 namespace jafar {
00011 namespace qdisplay {
00012
00013 class ImageView;
00014 class Shape;
00015 class Line;
00016 class PolyLine;
00017 class Viewer;
00018
00019 class MouseGraphicsScene: public QGraphicsScene
00020 {
00021 private:
00022 Viewer* viewer;
00023 public:
00024 MouseGraphicsScene(Viewer* viewer): viewer(viewer) {}
00025 void mouseMoveEvent ( QGraphicsSceneMouseEvent * event );
00026 void mouseReleaseEvent ( QGraphicsSceneMouseEvent * mouseEvent );
00027 };
00028
00033 class Viewer : public QGraphicsView {
00034 Q_OBJECT
00035 public:
00041 Viewer(int mosaicWidth = 0, int mosaicHeight = 0, QGraphicsScene* scene = 0);
00042
00043 ~Viewer();
00044 void setBackgroundColor(int R, int G, int B);
00045 QGraphicsScene* scene() { return m_scene; }
00051 ImageView* imageItem(int row = 0, int col = 0)
00052 {
00053 return m_imageMosaic[row][col];
00054 }
00060 void setImageView(ImageView* ii, int row = 0, int col= 0);
00061 int rows();
00062 int cols();
00066 void addShape(qdisplay::Shape* si);
00067
00068 void splitVertical();
00069 void splitHorizontal();
00070
00074 void addLine(qdisplay::Line* li);
00075
00076 void addPolyLine(qdisplay::PolyLine* pl);
00077
00078 bool isVisible() { return !QGraphicsView::isHidden(); }
00082 void scaleView(qreal scaleFactor);
00088 void setWindowSize( int width, int height );
00092 void close();
00093
00094 void setTitle(const std::string& _title );
00095 void setTitleWithMouseCoordinates(double x, double y);
00096 std::string const& getTitle() { return title; }
00097
00105 void setStatusMessage(QString& infoString, int timeout=0);
00106
00111 void setStatusMessage(const char* infoString, int timeout=0);
00112
00116 void exportView( const std::string& fileName );
00117 public slots:
00118 void exportView();
00119
00120 signals:
00121 void onKeyPress(QKeyEvent *event);
00122 void onMouseClick(QGraphicsSceneMouseEvent *mouseEvent, bool isClick);
00123 void onMouseMove(QGraphicsSceneMouseEvent *mouseEvent);
00124 protected:
00125 virtual void contextMenuEvent ( QContextMenuEvent * event );
00126 virtual void keyPressEvent ( QKeyEvent * event );
00127 virtual void wheelEvent(QWheelEvent *event);
00128 virtual void resizeEvent(QResizeEvent * event);
00129 virtual void mouseReleaseEvent ( QMouseEvent * event );
00130 virtual void mouseMoveEvent ( QMouseEvent * event );
00131 private:
00132 QGraphicsScene* m_scene;
00133 friend class MouseGraphicsScene;
00134 QMap< int, QMap< int, ImageView* > > m_imageMosaic;
00135 int m_mosaicWidth, m_mosaicHeight;
00136 int m_windowWidth, m_windowHeight;
00137 double m_currentZ;
00138 QAction *m_exportView;
00139 std::string title;
00144 QCursor* crossCursor;
00148 void createCursor();
00149
00150
00155 QStatusBar *statusBar;
00156 QStatusBar *statusBarShadow;
00157
00158 };
00159
00160 }
00161 }
00162
00163 #endif