Commit d6bbaea2 authored by Yannick Verdie's avatar Yannick Verdie

Qt imgRegion bug fixed

Qt compilation pb with OpenGL flags fixed
parent 5b7b6d91
......@@ -525,6 +525,8 @@ if (WITH_QT)
if (QT_QTOPENGL_FOUND AND OPENGL_FOUND)
set(HAVE_QT_OPENGL 1)
add_definitions(-DHAVE_QT_OPENGL)
link_directories("${OPENGL_LIBRARIES}")
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${OPENGL_LIBRARIES})
endif()
endif()
......
......@@ -2241,7 +2241,7 @@ void ViewPort::controlImagePosition()
//save also the inv matrix
matrixWorld_inv = param_matrixWorld.inverted();
viewport()->update();
//viewport()->update();
}
void ViewPort::moveView(QPointF delta)
......@@ -2409,9 +2409,12 @@ void ViewPort::icvmouseProcessing(QPointF pt, int cv_event, int flags)
{
//to convert mouse coordinate
qreal pfx, pfy;
//qreal ratioX = float(image2Draw_qt.width())/image2Draw_qt_resized.width();
//qreal ratioY = float(image2Draw_qt.height())/image2Draw_qt_resized.height();
matrixWorld_inv.map(pt.x(),pt.y(),&pfx,&pfy);
mouseCoordinate.rx()=floor(pfx);
mouseCoordinate.ry()=floor(pfy);
mouseCoordinate.rx()=floor(pfx/ratioX);
mouseCoordinate.ry()=floor(pfy/ratioY);
if (on_mouse)
on_mouse( cv_event, mouseCoordinate.x(),mouseCoordinate.y(), flags, on_mouse_param );
......@@ -2430,7 +2433,6 @@ QSize ViewPort::sizeHint() const
void ViewPort::resizeEvent ( QResizeEvent *event)
{
image2Draw_qt_resized = image2Draw_qt.scaled(this->width(),this->height(),Qt::IgnoreAspectRatio,Qt::SmoothTransformation);
controlImagePosition();
ratioX=width()/float(image2Draw_ipl->width);
......@@ -2493,8 +2495,14 @@ void ViewPort::paintEvent(QPaintEvent* event)
//in mode zoom/panning
if (param_matrixWorld.m11()>1)
{
if (param_matrixWorld.m11()>=threshold_zoom_img_region)
{
if (centralWidget->param_flags == CV_WINDOW_NORMAL)
startDisplayInfo("WARNING: The values displayed are the values of the resized image. If you want the values of the original image, use CV_WINDOW_AUTORESIZE", 1000);
drawImgRegion(&myPainter);
}
drawViewOverview(&myPainter);
}
......@@ -2512,7 +2520,8 @@ void ViewPort::paintEvent(QPaintEvent* event)
void ViewPort::draw2D(QPainter *painter)
{
painter->drawImage(0,0,image2Draw_qt.scaled(this->width(),this->height(),Qt::IgnoreAspectRatio,Qt::SmoothTransformation));
image2Draw_qt_resized = image2Draw_qt.scaled(this->width(),this->height(),Qt::IgnoreAspectRatio,Qt::SmoothTransformation);
painter->drawImage(0,0,image2Draw_qt_resized);
}
void ViewPort::drawStatusBar()
......@@ -2544,6 +2553,7 @@ void ViewPort::drawStatusBar()
}
}
void ViewPort::drawImgRegion(QPainter *painter)
{
qreal offsetX = param_matrixWorld.dx()/param_matrixWorld.m11();
......@@ -2573,22 +2583,33 @@ void ViewPort::drawImgRegion(QPainter *painter)
QPointF point1;//sorry, I do not know how to name it
QPointF point2;//idem
//qreal ratioX = float(image2Draw_qt.width())/image2Draw_qt_resized.width();
//qreal ratioY = float(image2Draw_qt.height())/image2Draw_qt_resized.height();
for (int j=-1;j<view.height()/param_matrixWorld.m11();j++)
for (int i=-1;i<view.width()/param_matrixWorld.m11();i++)
for (int j=-1;j<height()/param_matrixWorld.m11();j++)//-1 because display the pixels top rows left colums
for (int i=-1;i<width()/param_matrixWorld.m11();i++)//-1
{
point1.setX((i+offsetX)*param_matrixWorld.m11());
point1.setY((j+offsetY)*param_matrixWorld.m11());
matrixWorld_inv.map(point1.x(),point1.y(),&point2.rx(),&point2.ry());
point2.rx()= (long) (point2.x() + 0.5);
point2.ry()= (long) (point2.y() + 0.5);
if (point2.x() >= 0 && point2.y() >= 0)
rgbValue = image2Draw_qt.pixel(QPoint(point2.x(),point2.y()));
rgbValue = image2Draw_qt_resized.pixel(QPoint(point2.x(),point2.y()));
else
rgbValue = qRgb(0,0,0);
if (nbChannelOriginImage==3)
{
//for debug
val = tr("%1 %2").arg(point2.x()).arg(point2.y());
painter->setPen(QPen(Qt::black, 1));
painter->drawText(QRect(point1.x(),point1.y(),param_matrixWorld.m11(),param_matrixWorld.m11()/2),
Qt::AlignCenter, val);
val = tr("%1").arg(qRed(rgbValue));
painter->setPen(QPen(Qt::red, 1));
painter->drawText(QRect(point1.x(),point1.y(),param_matrixWorld.m11(),param_matrixWorld.m11()/3),
......
......@@ -101,6 +101,9 @@ enum { shortcut_zoom_normal = Qt::CTRL + Qt::Key_Z,
class CvWindow;
class ViewPort;
#if defined( HAVE_QT_OPENGL )
class OpenGLWidget;
#endif
class GuiReceiver : public QObject
......@@ -258,6 +261,18 @@ private:
void hideEvent ( QHideEvent * event ) ;
};
class GlobalLayout : public QBoxLayout
{
Q_OBJECT
public:
GlobalLayout(QWidget* parent) : QBoxLayout(QBoxLayout::TopToBottom,parent){};
bool hasHeightForWidth () {return true;};
int heightForWidth( int w ) {qDebug()<<"yopyopypp";return w;};
};
class CvWindow : public QWidget
{
Q_OBJECT
......@@ -275,7 +290,7 @@ public:
void hideTools();
void showTools();
static CvButtonbar* createButtonbar(QString bar_name);
QSize getAvailableSize();
ViewPort* getView();
......@@ -350,6 +365,8 @@ public:
void setOpenGLCallback(CvOpenGLCallback func,void* userdata, double arg3, double arg4, double arg5);
int getRatio();
void setRatio(int arg);
int heightForWidth( int w );// {qDebug()<<"yopyopypp";return w;};
bool hasHeightForWidth (){qDebug()<<"ask";return true;};
//parameters (will be save/load)
QTransform param_matrixWorld;
......@@ -402,6 +419,7 @@ private:
QPointer<QTimer> timerDisplay;
bool drawInfo;
QString infoText;
QRectF target;
//QImage* image;
void paintEvent(QPaintEvent* paintEventInfo);
......@@ -420,6 +438,7 @@ private:
void icvmouseProcessing(QPointF pt, int cv_event, int flags);
#if defined( HAVE_QT_OPENGL )
QPointer<OpenGLWidget> myGL;
double angle;
double zmin;
double zmax;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment