|
|
|
@ -60,7 +60,7 @@ static CvWinProperties* global_control_panel = NULL; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CV_IMPL CvFont cvFont_Qt(const char* nameFont, int pointSize,CvScalar color,int weight,int style, int spacing) |
|
|
|
|
CV_IMPL CvFont cvFontQt(const char* nameFont, int pointSize,CvScalar color,int weight,int style, int spacing) |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
@ -441,10 +441,10 @@ int icvInitSystem() |
|
|
|
|
new QApplication(parameterSystemC,parameterSystemV); |
|
|
|
|
|
|
|
|
|
wasInitialized = 1; |
|
|
|
|
qDebug()<<"init done"; |
|
|
|
|
//qDebug()<<"init done";
|
|
|
|
|
|
|
|
|
|
#if defined( HAVE_QT_OPENGL )//OK tested !
|
|
|
|
|
qDebug()<<"opengl support available"; |
|
|
|
|
//qDebug()<<"opengl support available";
|
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -905,7 +905,7 @@ void GuiReceiver::showImage(QString name, void* arr) |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
qDebug()<<"Do nothing (Window or Image NULL)"<<endl; |
|
|
|
|
CV_Error(CV_StsNullPtr, "Do nothing (Window or Image NULL)"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -982,6 +982,11 @@ void GuiReceiver::addButton(QString button_name, int button_type, int initial_bu |
|
|
|
|
//if (b)//button with this name already exist
|
|
|
|
|
// return;
|
|
|
|
|
|
|
|
|
|
if (global_control_panel->myLayout->count() == 0)//if that is the first button attach to the control panel, create a new button bar
|
|
|
|
|
{ |
|
|
|
|
b = CvWindow::createButtonbar(button_name);//the bar has the name of the first button attached to it
|
|
|
|
|
|
|
|
|
|
}else{ |
|
|
|
|
CvBar* lastbar = (CvBar*) global_control_panel->myLayout->itemAt(global_control_panel->myLayout->count()-1); |
|
|
|
|
|
|
|
|
|
if (lastbar->type == type_CvTrackbar)//if last bar is a trackbar, create a new buttonbar, else, attach to the current bar
|
|
|
|
@ -989,6 +994,8 @@ void GuiReceiver::addButton(QString button_name, int button_type, int initial_bu |
|
|
|
|
else |
|
|
|
|
b = (CvButtonbar*) lastbar; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
b->addButton( button_name,(CvButtonCallback) on_change, userdata, button_type, initial_button_state); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -1713,6 +1720,8 @@ void CvWindow::readSettings() |
|
|
|
|
//param_name = settings.value("name_window",param_name).toString();
|
|
|
|
|
param_flags = settings.value("mode_resize",param_flags).toInt(); |
|
|
|
|
param_gui_mode = settings.value("mode_gui",param_gui_mode).toInt(); |
|
|
|
|
|
|
|
|
|
param_ratio_mode = settings.value("mode_ratio",param_ratio_mode).toInt(); |
|
|
|
|
myview->param_keepRatio = settings.value("view_aspectRatio",myview->param_keepRatio).toInt(); |
|
|
|
|
|
|
|
|
|
param_flags = settings.value("mode_resize",param_flags).toInt(); |
|
|
|
@ -1732,6 +1741,12 @@ void CvWindow::readSettings() |
|
|
|
|
|
|
|
|
|
resize(size); |
|
|
|
|
move(pos); |
|
|
|
|
|
|
|
|
|
if (global_control_panel) |
|
|
|
|
{ |
|
|
|
|
icvLoadControlPanel(); |
|
|
|
|
global_control_panel->move(settings.value("posPanel", global_control_panel->pos()).toPoint()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void CvWindow::writeSettings() |
|
|
|
@ -1743,6 +1758,8 @@ void CvWindow::writeSettings() |
|
|
|
|
settings.setValue("size", size()); |
|
|
|
|
settings.setValue("mode_resize",param_flags); |
|
|
|
|
settings.setValue("mode_gui",param_gui_mode); |
|
|
|
|
|
|
|
|
|
settings.setValue("param_ratio_mode",param_ratio_mode); |
|
|
|
|
settings.setValue("view_aspectRatio",myview->param_keepRatio); |
|
|
|
|
|
|
|
|
|
settings.setValue("matrix_view.m11",myview->param_matrixWorld.m11()); |
|
|
|
@ -1756,8 +1773,134 @@ void CvWindow::writeSettings() |
|
|
|
|
settings.setValue("matrix_view.m33",myview->param_matrixWorld.m33()); |
|
|
|
|
|
|
|
|
|
icvSaveTrackbars(&settings); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (global_control_panel) |
|
|
|
|
{ |
|
|
|
|
icvSaveControlPanel(); |
|
|
|
|
settings.setValue("posPanel", global_control_panel->pos()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void CvWindow::icvLoadControlPanel() |
|
|
|
|
{ |
|
|
|
|
QSettings settings("OpenCV2", QFileInfo(QApplication::applicationFilePath()).fileName()+" control panel"); |
|
|
|
|
int size = settings.beginReadArray("bars"); |
|
|
|
|
int subsize; |
|
|
|
|
CvBar* t; |
|
|
|
|
if (size == global_control_panel->myLayout->layout()->count()) |
|
|
|
|
for (int i = 0; i < size; ++i) { |
|
|
|
|
t = (CvBar*) global_control_panel->myLayout->layout()->itemAt(i); |
|
|
|
|
settings.setArrayIndex(i); |
|
|
|
|
if (t->type == type_CvTrackbar) |
|
|
|
|
{ |
|
|
|
|
if (t->name_bar == settings.value("namebar").toString()) |
|
|
|
|
{ |
|
|
|
|
((CvTrackbar*)t)->slider->setValue(settings.value("valuebar").toInt()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (t->type == type_CvButtonbar) |
|
|
|
|
{ |
|
|
|
|
subsize = settings.beginReadArray(QString("buttonbar")+i); |
|
|
|
|
|
|
|
|
|
if ( subsize == ((CvButtonbar*)t)->layout()->count() ) |
|
|
|
|
icvLoadButtonbar((CvButtonbar*)t,&settings); |
|
|
|
|
|
|
|
|
|
settings.endArray(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
settings.endArray(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void CvWindow::icvSaveControlPanel() |
|
|
|
|
{ |
|
|
|
|
QSettings settings("OpenCV2", QFileInfo(QApplication::applicationFilePath()).fileName()+" control panel"); |
|
|
|
|
settings.beginWriteArray("bars"); |
|
|
|
|
|
|
|
|
|
CvBar* t; |
|
|
|
|
for (int i = 0; i < global_control_panel->myLayout->layout()->count(); ++i) { |
|
|
|
|
t = (CvBar*) global_control_panel->myLayout->layout()->itemAt(i); |
|
|
|
|
settings.setArrayIndex(i); |
|
|
|
|
if (t->type == type_CvTrackbar) |
|
|
|
|
{ |
|
|
|
|
settings.setValue("namebar", QString(t->name_bar)); |
|
|
|
|
settings.setValue("valuebar",((CvTrackbar*)t)->slider->value()); |
|
|
|
|
} |
|
|
|
|
if (t->type == type_CvButtonbar) |
|
|
|
|
{ |
|
|
|
|
settings.beginWriteArray(QString("buttonbar")+i); |
|
|
|
|
icvSaveButtonbar((CvButtonbar*)t,&settings); |
|
|
|
|
settings.endArray(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
settings.endArray(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void CvWindow::icvSaveButtonbar(CvButtonbar* b,QSettings *settings) |
|
|
|
|
{ |
|
|
|
|
QWidget* temp; |
|
|
|
|
QString myclass; |
|
|
|
|
for (int i = 0; i < b->layout()->count(); ++i) { |
|
|
|
|
settings->setArrayIndex(i); |
|
|
|
|
temp = (QWidget*) b->layout()->itemAt(i)->widget(); |
|
|
|
|
myclass = QString(temp->metaObject ()->className ()); |
|
|
|
|
if (myclass == "CvPushButton") |
|
|
|
|
{ |
|
|
|
|
CvPushButton* button = (CvPushButton*) temp; |
|
|
|
|
settings->setValue("namebutton", QString(button->text()) ); |
|
|
|
|
settings->setValue("valuebutton", int(button->isChecked())); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (myclass == "CvCheckBox") |
|
|
|
|
{ |
|
|
|
|
CvCheckBox* button = (CvCheckBox*) temp; |
|
|
|
|
settings->setValue("namebutton", QString(button->text()) ); |
|
|
|
|
settings->setValue("valuebutton", int(button->isChecked())); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (myclass == "CvRadioButton") |
|
|
|
|
{ |
|
|
|
|
CvRadioButton* button = (CvRadioButton*) temp; |
|
|
|
|
settings->setValue("namebutton", QString(button->text()) ); |
|
|
|
|
settings->setValue("valuebutton", int(button->isChecked())); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void CvWindow::icvLoadButtonbar(CvButtonbar* b,QSettings *settings) |
|
|
|
|
{ |
|
|
|
|
QWidget* temp; |
|
|
|
|
QString myclass; |
|
|
|
|
for (int i = 0; i < b->layout()->count(); ++i) |
|
|
|
|
{ |
|
|
|
|
settings->setArrayIndex(i); |
|
|
|
|
temp = (QWidget*) b->layout()->itemAt(i)->widget(); |
|
|
|
|
myclass = QString(temp->metaObject ()->className ()); |
|
|
|
|
if (myclass == "CvPushButton") |
|
|
|
|
{ |
|
|
|
|
CvPushButton* button = (CvPushButton*) temp; |
|
|
|
|
if (button->text() == settings->value("namebutton").toString()) |
|
|
|
|
button->setChecked(settings->value("valuebutton").toInt()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (myclass == "CvCheckBox") |
|
|
|
|
{ |
|
|
|
|
CvCheckBox* button = (CvCheckBox*) temp; |
|
|
|
|
if (button->text() == settings->value("namebutton").toString()) |
|
|
|
|
button->setChecked(settings->value("valuebutton").toInt()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (myclass == "CvRadioButton") |
|
|
|
|
{ |
|
|
|
|
CvRadioButton* button = (CvRadioButton*) temp; |
|
|
|
|
if (button->text() == settings->value("namebutton").toString()) |
|
|
|
|
button->setChecked(settings->value("valuebutton").toInt()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CvWindow::icvLoadTrackbars(QSettings *settings) |
|
|
|
|
{ |
|
|
|
|
int size = settings->beginReadArray("trackbars"); |
|
|
|
@ -1765,13 +1908,10 @@ void CvWindow::icvLoadTrackbars(QSettings *settings) |
|
|
|
|
|
|
|
|
|
//trackbar are saved in the same order, so no need to use icvFindTrackbarByName
|
|
|
|
|
|
|
|
|
|
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) |
|
|
|
|
if (myBarLayout->layout()->count() == size)//if not the same number, the window saved and loaded is not the same (nb trackbar not equal)
|
|
|
|
|
for (int i = 0; i < size; ++i) |
|
|
|
|
{ |
|
|
|
|
settings->setArrayIndex(i-start_index); |
|
|
|
|
settings->setArrayIndex(i); |
|
|
|
|
t = (CvTrackbar*) myBarLayout->layout()->itemAt(i); |
|
|
|
|
|
|
|
|
|
if (t->name_bar == settings->value("name").toString()) |
|
|
|
@ -1788,13 +1928,10 @@ void CvWindow::icvSaveTrackbars(QSettings *settings) |
|
|
|
|
|
|
|
|
|
settings->beginWriteArray("trackbars"); |
|
|
|
|
|
|
|
|
|
int start_index = 0; |
|
|
|
|
|
|
|
|
|
for (int i = start_index; i < myBarLayout->layout()->count()-1; ++i) { |
|
|
|
|
for (int i = 0; i < myBarLayout->layout()->count(); ++i) { |
|
|
|
|
t = (CvTrackbar*) myBarLayout->layout()->itemAt(i); |
|
|
|
|
settings->setArrayIndex(i-start_index); |
|
|
|
|
settings->setArrayIndex(i); |
|
|
|
|
settings->setValue("name", t->name_bar); |
|
|
|
|
//settings->setValue("name", t->getName());
|
|
|
|
|
settings->setValue("value", t->slider->value()); |
|
|
|
|
} |
|
|
|
|
settings->endArray(); |
|
|
|
@ -1920,7 +2057,7 @@ void ViewPort::saveView() |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
qDebug()<<"file extension not recognized, please choose between JPG, JPEG, BMP or PNG"; |
|
|
|
|
CV_Error(CV_StsNullPtr, "file extension not recognized, please choose between JPG, JPEG, BMP or PNG"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|