New functions with QT GUI:
- imgregion shortcut implemented (CTRL+O)
This commit is contained in:
@@ -810,20 +810,22 @@ CvWindow::CvWindow(QString arg, int arg2)
|
|||||||
myview->setAlignment(Qt::AlignHCenter);
|
myview->setAlignment(Qt::AlignHCenter);
|
||||||
|
|
||||||
|
|
||||||
shortcutZ = new QShortcut(Qt::CTRL + Qt::Key_P, this);
|
shortcut_r_Zoom = new QShortcut(Qt::CTRL + Qt::Key_P, this);
|
||||||
QObject::connect( shortcutZ, SIGNAL( activated ()),myview, SLOT( resetZoom( ) ));
|
QObject::connect( shortcut_r_Zoom, SIGNAL( activated ()),myview, SLOT( resetZoom( ) ));
|
||||||
shortcutPlus = new QShortcut(QKeySequence(QKeySequence::ZoomIn), this);
|
shortcut_imgRegion = new QShortcut(Qt::CTRL + Qt::Key_O, this);
|
||||||
QObject::connect( shortcutPlus, SIGNAL( activated ()),myview, SLOT( ZoomIn() ));
|
QObject::connect( shortcut_imgRegion, SIGNAL( activated ()),myview, SLOT( imgRegion( ) ));
|
||||||
shortcutMinus = new QShortcut(QKeySequence(QKeySequence::ZoomOut), this);
|
shortcut_Plus = new QShortcut(QKeySequence(QKeySequence::ZoomIn), this);
|
||||||
QObject::connect(shortcutMinus, SIGNAL( activated ()),myview, SLOT( ZoomOut() ));
|
QObject::connect( shortcut_Plus, SIGNAL( activated ()),myview, SLOT( ZoomIn() ));
|
||||||
shortcutLeft = new QShortcut(Qt::CTRL + Qt::Key_Left, this);
|
shortcut_Minus = new QShortcut(QKeySequence(QKeySequence::ZoomOut), this);
|
||||||
QObject::connect( shortcutLeft, SIGNAL( activated ()),myview, SLOT( siftWindowOnLeft() ));
|
QObject::connect(shortcut_Minus, SIGNAL( activated ()),myview, SLOT( ZoomOut() ));
|
||||||
shortcutRight = new QShortcut(Qt::CTRL + Qt::Key_Right, this);
|
shortcut_Left = new QShortcut(Qt::CTRL + Qt::Key_Left, this);
|
||||||
QObject::connect( shortcutRight, SIGNAL( activated ()),myview, SLOT( siftWindowOnRight() ));
|
QObject::connect( shortcut_Left, SIGNAL( activated ()),myview, SLOT( siftWindowOnLeft() ));
|
||||||
shortcutUp = new QShortcut(Qt::CTRL + Qt::Key_Up, this);
|
shortcut_Right = new QShortcut(Qt::CTRL + Qt::Key_Right, this);
|
||||||
QObject::connect(shortcutUp, SIGNAL( activated ()),myview, SLOT( siftWindowOnUp() ));
|
QObject::connect( shortcut_Right, SIGNAL( activated ()),myview, SLOT( siftWindowOnRight() ));
|
||||||
shortcutDown = new QShortcut(Qt::CTRL + Qt::Key_Down, this);
|
shortcut_Up = new QShortcut(Qt::CTRL + Qt::Key_Up, this);
|
||||||
QObject::connect(shortcutDown, SIGNAL( activated ()),myview, SLOT( siftWindowOnDown() ));
|
QObject::connect(shortcut_Up, SIGNAL( activated ()),myview, SLOT( siftWindowOnUp() ));
|
||||||
|
shortcut_Down = new QShortcut(Qt::CTRL + Qt::Key_Down, this);
|
||||||
|
QObject::connect(shortcut_Down, SIGNAL( activated ()),myview, SLOT( siftWindowOnDown() ));
|
||||||
|
|
||||||
layout = new QBoxLayout(QBoxLayout::TopToBottom);
|
layout = new QBoxLayout(QBoxLayout::TopToBottom);
|
||||||
//layout = new CustomLayout;
|
//layout = new CustomLayout;
|
||||||
@@ -871,13 +873,14 @@ CvWindow::~CvWindow()
|
|||||||
delete myBar_msg;
|
delete myBar_msg;
|
||||||
|
|
||||||
|
|
||||||
delete shortcutZ;
|
delete shortcut_r_Zoom;
|
||||||
delete shortcutPlus;
|
delete shortcut_imgRegion;
|
||||||
delete shortcutMinus;
|
delete shortcut_Plus;
|
||||||
delete shortcutLeft;
|
delete shortcut_Minus;
|
||||||
delete shortcutRight;
|
delete shortcut_Left;
|
||||||
delete shortcutUp;
|
delete shortcut_Right;
|
||||||
delete shortcutDown;
|
delete shortcut_Up;
|
||||||
|
delete shortcut_Down;
|
||||||
}
|
}
|
||||||
|
|
||||||
ViewPort* CvWindow::getView()
|
ViewPort* CvWindow::getView()
|
||||||
@@ -1025,14 +1028,19 @@ void ViewPort::resetZoom()
|
|||||||
controlImagePosition();
|
controlImagePosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ViewPort::imgRegion( )
|
||||||
|
{
|
||||||
|
scaleView(threshold_zoom_img_region/matrixWorld.m11(), QPointF(size().width()/2,size().height()/2),false);//false = do not process the 1st param
|
||||||
|
}
|
||||||
|
|
||||||
void ViewPort::ZoomIn()
|
void ViewPort::ZoomIn()
|
||||||
{
|
{
|
||||||
scaleView( 0.5,QPointF(size().width()/2,size().height()/2));
|
scaleView( 0.5,QPointF(size().width()/2,size().height()/2),true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViewPort::ZoomOut()
|
void ViewPort::ZoomOut()
|
||||||
{
|
{
|
||||||
scaleView( -0.5,QPointF(size().width()/2,size().height()/2));
|
scaleView( -0.5,QPointF(size().width()/2,size().height()/2),true);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Note: move 2 percent of the window
|
//Note: move 2 percent of the window
|
||||||
@@ -1159,10 +1167,13 @@ void ViewPort::moveView(QPointF delta)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//factor is -0.5 (zoom out) or 0.5 (zoom in)
|
//factor is -0.5 (zoom out) or 0.5 (zoom in)
|
||||||
void ViewPort::scaleView(qreal factor,QPointF center)
|
void ViewPort::scaleView(qreal factor,QPointF center,bool process_factor)
|
||||||
{
|
{
|
||||||
factor/=5;//-0.1 <-> 0.1
|
if (process_factor)
|
||||||
factor+=1;//0.9 <-> 1.1
|
{
|
||||||
|
factor/=5;//-0.1 <-> 0.1
|
||||||
|
factor+=1;//0.9 <-> 1.1
|
||||||
|
}
|
||||||
|
|
||||||
//limit zoom out ---
|
//limit zoom out ---
|
||||||
if (matrixWorld.m11()==1 && factor < 1)
|
if (matrixWorld.m11()==1 && factor < 1)
|
||||||
@@ -1196,7 +1207,7 @@ void ViewPort::scaleView(qreal factor,QPointF center)
|
|||||||
|
|
||||||
void ViewPort::wheelEvent(QWheelEvent *event)
|
void ViewPort::wheelEvent(QWheelEvent *event)
|
||||||
{
|
{
|
||||||
scaleView( -event->delta() / 240.0,event->pos());
|
scaleView( -event->delta() / 240.0,event->pos(),true);//true means process the 1st parameter
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViewPort::mousePressEvent(QMouseEvent *event)
|
void ViewPort::mousePressEvent(QMouseEvent *event)
|
||||||
|
|||||||
@@ -165,13 +165,14 @@ private:
|
|||||||
QPointer<ViewPort> myview;
|
QPointer<ViewPort> myview;
|
||||||
|
|
||||||
int status;//0 normal, 1 fullscreen (YV)
|
int status;//0 normal, 1 fullscreen (YV)
|
||||||
QPointer<QShortcut> shortcutZ;
|
QPointer<QShortcut> shortcut_r_Zoom;
|
||||||
QPointer<QShortcut> shortcutPlus;
|
QPointer<QShortcut> shortcut_imgRegion;
|
||||||
QPointer<QShortcut> shortcutMinus;
|
QPointer<QShortcut> shortcut_Plus;
|
||||||
QPointer<QShortcut> shortcutLeft;
|
QPointer<QShortcut> shortcut_Minus;
|
||||||
QPointer<QShortcut> shortcutRight;
|
QPointer<QShortcut> shortcut_Left;
|
||||||
QPointer<QShortcut> shortcutUp;
|
QPointer<QShortcut> shortcut_Right;
|
||||||
QPointer<QShortcut> shortcutDown;
|
QPointer<QShortcut> shortcut_Up;
|
||||||
|
QPointer<QShortcut> shortcut_Down;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -206,7 +207,8 @@ public slots:
|
|||||||
//reference:
|
//reference:
|
||||||
//http://www.qtcentre.org/wiki/index.php?title=QGraphicsView:_Smooth_Panning_and_Zooming
|
//http://www.qtcentre.org/wiki/index.php?title=QGraphicsView:_Smooth_Panning_and_Zooming
|
||||||
//http://doc.qt.nokia.com/4.6/gestures-imagegestures-imagewidget-cpp.html
|
//http://doc.qt.nokia.com/4.6/gestures-imagegestures-imagewidget-cpp.html
|
||||||
void scaleView(qreal scaleFactor, QPointF center);
|
void scaleView(qreal scaleFactor, QPointF center, bool process1stParam);
|
||||||
|
void imgRegion( );
|
||||||
void moveView(QPointF delta);
|
void moveView(QPointF delta);
|
||||||
void resetZoom();
|
void resetZoom();
|
||||||
void ZoomIn();
|
void ZoomIn();
|
||||||
|
|||||||
Reference in New Issue
Block a user