|
|
|
|
@@ -55,6 +55,7 @@ static const unsigned int threshold_zoom_img_region = 15;
|
|
|
|
|
//the minimum zoom value to start displaying the values in the grid
|
|
|
|
|
//that is also the number of pixel per grid
|
|
|
|
|
|
|
|
|
|
static CvWinProperties* global_control_panel = NULL;
|
|
|
|
|
//end static and global
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -264,7 +265,7 @@ CV_IMPL int cvWaitKey( int arg )
|
|
|
|
|
waitCondition.wait(&dummy, 2);
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#if defined WIN32 || defined _WIN32
|
|
|
|
|
#if defined WIN32 || defined _WIN32 || defined WIN64 || defined _WIN64
|
|
|
|
|
sleep(2);
|
|
|
|
|
#else
|
|
|
|
|
usleep(2);//to decrease CPU usage
|
|
|
|
|
@@ -321,101 +322,63 @@ CvWindow* icvFindWindowByName( const char* arg )
|
|
|
|
|
return window;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CvTrackbar* icvFindTrackbarByName( const char* name_trackbar, const char* name_window )
|
|
|
|
|
|
|
|
|
|
CvBar* icvFindBarbyName(QBoxLayout* layout, QString name_bar, typeBar type)
|
|
|
|
|
{
|
|
|
|
|
if (!layout)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
QPointer<CvTrackbar> result = NULL;
|
|
|
|
|
|
|
|
|
|
QPointer<CvWindow> w = icvFindWindowByName( name_window );
|
|
|
|
|
|
|
|
|
|
if( !w )
|
|
|
|
|
CV_Error( CV_StsNullPtr, "NULL window handler" );
|
|
|
|
|
|
|
|
|
|
QString nameQt(name_trackbar);
|
|
|
|
|
CvBar* t;
|
|
|
|
|
|
|
|
|
|
int start_index = 0;
|
|
|
|
|
int stop_index = 0;
|
|
|
|
|
QPointer<QLayout> myLayout;
|
|
|
|
|
int stop_index = layout->layout()->count();
|
|
|
|
|
|
|
|
|
|
if (w->param_gui_mode == CV_GUI_NORMAL)
|
|
|
|
|
for (int i = 0; i < stop_index; ++i)
|
|
|
|
|
{
|
|
|
|
|
myLayout = w->myLayout;
|
|
|
|
|
|
|
|
|
|
start_index = 1;
|
|
|
|
|
if (w->myToolBar)
|
|
|
|
|
start_index = 2;
|
|
|
|
|
//Warning ---- , asume the location 0 is toolbar, 1 is myview and max-1 the status bar
|
|
|
|
|
//done three times in the code, in loadtrackbars, savetrackbar and in findtrackbar
|
|
|
|
|
|
|
|
|
|
stop_index = myLayout->layout()->count()-1;
|
|
|
|
|
t = (CvBar*) layout->layout()->itemAt(i);
|
|
|
|
|
if (t->type == type && t->name_bar == name_bar)
|
|
|
|
|
return t;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (w->param_gui_mode == CV_GUI_EXPANDED)
|
|
|
|
|
{
|
|
|
|
|
myLayout = w->getWinProp()->myLayout;
|
|
|
|
|
if (!myLayout)
|
|
|
|
|
CV_Error( CV_StsNullPtr, "NULL window prop handler" );
|
|
|
|
|
|
|
|
|
|
start_index = 0;
|
|
|
|
|
stop_index = myLayout->layout()->count();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = start_index; i < stop_index; ++i)
|
|
|
|
|
{
|
|
|
|
|
t = (CvBar*) myLayout->layout()->itemAt(i);
|
|
|
|
|
if (t->type == type_CvTrackbar && t->name_bar == nameQt)
|
|
|
|
|
{
|
|
|
|
|
result = (CvTrackbar*) t;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CvButtonbar* icvFindButtonbarByName( const char* name_Buttonbar, const char* name_window )
|
|
|
|
|
CvTrackbar* icvFindTrackbarByName( const char* name_trackbar, const char* name_window, QBoxLayout* layout = NULL )
|
|
|
|
|
{
|
|
|
|
|
QString nameQt(name_trackbar);
|
|
|
|
|
CvBar* result = NULL;
|
|
|
|
|
|
|
|
|
|
QPointer<CvButtonbar> result = NULL;
|
|
|
|
|
|
|
|
|
|
if (!layout)
|
|
|
|
|
{
|
|
|
|
|
QPointer<CvWindow> w = icvFindWindowByName( name_window );
|
|
|
|
|
|
|
|
|
|
if( !w )
|
|
|
|
|
CV_Error( CV_StsNullPtr, "NULL window handler" );
|
|
|
|
|
|
|
|
|
|
QString nameQt = QString(name_Buttonbar);
|
|
|
|
|
CvBar* t;
|
|
|
|
|
int start_index;
|
|
|
|
|
int stop_index;
|
|
|
|
|
QPointer<QLayout> myLayout;
|
|
|
|
|
if ( w->param_gui_mode == CV_GUI_NORMAL)
|
|
|
|
|
return (CvTrackbar*) icvFindBarbyName( w->myBarLayout, nameQt, type_CvTrackbar);
|
|
|
|
|
|
|
|
|
|
if (w->param_gui_mode == CV_GUI_EXPANDED)
|
|
|
|
|
if ( w->param_gui_mode == CV_GUI_EXPANDED)
|
|
|
|
|
{
|
|
|
|
|
myLayout = w->getWinProp()->myLayout;
|
|
|
|
|
if (!myLayout)
|
|
|
|
|
CV_Error( CV_StsNullPtr, "NULL window prop handler" );
|
|
|
|
|
result = icvFindBarbyName( w->myBarLayout, nameQt, type_CvTrackbar);
|
|
|
|
|
|
|
|
|
|
start_index = 0;
|
|
|
|
|
stop_index = myLayout->layout()->count();
|
|
|
|
|
if (result)
|
|
|
|
|
return (CvTrackbar*) result;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = start_index; i < stop_index; ++i)
|
|
|
|
|
{
|
|
|
|
|
t = (CvBar*) myLayout->layout()->itemAt(i);
|
|
|
|
|
if (t->type == type_CvButtonbar && t->name_bar == nameQt)
|
|
|
|
|
{
|
|
|
|
|
result = (CvButtonbar*) t;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return (CvTrackbar*) icvFindBarbyName(w->parameters_window->myLayout, nameQt, type_CvTrackbar);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
return NULL;
|
|
|
|
|
}else
|
|
|
|
|
//layout was specified
|
|
|
|
|
{
|
|
|
|
|
return (CvTrackbar*) icvFindBarbyName( layout, nameQt, type_CvTrackbar);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CvButtonbar* icvFindButtonbarByName( const char* button_name,QBoxLayout* layout)
|
|
|
|
|
{
|
|
|
|
|
QString nameQt(button_name);
|
|
|
|
|
return (CvButtonbar*) icvFindBarbyName( layout, nameQt, type_CvButtonbar);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int icvInitSystem()
|
|
|
|
|
@@ -550,14 +513,16 @@ CV_IMPL int cvCreateTrackbar( const char* name_bar, const char* window_name, int
|
|
|
|
|
return 1;//dummy value
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CV_IMPL int cvCreateButton( const char* bar_name, const char* window_name, CvButtonCallback on_change, const char* button_name , void* userdata )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CV_IMPL int cvCreateButton(const char* button_name,CvButtonCallback on_change, void* userdata , int button_type, bool initial_button_state )
|
|
|
|
|
{
|
|
|
|
|
QMetaObject::invokeMethod(&guiMainThread,
|
|
|
|
|
"addButton",
|
|
|
|
|
Qt::AutoConnection,
|
|
|
|
|
Q_ARG(QString, QString(window_name)),
|
|
|
|
|
Q_ARG(QString, QString(bar_name)),
|
|
|
|
|
Q_ARG(QString, QString(button_name)),
|
|
|
|
|
Q_ARG(int, button_type),
|
|
|
|
|
Q_ARG(bool, initial_button_state),
|
|
|
|
|
Q_ARG(void*, (void*)on_change),
|
|
|
|
|
Q_ARG(void*, userdata)
|
|
|
|
|
);
|
|
|
|
|
@@ -734,11 +699,11 @@ void GuiReceiver::setPropWindow(QString name, double arg2 )
|
|
|
|
|
switch(flags)
|
|
|
|
|
{
|
|
|
|
|
case CV_WINDOW_NORMAL:
|
|
|
|
|
w->myLayout->setSizeConstraint(QLayout::SetMinAndMaxSize);
|
|
|
|
|
w->myGlobalLayout->setSizeConstraint(QLayout::SetMinAndMaxSize);
|
|
|
|
|
w->param_flags = flags;
|
|
|
|
|
break;
|
|
|
|
|
case CV_WINDOW_AUTOSIZE:
|
|
|
|
|
w->myLayout->setSizeConstraint(QLayout::SetFixedSize);
|
|
|
|
|
w->myGlobalLayout->setSizeConstraint(QLayout::SetFixedSize);
|
|
|
|
|
w->param_flags = flags;
|
|
|
|
|
break;
|
|
|
|
|
default:;
|
|
|
|
|
@@ -900,46 +865,55 @@ void GuiReceiver::resizeWindow(QString name, int width, int height)
|
|
|
|
|
w->resize(width, height);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GuiReceiver::addButton(QString window_name, QString bar_name, QString button_name, void* on_change, void* userdata)
|
|
|
|
|
void GuiReceiver::addButton(QString button_name, int button_type, bool initial_button_state , void* on_change, void* userdata)
|
|
|
|
|
{
|
|
|
|
|
QPointer<CvWindow> w = icvFindWindowByName( window_name.toLatin1().data() );
|
|
|
|
|
|
|
|
|
|
if (!w)
|
|
|
|
|
if (!global_control_panel)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (!on_change)
|
|
|
|
|
CV_Error(CV_StsNullPtr, "Callback is NULL");
|
|
|
|
|
QPointer<CvButtonbar> b;// = icvFindButtonbarByName( button_name.toLatin1().data(), global_control_panel->myLayout );
|
|
|
|
|
|
|
|
|
|
QPointer<CvButtonbar> b = icvFindButtonbarByName( bar_name.toLatin1().data() ,window_name.toLatin1().data() );
|
|
|
|
|
//if (b)//button with this name already exist
|
|
|
|
|
// return;
|
|
|
|
|
|
|
|
|
|
if (!b)//if the buttonbar does not exist, create it THEN, attached a new button
|
|
|
|
|
b = w->createButtonbar(bar_name);
|
|
|
|
|
CvBar* lastbar = (CvBar*) global_control_panel->myLayout->itemAt(global_control_panel->myLayout->count()-1);
|
|
|
|
|
|
|
|
|
|
if (b)
|
|
|
|
|
b->addButton( button_name,(CvButtonCallback) on_change, userdata);
|
|
|
|
|
if (lastbar->type == type_CvTrackbar)//if last bar is a trackbar, create a new buttonbar, else, attach to the current bar
|
|
|
|
|
b = CvWindow::createButtonbar(button_name);//the bar has the name of the first button attached to it
|
|
|
|
|
else
|
|
|
|
|
b = (CvButtonbar*) lastbar;
|
|
|
|
|
|
|
|
|
|
b->addButton( button_name,(CvButtonCallback) on_change, userdata, button_type, initial_button_state);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void GuiReceiver::addSlider(QString bar_name, QString window_name, void* value, int count, void* on_change)
|
|
|
|
|
{
|
|
|
|
|
QPointer<CvWindow> w = icvFindWindowByName( window_name.toLatin1().data() );
|
|
|
|
|
QBoxLayout *layout = NULL;
|
|
|
|
|
QPointer<CvWindow> w;
|
|
|
|
|
if (window_name != "")
|
|
|
|
|
{
|
|
|
|
|
w = icvFindWindowByName( window_name.toLatin1().data() );
|
|
|
|
|
|
|
|
|
|
if (!w)
|
|
|
|
|
return;
|
|
|
|
|
}else{
|
|
|
|
|
if (global_control_panel)
|
|
|
|
|
layout = global_control_panel->myLayout;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QPointer<CvTrackbar> t = icvFindTrackbarByName( bar_name.toLatin1().data() , window_name.toLatin1().data() );
|
|
|
|
|
QPointer<CvTrackbar> t = icvFindTrackbarByName( bar_name.toLatin1().data() , window_name.toLatin1().data(), layout );
|
|
|
|
|
|
|
|
|
|
if (t)//trackbar exists
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!value)
|
|
|
|
|
CV_Error(CV_StsNullPtr, "NULL value pointer" );
|
|
|
|
|
|
|
|
|
|
if (count<= 0)//count is the max value of the slider, so must be bigger than 0
|
|
|
|
|
CV_Error(CV_StsNullPtr, "Max value of the slider must be bigger than 0" );
|
|
|
|
|
|
|
|
|
|
w->addSlider(bar_name,(int*)value,count,(CvTrackbarCallback) on_change);
|
|
|
|
|
CvWindow::addSlider(w,bar_name,(int*)value,count,(CvTrackbarCallback) on_change);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int GuiReceiver::start()
|
|
|
|
|
@@ -1052,7 +1026,7 @@ CvTrackbar::~CvTrackbar()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//here CvButtonbar class
|
|
|
|
|
CvButtonbar::CvButtonbar(CvWindow* arg, QString arg2)
|
|
|
|
|
CvButtonbar::CvButtonbar(QWidget* arg, QString arg2)
|
|
|
|
|
{
|
|
|
|
|
type=type_CvButtonbar;
|
|
|
|
|
myparent = arg;
|
|
|
|
|
@@ -1081,33 +1055,73 @@ void CvButtonbar::setLabel()
|
|
|
|
|
label->setText(nameNormalized);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CvButtonbar::addButton( QString name, CvButtonCallback call, void* userdata)
|
|
|
|
|
void CvButtonbar::addButton( QString name, CvButtonCallback call, void* userdata, int button_type, bool initial_button_state)
|
|
|
|
|
{
|
|
|
|
|
CvButton* button = new CvButton(this, name,call, userdata);
|
|
|
|
|
QString button_name = name;
|
|
|
|
|
|
|
|
|
|
if (button_name == "")
|
|
|
|
|
button_name = tr("button %1").arg(this->count());
|
|
|
|
|
|
|
|
|
|
button->setText(button_name);
|
|
|
|
|
QObject::connect( button, SIGNAL( clicked() ),button, SLOT( callCallBack() ));
|
|
|
|
|
QPointer<QAbstractButton> button;
|
|
|
|
|
|
|
|
|
|
this->addWidget(button,Qt::AlignCenter);
|
|
|
|
|
if (button_type == CV_PUSH_BUTTON)
|
|
|
|
|
//CvPushButton*
|
|
|
|
|
button = (QAbstractButton*) new CvPushButton(this, button_name,call, userdata);
|
|
|
|
|
|
|
|
|
|
if (button_type == CV_CHECKBOX)
|
|
|
|
|
//CvCheckButton*
|
|
|
|
|
button = (QAbstractButton*) new CvCheckBox(this, button_name,call, userdata, initial_button_state);
|
|
|
|
|
|
|
|
|
|
if (button)
|
|
|
|
|
{
|
|
|
|
|
QObject::connect( button, SIGNAL( clicked() ),button, SLOT( callCallBack() ));
|
|
|
|
|
addWidget(button,Qt::AlignCenter);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CvButton::CvButton(CvButtonbar* arg1, QString arg2, CvButtonCallback arg3, void* arg4)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//buttons here
|
|
|
|
|
CvPushButton::CvPushButton(CvButtonbar* arg1, QString arg2, CvButtonCallback arg3, void* arg4)
|
|
|
|
|
{
|
|
|
|
|
myparent = arg1;
|
|
|
|
|
button_name = arg2;
|
|
|
|
|
callback = arg3;
|
|
|
|
|
userdata=arg4;
|
|
|
|
|
|
|
|
|
|
setObjectName(button_name);
|
|
|
|
|
setText(button_name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CvButton::callCallBack()
|
|
|
|
|
void CvPushButton::callCallBack()
|
|
|
|
|
{
|
|
|
|
|
callback(userdata);
|
|
|
|
|
callback(-1,userdata);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CvCheckBox::CvCheckBox(CvButtonbar* arg1, QString arg2, CvButtonCallback arg3, void* arg4, bool initial_button_state)
|
|
|
|
|
{
|
|
|
|
|
myparent = arg1;
|
|
|
|
|
button_name = arg2;
|
|
|
|
|
callback = arg3;
|
|
|
|
|
userdata=arg4;
|
|
|
|
|
|
|
|
|
|
setObjectName(button_name);
|
|
|
|
|
setCheckState((initial_button_state == 1?Qt::Checked:Qt::Unchecked));
|
|
|
|
|
setText(button_name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CvCheckBox::callCallBack()
|
|
|
|
|
{
|
|
|
|
|
callback(this->isChecked(),userdata);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//here CvWinProperties class
|
|
|
|
|
CvWinProperties::CvWinProperties(QString name_paraWindow, QWidget* parent)
|
|
|
|
|
{
|
|
|
|
|
@@ -1190,10 +1204,6 @@ CvWindow::CvWindow(QString arg, int arg2)
|
|
|
|
|
moveToThread(qApp->instance()->thread());
|
|
|
|
|
param_name = arg;
|
|
|
|
|
|
|
|
|
|
//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 expanded)
|
|
|
|
|
//CV_GUI_EXPANDED = 0x00000000 and CV_GUI_NORMAL = 0x00000010
|
|
|
|
|
param_flags = arg2 & 0x0000000F;
|
|
|
|
|
param_gui_mode = arg2 & 0x000000F0;
|
|
|
|
|
|
|
|
|
|
@@ -1204,36 +1214,47 @@ CvWindow::CvWindow(QString arg, int arg2)
|
|
|
|
|
|
|
|
|
|
resize(400,300);
|
|
|
|
|
|
|
|
|
|
createLayout();
|
|
|
|
|
//1: Layouts
|
|
|
|
|
createBarLayout();
|
|
|
|
|
createGlobalLayout();
|
|
|
|
|
|
|
|
|
|
//1: my view
|
|
|
|
|
//2: my view
|
|
|
|
|
int mode_display = CV_MODE_NORMAL;
|
|
|
|
|
#if defined(OPENCV_GL)
|
|
|
|
|
mode_display = CV_MODE_OPENGL;
|
|
|
|
|
#endif
|
|
|
|
|
createView(mode_display);
|
|
|
|
|
|
|
|
|
|
//2: shortcuts
|
|
|
|
|
//3: shortcuts and actions
|
|
|
|
|
createActions();
|
|
|
|
|
createShortcuts();
|
|
|
|
|
|
|
|
|
|
//toolBar and statusbar
|
|
|
|
|
//4: toolBar and statusbar
|
|
|
|
|
if (param_gui_mode == CV_GUI_EXPANDED)
|
|
|
|
|
{
|
|
|
|
|
createToolBar();
|
|
|
|
|
createStatusBar();
|
|
|
|
|
createParameterWindow();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//5: create control panel
|
|
|
|
|
if (!global_control_panel)
|
|
|
|
|
global_control_panel = createParameterWindow();
|
|
|
|
|
|
|
|
|
|
parameters_window = global_control_panel;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Now attach everything
|
|
|
|
|
if (myToolBar)
|
|
|
|
|
myLayout->addWidget(myToolBar,Qt::AlignCenter);
|
|
|
|
|
myGlobalLayout->addWidget(myToolBar,Qt::AlignCenter);
|
|
|
|
|
|
|
|
|
|
myLayout->addWidget(myview,Qt::AlignCenter);
|
|
|
|
|
myGlobalLayout->addWidget(myview,Qt::AlignCenter);
|
|
|
|
|
|
|
|
|
|
myGlobalLayout->addLayout(myBarLayout,Qt::AlignCenter);
|
|
|
|
|
|
|
|
|
|
if (myStatusBar)
|
|
|
|
|
myLayout->addWidget(myStatusBar,Qt::AlignCenter);
|
|
|
|
|
myGlobalLayout->addWidget(myStatusBar,Qt::AlignCenter);
|
|
|
|
|
|
|
|
|
|
setLayout(myLayout);
|
|
|
|
|
setLayout(myGlobalLayout);
|
|
|
|
|
show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -1241,14 +1262,23 @@ CvWindow::~CvWindow()
|
|
|
|
|
{
|
|
|
|
|
QLayoutItem *child;
|
|
|
|
|
|
|
|
|
|
if (myLayout)
|
|
|
|
|
if (myGlobalLayout)
|
|
|
|
|
{
|
|
|
|
|
while ((child = myLayout->takeAt(0)) != 0)
|
|
|
|
|
while ((child = myGlobalLayout->takeAt(0)) != 0)
|
|
|
|
|
delete child;
|
|
|
|
|
|
|
|
|
|
delete myLayout;
|
|
|
|
|
delete myGlobalLayout;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (myBarLayout)
|
|
|
|
|
{
|
|
|
|
|
while ((child = myBarLayout->takeAt(0)) != 0)
|
|
|
|
|
delete child;
|
|
|
|
|
|
|
|
|
|
delete myBarLayout;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (myStatusBar)
|
|
|
|
|
{
|
|
|
|
|
delete myStatusBar;
|
|
|
|
|
@@ -1267,28 +1297,21 @@ CvWindow::~CvWindow()
|
|
|
|
|
delete vect_QShortcuts[i];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CvButtonbar* CvWindow::createButtonbar(QString name_bar)
|
|
|
|
|
{
|
|
|
|
|
QPointer<CvButtonbar> t;
|
|
|
|
|
|
|
|
|
|
if (param_gui_mode == CV_GUI_EXPANDED)
|
|
|
|
|
{
|
|
|
|
|
t = new CvButtonbar(this,name_bar);
|
|
|
|
|
QPointer<CvButtonbar> t = new CvButtonbar(global_control_panel,name_bar);
|
|
|
|
|
t->setAlignment(Qt::AlignHCenter);
|
|
|
|
|
|
|
|
|
|
parameters_window->myLayout->insertLayout(parameters_window->myLayout->count(),t);
|
|
|
|
|
}
|
|
|
|
|
QPointer<QBoxLayout> myLayout = global_control_panel->myLayout;
|
|
|
|
|
|
|
|
|
|
myLayout->insertLayout(myLayout->count(),t);
|
|
|
|
|
|
|
|
|
|
return t;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CvWinProperties* CvWindow::getWinProp()
|
|
|
|
|
{
|
|
|
|
|
return parameters_window;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CvWindow::hideTools()
|
|
|
|
|
{
|
|
|
|
|
if (myToolBar)
|
|
|
|
|
@@ -1313,10 +1336,12 @@ void CvWindow::showTools()
|
|
|
|
|
// parameters_window->show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CvWindow::createParameterWindow()
|
|
|
|
|
CvWinProperties* CvWindow::createParameterWindow()
|
|
|
|
|
{
|
|
|
|
|
QString name_paraWindow=param_name+" window parameters";
|
|
|
|
|
parameters_window = new CvWinProperties(name_paraWindow,this);
|
|
|
|
|
QString name_paraWindow ="Global control panel";
|
|
|
|
|
|
|
|
|
|
CvWinProperties *result = new CvWinProperties(name_paraWindow,this);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CvWindow::displayPropertiesWin()
|
|
|
|
|
@@ -1327,56 +1352,62 @@ void CvWindow::displayPropertiesWin()
|
|
|
|
|
parameters_window->hide();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CvWindow::createActions()
|
|
|
|
|
{
|
|
|
|
|
vect_QActions.resize(10);
|
|
|
|
|
|
|
|
|
|
//if the shortcuts are changed in window_QT.h, we need to update the tooltip manually
|
|
|
|
|
vect_QActions[0] = new QAction(QIcon(":/left-icon"),"Panning left (CTRL+arrowLEFT)",this);
|
|
|
|
|
vect_QActions[0]->setIconVisibleInMenu(true);
|
|
|
|
|
QObject::connect( vect_QActions[0],SIGNAL(triggered()),myview, SLOT( siftWindowOnLeft() ));
|
|
|
|
|
|
|
|
|
|
vect_QActions[1] = new QAction(QIcon(":/right-icon"),"Panning right (CTRL+arrowRIGHT)",this);
|
|
|
|
|
vect_QActions[1]->setIconVisibleInMenu(true);
|
|
|
|
|
QObject::connect( vect_QActions[1],SIGNAL(triggered()),myview, SLOT( siftWindowOnRight() ));
|
|
|
|
|
|
|
|
|
|
vect_QActions[2] = new QAction(QIcon(":/up-icon"),"Panning up (CTRL+arrowUP)",this);
|
|
|
|
|
vect_QActions[2]->setIconVisibleInMenu(true);
|
|
|
|
|
QObject::connect( vect_QActions[2],SIGNAL(triggered()),myview, SLOT( siftWindowOnUp() ));
|
|
|
|
|
|
|
|
|
|
vect_QActions[3] = new QAction(QIcon(":/down-icon"),"Panning down (CTRL+arrowDOWN)",this);
|
|
|
|
|
vect_QActions[3]->setIconVisibleInMenu(true);
|
|
|
|
|
QObject::connect( vect_QActions[3],SIGNAL(triggered()),myview, SLOT( siftWindowOnDown() ));
|
|
|
|
|
|
|
|
|
|
vect_QActions[4] = new QAction(QIcon(":/zoom_x1-icon"),"Zoom x1 (CTRL+P)",this);
|
|
|
|
|
vect_QActions[4]->setIconVisibleInMenu(true);
|
|
|
|
|
QObject::connect( vect_QActions[4],SIGNAL(triggered()),myview, SLOT( resetZoom() ));
|
|
|
|
|
|
|
|
|
|
vect_QActions[5] = new QAction(QIcon(":/imgRegion-icon"),tr("Zoom x%1 (see label) (CTRL+X)")
|
|
|
|
|
.arg(threshold_zoom_img_region)
|
|
|
|
|
,this);
|
|
|
|
|
vect_QActions[5]->setIconVisibleInMenu(true);
|
|
|
|
|
QObject::connect( vect_QActions[5],SIGNAL(triggered()),myview, SLOT( imgRegion() ));
|
|
|
|
|
|
|
|
|
|
vect_QActions[6] = new QAction(QIcon(":/zoom_in-icon"),tr("Zoom in (CTRL++)"),this);
|
|
|
|
|
vect_QActions[6]->setIconVisibleInMenu(true);
|
|
|
|
|
QObject::connect( vect_QActions[6],SIGNAL(triggered()),myview, SLOT( ZoomIn() ));
|
|
|
|
|
|
|
|
|
|
vect_QActions[7] = new QAction(QIcon(":/zoom_out-icon"),tr("Zoom out (CTRL+-)"),this);
|
|
|
|
|
vect_QActions[7]->setIconVisibleInMenu(true);
|
|
|
|
|
QObject::connect( vect_QActions[7],SIGNAL(triggered()),myview, SLOT( ZoomOut() ));
|
|
|
|
|
|
|
|
|
|
vect_QActions[8] = new QAction(QIcon(":/save-icon"),tr("Save current image (CTRL+S)"),this);
|
|
|
|
|
vect_QActions[8]->setIconVisibleInMenu(true);
|
|
|
|
|
QObject::connect( vect_QActions[8],SIGNAL(triggered()),myview, SLOT( saveView() ));
|
|
|
|
|
|
|
|
|
|
vect_QActions[9] = new QAction(QIcon(":/properties-icon"),tr("Display properties window (CTRL+P)"),this);
|
|
|
|
|
vect_QActions[9]->setIconVisibleInMenu(true);
|
|
|
|
|
QObject::connect( vect_QActions[9],SIGNAL(triggered()),this, SLOT( displayPropertiesWin() ));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CvWindow::createToolBar()
|
|
|
|
|
{
|
|
|
|
|
myToolBar = new QToolBar;
|
|
|
|
|
myToolBar->setFloatable(false);//is not a window
|
|
|
|
|
myToolBar->setMaximumHeight(28);
|
|
|
|
|
|
|
|
|
|
vect_QActions.resize(10);
|
|
|
|
|
|
|
|
|
|
//if the shortcuts are changed in window_QT.h, we need to update the tooltip manually
|
|
|
|
|
vect_QActions[0] = new QAction(QIcon(":/left-icon"),"Panning left (CTRL+arrowLEFT)",this);
|
|
|
|
|
QObject::connect( vect_QActions[0],SIGNAL(triggered()),myview, SLOT( siftWindowOnLeft() ));
|
|
|
|
|
myToolBar->addAction(vect_QActions[0]);
|
|
|
|
|
|
|
|
|
|
vect_QActions[1] = new QAction(QIcon(":/right-icon"),"Panning right (CTRL+arrowRIGHT)",this);
|
|
|
|
|
QObject::connect( vect_QActions[1],SIGNAL(triggered()),myview, SLOT( siftWindowOnRight() ));
|
|
|
|
|
myToolBar->addAction(vect_QActions[1]);
|
|
|
|
|
|
|
|
|
|
vect_QActions[2] = new QAction(QIcon(":/up-icon"),"Panning up (CTRL+arrowUP)",this);
|
|
|
|
|
QObject::connect( vect_QActions[2],SIGNAL(triggered()),myview, SLOT( siftWindowOnUp() ));
|
|
|
|
|
myToolBar->addAction(vect_QActions[2]);
|
|
|
|
|
|
|
|
|
|
vect_QActions[3] = new QAction(QIcon(":/down-icon"),"Panning down (CTRL+arrowDOWN)",this);
|
|
|
|
|
QObject::connect( vect_QActions[3],SIGNAL(triggered()),myview, SLOT( siftWindowOnDown() ));
|
|
|
|
|
myToolBar->addAction(vect_QActions[3]);
|
|
|
|
|
|
|
|
|
|
vect_QActions[4] = new QAction(QIcon(":/zoom_x1-icon"),"Zoom x1 (CTRL+P)",this);
|
|
|
|
|
QObject::connect( vect_QActions[4],SIGNAL(triggered()),myview, SLOT( resetZoom() ));
|
|
|
|
|
myToolBar->addAction(vect_QActions[4]);
|
|
|
|
|
|
|
|
|
|
vect_QActions[5] = new QAction(QIcon(":/imgRegion-icon"),tr("Zoom x%1 (see label) (CTRL+X)")
|
|
|
|
|
.arg(threshold_zoom_img_region)
|
|
|
|
|
,this);
|
|
|
|
|
QObject::connect( vect_QActions[5],SIGNAL(triggered()),myview, SLOT( imgRegion() ));
|
|
|
|
|
myToolBar->addAction(vect_QActions[5]);
|
|
|
|
|
|
|
|
|
|
vect_QActions[6] = new QAction(QIcon(":/zoom_in-icon"),tr("Zoom in (CTRL++)"),this);
|
|
|
|
|
QObject::connect( vect_QActions[6],SIGNAL(triggered()),myview, SLOT( ZoomIn() ));
|
|
|
|
|
myToolBar->addAction(vect_QActions[6]);
|
|
|
|
|
|
|
|
|
|
vect_QActions[7] = new QAction(QIcon(":/zoom_out-icon"),tr("Zoom out (CTRL+-)"),this);
|
|
|
|
|
QObject::connect( vect_QActions[7],SIGNAL(triggered()),myview, SLOT( ZoomOut() ));
|
|
|
|
|
myToolBar->addAction(vect_QActions[7]);
|
|
|
|
|
|
|
|
|
|
vect_QActions[8] = new QAction(QIcon(":/save-icon"),tr("Save current image (CTRL+S)"),this);
|
|
|
|
|
QObject::connect( vect_QActions[8],SIGNAL(triggered()),myview, SLOT( saveView() ));
|
|
|
|
|
myToolBar->addAction(vect_QActions[8]);
|
|
|
|
|
|
|
|
|
|
vect_QActions[9] = new QAction(QIcon(":/properties-icon"),tr("Display properties window (CTRL+P)"),this);
|
|
|
|
|
QObject::connect( vect_QActions[9],SIGNAL(triggered()),this, SLOT( displayPropertiesWin() ));
|
|
|
|
|
myToolBar->addAction(vect_QActions[9]);
|
|
|
|
|
foreach (QAction *a, vect_QActions)
|
|
|
|
|
myToolBar->addAction(a);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CvWindow::createStatusBar()
|
|
|
|
|
@@ -1390,16 +1421,25 @@ void CvWindow::createStatusBar()
|
|
|
|
|
myStatusBar->addWidget(myStatusBar_msg);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CvWindow::createLayout()
|
|
|
|
|
void CvWindow::createGlobalLayout()
|
|
|
|
|
{
|
|
|
|
|
myLayout = new QBoxLayout(QBoxLayout::TopToBottom);
|
|
|
|
|
myLayout->setObjectName(QString::fromUtf8("boxLayout"));
|
|
|
|
|
myLayout->setContentsMargins(0, 0, 0, 0);
|
|
|
|
|
myLayout->setSpacing(0);
|
|
|
|
|
myLayout->setMargin(0);
|
|
|
|
|
myGlobalLayout = new QBoxLayout(QBoxLayout::TopToBottom);
|
|
|
|
|
myGlobalLayout->setObjectName(QString::fromUtf8("boxLayout"));
|
|
|
|
|
myGlobalLayout->setContentsMargins(0, 0, 0, 0);
|
|
|
|
|
myGlobalLayout->setSpacing(0);
|
|
|
|
|
myGlobalLayout->setMargin(0);
|
|
|
|
|
|
|
|
|
|
if (param_flags == CV_WINDOW_AUTOSIZE)
|
|
|
|
|
myLayout->setSizeConstraint(QLayout::SetFixedSize);
|
|
|
|
|
myGlobalLayout->setSizeConstraint(QLayout::SetFixedSize);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CvWindow::createBarLayout()
|
|
|
|
|
{
|
|
|
|
|
myBarLayout = new QBoxLayout(QBoxLayout::TopToBottom);
|
|
|
|
|
myBarLayout->setObjectName(QString::fromUtf8("barLayout"));
|
|
|
|
|
myBarLayout->setContentsMargins(0, 0, 0, 0);
|
|
|
|
|
myBarLayout->setSpacing(0);
|
|
|
|
|
myBarLayout->setMargin(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CvWindow::createShortcuts()
|
|
|
|
|
@@ -1466,29 +1506,21 @@ void CvWindow::setMouseCallBack(CvMouseCallback m, void* param)
|
|
|
|
|
myview->setMouseCallBack(m,param);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CvWindow::addSlider(QString name, int* value, int count,CvTrackbarCallback on_change)
|
|
|
|
|
//addSlider is static
|
|
|
|
|
void CvWindow::addSlider(CvWindow* w,QString name, int* value, int count,CvTrackbarCallback on_change)
|
|
|
|
|
{
|
|
|
|
|
QPointer<CvTrackbar> t = new CvTrackbar(this,name,value, count, on_change);
|
|
|
|
|
QPointer<CvTrackbar> t = new CvTrackbar(w,name,value, count, on_change);
|
|
|
|
|
t->setAlignment(Qt::AlignHCenter);
|
|
|
|
|
|
|
|
|
|
int position_insert;
|
|
|
|
|
if (param_gui_mode == CV_GUI_NORMAL)
|
|
|
|
|
{
|
|
|
|
|
position_insert = myLayout->count();
|
|
|
|
|
QPointer<QBoxLayout> myLayout;
|
|
|
|
|
|
|
|
|
|
if (myStatusBar)
|
|
|
|
|
position_insert--;//max-1 means add trackbar between myview and statusbar
|
|
|
|
|
if (w)
|
|
|
|
|
myLayout = w->myBarLayout;
|
|
|
|
|
else
|
|
|
|
|
myLayout = global_control_panel->myLayout;
|
|
|
|
|
|
|
|
|
|
myLayout->insertLayout(position_insert,t);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
myLayout->insertLayout( myLayout->count(),t);
|
|
|
|
|
|
|
|
|
|
if (param_gui_mode == CV_GUI_EXPANDED)
|
|
|
|
|
{
|
|
|
|
|
position_insert = parameters_window->myLayout->count();
|
|
|
|
|
parameters_window->myLayout->insertLayout(position_insert,t);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -1584,33 +1616,21 @@ void CvWindow::icvLoadTrackbars(QSettings *settings)
|
|
|
|
|
{
|
|
|
|
|
int size = settings->beginReadArray("trackbars");
|
|
|
|
|
QPointer<CvTrackbar> t;
|
|
|
|
|
//Warning ---- , asume the location 0 is toolbar, 1 is myview and max-1 the status bar
|
|
|
|
|
//done three times in the code, in loadtrackbars, savetrackbar and in findtrackbar
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//trackbar are saved in the same order, so no need to use icvFindTrackbarByName
|
|
|
|
|
|
|
|
|
|
int start_index = 1;//index 0 is myview
|
|
|
|
|
if (myToolBar)
|
|
|
|
|
start_index ++;//index 0 is statusbar, 1 is myview
|
|
|
|
|
|
|
|
|
|
int stop_index = myLayout->layout()->count() - start_index ;
|
|
|
|
|
if (myStatusBar)
|
|
|
|
|
stop_index --;// index max-1 is the statusbar
|
|
|
|
|
|
|
|
|
|
//(in expended mode) nbTrackbar = count() - (toolbar + myview + statusbar) (3) = stop_index - start_index
|
|
|
|
|
int start_index = 0;
|
|
|
|
|
int stop_index = myBarLayout->layout()->count() ;
|
|
|
|
|
|
|
|
|
|
if (stop_index-start_index == size)//if not the same number, the window saved and loaded is not the same (nb trackbar not equal)
|
|
|
|
|
for (int i = start_index; i < size+start_index; ++i)
|
|
|
|
|
{
|
|
|
|
|
settings->setArrayIndex(i-start_index);
|
|
|
|
|
t = (CvTrackbar*) myLayout->layout()->itemAt(i);
|
|
|
|
|
t = (CvTrackbar*) myBarLayout->layout()->itemAt(i);
|
|
|
|
|
|
|
|
|
|
if (t->name_bar == settings->value("name").toString())
|
|
|
|
|
//if (t->getName() == settings->value("name").toString())
|
|
|
|
|
{
|
|
|
|
|
t->slider->setValue(settings->value("value").toInt());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
settings->endArray();
|
|
|
|
|
|
|
|
|
|
@@ -1620,16 +1640,12 @@ void CvWindow::icvSaveTrackbars(QSettings *settings)
|
|
|
|
|
{
|
|
|
|
|
QPointer<CvTrackbar> t;
|
|
|
|
|
|
|
|
|
|
//Warning ---- , asume the location 0 is toolbar, 1 is myview and max-1 the status bar
|
|
|
|
|
//done three times in the code, in loadtrackbars, savetrackbar and in findtrackbar
|
|
|
|
|
settings->beginWriteArray("trackbars");
|
|
|
|
|
|
|
|
|
|
int start_index = 2;
|
|
|
|
|
if (myToolBar)
|
|
|
|
|
start_index=3;
|
|
|
|
|
int start_index = 0;
|
|
|
|
|
|
|
|
|
|
for (int i = start_index; i < myLayout->layout()->count()-1; ++i) {
|
|
|
|
|
t = (CvTrackbar*) myLayout->layout()->itemAt(i);
|
|
|
|
|
for (int i = start_index; i < myBarLayout->layout()->count()-1; ++i) {
|
|
|
|
|
t = (CvTrackbar*) myBarLayout->layout()->itemAt(i);
|
|
|
|
|
settings->setArrayIndex(i-start_index);
|
|
|
|
|
settings->setValue("name", t->name_bar);
|
|
|
|
|
//settings->setValue("name", t->getName());
|
|
|
|
|
@@ -1696,6 +1712,18 @@ ViewPort::~ViewPort()
|
|
|
|
|
delete timerDisplay;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ViewPort::contextMenuEvent(QContextMenuEvent *event)
|
|
|
|
|
{
|
|
|
|
|
if (centralWidget->vect_QActions.size() > 0)
|
|
|
|
|
{
|
|
|
|
|
QMenu menu(this);
|
|
|
|
|
foreach (QAction *a, centralWidget->vect_QActions)
|
|
|
|
|
menu.addAction(a);
|
|
|
|
|
// menu.popup(event->globalPos());
|
|
|
|
|
menu.exec(event->globalPos());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//can save as JPG, JPEG, BMP, PNG
|
|
|
|
|
void ViewPort::saveView()
|
|
|
|
|
{
|
|
|
|
|
|