From ffe7bdf69c1bfd16198bac4a9abd887aa716ff67 Mon Sep 17 00:00:00 2001 From: Yannick Verdie Date: Fri, 23 Jul 2010 12:09:13 +0000 Subject: [PATCH] ticket 490: bool not defined ? -> changed everything in int --- .../highgui/include/opencv2/highgui/highgui_c.h | 4 ++-- modules/highgui/src/window_QT.cpp | 26 +++++++++++++--------- modules/highgui/src/window_QT.h | 10 ++++----- 3 files changed, 23 insertions(+), 17 deletions(-) diff --git a/modules/highgui/include/opencv2/highgui/highgui_c.h b/modules/highgui/include/opencv2/highgui/highgui_c.h index cd62639..4f6dac9 100644 --- a/modules/highgui/include/opencv2/highgui/highgui_c.h +++ b/modules/highgui/include/opencv2/highgui/highgui_c.h @@ -96,7 +96,7 @@ CVAPI(void) cvStopLoop(); typedef void (CV_CDECL *CvButtonCallback)(int state, void* userdata); enum {CV_PUSH_BUTTON = 0, CV_CHECKBOX = 1, CV_RADIOBOX = 2}; -CVAPI(int) cvCreateButton( const char* button_name CV_DEFAULT(NULL),CvButtonCallback on_change CV_DEFAULT(NULL), void* userdata CV_DEFAULT(NULL) , int button_type CV_DEFAULT(CV_PUSH_BUTTON), bool initial_button_state CV_DEFAULT(0)); +CVAPI(int) cvCreateButton( const char* button_name CV_DEFAULT(NULL),CvButtonCallback on_change CV_DEFAULT(NULL), void* userdata CV_DEFAULT(NULL) , int button_type CV_DEFAULT(CV_PUSH_BUTTON), int initial_button_state CV_DEFAULT(0)); //---------------------- @@ -154,7 +154,7 @@ typedef void (CV_CDECL *CvTrackbarCallback)(int pos); /* create trackbar and display it on top of given window, set callback */ CVAPI(int) cvCreateTrackbar( const char* trackbar_name, const char* window_name, - int* value, int count, CvTrackbarCallback on_change); + int* value, int count, CvTrackbarCallback on_change CV_DEFAULT(NULL)); typedef void (CV_CDECL *CvTrackbarCallback2)(int pos, void* userdata); diff --git a/modules/highgui/src/window_QT.cpp b/modules/highgui/src/window_QT.cpp index 0fea7bc..fbe2e08 100755 --- a/modules/highgui/src/window_QT.cpp +++ b/modules/highgui/src/window_QT.cpp @@ -515,14 +515,17 @@ CV_IMPL int cvCreateTrackbar( const char* name_bar, const char* window_name, int -CV_IMPL int cvCreateButton(const char* button_name,CvButtonCallback on_change, void* userdata , int button_type, bool initial_button_state ) +CV_IMPL int cvCreateButton(const char* button_name,CvButtonCallback on_change, void* userdata , int button_type, int initial_button_state ) { + if (initial_button_state < 0 || initial_button_state > 1) + return 0; + QMetaObject::invokeMethod(&guiMainThread, "addButton", Qt::AutoConnection, Q_ARG(QString, QString(button_name)), Q_ARG(int, button_type), - Q_ARG(bool, initial_button_state), + Q_ARG(int, initial_button_state), Q_ARG(void*, (void*)on_change), Q_ARG(void*, userdata) ); @@ -865,7 +868,7 @@ void GuiReceiver::resizeWindow(QString name, int width, int height) w->resize(width, height); } -void GuiReceiver::addButton(QString button_name, int button_type, bool initial_button_state , void* on_change, void* userdata) +void GuiReceiver::addButton(QString button_name, int button_type, int initial_button_state , void* on_change, void* userdata) { if (!global_control_panel) @@ -1058,7 +1061,7 @@ void CvButtonbar::setLabel() label->setText(nameNormalized); } -void CvButtonbar::addButton( QString name, CvButtonCallback call, void* userdata, int button_type, bool initial_button_state) +void CvButtonbar::addButton( QString name, CvButtonCallback call, void* userdata, int button_type, int initial_button_state) { QString button_name = name; @@ -1107,10 +1110,11 @@ CvPushButton::CvPushButton(CvButtonbar* arg1, QString arg2, CvButtonCallback arg void CvPushButton::callCallBack() { - callback(-1,userdata); + if (callback) + callback(-1,userdata); } -CvCheckBox::CvCheckBox(CvButtonbar* arg1, QString arg2, CvButtonCallback arg3, void* arg4, bool initial_button_state) +CvCheckBox::CvCheckBox(CvButtonbar* arg1, QString arg2, CvButtonCallback arg3, void* arg4, int initial_button_state) { myparent = arg1; button_name = arg2; @@ -1124,10 +1128,11 @@ CvCheckBox::CvCheckBox(CvButtonbar* arg1, QString arg2, CvButtonCallback arg3, v void CvCheckBox::callCallBack() { - callback(this->isChecked(),userdata); + if (callback) + callback(this->isChecked(),userdata); } -CvRadioButton::CvRadioButton(CvButtonbar* arg1, QString arg2, CvButtonCallback arg3, void* arg4, bool initial_button_state) +CvRadioButton::CvRadioButton(CvButtonbar* arg1, QString arg2, CvButtonCallback arg3, void* arg4, int initial_button_state) { myparent = arg1; button_name = arg2; @@ -1141,7 +1146,8 @@ CvRadioButton::CvRadioButton(CvButtonbar* arg1, QString arg2, CvButtonCallback a void CvRadioButton::callCallBack() { - callback(this->isChecked(),userdata); + if (callback) + callback(this->isChecked(),userdata); } @@ -1363,7 +1369,7 @@ void CvWindow::showTools() CvWinProperties* CvWindow::createParameterWindow() { - QString name_paraWindow ="Global control panel"; + QString name_paraWindow =QFileInfo(QApplication::applicationFilePath()).fileName()+" settings"; CvWinProperties *result = new CvWinProperties(name_paraWindow,this); return result; diff --git a/modules/highgui/src/window_QT.h b/modules/highgui/src/window_QT.h index 40f195d..9f988ea 100644 --- a/modules/highgui/src/window_QT.h +++ b/modules/highgui/src/window_QT.h @@ -135,7 +135,7 @@ public slots: void loadWindowParameters(QString name); void setOpenGLCallback(QString window_name, void* callbackOpenGL, void* userdata); void putText(void* arg1, QString text, QPoint org, void* font); - void addButton(QString button_name, int button_type, bool 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); }; @@ -155,7 +155,7 @@ class CvButtonbar : public CvBar public: CvButtonbar(QWidget* arg, QString bar_name); ~CvButtonbar(); - void addButton( QString button_name, CvButtonCallback call, void* userdata, int button_type, bool initial_button_state); + void addButton( QString button_name, CvButtonCallback call, void* userdata, int button_type, int initial_button_state); private: void setLabel(); @@ -187,7 +187,7 @@ class CvCheckBox : public QCheckBox { Q_OBJECT public: - CvCheckBox(CvButtonbar* par, QString button_name, CvButtonCallback call, void* userdata, bool initial_button_state); + CvCheckBox(CvButtonbar* par, QString button_name, CvButtonCallback call, void* userdata, int initial_button_state); private: CvButtonbar* myparent; @@ -203,7 +203,7 @@ class CvRadioButton : public QRadioButton { Q_OBJECT public: - CvRadioButton(CvButtonbar* par, QString button_name, CvButtonCallback call, void* userdata, bool initial_button_state); + CvRadioButton(CvButtonbar* par, QString button_name, CvButtonCallback call, void* userdata, int initial_button_state); private: CvButtonbar* myparent; @@ -284,7 +284,7 @@ public: //parameters (will be save/load) QString param_name; - QPointer parameters_window ; + CvWinProperties* parameters_window ; int param_flags; int param_gui_mode; QVector vect_QActions; -- 2.7.4