New functions with QT GUI:
Fixed bugs indicated by Vadim
This commit is contained in:
parent
5cbe64dac7
commit
c007b60b25
@ -144,9 +144,8 @@ CV_IMPL int cvWaitKey( int arg )
|
|||||||
timer.setSingleShot(true);
|
timer.setSingleShot(true);
|
||||||
|
|
||||||
if (arg>0)
|
if (arg>0)
|
||||||
timer.start(arg);//delayms);
|
timer.start(arg);
|
||||||
|
|
||||||
//QTimer::singleShot(delayms, &guiMainThread, SLOT(timeOut()));
|
|
||||||
while(!guiMainThread._bTimeOut)
|
while(!guiMainThread._bTimeOut)
|
||||||
{
|
{
|
||||||
qApp->processEvents(QEventLoop::AllEvents);
|
qApp->processEvents(QEventLoop::AllEvents);
|
||||||
@ -157,6 +156,7 @@ CV_IMPL int cvWaitKey( int arg )
|
|||||||
result = last_key;
|
result = last_key;
|
||||||
last_key = -1;
|
last_key = -1;
|
||||||
timer.stop();
|
timer.stop();
|
||||||
|
//printf("keypressed\n");
|
||||||
}
|
}
|
||||||
mutexKey.unlock();
|
mutexKey.unlock();
|
||||||
|
|
||||||
@ -724,8 +724,6 @@ CvTrackbar::~CvTrackbar()
|
|||||||
CvWindow::CvWindow(QString arg, int arg2)
|
CvWindow::CvWindow(QString arg, int arg2)
|
||||||
{
|
{
|
||||||
moveToThread(qApp->instance()->thread());
|
moveToThread(qApp->instance()->thread());
|
||||||
|
|
||||||
last_key = 0;
|
|
||||||
name = arg;
|
name = arg;
|
||||||
flags = arg2;
|
flags = arg2;
|
||||||
|
|
||||||
@ -826,12 +824,11 @@ void CvWindow::keyPressEvent(QKeyEvent *event)
|
|||||||
goodKey = true;
|
goodKey = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//control plus Z, plus +, and plus - are used for zoom functions
|
//control plus (Z, +, -, up, down, left, right) are used for zoom/panning functions
|
||||||
if (event->modifiers() != Qt::ControlModifier && goodKey)
|
if (event->modifiers() != Qt::ControlModifier && goodKey)
|
||||||
{
|
{
|
||||||
mutexKey.lock();
|
mutexKey.lock();
|
||||||
last_key = key;
|
last_key = key;
|
||||||
|
|
||||||
//last_key = event->nativeVirtualKey ();
|
//last_key = event->nativeVirtualKey ();
|
||||||
mutexKey.unlock();
|
mutexKey.unlock();
|
||||||
key_pressed.wakeAll();
|
key_pressed.wakeAll();
|
||||||
@ -874,7 +871,7 @@ ViewPort::ViewPort(QWidget* arg, int arg2)
|
|||||||
drawInfo = false;
|
drawInfo = false;
|
||||||
positionGrabbing = QPointF(0,0);
|
positionGrabbing = QPointF(0,0);
|
||||||
positionCorners = QRect(0,0,size().width(),size().height());
|
positionCorners = QRect(0,0,size().width(),size().height());
|
||||||
|
on_mouse = NULL;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -1115,6 +1112,8 @@ void ViewPort::mousePressEvent(QMouseEvent *event)
|
|||||||
{
|
{
|
||||||
int a, b;
|
int a, b;
|
||||||
matrixWorld_inv.map(pt.x(),pt.y(),&a,&b);
|
matrixWorld_inv.map(pt.x(),pt.y(),&a,&b);
|
||||||
|
a*=float(image2Draw->width)/float(width());
|
||||||
|
b*=float(image2Draw->height)/float(height());
|
||||||
on_mouse( cv_event, a, b, flags, on_mouse_param );
|
on_mouse( cv_event, a, b, flags, on_mouse_param );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1176,6 +1175,8 @@ void ViewPort::mouseReleaseEvent(QMouseEvent *event)
|
|||||||
{
|
{
|
||||||
int a, b;
|
int a, b;
|
||||||
matrixWorld_inv.map(pt.x(),pt.y(),&a,&b);
|
matrixWorld_inv.map(pt.x(),pt.y(),&a,&b);
|
||||||
|
a*=float(image2Draw->width)/float(width());
|
||||||
|
b*=float(image2Draw->height)/float(height());
|
||||||
on_mouse( cv_event, a, b, flags, on_mouse_param );
|
on_mouse( cv_event, a, b, flags, on_mouse_param );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1231,6 +1232,8 @@ void ViewPort::mouseDoubleClickEvent(QMouseEvent *event)
|
|||||||
{
|
{
|
||||||
int a, b;
|
int a, b;
|
||||||
matrixWorld_inv.map(pt.x(),pt.y(),&a,&b);
|
matrixWorld_inv.map(pt.x(),pt.y(),&a,&b);
|
||||||
|
a*=float(image2Draw->width)/float(width());
|
||||||
|
b*=float(image2Draw->height)/float(height());
|
||||||
on_mouse( cv_event, a, b, flags, on_mouse_param );
|
on_mouse( cv_event, a, b, flags, on_mouse_param );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1263,11 +1266,26 @@ void ViewPort::mouseMoveEvent(QMouseEvent *event)
|
|||||||
}
|
}
|
||||||
|
|
||||||
cv_event = CV_EVENT_MOUSEMOVE;
|
cv_event = CV_EVENT_MOUSEMOVE;
|
||||||
|
switch(event->buttons())
|
||||||
|
{
|
||||||
|
case Qt::LeftButton:
|
||||||
|
flags |= CV_EVENT_FLAG_LBUTTON;
|
||||||
|
break;
|
||||||
|
case Qt::RightButton:
|
||||||
|
flags |= CV_EVENT_FLAG_RBUTTON;
|
||||||
|
break;
|
||||||
|
case Qt::MidButton:
|
||||||
|
flags |= CV_EVENT_FLAG_MBUTTON;
|
||||||
|
break;
|
||||||
|
default:;
|
||||||
|
}
|
||||||
|
|
||||||
if (on_mouse)
|
if (on_mouse)
|
||||||
{
|
{
|
||||||
int a, b;
|
int a, b;
|
||||||
matrixWorld_inv.map(pt.x(),pt.y(),&a,&b);
|
matrixWorld_inv.map(pt.x(),pt.y(),&a,&b);
|
||||||
|
a*=float(image2Draw->width)/float(width());
|
||||||
|
b*=float(image2Draw->height)/float(height());
|
||||||
on_mouse( cv_event, a, b, flags, on_mouse_param );
|
on_mouse( cv_event, a, b, flags, on_mouse_param );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user