mirror of
https://github.com/opencv/opencv.git
synced 2025-01-20 07:34:42 +08:00
QT new functions:
- Add toolbar - Clean the code - Window properties in progress
This commit is contained in:
parent
b8535d1726
commit
ddc29e08be
@ -77,12 +77,15 @@ if (HAVE_QT)
|
||||
set(QT_USE_QTOPENGL TRUE)
|
||||
endif()
|
||||
INCLUDE(${QT_USE_FILE})
|
||||
|
||||
|
||||
SET(_RCCS_FILES src/window_QT.qrc)
|
||||
QT4_ADD_RESOURCES(_RCC_OUTFILES ${_RCCS_FILES})
|
||||
|
||||
SET(_MOC_HEADERS src/window_QT.h )
|
||||
QT4_WRAP_CPP(_MOC_OUTFILES ${_MOC_HEADERS})
|
||||
|
||||
set(HIGHGUI_LIBRARIES ${HIGHGUI_LIBRARIES} ${QT_LIBRARIES})
|
||||
set(highgui_srcs ${highgui_srcs} src/window_QT.cpp ${_MOC_OUTFILES})
|
||||
set(highgui_srcs ${highgui_srcs} src/window_QT.cpp ${_MOC_OUTFILES} ${_RCC_OUTFILES} )
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
|
@ -72,6 +72,11 @@ enum { CV_STYLE_NORMAL = 0,//QFont::StyleNormal,
|
||||
};
|
||||
/* ---------*/
|
||||
|
||||
//the first bit is for normal or autoresize
|
||||
//CV_WINDOW_NORMAL = 0x00000000 and CV_WINDOW_AUTOSIZE = 0x00000001
|
||||
//the secont bit is for the gui mode (normal or extended)
|
||||
enum {CV_GUI_EXTENDED = 0x00000000, CV_GUI_NORMAL = 0x00000010};
|
||||
|
||||
//for color cvScalar(blue_component, green_component, red\_component[, alpha_component])
|
||||
//and alpha= 0 <-> 0xFF (not transparent <-> transparent)
|
||||
CVAPI(CvFont) cvFont_Qt(const char* nameFont, int pointSize CV_DEFAULT(-1), CvScalar color CV_DEFAULT(cvScalarAll(0)), int weight CV_DEFAULT(CV_FONT_NORMAL), int style CV_DEFAULT(CV_STYLE_NORMAL), int spacing CV_DEFAULT(0));
|
||||
@ -96,23 +101,26 @@ CVAPI(int) cvInitSystem( int argc, char** argv );
|
||||
|
||||
CVAPI(int) cvStartWindowThread();
|
||||
|
||||
enum { CV_WINDOW_AUTOSIZE = 1 };
|
||||
|
||||
/* create window */
|
||||
CVAPI(int) cvNamedWindow( const char* name, int flags CV_DEFAULT(CV_WINDOW_AUTOSIZE) );
|
||||
|
||||
// --------- YV ---------
|
||||
enum
|
||||
{
|
||||
CV_WND_PROP_FULLSCREEN = 0,
|
||||
CV_WND_PROP_AUTOSIZE = 1,
|
||||
CV_WND_PROP_ASPECTRATIO= 2,
|
||||
CV_WINDOW_NORMAL = 0,
|
||||
CV_WINDOW_FULLSCREEN = 1,
|
||||
CV_WINDOW_FREERATIO = 0,
|
||||
CV_WINDOW_KEEPRATIO = 1
|
||||
//These 3 flags are used by cvSet/GetWindowProperty
|
||||
CV_WND_PROP_FULLSCREEN = 0,//to change/get window's fullscreen property
|
||||
CV_WND_PROP_AUTOSIZE = 1,//to change/get window's autosize property
|
||||
CV_WND_PROP_ASPECTRATIO= 2,//to change/get window's aspectratio property
|
||||
//
|
||||
//These 2 flags are used by cvNamedWindow and cvSet/GetWindowProperty
|
||||
CV_WINDOW_NORMAL = 0,//the user can resize the window (no constraint)
|
||||
CV_WINDOW_AUTOSIZE = 1,//the user cannot resize the window, the size is constrainted by the image displayed
|
||||
//
|
||||
//These 2 flags are used by cvNamedWindow and cvSet/GetWindowProperty
|
||||
CV_WINDOW_FULLSCREEN = 1,//change the window to fullscreen
|
||||
CV_WINDOW_FREERATIO = 0,//the image expends as much as it can (no ratio constraint)
|
||||
CV_WINDOW_KEEPRATIO = 1//the ration image is respected.
|
||||
};
|
||||
|
||||
/* create window */
|
||||
CVAPI(int) cvNamedWindow( const char* name, int flags CV_DEFAULT(CV_WINDOW_AUTOSIZE) );
|
||||
|
||||
/* Set and Get Property of the window */
|
||||
CVAPI(void) cvSetWindowProperty(const char* name, int prop_id, double prop_value);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -72,8 +72,10 @@
|
||||
#include <QFileInfo>
|
||||
#include <QDate>
|
||||
#include <QFileDialog>
|
||||
#include <QToolBar>
|
||||
#include <QAction>
|
||||
|
||||
//start enum
|
||||
//start private enum
|
||||
enum {CV_MODE_NORMAL= 0, CV_MODE_OPENGL = 1};
|
||||
|
||||
//we can change the keyboard shortcuts from here !
|
||||
@ -155,6 +157,7 @@ private:
|
||||
|
||||
};
|
||||
|
||||
|
||||
class CvWindow : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -172,12 +175,14 @@ public:
|
||||
ViewPort* getView();
|
||||
|
||||
QPointer<QBoxLayout> layout;
|
||||
QPointer<QStatusBar> myBar;
|
||||
QPointer<QLabel> myBar_msg;
|
||||
QPointer<QStatusBar> myStatusBar;
|
||||
QPointer<QToolBar> myToolBar;
|
||||
QPointer<QLabel> myStatusBar_msg;
|
||||
|
||||
//parameters (will be save/load)
|
||||
QString param_name;
|
||||
int param_flags;
|
||||
int param_gui_mode;
|
||||
|
||||
|
||||
protected:
|
||||
@ -185,19 +190,17 @@ protected:
|
||||
|
||||
private:
|
||||
QPointer<ViewPort> myview;
|
||||
QPointer<QShortcut> shortcut_Z;
|
||||
QPointer<QShortcut> shortcut_S;
|
||||
QPointer<QShortcut> shortcut_P;
|
||||
QPointer<QShortcut> shortcut_X;
|
||||
QPointer<QShortcut> shortcut_Plus;
|
||||
QPointer<QShortcut> shortcut_Minus;
|
||||
QPointer<QShortcut> shortcut_Left;
|
||||
QPointer<QShortcut> shortcut_Right;
|
||||
QPointer<QShortcut> shortcut_Up;
|
||||
QPointer<QShortcut> shortcut_Down;
|
||||
QVector<QAction*> vect_QActions;
|
||||
QVector<QShortcut*> vect_QShortcuts;
|
||||
|
||||
void icvLoadTrackbars(QSettings *settings);
|
||||
void icvSaveTrackbars(QSettings *settings);
|
||||
|
||||
void createShortcuts();
|
||||
void createToolBar();
|
||||
void createView(int mode);
|
||||
void createStatusBar();
|
||||
void createLayout();
|
||||
};
|
||||
|
||||
|
||||
@ -253,6 +256,7 @@ public slots:
|
||||
void siftWindowOnDown();
|
||||
void resizeEvent ( QResizeEvent * );
|
||||
void saveView();
|
||||
void displayPropertiesWin();
|
||||
|
||||
private:
|
||||
QPoint mouseCoordinate;
|
||||
@ -260,11 +264,11 @@ private:
|
||||
QRect positionCorners;
|
||||
QTransform matrixWorld_inv;
|
||||
float ratioX, ratioY;
|
||||
|
||||
|
||||
//for mouse callback
|
||||
CvMouseCallback on_mouse;
|
||||
void* on_mouse_param;
|
||||
|
||||
|
||||
//for opengl callback
|
||||
CvOpenGLCallback on_openGL_draw3D;
|
||||
void* on_openGL_param;
|
||||
@ -304,66 +308,4 @@ private slots:
|
||||
void stopDisplayInfo();
|
||||
};
|
||||
|
||||
|
||||
|
||||
//here css for trackbar
|
||||
/* from http://thesmithfam.org/blog/2010/03/10/fancy-qslider-stylesheet */
|
||||
static const QString str_Trackbar_css = QString("")
|
||||
+ "QSlider::groove:horizontal {"
|
||||
+ "border: 1px solid #bbb;"
|
||||
+ "background: white;"
|
||||
+ "height: 10px;"
|
||||
+ "border-radius: 4px;"
|
||||
+ "}"
|
||||
|
||||
+ "QSlider::sub-page:horizontal {"
|
||||
+ "background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,"
|
||||
+ "stop: 0 #66e, stop: 1 #bbf);"
|
||||
+ "background: qlineargradient(x1: 0, y1: 0.2, x2: 1, y2: 1,"
|
||||
+ "stop: 0 #bbf, stop: 1 #55f);"
|
||||
+ "border: 1px solid #777;"
|
||||
+ "height: 10px;"
|
||||
+ "border-radius: 4px;"
|
||||
+ "}"
|
||||
|
||||
+ "QSlider::add-page:horizontal {"
|
||||
+ "background: #fff;"
|
||||
+ "border: 1px solid #777;"
|
||||
+ "height: 10px;"
|
||||
+ "border-radius: 4px;"
|
||||
+ "}"
|
||||
|
||||
+ "QSlider::handle:horizontal {"
|
||||
+ "background: qlineargradient(x1:0, y1:0, x2:1, y2:1,"
|
||||
+ "stop:0 #eee, stop:1 #ccc);"
|
||||
+ "border: 1px solid #777;"
|
||||
+ "width: 13px;"
|
||||
+ "margin-top: -2px;"
|
||||
+ "margin-bottom: -2px;"
|
||||
+ "border-radius: 4px;"
|
||||
+ "}"
|
||||
|
||||
+ "QSlider::handle:horizontal:hover {"
|
||||
+ "background: qlineargradient(x1:0, y1:0, x2:1, y2:1,"
|
||||
+ "stop:0 #fff, stop:1 #ddd);"
|
||||
+ "border: 1px solid #444;"
|
||||
+ "border-radius: 4px;"
|
||||
+ "}"
|
||||
|
||||
+ "QSlider::sub-page:horizontal:disabled {"
|
||||
+ "background: #bbb;"
|
||||
+ "border-color: #999;"
|
||||
+ "}"
|
||||
|
||||
+ "QSlider::add-page:horizontal:disabled {"
|
||||
+ "background: #eee;"
|
||||
+ "border-color: #999;"
|
||||
+ "}"
|
||||
|
||||
+ "QSlider::handle:horizontal:disabled {"
|
||||
+ "background: #eee;"
|
||||
+ "border: 1px solid #aaa;"
|
||||
+ "border-radius: 4px;"
|
||||
+ "}";
|
||||
|
||||
#endif
|
||||
|
15
modules/highgui/src/window_QT.qrc
Normal file
15
modules/highgui/src/window_QT.qrc
Normal file
@ -0,0 +1,15 @@
|
||||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file alias="left-icon">files_Qt/Milky/48/28.png</file>
|
||||
<file alias="right-icon">files_Qt/Milky/48/23.png</file>
|
||||
<file alias="up-icon">files_Qt/Milky/48/19.png</file>
|
||||
<file alias="down-icon">files_Qt/Milky/48/24.png</file>
|
||||
<file alias="zoom_x1-icon">files_Qt/Milky/48/27.png</file>
|
||||
<file alias="imgRegion-icon">files_Qt/Milky/48/61.png</file>
|
||||
<file alias="zoom_in-icon">files_Qt/Milky/48/106.png</file>
|
||||
<file alias="zoom_out-icon">files_Qt/Milky/48/107.png</file>
|
||||
<file alias="save-icon">files_Qt/Milky/48/7.png</file>
|
||||
<file alias="properties-icon">files_Qt/Milky/48/38.png</file>
|
||||
<file alias="stylesheet-trackbar">files_Qt/stylesheet_trackbar.qss</file>
|
||||
</qresource>
|
||||
</RCC>
|
Loading…
Reference in New Issue
Block a user