40 #ifndef __OPENCV_HIGHGUI_QT_H__
41 #define __OPENCV_HIGHGUI_QT_H__
44 #pragma warning(disable:4503)
46 #pragma warning(disable:4996 4251 4275 4800)
48 #include "opencv2/core/utility.hpp"
49 #include "opencv2/highgui/highgui_c.h"
50 #include "opencv2/imgproc.hpp"
52 #include <QAbstractEventDispatcher>
53 #include <QApplication>
55 #include <QPushButton>
56 #include <QGraphicsView>
57 #include <QSizePolicy>
58 #include <QInputDialog>
62 #include <QtConcurrent/QtConcurrentRun>
63 #include <QWaitCondition>
65 #include <QMetaObject>
72 #include <QVarLengthArray>
75 #include <QFileDialog>
78 #include <QPushButton>
80 #include <QRadioButton>
81 #include <QButtonGroup>
85 #include <boost/thread/mutex.hpp>
86 #include <boost/thread/recursive_mutex.hpp>
87 #include <boost/thread/condition_variable.hpp>
96 enum { CV_MODE_NORMAL = 0, CV_MODE_OPENGL = 1 };
100 shortcut_zoom_normal = Qt::CTRL + Qt::Key_Z,
101 shortcut_zoom_imgRegion = Qt::CTRL + Qt::Key_X,
102 shortcut_save_img = Qt::CTRL + Qt::Key_S,
103 shortcut_edit_pen_img = Qt::CTRL + Qt::Key_E,
104 shortcut_properties_win = Qt::CTRL + Qt::Key_P,
105 shortcut_zoom_in = Qt::CTRL + Qt::Key_Plus,
106 shortcut_zoom_out = Qt::CTRL + Qt::Key_Minus,
107 shortcut_panning_left = Qt::CTRL + Qt::Key_Left,
108 shortcut_panning_right = Qt::CTRL + Qt::Key_Right,
109 shortcut_panning_up = Qt::CTRL + Qt::Key_Up,
110 shortcut_panning_down = Qt::CTRL + Qt::Key_Down,
111 shortcut_always_top = Qt::CTRL + Qt::Key_T
115 #define _WINDOW_MATRIX_CREATION_MODE 0x00010000
124 void addWidget(QWidget* obj);
128 void closeEvent(QCloseEvent * e);
129 void showEvent(QShowEvent * event);
130 void hideEvent(QHideEvent * event);
134 QPushButton* _updateMatrix;
135 QComboBox* _matrixTypes;
136 QComboBox* _matrixVals;
139 QLineEdit* _channels;
141 QPushButton* color_choose;
142 QLineEdit* pencilSize;
144 QPointer<QBoxLayout> myLayout;
150 #define __ACT_IMGRAPH_LOAD 0
151 #define __ACT_IMGRAPH_SAVE __ACT_IMGRAPH_LOAD +1
152 #define __ACT_IMGRAPH_LEFT __ACT_IMGRAPH_SAVE +1
153 #define __ACT_IMGRAPH_RIGHT __ACT_IMGRAPH_LEFT +1
154 #define __ACT_IMGRAPH_UP __ACT_IMGRAPH_RIGHT +1
155 #define __ACT_IMGRAPH_DOWN __ACT_IMGRAPH_UP +1
156 #define __ACT_IMGRAPH_ZOOM_X1 __ACT_IMGRAPH_DOWN +1
157 #define __ACT_IMGRAPH_ZOOM_IN __ACT_IMGRAPH_ZOOM_X1 +1
158 #define __ACT_IMGRAPH_ZOOM_OUT __ACT_IMGRAPH_ZOOM_IN +1
159 #define __ACT_IMGRAPH_PEN_EDIT __ACT_IMGRAPH_ZOOM_OUT +1
160 #define __ACT_IMGRAPH_ONTOP __ACT_IMGRAPH_PEN_EDIT +1
167 MatrixViewer(QString arg2,
int flag = CV_WINDOW_NORMAL);
170 void writeSettings();
174 void setPropWindow(
int flags);
176 bool isPencil_mode()
const {
return pencil_mode; };
178 void toggleFullScreen(
int flags);
180 void updateImage(cv::Mat arr);
183 void displayInfo(QString text,
int delayms);
184 void displayStatusBar(QString text,
int delayms);
186 void enablePropertiesButton();
188 void setViewportSize(QSize size);
195 int param_creation_mode;
197 QPointer<QBoxLayout> myGlobalLayout;
199 QVector<QAction*> vect_QActions;
201 QPointer<QStatusBar> myStatusBar;
202 QPointer<QToolBar> myToolBar;
203 QPointer<QLabel> myStatusBar_msg;
206 void changePenSize();
208 virtual void keyPressEvent(QKeyEvent* event);
217 QVector<QShortcut*> vect_QShortcuts;
219 void createActions();
220 void createShortcuts();
222 void createGlobalLayout();
227 QSize getAvailableSize();
230 void displayPropertiesWin();
231 void switchEditingImg();
237 enum _typemouse_event { mouse_up = 0, mouse_down = 1, mouse_dbclick = 2, mouse_move = 3 };
238 static const int tableMouseButtons[][3] = {
239 { CV_EVENT_LBUTTONUP, CV_EVENT_RBUTTONUP, CV_EVENT_MBUTTONUP },
240 { CV_EVENT_LBUTTONDOWN, CV_EVENT_RBUTTONDOWN, CV_EVENT_MBUTTONDOWN },
241 { CV_EVENT_LBUTTONDBLCLK, CV_EVENT_RBUTTONDBLCLK, CV_EVENT_MBUTTONDBLCLK },
242 { CV_EVENT_MOUSEMOVE, CV_EVENT_MOUSEMOVE, CV_EVENT_MOUSEMOVE }
251 virtual QWidget* getWidget() = 0;
253 virtual void writeSettings(QSettings& settings) = 0;
254 virtual void readSettings(QSettings& settings) = 0;
256 virtual void updateImage(
const cv::Mat arr) = 0;
258 virtual void startDisplayInfo(QString text,
int delayms) = 0;
260 virtual void setSize(QSize size_) = 0;
271 boost::recursive_mutex _mtx;
276 QWidget* getWidget();
278 void writeSettings(QSettings& settings);
279 void readSettings(QSettings& settings);
282 void setRatio(
int flags);
284 void updateImage(
const cv::Mat arr);
286 void startDisplayInfo(QString text,
int delayms);
288 void setSize(QSize size_);
290 void updateViewport(){ viewport()->update(); };
297 void siftWindowOnLeft();
298 void siftWindowOnRight();
299 void siftWindowOnUp();
300 void siftWindowOnDown();
309 QColor getPenColor()
const {
return myPenColor; }
310 void setPenColor(QColor val) { myPenColor = val; }
311 float getPenSize()
const {
return myPenWidth; }
312 void setPenSize(
float newSize) { myPenWidth = newSize; }
317 void contextMenuEvent(QContextMenuEvent* event);
318 void resizeEvent(QResizeEvent* event);
319 void paintEvent(QPaintEvent* paintEventInfo);
320 void wheelEvent(QWheelEvent* event);
321 void mouseMoveEvent(QMouseEvent* event);
322 void mousePressEvent(QMouseEvent* event);
323 void mouseReleaseEvent(QMouseEvent* event);
324 void mouseDoubleClickEvent(QMouseEvent* event);
326 void drawLineTo(
const QPointF &endPoint);
327 QPoint toImgCoord(QPointF src);
336 QTransform param_matrixWorld;
338 cv::Mat image2Draw_mat;
340 QImage image2Draw_qt;
341 int nbChannelOriginImage;
343 void scaleView(qreal scaleFactor, QPointF center);
344 void moveView(QPointF delta);
346 QPoint mouseCoordinate;
347 QPoint positionGrabbing;
348 QRect positionCorners;
349 QTransform matrixWorld_inv;
350 float ratioX, ratioY;
352 bool isSameSize(IplImage* img1, IplImage* img2);
354 QSize sizeHint()
const;
355 QPointer<MatrixViewer> centralWidget;
356 QPointer<QTimer> timerDisplay;
365 QLineEdit *imgEditPixel_R;
366 QLineEdit *imgEditPixel_G;
367 QLineEdit *imgEditPixel_B;
368 QLineEdit *imgEditPixel_A;
370 void drawInstructions(QPainter *painter);
371 void drawViewOverview(QPainter *painter);
372 void drawImgRegion(QPainter *painter);
373 void draw2D(QPainter *painter);
374 void drawStatusBar();
375 void controlImagePosition();
376 void icvmouseProcessing(QPointF pt,
int cv_event,
int flags);
379 void stopDisplayInfo();
Definition: MatrixViewer.h:266
Definition: MatrixViewer.h:162
Definition: MatrixViewer.h:246