|
|
|
@@ -51,7 +51,10 @@ static bool multiThreads = false;
|
|
|
|
|
static int last_key = -1;
|
|
|
|
|
QWaitCondition key_pressed;
|
|
|
|
|
QMutex mutexKey;
|
|
|
|
|
static const unsigned int threshold_zoom_img_region = 15;//the minimum zoom value to start displaying the values' grid
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
//end static and global
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -287,9 +290,7 @@ CV_IMPL void cvStopLoop()
|
|
|
|
|
{
|
|
|
|
|
qApp->exit();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CV_IMPL CvWindow* icvFindWindowByName( const char* arg )
|
|
|
|
|
CvWindow* icvFindWindowByName( const char* arg )
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
QPointer<CvWindow> window = NULL;
|
|
|
|
@@ -300,6 +301,8 @@ CV_IMPL CvWindow* icvFindWindowByName( const char* arg )
|
|
|
|
|
QString name(arg);
|
|
|
|
|
QPointer<CvWindow> w;
|
|
|
|
|
foreach (QWidget *widget, QApplication::topLevelWidgets())
|
|
|
|
|
{
|
|
|
|
|
if (widget->isWindow() && !widget->parentWidget ())//is a window without parent
|
|
|
|
|
{
|
|
|
|
|
w = (CvWindow*) widget;
|
|
|
|
|
if (w->param_name==name)
|
|
|
|
@@ -308,6 +311,7 @@ CV_IMPL CvWindow* icvFindWindowByName( const char* arg )
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return window;
|
|
|
|
|
}
|
|
|
|
@@ -325,11 +329,13 @@ CvTrackbar* icvFindTrackbarByName( const char* name_trackbar, const char* name_w
|
|
|
|
|
QString nameQt = QString(name_trackbar);
|
|
|
|
|
QPointer<CvTrackbar> t;
|
|
|
|
|
|
|
|
|
|
//Warning ---- , asume the location 0 is myview and max-1 the status bar
|
|
|
|
|
int 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
|
|
|
|
|
for (int i = 1; i < w->layout->layout()->count()-1; ++i)
|
|
|
|
|
for (int i = start_index; i < w->layout->layout()->count()-1; ++i)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
t = (CvTrackbar*) w->layout->layout()->itemAt(i);
|
|
|
|
|
if (t->trackbar_name==nameQt)
|
|
|
|
|
{
|
|
|
|
@@ -546,7 +552,7 @@ GuiReceiver::GuiReceiver() : _bTimeOut(false)
|
|
|
|
|
|
|
|
|
|
void GuiReceiver::putText(void* arg1, QString text, QPoint org, void* arg2)
|
|
|
|
|
{
|
|
|
|
|
CV_Assert(arg1);
|
|
|
|
|
CV_Assert(arg1)
|
|
|
|
|
|
|
|
|
|
IplImage* img = (IplImage*)arg1;
|
|
|
|
|
|
|
|
|
@@ -843,14 +849,14 @@ CvTrackbar::CvTrackbar(CvWindow* arg, QString name, int* value, int count, CvTra
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Change style of the Slider
|
|
|
|
|
slider->setStyleSheet(str_Trackbar_css);
|
|
|
|
|
//slider->setStyleSheet(str_Trackbar_css);
|
|
|
|
|
|
|
|
|
|
//QFile qss(PATH_QSLIDERCSS);
|
|
|
|
|
//if (qss.open(QFile::ReadOnly))
|
|
|
|
|
//{
|
|
|
|
|
// slider->setStyleSheet(QLatin1String(qss.readAll()));
|
|
|
|
|
// qss.close();
|
|
|
|
|
//}
|
|
|
|
|
QFile qss(":/stylesheet-trackbar");
|
|
|
|
|
if (qss.open(QFile::ReadOnly))
|
|
|
|
|
{
|
|
|
|
|
slider->setStyleSheet(QLatin1String(qss.readAll()));
|
|
|
|
|
qss.close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//this next line does not work if we change the style with a stylesheet, why ? (bug in QT ?)
|
|
|
|
@@ -925,14 +931,18 @@ CvTrackbar::~CvTrackbar()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Here CvWindow class
|
|
|
|
|
CvWindow::CvWindow(QString arg, int arg2)
|
|
|
|
|
{
|
|
|
|
|
moveToThread(qApp->instance()->thread());
|
|
|
|
|
param_name = arg;
|
|
|
|
|
param_flags = arg2;
|
|
|
|
|
|
|
|
|
|
//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)
|
|
|
|
|
//CV_GUI_EXTENDED = 0x00000000 and CV_GUI_NORMAL = 0x00000010
|
|
|
|
|
param_flags = arg2 & 0x0000000F;
|
|
|
|
|
param_gui_mode = arg2 & 0x000000F0;
|
|
|
|
|
|
|
|
|
|
setAttribute(Qt::WA_DeleteOnClose);//in other case, does not release memory
|
|
|
|
|
setContentsMargins(0,0,0,0);
|
|
|
|
@@ -941,58 +951,33 @@ CvWindow::CvWindow(QString arg, int arg2)
|
|
|
|
|
|
|
|
|
|
resize(400,300);
|
|
|
|
|
|
|
|
|
|
int mode_display = CV_MODE_NORMAL;
|
|
|
|
|
createLayout();
|
|
|
|
|
|
|
|
|
|
//1: my view
|
|
|
|
|
int mode_display = CV_MODE_NORMAL;
|
|
|
|
|
#if defined(OPENCV_GL)
|
|
|
|
|
mode_display = CV_MODE_OPENGL;
|
|
|
|
|
#endif
|
|
|
|
|
createView(mode_display);
|
|
|
|
|
|
|
|
|
|
//CV_MODE_NORMAL or CV_MODE_OPENGL
|
|
|
|
|
myview = new ViewPort(this, mode_display,CV_WINDOW_KEEPRATIO);//parent, mode_display, keep_aspect_ratio
|
|
|
|
|
myview->setAlignment(Qt::AlignHCenter);
|
|
|
|
|
//2: shortcuts
|
|
|
|
|
createShortcuts();
|
|
|
|
|
|
|
|
|
|
//toolBar and statusbar
|
|
|
|
|
if (param_gui_mode == CV_GUI_EXTENDED)
|
|
|
|
|
{
|
|
|
|
|
createToolBar();
|
|
|
|
|
createStatusBar();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
shortcut_Z = new QShortcut(shortcut_zoom_normal, this);
|
|
|
|
|
QObject::connect( shortcut_Z, SIGNAL( activated ()),myview, SLOT( resetZoom( ) ));
|
|
|
|
|
shortcut_S = new QShortcut(shortcut_save_img, this);
|
|
|
|
|
QObject::connect( shortcut_S, SIGNAL( activated ()),myview, SLOT( saveView( ) ));
|
|
|
|
|
shortcut_P = new QShortcut(shortcut_properties_win, this);
|
|
|
|
|
//QObject::connect( shortcut_P, SIGNAL( activated ()),myview, SLOT( callPropertiesWin( ) ));
|
|
|
|
|
shortcut_X = new QShortcut(shortcut_zoom_imgRegion, this);
|
|
|
|
|
QObject::connect( shortcut_X, SIGNAL( activated ()),myview, SLOT( imgRegion( ) ));
|
|
|
|
|
shortcut_Plus = new QShortcut(shortcut_zoom_in, this);
|
|
|
|
|
QObject::connect( shortcut_Plus, SIGNAL( activated ()),myview, SLOT( ZoomIn() ));
|
|
|
|
|
shortcut_Minus = new QShortcut(shortcut_zoom_out, this);
|
|
|
|
|
QObject::connect(shortcut_Minus, SIGNAL( activated ()),myview, SLOT( ZoomOut() ));
|
|
|
|
|
shortcut_Left = new QShortcut(shortcut_panning_left, this);
|
|
|
|
|
QObject::connect( shortcut_Left, SIGNAL( activated ()),myview, SLOT( siftWindowOnLeft() ));
|
|
|
|
|
shortcut_Right = new QShortcut(shortcut_panning_right, this);
|
|
|
|
|
QObject::connect( shortcut_Right, SIGNAL( activated ()),myview, SLOT( siftWindowOnRight() ));
|
|
|
|
|
shortcut_Up = new QShortcut(shortcut_panning_up, this);
|
|
|
|
|
QObject::connect(shortcut_Up, SIGNAL( activated ()),myview, SLOT( siftWindowOnUp() ));
|
|
|
|
|
shortcut_Down = new QShortcut(shortcut_panning_down, this);
|
|
|
|
|
QObject::connect(shortcut_Down, SIGNAL( activated ()),myview, SLOT( siftWindowOnDown() ));
|
|
|
|
|
//Now attach everything
|
|
|
|
|
if (myToolBar)
|
|
|
|
|
layout->addWidget(myToolBar,Qt::AlignCenter);
|
|
|
|
|
|
|
|
|
|
layout = new QBoxLayout(QBoxLayout::TopToBottom);
|
|
|
|
|
layout->setObjectName(QString::fromUtf8("boxLayout"));
|
|
|
|
|
layout->setContentsMargins(0, 0, 0, 0);
|
|
|
|
|
layout->setSpacing(0);
|
|
|
|
|
layout->setMargin(0);
|
|
|
|
|
layout->addWidget(myview,Qt::AlignCenter);
|
|
|
|
|
|
|
|
|
|
if (param_flags == CV_WINDOW_AUTOSIZE)
|
|
|
|
|
layout->setSizeConstraint(QLayout::SetFixedSize);
|
|
|
|
|
|
|
|
|
|
//now status bar
|
|
|
|
|
myBar = new QStatusBar;
|
|
|
|
|
myBar->setSizeGripEnabled(false);
|
|
|
|
|
myBar->setMaximumHeight(20);
|
|
|
|
|
myBar_msg = new QLabel;
|
|
|
|
|
myBar_msg->setFrameStyle(QFrame::Raised);
|
|
|
|
|
myBar_msg->setAlignment(Qt::AlignHCenter);
|
|
|
|
|
myBar->addWidget(myBar_msg);
|
|
|
|
|
layout->addWidget(myBar,Qt::AlignCenter);
|
|
|
|
|
|
|
|
|
|
if (myStatusBar)
|
|
|
|
|
layout->addWidget(myStatusBar,Qt::AlignCenter);
|
|
|
|
|
|
|
|
|
|
setLayout(layout);
|
|
|
|
|
show();
|
|
|
|
@@ -1010,20 +995,125 @@ CvWindow::~CvWindow()
|
|
|
|
|
delete layout;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
delete myBar;
|
|
|
|
|
delete myBar_msg;
|
|
|
|
|
delete myStatusBar;
|
|
|
|
|
delete myStatusBar_msg;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
delete shortcut_Z;
|
|
|
|
|
delete shortcut_S;
|
|
|
|
|
delete shortcut_P;
|
|
|
|
|
delete shortcut_X;
|
|
|
|
|
delete shortcut_Plus;
|
|
|
|
|
delete shortcut_Minus;
|
|
|
|
|
delete shortcut_Left;
|
|
|
|
|
delete shortcut_Right;
|
|
|
|
|
delete shortcut_Up;
|
|
|
|
|
delete shortcut_Down;
|
|
|
|
|
for (int i=0;i<vect_QShortcuts.count();i++)
|
|
|
|
|
delete vect_QShortcuts[i];
|
|
|
|
|
|
|
|
|
|
for (int i=0;i<vect_QActions.count();i++)
|
|
|
|
|
delete vect_QActions[i];
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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()),myview, SLOT( displayPropertiesWin() ));
|
|
|
|
|
myToolBar->addAction(vect_QActions[9]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CvWindow::createStatusBar()
|
|
|
|
|
{
|
|
|
|
|
myStatusBar = new QStatusBar;
|
|
|
|
|
myStatusBar->setSizeGripEnabled(false);
|
|
|
|
|
myStatusBar->setMaximumHeight(20);
|
|
|
|
|
myStatusBar_msg = new QLabel;
|
|
|
|
|
myStatusBar_msg->setFrameStyle(QFrame::Raised);
|
|
|
|
|
myStatusBar_msg->setAlignment(Qt::AlignHCenter);
|
|
|
|
|
myStatusBar->addWidget(myStatusBar_msg);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CvWindow::createLayout()
|
|
|
|
|
{
|
|
|
|
|
layout = new QBoxLayout(QBoxLayout::TopToBottom);
|
|
|
|
|
layout->setObjectName(QString::fromUtf8("boxLayout"));
|
|
|
|
|
layout->setContentsMargins(0, 0, 0, 0);
|
|
|
|
|
layout->setSpacing(0);
|
|
|
|
|
layout->setMargin(0);
|
|
|
|
|
|
|
|
|
|
if (param_flags == CV_WINDOW_AUTOSIZE)
|
|
|
|
|
layout->setSizeConstraint(QLayout::SetFixedSize);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CvWindow::createShortcuts()
|
|
|
|
|
{
|
|
|
|
|
vect_QShortcuts.resize(10);
|
|
|
|
|
|
|
|
|
|
vect_QShortcuts[0] = new QShortcut(shortcut_panning_left, this);
|
|
|
|
|
QObject::connect( vect_QShortcuts[0], SIGNAL( activated ()),myview, SLOT( siftWindowOnLeft() ));
|
|
|
|
|
vect_QShortcuts[1] = new QShortcut(shortcut_panning_right, this);
|
|
|
|
|
QObject::connect( vect_QShortcuts[1], SIGNAL( activated ()),myview, SLOT( siftWindowOnRight() ));
|
|
|
|
|
vect_QShortcuts[2] = new QShortcut(shortcut_panning_up, this);
|
|
|
|
|
QObject::connect(vect_QShortcuts[2], SIGNAL( activated ()),myview, SLOT( siftWindowOnUp() ));
|
|
|
|
|
vect_QShortcuts[3] = new QShortcut(shortcut_panning_down, this);
|
|
|
|
|
QObject::connect(vect_QShortcuts[3], SIGNAL( activated ()),myview, SLOT( siftWindowOnDown() ));
|
|
|
|
|
|
|
|
|
|
vect_QShortcuts[4] = new QShortcut(shortcut_zoom_normal, this);
|
|
|
|
|
QObject::connect( vect_QShortcuts[4], SIGNAL( activated ()),myview, SLOT( resetZoom( ) ));
|
|
|
|
|
vect_QShortcuts[5] = new QShortcut(shortcut_zoom_imgRegion, this);
|
|
|
|
|
QObject::connect( vect_QShortcuts[5], SIGNAL( activated ()),myview, SLOT( imgRegion( ) ));
|
|
|
|
|
vect_QShortcuts[6] = new QShortcut(shortcut_zoom_in, this);
|
|
|
|
|
QObject::connect( vect_QShortcuts[6], SIGNAL( activated ()),myview, SLOT( ZoomIn() ));
|
|
|
|
|
vect_QShortcuts[7] = new QShortcut(shortcut_zoom_out, this);
|
|
|
|
|
QObject::connect(vect_QShortcuts[7], SIGNAL( activated ()),myview, SLOT( ZoomOut() ));
|
|
|
|
|
vect_QShortcuts[8] = new QShortcut(shortcut_save_img, this);
|
|
|
|
|
QObject::connect( vect_QShortcuts[8], SIGNAL( activated ()),myview, SLOT( saveView( ) ));
|
|
|
|
|
vect_QShortcuts[9] = new QShortcut(shortcut_properties_win, this);
|
|
|
|
|
QObject::connect( vect_QShortcuts[9], SIGNAL( activated ()),myview, SLOT( displayPropertiesWin() ));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CvWindow::createView(int mode)
|
|
|
|
|
{
|
|
|
|
|
//mode = CV_MODE_NORMAL or CV_MODE_OPENGL
|
|
|
|
|
myview = new ViewPort(this, mode,CV_WINDOW_KEEPRATIO);//parent, mode_display, keep_aspect_ratio
|
|
|
|
|
myview->setAlignment(Qt::AlignHCenter);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CvWindow::setOpenGLCallback(CvOpenGLCallback func,void* userdata)
|
|
|
|
@@ -1043,7 +1133,7 @@ void CvWindow::displayInfo(QString text,int delayms)
|
|
|
|
|
|
|
|
|
|
void CvWindow::displayStatusBar(QString text,int delayms)
|
|
|
|
|
{
|
|
|
|
|
myBar->showMessage(text,delayms);
|
|
|
|
|
myStatusBar->showMessage(text,delayms);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CvWindow::updateImage(void* arr)
|
|
|
|
@@ -1060,7 +1150,12 @@ void CvWindow::addSlider(QString name, int* value, int count,CvTrackbarCallback
|
|
|
|
|
{
|
|
|
|
|
QPointer<CvTrackbar> t = new CvTrackbar(this,name,value, count, on_change);
|
|
|
|
|
t->setAlignment(Qt::AlignHCenter);
|
|
|
|
|
layout->insertLayout(layout->count()-1,t);//max-1 means add trackbar between myview and statusbar
|
|
|
|
|
int position_insert = layout->count();
|
|
|
|
|
|
|
|
|
|
if (myStatusBar)
|
|
|
|
|
position_insert--;//max-1 means add trackbar between myview and statusbar
|
|
|
|
|
|
|
|
|
|
layout->insertLayout(position_insert,t);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Need more test here !
|
|
|
|
@@ -1152,15 +1247,27 @@ void CvWindow::icvLoadTrackbars(QSettings *settings)
|
|
|
|
|
{
|
|
|
|
|
int size = settings->beginReadArray("trackbars");
|
|
|
|
|
QPointer<CvTrackbar> t;
|
|
|
|
|
//Warning ---- , asume the location 0 is myview and max-1 the status bar
|
|
|
|
|
//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
|
|
|
|
|
if (layout->layout()->count()-2 == 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)
|
|
|
|
|
|
|
|
|
|
int start_index = 1;//index 0 is myview
|
|
|
|
|
if (myToolBar)
|
|
|
|
|
start_index ++;//index 0 is statusbar, 1 is myview
|
|
|
|
|
|
|
|
|
|
int stop_index = layout->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
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
t = (CvTrackbar*) layout->layout()->itemAt(i+1);//+1 because index 0 is myview (see Warning)
|
|
|
|
|
settings->setArrayIndex(i-start_index);
|
|
|
|
|
t = (CvTrackbar*) layout->layout()->itemAt(i);
|
|
|
|
|
|
|
|
|
|
if (t->trackbar_name == settings->value("name").toString())
|
|
|
|
|
{
|
|
|
|
@@ -1175,12 +1282,17 @@ void CvWindow::icvSaveTrackbars(QSettings *settings)
|
|
|
|
|
{
|
|
|
|
|
QPointer<CvTrackbar> t;
|
|
|
|
|
|
|
|
|
|
//Warning ---- , asume the location 0 is myview and max-1 the status bar
|
|
|
|
|
//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");
|
|
|
|
|
for (int i = 0; i < layout->layout()->count()-2; ++i) {
|
|
|
|
|
t = (CvTrackbar*) layout->layout()->itemAt(i+1);//+1 because index 0 is myview (see Warning)
|
|
|
|
|
settings->setArrayIndex(i);
|
|
|
|
|
|
|
|
|
|
int start_index = 2;
|
|
|
|
|
if (myToolBar)
|
|
|
|
|
start_index=3;
|
|
|
|
|
|
|
|
|
|
for (int i = start_index; i < layout->layout()->count()-1; ++i) {
|
|
|
|
|
t = (CvTrackbar*) layout->layout()->itemAt(i);
|
|
|
|
|
settings->setArrayIndex(i-start_index);
|
|
|
|
|
settings->setValue("name", t->trackbar_name);
|
|
|
|
|
settings->setValue("value", t->slider->value());
|
|
|
|
|
}
|
|
|
|
@@ -1197,6 +1309,7 @@ void CvWindow::icvSaveTrackbars(QSettings *settings)
|
|
|
|
|
ViewPort::ViewPort(CvWindow* arg, int arg2, int arg3)
|
|
|
|
|
{
|
|
|
|
|
centralWidget = arg,
|
|
|
|
|
setParent(centralWidget);
|
|
|
|
|
mode_display = arg2;
|
|
|
|
|
param_keepRatio = arg3;
|
|
|
|
|
|
|
|
|
@@ -1288,6 +1401,11 @@ void ViewPort::saveView()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ViewPort::displayPropertiesWin()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ViewPort::setRatio(int flags)
|
|
|
|
|
{
|
|
|
|
|
param_keepRatio = flags;
|
|
|
|
@@ -1482,6 +1600,7 @@ void ViewPort::scaleView(qreal factor,QPointF center)
|
|
|
|
|
controlImagePosition();
|
|
|
|
|
|
|
|
|
|
//display new zoom
|
|
|
|
|
if (centralWidget->myStatusBar)
|
|
|
|
|
centralWidget->displayStatusBar(tr("Zoom: %1%").arg(param_matrixWorld.m11()*100),1000);
|
|
|
|
|
|
|
|
|
|
if (param_matrixWorld.m11()>1)
|
|
|
|
@@ -1560,6 +1679,7 @@ void ViewPort::mouseMoveEvent(QMouseEvent *event)
|
|
|
|
|
|
|
|
|
|
//I update the statusbar here because if the user does a cvWaitkey(0) (like with inpaint.cpp)
|
|
|
|
|
//the status bar will only be repaint when a click occurs.
|
|
|
|
|
if (centralWidget->myStatusBar)
|
|
|
|
|
viewport()->update();
|
|
|
|
|
|
|
|
|
|
QWidget::mouseMoveEvent(event);
|
|
|
|
@@ -1653,6 +1773,11 @@ void ViewPort::resizeEvent ( QResizeEvent *event)
|
|
|
|
|
//move to the middle
|
|
|
|
|
//newSize get the delta offset to place the picture in the middle of its parent
|
|
|
|
|
newSize= (event->size()-newSize)/2;
|
|
|
|
|
|
|
|
|
|
//if the toolbar is displayed, avoid drawing myview on top of it
|
|
|
|
|
if (centralWidget->myToolBar)
|
|
|
|
|
newSize +=QSize(0,centralWidget->myToolBar->height());
|
|
|
|
|
|
|
|
|
|
move(newSize.width(),newSize.height());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@@ -1709,6 +1834,7 @@ void ViewPort::paintEvent(QPaintEvent* event)
|
|
|
|
|
//end display
|
|
|
|
|
|
|
|
|
|
//for statusbar
|
|
|
|
|
if (centralWidget->myStatusBar)
|
|
|
|
|
drawStatusBar();
|
|
|
|
|
|
|
|
|
|
QGraphicsView::paintEvent(event);
|
|
|
|
@@ -1730,7 +1856,7 @@ void ViewPort::drawStatusBar()
|
|
|
|
|
|
|
|
|
|
if (nbChannelOriginImage==3)
|
|
|
|
|
{
|
|
|
|
|
centralWidget->myBar_msg->setText(tr("<font color='black'>Coordinate: %1x%2 ~ </font>")
|
|
|
|
|
centralWidget->myStatusBar_msg->setText(tr("<font color='black'>Coordinate: %1x%2 ~ </font>")
|
|
|
|
|
.arg(mouseCoordinate.x())
|
|
|
|
|
.arg(mouseCoordinate.y())+
|
|
|
|
|
tr("<font color='red'>R:%3 </font>").arg(qRed(rgbValue))+//.arg(value.val[0])+
|
|
|
|
@@ -1739,7 +1865,7 @@ void ViewPort::drawStatusBar()
|
|
|
|
|
);
|
|
|
|
|
}else{
|
|
|
|
|
//all the channel have the same value (because of cvconvertimage), so only the r channel is dsplayed
|
|
|
|
|
centralWidget->myBar_msg->setText(tr("<font color='black'>Coordinate: %1x%2 ~ </font>")
|
|
|
|
|
centralWidget->myStatusBar_msg->setText(tr("<font color='black'>Coordinate: %1x%2 ~ </font>")
|
|
|
|
|
.arg(mouseCoordinate.x())
|
|
|
|
|
.arg(mouseCoordinate.y())+
|
|
|
|
|
tr("<font color='grey'>grey:%3 </font>").arg(qRed(rgbValue))
|
|
|
|
@@ -1766,8 +1892,10 @@ void ViewPort::drawImgRegion(QPainter *painter)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QFont f = painter->font();
|
|
|
|
|
int original_font_size = f.pointSize();
|
|
|
|
|
//change font size
|
|
|
|
|
//f.setPointSize(4+(param_matrixWorld.m11()-threshold_zoom_img_region)/5);
|
|
|
|
|
f.setPixelSize(6+(param_matrixWorld.m11()-threshold_zoom_img_region)/5);
|
|
|
|
|
//f.setStretch(0);
|
|
|
|
|
painter->setFont(f);
|
|
|
|
|
QString val;
|
|
|
|
|
QRgb rgbValue;
|
|
|
|
@@ -1820,6 +1948,10 @@ void ViewPort::drawImgRegion(QPainter *painter)
|
|
|
|
|
painter->drawLines(linesX.data(), linesX.size());
|
|
|
|
|
painter->drawLines(linesY.data(), linesY.size());
|
|
|
|
|
|
|
|
|
|
//restore font size
|
|
|
|
|
f.setPointSize(original_font_size);
|
|
|
|
|
painter->setFont(f);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ViewPort::drawViewOverview(QPainter *painter)
|
|
|
|
@@ -1858,6 +1990,7 @@ void ViewPort::drawInstructions(QPainter *painter)
|
|
|
|
|
painter->setPen(Qt::white);
|
|
|
|
|
painter->fillRect(QRect(0, 0, width(), rect.height() + 2*border),
|
|
|
|
|
QColor(0, 0, 0, 127));
|
|
|
|
|
|
|
|
|
|
painter->drawText((width() - rect.width())/2, border,
|
|
|
|
|
rect.width(), rect.height(),
|
|
|
|
|
Qt::AlignCenter | Qt::TextWordWrap, infoText);
|
|
|
|
|