Commit ddc29e08 authored by Yannick Verdie's avatar Yannick Verdie

QT new functions:

 - Add toolbar
 - Clean the code
 - Window properties in progress
parent b8535d17
...@@ -77,12 +77,15 @@ if (HAVE_QT) ...@@ -77,12 +77,15 @@ if (HAVE_QT)
set(QT_USE_QTOPENGL TRUE) set(QT_USE_QTOPENGL TRUE)
endif() endif()
INCLUDE(${QT_USE_FILE}) 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 ) SET(_MOC_HEADERS src/window_QT.h )
QT4_WRAP_CPP(_MOC_OUTFILES ${_MOC_HEADERS}) QT4_WRAP_CPP(_MOC_OUTFILES ${_MOC_HEADERS})
set(HIGHGUI_LIBRARIES ${HIGHGUI_LIBRARIES} ${QT_LIBRARIES}) 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() endif()
if(WIN32) if(WIN32)
......
...@@ -72,6 +72,11 @@ enum { CV_STYLE_NORMAL = 0,//QFont::StyleNormal, ...@@ -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]) //for color cvScalar(blue_component, green_component, red\_component[, alpha_component])
//and alpha= 0 <-> 0xFF (not transparent <-> transparent) //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)); 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 ); ...@@ -96,23 +101,26 @@ CVAPI(int) cvInitSystem( int argc, char** argv );
CVAPI(int) cvStartWindowThread(); CVAPI(int) cvStartWindowThread();
enum { CV_WINDOW_AUTOSIZE = 1 };
/* create window */
CVAPI(int) cvNamedWindow( const char* name, int flags CV_DEFAULT(CV_WINDOW_AUTOSIZE) );
// --------- YV --------- // --------- YV ---------
enum enum
{ {
CV_WND_PROP_FULLSCREEN = 0, //These 3 flags are used by cvSet/GetWindowProperty
CV_WND_PROP_AUTOSIZE = 1, CV_WND_PROP_FULLSCREEN = 0,//to change/get window's fullscreen property
CV_WND_PROP_ASPECTRATIO= 2, CV_WND_PROP_AUTOSIZE = 1,//to change/get window's autosize property
CV_WINDOW_NORMAL = 0, CV_WND_PROP_ASPECTRATIO= 2,//to change/get window's aspectratio property
CV_WINDOW_FULLSCREEN = 1, //
CV_WINDOW_FREERATIO = 0, //These 2 flags are used by cvNamedWindow and cvSet/GetWindowProperty
CV_WINDOW_KEEPRATIO = 1 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 */ /* Set and Get Property of the window */
CVAPI(void) cvSetWindowProperty(const char* name, int prop_id, double prop_value); CVAPI(void) cvSetWindowProperty(const char* name, int prop_id, double prop_value);
......
This diff is collapsed.
...@@ -72,8 +72,10 @@ ...@@ -72,8 +72,10 @@
#include <QFileInfo> #include <QFileInfo>
#include <QDate> #include <QDate>
#include <QFileDialog> #include <QFileDialog>
#include <QToolBar>
#include <QAction>
//start enum //start private enum
enum {CV_MODE_NORMAL= 0, CV_MODE_OPENGL = 1}; enum {CV_MODE_NORMAL= 0, CV_MODE_OPENGL = 1};
//we can change the keyboard shortcuts from here ! //we can change the keyboard shortcuts from here !
...@@ -155,6 +157,7 @@ private: ...@@ -155,6 +157,7 @@ private:
}; };
class CvWindow : public QWidget class CvWindow : public QWidget
{ {
Q_OBJECT Q_OBJECT
...@@ -172,12 +175,14 @@ public: ...@@ -172,12 +175,14 @@ public:
ViewPort* getView(); ViewPort* getView();
QPointer<QBoxLayout> layout; QPointer<QBoxLayout> layout;
QPointer<QStatusBar> myBar; QPointer<QStatusBar> myStatusBar;
QPointer<QLabel> myBar_msg; QPointer<QToolBar> myToolBar;
QPointer<QLabel> myStatusBar_msg;
//parameters (will be save/load) //parameters (will be save/load)
QString param_name; QString param_name;
int param_flags; int param_flags;
int param_gui_mode;
protected: protected:
...@@ -185,19 +190,17 @@ protected: ...@@ -185,19 +190,17 @@ protected:
private: private:
QPointer<ViewPort> myview; QPointer<ViewPort> myview;
QPointer<QShortcut> shortcut_Z; QVector<QAction*> vect_QActions;
QPointer<QShortcut> shortcut_S; QVector<QShortcut*> vect_QShortcuts;
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;
void icvLoadTrackbars(QSettings *settings); void icvLoadTrackbars(QSettings *settings);
void icvSaveTrackbars(QSettings *settings); void icvSaveTrackbars(QSettings *settings);
void createShortcuts();
void createToolBar();
void createView(int mode);
void createStatusBar();
void createLayout();
}; };
...@@ -253,6 +256,7 @@ public slots: ...@@ -253,6 +256,7 @@ public slots:
void siftWindowOnDown(); void siftWindowOnDown();
void resizeEvent ( QResizeEvent * ); void resizeEvent ( QResizeEvent * );
void saveView(); void saveView();
void displayPropertiesWin();
private: private:
QPoint mouseCoordinate; QPoint mouseCoordinate;
...@@ -260,11 +264,11 @@ private: ...@@ -260,11 +264,11 @@ private:
QRect positionCorners; QRect positionCorners;
QTransform matrixWorld_inv; QTransform matrixWorld_inv;
float ratioX, ratioY; float ratioX, ratioY;
//for mouse callback //for mouse callback
CvMouseCallback on_mouse; CvMouseCallback on_mouse;
void* on_mouse_param; void* on_mouse_param;
//for opengl callback //for opengl callback
CvOpenGLCallback on_openGL_draw3D; CvOpenGLCallback on_openGL_draw3D;
void* on_openGL_param; void* on_openGL_param;
...@@ -304,66 +308,4 @@ private slots: ...@@ -304,66 +308,4 @@ private slots:
void stopDisplayInfo(); 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 #endif
<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>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment