New functions with QT GUI
Zoom function done, working on panning now (weel enable it) Fixed mouse coordinate bugs
This commit is contained in:
parent
56f17b78bb
commit
c4fded9afa
@ -45,9 +45,9 @@
|
|||||||
|
|
||||||
//Static and global first
|
//Static and global first
|
||||||
static GuiReceiver guiMainThread;
|
static GuiReceiver guiMainThread;
|
||||||
|
static int parameterSystemC = 1;
|
||||||
|
static char* parameterSystemV[] = {""};
|
||||||
static bool multiThreads = false;
|
static bool multiThreads = false;
|
||||||
static const int myargc = 1;
|
|
||||||
static char* myargv[] = {""};
|
|
||||||
static int last_key = -1;
|
static int last_key = -1;
|
||||||
QWaitCondition key_pressed;
|
QWaitCondition key_pressed;
|
||||||
QMutex mutexKey;
|
QMutex mutexKey;
|
||||||
@ -166,7 +166,9 @@ CV_IMPL int cvWaitKey( int arg )
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Yannick Verdie
|
||||||
|
//This function is experimental and some functions (such as cvSet/getWindowProperty will not work)
|
||||||
|
//We recommend not using this function for now
|
||||||
CV_IMPL int cvStartLoop(int (*pt2Func)(int argc, char *argv[]), int argc, char* argv[])
|
CV_IMPL int cvStartLoop(int (*pt2Func)(int argc, char *argv[]), int argc, char* argv[])
|
||||||
{
|
{
|
||||||
multiThreads = true;
|
multiThreads = true;
|
||||||
@ -230,6 +232,22 @@ CvTrackbar* icvFindTrackbarByName( const char* name_trackbar, const char* name_w
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CV_IMPL int icvInitSystem()
|
||||||
|
{
|
||||||
|
static int wasInitialized = 0;
|
||||||
|
|
||||||
|
// check initialization status
|
||||||
|
if( !wasInitialized)
|
||||||
|
{
|
||||||
|
new QApplication(parameterSystemC,parameterSystemV);
|
||||||
|
|
||||||
|
wasInitialized = 1;
|
||||||
|
qDebug()<<"init done"<<endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
CV_IMPL int cvNamedWindow( const char* name, int flags )
|
CV_IMPL int cvNamedWindow( const char* name, int flags )
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -248,24 +266,6 @@ CV_IMPL int cvNamedWindow( const char* name, int flags )
|
|||||||
return 1;//Dummy value
|
return 1;//Dummy value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CV_IMPL int icvInitSystem( int argc, char** argv )
|
|
||||||
{
|
|
||||||
|
|
||||||
static int wasInitialized = 0;
|
|
||||||
|
|
||||||
// check initialization status
|
|
||||||
if( !wasInitialized)
|
|
||||||
{
|
|
||||||
new QApplication(argc,argv);
|
|
||||||
|
|
||||||
wasInitialized = 1;
|
|
||||||
qDebug()<<"init done"<<endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
CV_IMPL void cvDestroyWindow( const char* name )
|
CV_IMPL void cvDestroyWindow( const char* name )
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -422,7 +422,7 @@ CV_IMPL void cvShowImage( const char* name, const CvArr* arr )
|
|||||||
|
|
||||||
GuiReceiver::GuiReceiver() : _bTimeOut(false)
|
GuiReceiver::GuiReceiver() : _bTimeOut(false)
|
||||||
{
|
{
|
||||||
icvInitSystem(myargc,myargv );
|
icvInitSystem();
|
||||||
qApp->setQuitOnLastWindowClosed ( false );//maybe the user would like to access this setting
|
qApp->setQuitOnLastWindowClosed ( false );//maybe the user would like to access this setting
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -723,7 +723,6 @@ CvWindow::CvWindow(QString arg, int arg2)
|
|||||||
|
|
||||||
last_key = 0;
|
last_key = 0;
|
||||||
name = arg;
|
name = arg;
|
||||||
on_mouse = NULL;
|
|
||||||
flags = arg2;
|
flags = arg2;
|
||||||
|
|
||||||
setAttribute(Qt::WA_DeleteOnClose);//in other case, does not release memory
|
setAttribute(Qt::WA_DeleteOnClose);//in other case, does not release memory
|
||||||
@ -765,6 +764,13 @@ CvWindow::~CvWindow()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
void CvWindow::startNavigate()
|
||||||
|
{
|
||||||
|
cout<<"here"<<endl;
|
||||||
|
//myview->zoomIn();
|
||||||
|
}*/
|
||||||
|
|
||||||
void CvWindow::displayInfo(QString text,int delayms)
|
void CvWindow::displayInfo(QString text,int delayms)
|
||||||
{
|
{
|
||||||
myview->startDisplayInfo(text, delayms);
|
myview->startDisplayInfo(text, delayms);
|
||||||
@ -777,10 +783,7 @@ void CvWindow::updateImage(void* arr)
|
|||||||
|
|
||||||
void CvWindow::setMouseCallBack(CvMouseCallback m, void* param)
|
void CvWindow::setMouseCallBack(CvMouseCallback m, void* param)
|
||||||
{
|
{
|
||||||
setMouseTracking (true);//receive mouse event everytime
|
myview->setMouseCallBack(m,param);
|
||||||
myview->setMouseTracking (true);//receive mouse event everytime
|
|
||||||
on_mouse = m;
|
|
||||||
on_mouse_param = param;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CvWindow::addSlider(QString name, int* value, int count,CvTrackbarCallback on_change)
|
void CvWindow::addSlider(QString name, int* value, int count,CvTrackbarCallback on_change)
|
||||||
@ -799,7 +802,136 @@ void CvWindow::keyPressEvent(QKeyEvent *event)
|
|||||||
QWidget::keyPressEvent(event);
|
QWidget::keyPressEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CvWindow::mousePressEvent(QMouseEvent *event)
|
|
||||||
|
void CvWindow::readSettings()//not tested
|
||||||
|
{
|
||||||
|
QSettings settings("Trolltech", "Application Example");
|
||||||
|
QPoint pos = settings.value("pos", QPoint(200, 200)).toPoint();
|
||||||
|
QSize size = settings.value("size", QSize(400, 400)).toSize();
|
||||||
|
resize(size);
|
||||||
|
move(pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CvWindow::writeSettings()//not tested
|
||||||
|
{
|
||||||
|
QSettings settings("Trolltech", "Application Example");
|
||||||
|
settings.setValue("pos", pos());
|
||||||
|
settings.setValue("size", size());
|
||||||
|
}
|
||||||
|
|
||||||
|
//Here is ViewPort
|
||||||
|
ViewPort::ViewPort(QWidget* arg, int arg2)
|
||||||
|
{
|
||||||
|
mode = arg2;
|
||||||
|
centralWidget = arg,
|
||||||
|
setupViewport(centralWidget);
|
||||||
|
setUpdatesEnabled(true);
|
||||||
|
setObjectName(QString::fromUtf8("graphicsView"));
|
||||||
|
timerDisplay = new QTimer(this);
|
||||||
|
timerDisplay->setSingleShot(true);
|
||||||
|
connect(timerDisplay, SIGNAL(timeout()), this, SLOT(stopDisplayInfo()));
|
||||||
|
drawInfo = false;
|
||||||
|
previousFactor = 1;
|
||||||
|
previousCenter = QPointF(0,0);
|
||||||
|
previousDelta = QPointF(0,0);
|
||||||
|
|
||||||
|
if (mode == CV_MODE_OPENGL)
|
||||||
|
{
|
||||||
|
#if defined(OPENCV_GL)
|
||||||
|
setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));
|
||||||
|
initGL();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
image2Draw=cvCreateImage(cvSize(centralWidget->width(),centralWidget->height()),IPL_DEPTH_8U,3);
|
||||||
|
cvZero(image2Draw);
|
||||||
|
}
|
||||||
|
|
||||||
|
ViewPort::~ViewPort()
|
||||||
|
{
|
||||||
|
if (image2Draw)
|
||||||
|
cvReleaseImage(&image2Draw);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ViewPort::startDisplayInfo(QString text, int delayms)
|
||||||
|
{
|
||||||
|
if (timerDisplay->isActive())
|
||||||
|
stopDisplayInfo();
|
||||||
|
|
||||||
|
infoText = text;
|
||||||
|
timerDisplay->start(delayms);
|
||||||
|
drawInfo = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ViewPort::stopDisplayInfo()
|
||||||
|
{
|
||||||
|
timerDisplay->stop();
|
||||||
|
drawInfo = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool ViewPort::isSameSize(IplImage* img1,IplImage* img2)
|
||||||
|
{
|
||||||
|
return img1->width == img2->width && img1->height == img2->height;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ViewPort::updateImage(void* arr)
|
||||||
|
{
|
||||||
|
if (!arr)
|
||||||
|
CV_Error(CV_StsNullPtr, "NULL arr pointer (in showImage)" );
|
||||||
|
|
||||||
|
IplImage* tempImage = (IplImage*)arr;
|
||||||
|
|
||||||
|
if (!isSameSize(image2Draw,tempImage))
|
||||||
|
{
|
||||||
|
cvReleaseImage(&image2Draw);
|
||||||
|
image2Draw=cvCreateImage(cvGetSize(tempImage),IPL_DEPTH_8U,3);
|
||||||
|
|
||||||
|
updateGeometry();
|
||||||
|
}
|
||||||
|
|
||||||
|
cvConvertImage(tempImage,image2Draw,CV_CVTIMG_SWAP_RB );
|
||||||
|
viewport()->update();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ViewPort::setMouseCallBack(CvMouseCallback m, void* param)
|
||||||
|
{
|
||||||
|
setMouseTracking (true);//receive mouse event everytime
|
||||||
|
on_mouse = m;
|
||||||
|
on_mouse_param = param;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ViewPort::scaleView(qreal factor,QPointF center)
|
||||||
|
{
|
||||||
|
factor += previousFactor;
|
||||||
|
if (factor < 1 || factor > 100)
|
||||||
|
return;
|
||||||
|
|
||||||
|
center= (center-previousCenter)/previousFactor + previousCenter;//move to global coordinate
|
||||||
|
QPointF delta = QPointF(center-center*factor);
|
||||||
|
|
||||||
|
matrixWorld.reset ();
|
||||||
|
matrixWorld.translate(delta.x(),delta.y());//newCenter.x(),newCenter.y());
|
||||||
|
matrixWorld.scale(factor,factor);
|
||||||
|
|
||||||
|
previousCenter = center;
|
||||||
|
previousDelta = delta;
|
||||||
|
previousFactor = factor;
|
||||||
|
|
||||||
|
if (previousFactor>1)
|
||||||
|
setCursor(Qt::OpenHandCursor);
|
||||||
|
else
|
||||||
|
unsetCursor();
|
||||||
|
|
||||||
|
viewport()->update();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ViewPort::wheelEvent(QWheelEvent *event)
|
||||||
|
{
|
||||||
|
scaleView( -event->delta() / 480.0,event->pos());
|
||||||
|
}
|
||||||
|
|
||||||
|
void ViewPort::mousePressEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
int cv_event = -1, flags = 0;
|
int cv_event = -1, flags = 0;
|
||||||
QPoint pt = event->pos();
|
QPoint pt = event->pos();
|
||||||
@ -845,10 +977,14 @@ void CvWindow::mousePressEvent(QMouseEvent *event)
|
|||||||
if (on_mouse)
|
if (on_mouse)
|
||||||
on_mouse( cv_event, pt.x(), pt.y(), flags, on_mouse_param );
|
on_mouse( cv_event, pt.x(), pt.y(), flags, on_mouse_param );
|
||||||
|
|
||||||
|
|
||||||
|
if (previousFactor>1)
|
||||||
|
setCursor(Qt::ClosedHandCursor);
|
||||||
|
|
||||||
QWidget::mousePressEvent(event);
|
QWidget::mousePressEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CvWindow::mouseReleaseEvent(QMouseEvent *event)
|
void ViewPort::mouseReleaseEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
|
|
||||||
int cv_event = -1, flags = 0;
|
int cv_event = -1, flags = 0;
|
||||||
@ -895,10 +1031,13 @@ void CvWindow::mouseReleaseEvent(QMouseEvent *event)
|
|||||||
if (on_mouse)
|
if (on_mouse)
|
||||||
on_mouse( cv_event, pt.x(), pt.y(), flags, on_mouse_param );
|
on_mouse( cv_event, pt.x(), pt.y(), flags, on_mouse_param );
|
||||||
|
|
||||||
|
if (previousFactor>1)
|
||||||
|
setCursor(Qt::OpenHandCursor);
|
||||||
|
|
||||||
QWidget::mouseReleaseEvent(event);
|
QWidget::mouseReleaseEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CvWindow::mouseDoubleClickEvent(QMouseEvent *event)
|
void ViewPort::mouseDoubleClickEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
int cv_event = -1, flags = 0;
|
int cv_event = -1, flags = 0;
|
||||||
QPoint pt = event->pos();
|
QPoint pt = event->pos();
|
||||||
@ -945,11 +1084,12 @@ void CvWindow::mouseDoubleClickEvent(QMouseEvent *event)
|
|||||||
|
|
||||||
QWidget::mouseDoubleClickEvent(event);
|
QWidget::mouseDoubleClickEvent(event);
|
||||||
}
|
}
|
||||||
void CvWindow::mouseMoveEvent(QMouseEvent *event)
|
void ViewPort::mouseMoveEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
int cv_event = -1, flags = 0;
|
int cv_event = -1, flags = 0;
|
||||||
QPoint pt = event->pos();
|
QPoint pt = event->pos();
|
||||||
|
|
||||||
|
|
||||||
switch(event->modifiers())
|
switch(event->modifiers())
|
||||||
{
|
{
|
||||||
case Qt::ShiftModifier:
|
case Qt::ShiftModifier:
|
||||||
@ -979,118 +1119,6 @@ void CvWindow::mouseMoveEvent(QMouseEvent *event)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void CvWindow::readSettings()//not tested
|
|
||||||
{
|
|
||||||
QSettings settings("Trolltech", "Application Example");
|
|
||||||
QPoint pos = settings.value("pos", QPoint(200, 200)).toPoint();
|
|
||||||
QSize size = settings.value("size", QSize(400, 400)).toSize();
|
|
||||||
resize(size);
|
|
||||||
move(pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CvWindow::writeSettings()//not tested
|
|
||||||
{
|
|
||||||
QSettings settings("Trolltech", "Application Example");
|
|
||||||
settings.setValue("pos", pos());
|
|
||||||
settings.setValue("size", size());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Here is ViewPort
|
|
||||||
ViewPort::ViewPort(QWidget* arg, int arg2)
|
|
||||||
{
|
|
||||||
mode = arg2;
|
|
||||||
centralWidget = arg,
|
|
||||||
setupViewport(centralWidget);
|
|
||||||
setUpdatesEnabled(true);
|
|
||||||
setObjectName(QString::fromUtf8("graphicsView"));
|
|
||||||
timerDisplay = new QTimer(this);
|
|
||||||
timerDisplay->setSingleShot(true);
|
|
||||||
connect(timerDisplay, SIGNAL(timeout()), this, SLOT(stopDisplayInfo()));
|
|
||||||
drawInfo = false;
|
|
||||||
|
|
||||||
if (mode == CV_MODE_OPENGL)
|
|
||||||
{
|
|
||||||
#if defined(OPENCV_GL)
|
|
||||||
setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));
|
|
||||||
initGL();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
image2Draw=cvCreateImage(cvSize(centralWidget->width(),centralWidget->height()),IPL_DEPTH_8U,3);
|
|
||||||
cvZero(image2Draw);
|
|
||||||
}
|
|
||||||
|
|
||||||
ViewPort::~ViewPort()
|
|
||||||
{
|
|
||||||
if (image2Draw)
|
|
||||||
cvReleaseImage(&image2Draw);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ViewPort::startDisplayInfo(QString text, int delayms)
|
|
||||||
{
|
|
||||||
if (timerDisplay->isActive())
|
|
||||||
stopDisplayInfo();
|
|
||||||
|
|
||||||
infoText = text;
|
|
||||||
timerDisplay->start(delayms);
|
|
||||||
drawInfo = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ViewPort::stopDisplayInfo()
|
|
||||||
{
|
|
||||||
timerDisplay->stop();
|
|
||||||
drawInfo = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool ViewPort::isSameSize(IplImage* img1,IplImage* img2)
|
|
||||||
{
|
|
||||||
return img1->width == img2->width && img1->height == img2->height;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ViewPort::updateImage(void* arr)
|
|
||||||
{
|
|
||||||
if (!arr)
|
|
||||||
CV_Error(CV_StsNullPtr, "NULL arr pointer (in showImage)" );
|
|
||||||
|
|
||||||
IplImage* tempImage = (IplImage*)arr;
|
|
||||||
|
|
||||||
if (!isSameSize(image2Draw,tempImage))
|
|
||||||
{
|
|
||||||
cvReleaseImage(&image2Draw);
|
|
||||||
image2Draw=cvCreateImage(cvGetSize(tempImage),IPL_DEPTH_8U,3);
|
|
||||||
|
|
||||||
updateGeometry();
|
|
||||||
}
|
|
||||||
|
|
||||||
cvConvertImage(tempImage,image2Draw,CV_CVTIMG_SWAP_RB );
|
|
||||||
viewport()->update();
|
|
||||||
}
|
|
||||||
|
|
||||||
//----- implemented to redirect event to the parent ------
|
|
||||||
void ViewPort::mouseMoveEvent(QMouseEvent *event)
|
|
||||||
{
|
|
||||||
event->ignore();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ViewPort::mousePressEvent(QMouseEvent *event)
|
|
||||||
{
|
|
||||||
event->ignore();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ViewPort::mouseReleaseEvent(QMouseEvent *event)
|
|
||||||
{
|
|
||||||
event->ignore();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ViewPort::mouseDoubleClickEvent(QMouseEvent *event)
|
|
||||||
{
|
|
||||||
event->ignore();
|
|
||||||
}
|
|
||||||
//---------------------------------------------------------
|
|
||||||
|
|
||||||
QSize ViewPort::sizeHint() const
|
QSize ViewPort::sizeHint() const
|
||||||
{
|
{
|
||||||
if(image2Draw)
|
if(image2Draw)
|
||||||
@ -1103,11 +1131,13 @@ QSize ViewPort::sizeHint() const
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void ViewPort::paintEvent(QPaintEvent* event)
|
void ViewPort::paintEvent(QPaintEvent* event)
|
||||||
{
|
{
|
||||||
QPainter painter(viewport());
|
QPainter myPainter(viewport());
|
||||||
|
myPainter.setWorldTransform(matrixWorld);
|
||||||
|
|
||||||
draw2D(&painter);
|
draw2D(&myPainter);
|
||||||
|
|
||||||
if (mode == CV_MODE_OPENGL)
|
if (mode == CV_MODE_OPENGL)
|
||||||
{
|
{
|
||||||
@ -1119,7 +1149,10 @@ void ViewPort::paintEvent(QPaintEvent* event)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (drawInfo)
|
if (drawInfo)
|
||||||
drawInstructions(&painter);
|
{
|
||||||
|
myPainter.setWorldMatrixEnabled (false );
|
||||||
|
drawInstructions(&myPainter);
|
||||||
|
}
|
||||||
|
|
||||||
QGraphicsView::paintEvent(event);
|
QGraphicsView::paintEvent(event);
|
||||||
}
|
}
|
||||||
@ -1130,6 +1163,7 @@ void ViewPort::draw2D(QPainter *painter)
|
|||||||
painter->drawImage(0,0,image.scaled(this->width(),this->height(),Qt::IgnoreAspectRatio,Qt::SmoothTransformation));
|
painter->drawImage(0,0,image.scaled(this->width(),this->height(),Qt::IgnoreAspectRatio,Qt::SmoothTransformation));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ViewPort::drawInstructions(QPainter *painter)
|
void ViewPort::drawInstructions(QPainter *painter)
|
||||||
{
|
{
|
||||||
QFontMetrics metrics = QFontMetrics(font());
|
QFontMetrics metrics = QFontMetrics(font());
|
||||||
|
@ -75,7 +75,6 @@ class CvWindow;
|
|||||||
class ViewPort;
|
class ViewPort;
|
||||||
//class CvTrackbar;
|
//class CvTrackbar;
|
||||||
|
|
||||||
|
|
||||||
class GuiReceiver : public QObject
|
class GuiReceiver : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -84,6 +83,7 @@ public:
|
|||||||
GuiReceiver();
|
GuiReceiver();
|
||||||
int start();
|
int start();
|
||||||
bool _bTimeOut;
|
bool _bTimeOut;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
||||||
@ -148,19 +148,12 @@ protected:
|
|||||||
void writeSettings();
|
void writeSettings();
|
||||||
|
|
||||||
virtual void keyPressEvent(QKeyEvent *event);
|
virtual void keyPressEvent(QKeyEvent *event);
|
||||||
void mousePressEvent(QMouseEvent *event);
|
|
||||||
void mouseReleaseEvent(QMouseEvent *event);
|
|
||||||
void mouseDoubleClickEvent(QMouseEvent *event);
|
|
||||||
void mouseMoveEvent(QMouseEvent *event);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPointer<ViewPort> myview;
|
QPointer<ViewPort> myview;
|
||||||
|
|
||||||
int status;//0 normal, 1 fullscreen (YV)
|
int status;//0 normal, 1 fullscreen (YV)
|
||||||
|
|
||||||
CvMouseCallback on_mouse;
|
|
||||||
void* on_mouse_param;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -173,14 +166,24 @@ public:
|
|||||||
~ViewPort();
|
~ViewPort();
|
||||||
void updateImage(void* arr);
|
void updateImage(void* arr);
|
||||||
void startDisplayInfo(QString text, int delayms);
|
void startDisplayInfo(QString text, int delayms);
|
||||||
|
void setMouseCallBack(CvMouseCallback m, void* param);
|
||||||
|
|
||||||
|
QTransform matrixWorld;
|
||||||
|
qreal scaleFactor;//for zoom int/out
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void zoomIn() { scale(1.2, 1.2); }
|
//reference:
|
||||||
void zoomOut() { scale(1 / 1.2, 1 / 1.2); }
|
//http://www.qtcentre.org/wiki/index.php?title=QGraphicsView:_Smooth_Panning_and_Zooming
|
||||||
void rotateLeft() { rotate(-10); }
|
void scaleView(qreal scaleFactor, QPointF center);
|
||||||
void rotateRight() { rotate(10); }
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
QPointF previousCenter ;
|
||||||
|
qreal previousFactor;//for zoom int/out
|
||||||
|
QPointF previousDelta;
|
||||||
|
|
||||||
|
CvMouseCallback on_mouse;
|
||||||
|
void* on_mouse_param;
|
||||||
|
|
||||||
int mode;
|
int mode;
|
||||||
IplImage* image2Draw;
|
IplImage* image2Draw;
|
||||||
bool isSameSize(IplImage* img1,IplImage* img2);
|
bool isSameSize(IplImage* img1,IplImage* img2);
|
||||||
@ -192,6 +195,7 @@ private:
|
|||||||
//QImage* image;
|
//QImage* image;
|
||||||
|
|
||||||
void paintEvent(QPaintEvent* paintEventInfo);
|
void paintEvent(QPaintEvent* paintEventInfo);
|
||||||
|
void wheelEvent(QWheelEvent *event);
|
||||||
void mouseMoveEvent(QMouseEvent *event);
|
void mouseMoveEvent(QMouseEvent *event);
|
||||||
void mousePressEvent(QMouseEvent *event);
|
void mousePressEvent(QMouseEvent *event);
|
||||||
void mouseReleaseEvent(QMouseEvent *event);
|
void mouseReleaseEvent(QMouseEvent *event);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user