fixed new OpenGL functionality under Qt
This commit is contained in:
parent
f1efd955b4
commit
3afc97e67e
@ -895,19 +895,16 @@ if (WITH_QT)
|
|||||||
if (QT4_FOUND)
|
if (QT4_FOUND)
|
||||||
set(HAVE_QT 1)
|
set(HAVE_QT 1)
|
||||||
add_definitions(-DHAVE_QT) #We need to define te macro this way, using cvconfig.h.cmake does not work
|
add_definitions(-DHAVE_QT) #We need to define te macro this way, using cvconfig.h.cmake does not work
|
||||||
find_package (OpenGL QUIET)
|
|
||||||
|
|
||||||
#if (NOT WIN32)
|
|
||||||
if (WITH_OPENGL)
|
if (WITH_OPENGL)
|
||||||
|
find_package (OpenGL QUIET)
|
||||||
if (QT_QTOPENGL_FOUND AND OPENGL_FOUND)
|
if (QT_QTOPENGL_FOUND AND OPENGL_FOUND)
|
||||||
#set(HAVE_OPENGL 1)
|
set(HAVE_OPENGL 1)
|
||||||
set(HAVE_QT_OPENGL 1)
|
set(HAVE_QT_OPENGL 1)
|
||||||
add_definitions(-DHAVE_QT_OPENGL)
|
add_definitions(-DHAVE_QT_OPENGL)
|
||||||
#link_directories("${OPENGL_LIBRARIES}")
|
|
||||||
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${OPENGL_LIBRARIES})
|
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${OPENGL_LIBRARIES})
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
#endif()
|
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -125,14 +125,8 @@ CV_EXPORTS_W void setTrackbarPos(const string& trackbarname, const string& winna
|
|||||||
|
|
||||||
// OpenGL support
|
// OpenGL support
|
||||||
|
|
||||||
typedef void (CV_CDECL *OpenGLCallback)(void* userdata);
|
|
||||||
CV_EXPORTS void createOpenGLCallback(const string& winname, OpenGLCallback onOpenGlDraw, void* userdata = 0);
|
|
||||||
|
|
||||||
typedef void (*OpenGlDrawCallback)(void* userdata);
|
typedef void (*OpenGlDrawCallback)(void* userdata);
|
||||||
static inline void setOpenGlDrawCallback(const string& winname, OpenGlDrawCallback onOpenGlDraw, void* userdata = 0)
|
CV_EXPORTS void setOpenGlDrawCallback(const string& winname, OpenGlDrawCallback onOpenGlDraw, void* userdata = 0);
|
||||||
{
|
|
||||||
createOpenGLCallback(winname, onOpenGlDraw, userdata);
|
|
||||||
}
|
|
||||||
|
|
||||||
CV_EXPORTS void setOpenGlContext(const string& winname);
|
CV_EXPORTS void setOpenGlContext(const string& winname);
|
||||||
|
|
||||||
|
@ -251,8 +251,8 @@ CVAPI(int) cvWaitKey(int delay CV_DEFAULT(0));
|
|||||||
|
|
||||||
// OpenGL support
|
// OpenGL support
|
||||||
|
|
||||||
typedef void (CV_CDECL *CvOpenGLCallback)(void* userdata);
|
typedef void (CV_CDECL *CvOpenGlDrawCallback)(void* userdata);
|
||||||
CVAPI(void) cvCreateOpenGLCallback( const char* window_name, CvOpenGLCallback callbackOpenGL, void* userdata CV_DEFAULT(NULL), double angle CV_DEFAULT(-1), double zmin CV_DEFAULT(-1), double zmax CV_DEFAULT(-1));
|
CVAPI(void) cvSetOpenGlDrawCallback(const char* window_name, CvOpenGlDrawCallback callback, void* userdata CV_DEFAULT(NULL));
|
||||||
|
|
||||||
CVAPI(void) cvSetOpenGlContext(const char* window_name);
|
CVAPI(void) cvSetOpenGlContext(const char* window_name);
|
||||||
CVAPI(void) cvUpdateWindow(const char* window_name);
|
CVAPI(void) cvUpdateWindow(const char* window_name);
|
||||||
|
@ -198,10 +198,14 @@ double cvGetOpenGlProp_GTK(const char* name);
|
|||||||
#if defined (HAVE_QT)
|
#if defined (HAVE_QT)
|
||||||
double cvGetModeWindow_QT(const char* name);
|
double cvGetModeWindow_QT(const char* name);
|
||||||
void cvSetModeWindow_QT(const char* name, double prop_value);
|
void cvSetModeWindow_QT(const char* name, double prop_value);
|
||||||
|
|
||||||
double cvGetPropWindow_QT(const char* name);
|
double cvGetPropWindow_QT(const char* name);
|
||||||
void cvSetPropWindow_QT(const char* name,double prop_value);
|
void cvSetPropWindow_QT(const char* name,double prop_value);
|
||||||
|
|
||||||
double cvGetRatioWindow_QT(const char* name);
|
double cvGetRatioWindow_QT(const char* name);
|
||||||
void cvSetRatioWindow_QT(const char* name,double prop_value);
|
void cvSetRatioWindow_QT(const char* name,double prop_value);
|
||||||
|
|
||||||
|
double cvGetOpenGlProp_QT(const char* name);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// OpenGL
|
// OpenGL
|
||||||
|
@ -133,6 +133,7 @@ CV_IMPL double cvGetWindowProperty(const char* name, int prop_id)
|
|||||||
case CV_WND_PROP_OPENGL:
|
case CV_WND_PROP_OPENGL:
|
||||||
|
|
||||||
#if defined (HAVE_QT)
|
#if defined (HAVE_QT)
|
||||||
|
return cvGetOpenGlProp_QT(name);
|
||||||
#elif defined WIN32 || defined _WIN32
|
#elif defined WIN32 || defined _WIN32
|
||||||
return cvGetOpenGlProp_W32(name);
|
return cvGetOpenGlProp_W32(name);
|
||||||
#elif defined (HAVE_GTK)
|
#elif defined (HAVE_GTK)
|
||||||
@ -218,9 +219,9 @@ int cv::startWindowThread()
|
|||||||
|
|
||||||
// OpenGL support
|
// OpenGL support
|
||||||
|
|
||||||
void cv::createOpenGLCallback(const string& name, OpenGLCallback callback, void* userdata)
|
void cv::setOpenGlDrawCallback(const string& name, OpenGlDrawCallback callback, void* userdata)
|
||||||
{
|
{
|
||||||
cvCreateOpenGLCallback(name.c_str(), callback, userdata);
|
cvSetOpenGlDrawCallback(name.c_str(), callback, userdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cv::setOpenGlContext(const string& windowName)
|
void cv::setOpenGlContext(const string& windowName)
|
||||||
@ -344,8 +345,6 @@ void cv::imshow( const string& winname, InputArray _img )
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
namedWindow(winname, WINDOW_OPENGL | WINDOW_AUTOSIZE);
|
|
||||||
|
|
||||||
double autoSize = getWindowProperty(winname, WND_PROP_AUTOSIZE);
|
double autoSize = getWindowProperty(winname, WND_PROP_AUTOSIZE);
|
||||||
|
|
||||||
if (autoSize > 0)
|
if (autoSize > 0)
|
||||||
@ -492,12 +491,10 @@ void cv::pointCloudShow(const std::string& winname, const cv::GlCamera& camera,
|
|||||||
|
|
||||||
#ifndef HAVE_OPENGL
|
#ifndef HAVE_OPENGL
|
||||||
|
|
||||||
#ifndef HAVE_QT
|
CV_IMPL void cvSetOpenGlDrawCallback(const char*, CvOpenGlDrawCallback, void*)
|
||||||
CV_IMPL void cvCreateOpenGLCallback(const char*, CvOpenGLCallback, void*, double, double, double)
|
|
||||||
{
|
{
|
||||||
CV_Error(CV_OpenGlNotSupported, "The library is compiled without OpenGL support");
|
CV_Error(CV_OpenGlNotSupported, "The library is compiled without OpenGL support");
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
CV_IMPL void cvSetOpenGlContext(const char*)
|
CV_IMPL void cvSetOpenGlContext(const char*)
|
||||||
{
|
{
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -40,7 +40,6 @@
|
|||||||
#ifndef __OPENCV_HIGHGUI_QT_H__
|
#ifndef __OPENCV_HIGHGUI_QT_H__
|
||||||
#define __OPENCV_HIGHGUI_QT_H__
|
#define __OPENCV_HIGHGUI_QT_H__
|
||||||
|
|
||||||
|
|
||||||
#include "precomp.hpp"
|
#include "precomp.hpp"
|
||||||
|
|
||||||
#if defined( HAVE_QT_OPENGL )
|
#if defined( HAVE_QT_OPENGL )
|
||||||
@ -97,14 +96,10 @@ enum { shortcut_zoom_normal = Qt::CTRL + Qt::Key_Z,
|
|||||||
shortcut_panning_down = Qt::CTRL + Qt::Key_Down
|
shortcut_panning_down = Qt::CTRL + Qt::Key_Down
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//end enum
|
//end enum
|
||||||
|
|
||||||
class CvWindow;
|
class CvWindow;
|
||||||
class ViewPort;
|
class ViewPort;
|
||||||
#if defined( HAVE_QT_OPENGL )
|
|
||||||
class OpenGLWidget;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
class GuiReceiver : public QObject
|
class GuiReceiver : public QObject
|
||||||
@ -114,16 +109,13 @@ class GuiReceiver : public QObject
|
|||||||
public:
|
public:
|
||||||
GuiReceiver();
|
GuiReceiver();
|
||||||
~GuiReceiver();
|
~GuiReceiver();
|
||||||
|
|
||||||
int start();
|
int start();
|
||||||
void isLastWindow();
|
void isLastWindow();
|
||||||
|
|
||||||
bool _bTimeOut;
|
bool bTimeOut;
|
||||||
QTimer* timer;
|
QTimer* timer;
|
||||||
|
|
||||||
private:
|
|
||||||
int nb_windows;
|
|
||||||
bool doesExternalQAppExist;
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void createWindow( QString name, int flags = 0 );
|
void createWindow( QString name, int flags = 0 );
|
||||||
void destroyWindow(QString name);
|
void destroyWindow(QString name);
|
||||||
@ -144,12 +136,22 @@ public slots:
|
|||||||
void setRatioWindow(QString name, double arg2 );
|
void setRatioWindow(QString name, double arg2 );
|
||||||
void saveWindowParameters(QString name);
|
void saveWindowParameters(QString name);
|
||||||
void loadWindowParameters(QString name);
|
void loadWindowParameters(QString name);
|
||||||
void setOpenGLCallback(QString window_name, void* callbackOpenGL, void* userdata, double angle, double zmin, double zmax);
|
|
||||||
void putText(void* arg1, QString text, QPoint org, void* font);
|
void putText(void* arg1, QString text, QPoint org, void* font);
|
||||||
void addButton(QString button_name, int button_type, int initial_button_state , void* on_change, void* userdata);
|
void addButton(QString button_name, int button_type, int initial_button_state , void* on_change, void* userdata);
|
||||||
void enablePropertiesButtonEachWindow();
|
void enablePropertiesButtonEachWindow();
|
||||||
|
|
||||||
|
void setOpenGlDrawCallback(QString name, void* callback, void* userdata);
|
||||||
|
void setOpenGlCleanCallback(QString name, void* callback, void* userdata);
|
||||||
|
void setOpenGlContext(QString name);
|
||||||
|
void updateWindow(QString name);
|
||||||
|
double isOpenGl(QString name);
|
||||||
|
|
||||||
|
private:
|
||||||
|
int nb_windows;
|
||||||
|
bool doesExternalQAppExist;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
enum typeBar { type_CvTrackbar = 0, type_CvButtonbar = 1 };
|
enum typeBar { type_CvTrackbar = 0, type_CvButtonbar = 1 };
|
||||||
class CvBar : public QHBoxLayout
|
class CvBar : public QHBoxLayout
|
||||||
{
|
{
|
||||||
@ -165,7 +167,7 @@ class CvButtonbar : public CvBar
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
CvButtonbar(QWidget* arg, QString bar_name);
|
CvButtonbar(QWidget* arg, QString bar_name);
|
||||||
~CvButtonbar();
|
|
||||||
void addButton(QString button_name, CvButtonCallback call, void* userdata, int button_type, int initial_button_state);
|
void addButton(QString button_name, CvButtonCallback call, void* userdata, int button_type, int initial_button_state);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -193,7 +195,6 @@ private slots:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class CvCheckBox : public QCheckBox
|
class CvCheckBox : public QCheckBox
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -210,6 +211,7 @@ private slots:
|
|||||||
void callCallBack(bool);
|
void callCallBack(bool);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class CvRadioButton : public QRadioButton
|
class CvRadioButton : public QRadioButton
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -227,16 +229,13 @@ private slots:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class CvTrackbar : public CvBar
|
class CvTrackbar : public CvBar
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
CvTrackbar(CvWindow* parent, QString name, int* value, int count, CvTrackbarCallback on_change);
|
CvTrackbar(CvWindow* parent, QString name, int* value, int count, CvTrackbarCallback on_change);
|
||||||
CvTrackbar(CvWindow* parent, QString name, int* value, int count, CvTrackbarCallback2 on_change, void* data);
|
CvTrackbar(CvWindow* parent, QString name, int* value, int count, CvTrackbarCallback2 on_change, void* data);
|
||||||
~CvTrackbar();
|
|
||||||
|
|
||||||
//QString trackbar_name;
|
|
||||||
QPointer<QSlider> slider;
|
QPointer<QSlider> slider;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
@ -245,21 +244,19 @@ private slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void setLabel(int myvalue);
|
void setLabel(int myvalue);
|
||||||
void construc_trackbar(CvWindow* arg, QString name, int* value, int count);
|
void create(CvWindow* arg, QString name, int* value, int count);
|
||||||
QString createLabel();
|
QString createLabel();
|
||||||
QPointer<QPushButton > label;
|
QPointer<QPushButton > label;
|
||||||
CvTrackbarCallback callback;
|
CvTrackbarCallback callback;
|
||||||
CvTrackbarCallback2 callback2;//look like it is use by python binding
|
CvTrackbarCallback2 callback2;//look like it is use by python binding
|
||||||
int* dataSlider;
|
int* dataSlider;
|
||||||
void* userdata;
|
void* userdata;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//Both are top level window, so that a way to differenciate them.
|
//Both are top level window, so that a way to differenciate them.
|
||||||
//if (obj->metaObject ()->className () == "CvWindow") does not give me robust result
|
//if (obj->metaObject ()->className () == "CvWindow") does not give me robust result
|
||||||
|
|
||||||
enum typeWindow { type_CvWindow = 1, type_CvWinProperties = 2 };
|
enum typeWindow { type_CvWindow = 1, type_CvWinProperties = 2 };
|
||||||
|
|
||||||
class CvWinModel : public QWidget
|
class CvWinModel : public QWidget
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -288,42 +285,62 @@ class CvWindow : public CvWinModel
|
|||||||
public:
|
public:
|
||||||
CvWindow(QString arg2, int flag = CV_WINDOW_NORMAL);
|
CvWindow(QString arg2, int flag = CV_WINDOW_NORMAL);
|
||||||
~CvWindow();
|
~CvWindow();
|
||||||
static void addSlider(CvWindow* w,QString name, int* value, int count, CvTrackbarCallback on_change CV_DEFAULT(NULL));
|
|
||||||
static void addSlider2(CvWindow* w,QString name, int* value, int count, CvTrackbarCallback2 on_change CV_DEFAULT(NULL), void* userdata CV_DEFAULT(0));
|
|
||||||
void setMouseCallBack(CvMouseCallback m, void* param);
|
void setMouseCallBack(CvMouseCallback m, void* param);
|
||||||
|
|
||||||
|
void writeSettings();
|
||||||
|
void readSettings();
|
||||||
|
|
||||||
|
double getRatio();
|
||||||
|
void setRatio(int flags);
|
||||||
|
|
||||||
|
int getPropWindow();
|
||||||
|
void setPropWindow(int flags);
|
||||||
|
|
||||||
|
void toggleFullScreen(int flags);
|
||||||
|
|
||||||
void updateImage(void* arr);
|
void updateImage(void* arr);
|
||||||
|
|
||||||
void displayInfo(QString text, int delayms);
|
void displayInfo(QString text, int delayms);
|
||||||
void displayStatusBar(QString text, int delayms);
|
void displayStatusBar(QString text, int delayms);
|
||||||
void readSettings();
|
|
||||||
void writeSettings();
|
|
||||||
void setOpenGLCallback(CvOpenGLCallback arg1,void* userdata, double angle, double zmin, double zmax);
|
|
||||||
void hideTools();
|
|
||||||
void showTools();
|
|
||||||
static CvButtonbar* createButtonbar(QString bar_name);
|
|
||||||
QSize getAvailableSize();
|
|
||||||
|
|
||||||
|
void enablePropertiesButton();
|
||||||
|
|
||||||
ViewPort* getView();
|
static CvButtonbar* createButtonBar(QString bar_name);
|
||||||
|
|
||||||
QPointer<QBoxLayout> myGlobalLayout;//All the widget (toolbar, view, LayoutBar, ...) are attached to it
|
static void addSlider(CvWindow* w, QString name, int* value, int count, CvTrackbarCallback on_change CV_DEFAULT(NULL));
|
||||||
QPointer<QBoxLayout> myBarLayout;
|
static void addSlider2(CvWindow* w, QString name, int* value, int count, CvTrackbarCallback2 on_change CV_DEFAULT(NULL), void* userdata CV_DEFAULT(0));
|
||||||
QPointer<QStatusBar> myStatusBar;
|
|
||||||
QPointer<QToolBar> myToolBar;
|
void setOpenGlDrawCallback(CvOpenGlDrawCallback callback, void* userdata);
|
||||||
QPointer<QLabel> myStatusBar_msg;
|
void setOpenGlCleanCallback(CvOpenGlCleanCallback callback, void* userdata);
|
||||||
|
void makeCurrentOpenGlContext();
|
||||||
|
void updateGl();
|
||||||
|
bool isOpenGl();
|
||||||
|
|
||||||
|
void setViewportSize(QSize size);
|
||||||
|
|
||||||
//parameters (will be save/load)
|
//parameters (will be save/load)
|
||||||
QString param_name;
|
|
||||||
int param_flags;
|
int param_flags;
|
||||||
int param_gui_mode;
|
int param_gui_mode;
|
||||||
int param_ratio_mode;
|
int param_ratio_mode;
|
||||||
|
|
||||||
|
QPointer<QBoxLayout> myGlobalLayout; //All the widget (toolbar, view, LayoutBar, ...) are attached to it
|
||||||
|
QPointer<QBoxLayout> myBarLayout;
|
||||||
|
|
||||||
QVector<QAction*> vect_QActions;
|
QVector<QAction*> vect_QActions;
|
||||||
|
|
||||||
|
QPointer<QStatusBar> myStatusBar;
|
||||||
|
QPointer<QToolBar> myToolBar;
|
||||||
|
QPointer<QLabel> myStatusBar_msg;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void keyPressEvent(QKeyEvent* event);
|
virtual void keyPressEvent(QKeyEvent* event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPointer<ViewPort> myview;
|
|
||||||
|
int mode_display; //opengl or native
|
||||||
|
ViewPort* myView;
|
||||||
|
|
||||||
QVector<QShortcut*> vect_QShortcuts;
|
QVector<QShortcut*> vect_QShortcuts;
|
||||||
|
|
||||||
void icvLoadTrackbars(QSettings *settings);
|
void icvLoadTrackbars(QSettings *settings);
|
||||||
@ -336,21 +353,22 @@ private:
|
|||||||
void createActions();
|
void createActions();
|
||||||
void createShortcuts();
|
void createShortcuts();
|
||||||
void createToolBar();
|
void createToolBar();
|
||||||
void createView(int display_mode, int ratio_mode);
|
void createView();
|
||||||
void createStatusBar();
|
void createStatusBar();
|
||||||
void createGlobalLayout();
|
void createGlobalLayout();
|
||||||
void createBarLayout();
|
void createBarLayout();
|
||||||
CvWinProperties* createParameterWindow();
|
CvWinProperties* createParameterWindow();
|
||||||
|
|
||||||
|
void hideTools();
|
||||||
|
void showTools();
|
||||||
|
QSize getAvailableSize();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void displayPropertiesWin();
|
void displayPropertiesWin();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
enum type_mouse_event { mouse_up = 0, mouse_down = 1, mouse_dbclick = 2, mouse_move = 3 };
|
enum type_mouse_event { mouse_up = 0, mouse_down = 1, mouse_dbclick = 2, mouse_move = 3 };
|
||||||
|
|
||||||
static const int tableMouseButtons[][3]={
|
static const int tableMouseButtons[][3]={
|
||||||
{CV_EVENT_LBUTTONUP, CV_EVENT_RBUTTONUP, CV_EVENT_MBUTTONUP}, //mouse_up
|
{CV_EVENT_LBUTTONUP, CV_EVENT_RBUTTONUP, CV_EVENT_MBUTTONUP}, //mouse_up
|
||||||
{CV_EVENT_LBUTTONDOWN, CV_EVENT_RBUTTONDOWN, CV_EVENT_MBUTTONDOWN}, //mouse_down
|
{CV_EVENT_LBUTTONDOWN, CV_EVENT_RBUTTONDOWN, CV_EVENT_MBUTTONDOWN}, //mouse_down
|
||||||
@ -359,83 +377,187 @@ static const int tableMouseButtons[][3]={
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static const double DEFAULT_ANGLE = 45.0;
|
class ViewPort
|
||||||
static const double DEFAULT_ZMIN = 0.01;
|
{
|
||||||
static const double DEFAULT_ZMAX = 1000.0;
|
public:
|
||||||
class ViewPort : public QGraphicsView
|
virtual ~ViewPort() {}
|
||||||
|
|
||||||
|
virtual QWidget* getWidget() = 0;
|
||||||
|
|
||||||
|
virtual void setMouseCallBack(CvMouseCallback callback, void* param) = 0;
|
||||||
|
|
||||||
|
virtual void writeSettings(QSettings& settings) = 0;
|
||||||
|
virtual void readSettings(QSettings& settings) = 0;
|
||||||
|
|
||||||
|
virtual double getRatio() = 0;
|
||||||
|
virtual void setRatio(int flags) = 0;
|
||||||
|
|
||||||
|
virtual void updateImage(const CvArr* arr) = 0;
|
||||||
|
|
||||||
|
virtual void startDisplayInfo(QString text, int delayms) = 0;
|
||||||
|
|
||||||
|
virtual void setOpenGlDrawCallback(CvOpenGlDrawCallback callback, void* userdata) = 0;
|
||||||
|
virtual void setOpenGlCleanCallback(CvOpenGlCleanCallback callback, void* userdata) = 0;
|
||||||
|
virtual void makeCurrentOpenGlContext() = 0;
|
||||||
|
virtual void updateGl() = 0;
|
||||||
|
|
||||||
|
virtual void setSize(QSize size_) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef HAVE_QT_OPENGL
|
||||||
|
|
||||||
|
class OpenGlViewPort : public QGLWidget, public ViewPort
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit OpenGlViewPort(QWidget* parent);
|
||||||
|
~OpenGlViewPort();
|
||||||
|
|
||||||
|
QWidget* getWidget();
|
||||||
|
|
||||||
|
void setMouseCallBack(CvMouseCallback callback, void* param);
|
||||||
|
|
||||||
|
void writeSettings(QSettings& settings);
|
||||||
|
void readSettings(QSettings& settings);
|
||||||
|
|
||||||
|
double getRatio();
|
||||||
|
void setRatio(int flags);
|
||||||
|
|
||||||
|
void updateImage(const CvArr* arr);
|
||||||
|
|
||||||
|
void startDisplayInfo(QString text, int delayms);
|
||||||
|
|
||||||
|
void setOpenGlDrawCallback(CvOpenGlDrawCallback callback, void* userdata);
|
||||||
|
void setOpenGlCleanCallback(CvOpenGlCleanCallback callback, void* userdata);
|
||||||
|
void makeCurrentOpenGlContext();
|
||||||
|
void updateGl();
|
||||||
|
|
||||||
|
void setSize(QSize size_);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void initializeGL();
|
||||||
|
void resizeGL(int w, int h);
|
||||||
|
void paintGL();
|
||||||
|
|
||||||
|
void mouseMoveEvent(QMouseEvent* event);
|
||||||
|
void mousePressEvent(QMouseEvent* event);
|
||||||
|
void mouseReleaseEvent(QMouseEvent* event);
|
||||||
|
void mouseDoubleClickEvent(QMouseEvent* event);
|
||||||
|
|
||||||
|
QSize sizeHint() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
QSize size;
|
||||||
|
|
||||||
|
CvMouseCallback mouseCallback;
|
||||||
|
void* mouseData;
|
||||||
|
|
||||||
|
CvOpenGlDrawCallback glDrawCallback;
|
||||||
|
void* glDrawData;
|
||||||
|
|
||||||
|
CvOpenGlCleanCallback glCleanCallback;
|
||||||
|
void* glCleanData;
|
||||||
|
|
||||||
|
CvOpenGlFuncTab* glFuncTab;
|
||||||
|
|
||||||
|
void icvmouseHandler(QMouseEvent* event, type_mouse_event category, int& cv_event, int& flags);
|
||||||
|
void icvmouseProcessing(QPointF pt, int cv_event, int flags);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // HAVE_QT_OPENGL
|
||||||
|
|
||||||
|
|
||||||
|
class DefaultViewPort : public QGraphicsView, public ViewPort
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ViewPort(CvWindow* centralWidget, int mode = CV_MODE_NORMAL, int keepRatio = CV_WINDOW_KEEPRATIO);
|
DefaultViewPort(CvWindow* centralWidget, int arg2);
|
||||||
~ViewPort();
|
~DefaultViewPort();
|
||||||
|
|
||||||
|
QWidget* getWidget();
|
||||||
|
|
||||||
|
void setMouseCallBack(CvMouseCallback callback, void* param);
|
||||||
|
|
||||||
|
void writeSettings(QSettings& settings);
|
||||||
|
void readSettings(QSettings& settings);
|
||||||
|
|
||||||
|
double getRatio();
|
||||||
|
void setRatio(int flags);
|
||||||
|
|
||||||
void updateImage(const CvArr* arr);
|
void updateImage(const CvArr* arr);
|
||||||
|
|
||||||
void startDisplayInfo(QString text, int delayms);
|
void startDisplayInfo(QString text, int delayms);
|
||||||
void setMouseCallBack(CvMouseCallback m, void* param);
|
|
||||||
void setOpenGLCallback(CvOpenGLCallback func,void* userdata, double arg3, double arg4, double arg5);
|
|
||||||
int getRatio();
|
|
||||||
void setRatio(int arg);
|
|
||||||
|
|
||||||
//parameters (will be save/load)
|
void setOpenGlDrawCallback(CvOpenGlDrawCallback callback, void* userdata);
|
||||||
QTransform param_matrixWorld;
|
void setOpenGlCleanCallback(CvOpenGlCleanCallback callback, void* userdata);
|
||||||
|
void makeCurrentOpenGlContext();
|
||||||
|
void updateGl();
|
||||||
|
|
||||||
int param_keepRatio;
|
void setSize(QSize size_);
|
||||||
|
|
||||||
//IplImage* image2Draw_ipl;
|
|
||||||
CvMat* image2Draw_mat;
|
|
||||||
QImage image2Draw_qt;
|
|
||||||
QImage image2Draw_qt_resized;
|
|
||||||
int mode_display;//opengl or native
|
|
||||||
int nbChannelOriginImage;
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
//reference:
|
//reference:
|
||||||
//http://www.qtcentre.org/wiki/index.php?title=QGraphicsView:_Smooth_Panning_and_Zooming
|
//http://www.qtcentre.org/wiki/index.php?title=QGraphicsView:_Smooth_Panning_and_Zooming
|
||||||
//http://doc.qt.nokia.com/4.6/gestures-imagegestures-imagewidget-cpp.html
|
//http://doc.qt.nokia.com/4.6/gestures-imagegestures-imagewidget-cpp.html
|
||||||
void scaleView(qreal scaleFactor, QPointF center);
|
|
||||||
void imgRegion();
|
|
||||||
void moveView(QPointF delta);
|
|
||||||
void resetZoom();
|
|
||||||
void ZoomIn();
|
|
||||||
void ZoomOut();
|
|
||||||
void siftWindowOnLeft();
|
void siftWindowOnLeft();
|
||||||
void siftWindowOnRight();
|
void siftWindowOnRight();
|
||||||
void siftWindowOnUp() ;
|
void siftWindowOnUp() ;
|
||||||
void siftWindowOnDown();
|
void siftWindowOnDown();
|
||||||
void resizeEvent ( QResizeEvent * );
|
|
||||||
|
void resetZoom();
|
||||||
|
void imgRegion();
|
||||||
|
void ZoomIn();
|
||||||
|
void ZoomOut();
|
||||||
|
|
||||||
void saveView();
|
void saveView();
|
||||||
|
|
||||||
|
protected:
|
||||||
void contextMenuEvent(QContextMenuEvent* event);
|
void contextMenuEvent(QContextMenuEvent* event);
|
||||||
|
void resizeEvent(QResizeEvent* event);
|
||||||
|
|
||||||
private:
|
|
||||||
QPoint mouseCoordinate;
|
|
||||||
QPointF positionGrabbing;
|
|
||||||
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;
|
|
||||||
|
|
||||||
bool isSameSize(IplImage* img1,IplImage* img2);
|
|
||||||
QSize sizeHint() const;
|
|
||||||
QPointer<CvWindow> centralWidget;
|
|
||||||
QPointer<QTimer> timerDisplay;
|
|
||||||
bool drawInfo;
|
|
||||||
QString infoText;
|
|
||||||
QRectF target;
|
|
||||||
//QImage* image;
|
|
||||||
|
|
||||||
void paintEvent(QPaintEvent* paintEventInfo);
|
void paintEvent(QPaintEvent* paintEventInfo);
|
||||||
void wheelEvent(QWheelEvent* event);
|
void wheelEvent(QWheelEvent* event);
|
||||||
void mouseMoveEvent(QMouseEvent* event);
|
void mouseMoveEvent(QMouseEvent* event);
|
||||||
void mousePressEvent(QMouseEvent* event);
|
void mousePressEvent(QMouseEvent* event);
|
||||||
void mouseReleaseEvent(QMouseEvent* event);
|
void mouseReleaseEvent(QMouseEvent* event);
|
||||||
void mouseDoubleClickEvent(QMouseEvent* event);
|
void mouseDoubleClickEvent(QMouseEvent* event);
|
||||||
|
|
||||||
|
private:
|
||||||
|
int param_keepRatio;
|
||||||
|
|
||||||
|
//parameters (will be save/load)
|
||||||
|
QTransform param_matrixWorld;
|
||||||
|
|
||||||
|
CvMat* image2Draw_mat;
|
||||||
|
QImage image2Draw_qt;
|
||||||
|
QImage image2Draw_qt_resized;
|
||||||
|
int nbChannelOriginImage;
|
||||||
|
|
||||||
|
//for mouse callback
|
||||||
|
CvMouseCallback on_mouse;
|
||||||
|
void* on_mouse_param;
|
||||||
|
|
||||||
|
|
||||||
|
void scaleView(qreal scaleFactor, QPointF center);
|
||||||
|
void moveView(QPointF delta);
|
||||||
|
|
||||||
|
QPoint mouseCoordinate;
|
||||||
|
QPointF positionGrabbing;
|
||||||
|
QRect positionCorners;
|
||||||
|
QTransform matrixWorld_inv;
|
||||||
|
float ratioX, ratioY;
|
||||||
|
|
||||||
|
bool isSameSize(IplImage* img1,IplImage* img2);
|
||||||
|
|
||||||
|
QSize sizeHint() const;
|
||||||
|
QPointer<CvWindow> centralWidget;
|
||||||
|
QPointer<QTimer> timerDisplay;
|
||||||
|
bool drawInfo;
|
||||||
|
QString infoText;
|
||||||
|
QRectF target;
|
||||||
|
|
||||||
void drawInstructions(QPainter *painter);
|
void drawInstructions(QPainter *painter);
|
||||||
void drawViewOverview(QPainter *painter);
|
void drawViewOverview(QPainter *painter);
|
||||||
void drawImgRegion(QPainter *painter);
|
void drawImgRegion(QPainter *painter);
|
||||||
@ -445,17 +567,6 @@ private:
|
|||||||
void icvmouseHandler(QMouseEvent *event, type_mouse_event category, int &cv_event, int &flags);
|
void icvmouseHandler(QMouseEvent *event, type_mouse_event category, int &cv_event, int &flags);
|
||||||
void icvmouseProcessing(QPointF pt, int cv_event, int flags);
|
void icvmouseProcessing(QPointF pt, int cv_event, int flags);
|
||||||
|
|
||||||
#if defined( HAVE_QT_OPENGL )
|
|
||||||
QPointer<QGLWidget> myGL;
|
|
||||||
double angle;
|
|
||||||
double zmin;
|
|
||||||
double zmax;
|
|
||||||
void unsetGL();
|
|
||||||
void initGL();
|
|
||||||
void setGL(int width, int height);
|
|
||||||
void icvgluPerspective(GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void stopDisplayInfo();
|
void stopDisplayInfo();
|
||||||
};
|
};
|
||||||
|
@ -427,7 +427,7 @@ typedef struct CvWindow
|
|||||||
#ifdef HAVE_OPENGL
|
#ifdef HAVE_OPENGL
|
||||||
bool useGl;
|
bool useGl;
|
||||||
|
|
||||||
CvOpenGLCallback glDrawCallback;
|
CvOpenGlDrawCallback glDrawCallback;
|
||||||
void* glDrawData;
|
void* glDrawData;
|
||||||
|
|
||||||
CvOpenGlCleanCallback glCleanCallback;
|
CvOpenGlCleanCallback glCleanCallback;
|
||||||
@ -1216,7 +1216,7 @@ CV_IMPL void cvUpdateWindow(const char* name)
|
|||||||
__END__;
|
__END__;
|
||||||
}
|
}
|
||||||
|
|
||||||
CV_IMPL void cvCreateOpenGLCallback(const char* name, CvOpenGLCallback callback, void* userdata, double, double, double)
|
CV_IMPL void cvSetOpenGlDrawCallback(const char* name, CvOpenGlDrawCallback callback, void* userdata)
|
||||||
{
|
{
|
||||||
CvWindow* window;
|
CvWindow* window;
|
||||||
|
|
||||||
|
@ -174,7 +174,7 @@ typedef struct CvWindow
|
|||||||
bool useGl;
|
bool useGl;
|
||||||
HGLRC hGLRC;
|
HGLRC hGLRC;
|
||||||
|
|
||||||
CvOpenGLCallback glDrawCallback;
|
CvOpenGlDrawCallback glDrawCallback;
|
||||||
void* glDrawData;
|
void* glDrawData;
|
||||||
|
|
||||||
CvOpenGlCleanCallback glCleanCallback;
|
CvOpenGlCleanCallback glCleanCallback;
|
||||||
@ -1121,7 +1121,7 @@ CV_IMPL void cvUpdateWindow(const char* name)
|
|||||||
__END__;
|
__END__;
|
||||||
}
|
}
|
||||||
|
|
||||||
CV_IMPL void cvCreateOpenGLCallback(const char* name, CvOpenGLCallback callback, void* userdata, double, double, double)
|
CV_IMPL void cvSetOpenGlDrawCallback(const char* name, CvOpenGlDrawCallback callback, void* userdata)
|
||||||
{
|
{
|
||||||
CV_FUNCNAME( "cvCreateOpenGLCallback" );
|
CV_FUNCNAME( "cvCreateOpenGLCallback" );
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user