Commit 48090fd3 authored by Yannick Verdie's avatar Yannick Verdie

Qt bug fixed #534

parent 97d17d8a
...@@ -343,21 +343,27 @@ CvWindow* icvFindWindowByName( const char* arg ) ...@@ -343,21 +343,27 @@ CvWindow* icvFindWindowByName( const char* arg )
QString name(arg); QString name(arg);
CvWindow* w; CvWindow* w;
CvWinModel* temp;
foreach (QWidget *widget, QApplication::topLevelWidgets()) foreach (QWidget *widget, QApplication::topLevelWidgets())
{ {
if (widget->isWindow() && !widget->parentWidget ())//is a window without parent if (widget->isWindow() && !widget->parentWidget ())//is a window without parent
{ {
w = (CvWindow*) widget; temp = (CvWinModel*) widget;
if (temp->type == type_CvWindow)
{
w = (CvWindow*) temp;
if (w->param_name==name) if (w->param_name==name)
{ {
window = w; window = w;
break; break;
} }
}
} }
} }
return window; return window;
} }
...@@ -695,7 +701,7 @@ void GuiReceiver::isLastWindow() ...@@ -695,7 +701,7 @@ void GuiReceiver::isLastWindow()
{ {
if (--nb_windows <= 0) if (--nb_windows <= 0)
{ {
delete guiMainThread; delete guiMainThread;//delete global_control_panel too
guiMainThread = NULL; guiMainThread = NULL;
qApp->quit(); qApp->quit();
} }
...@@ -703,8 +709,12 @@ void GuiReceiver::isLastWindow() ...@@ -703,8 +709,12 @@ void GuiReceiver::isLastWindow()
GuiReceiver::~GuiReceiver() GuiReceiver::~GuiReceiver()
{ {
if (global_control_panel) if (global_control_panel)
{
delete global_control_panel; delete global_control_panel;
global_control_panel = NULL;
}
delete timer; delete timer;
} }
...@@ -913,6 +923,9 @@ void GuiReceiver::showImage(QString name, void* arr) ...@@ -913,6 +923,9 @@ void GuiReceiver::showImage(QString name, void* arr)
if( w && arr ) if( w && arr )
{ {
w->updateImage(arr); w->updateImage(arr);
if (w->isHidden())
w->show();
} }
else else
{ {
...@@ -1353,9 +1366,10 @@ void CvRadioButton::callCallBack(bool checked) ...@@ -1353,9 +1366,10 @@ void CvRadioButton::callCallBack(bool checked)
//here CvWinProperties class //here CvWinProperties class
CvWinProperties::CvWinProperties(QString name_paraWindow, QWidget* parent) CvWinProperties::CvWinProperties(QString name_paraWindow, QObject* parent)
{ {
setParent(parent); //setParent(parent);
type = type_CvWinProperties;
setWindowFlags(Qt::Tool); setWindowFlags(Qt::Tool);
setContentsMargins(0,0,0,0); setContentsMargins(0,0,0,0);
setWindowTitle(name_paraWindow); setWindowTitle(name_paraWindow);
...@@ -1411,7 +1425,6 @@ CvWinProperties::~CvWinProperties() ...@@ -1411,7 +1425,6 @@ CvWinProperties::~CvWinProperties()
QSettings settings("OpenCV2", this->windowTitle()); QSettings settings("OpenCV2", this->windowTitle());
settings.remove("pos"); settings.remove("pos");
QLayoutItem *child; QLayoutItem *child;
if (myLayout) if (myLayout)
{ {
...@@ -1430,6 +1443,7 @@ CvWinProperties::~CvWinProperties() ...@@ -1430,6 +1443,7 @@ CvWinProperties::~CvWinProperties()
//Here CvWindow class //Here CvWindow class
CvWindow::CvWindow(QString arg, int arg2) CvWindow::CvWindow(QString arg, int arg2)
{ {
type = type_CvWindow;
moveToThread(qApp->instance()->thread()); moveToThread(qApp->instance()->thread());
param_name = arg; param_name = arg;
...@@ -1437,7 +1451,7 @@ CvWindow::CvWindow(QString arg, int arg2) ...@@ -1437,7 +1451,7 @@ CvWindow::CvWindow(QString arg, int arg2)
param_gui_mode = arg2 & 0x000000F0; param_gui_mode = arg2 & 0x000000F0;
param_ratio_mode = arg2 & 0x00000F00; param_ratio_mode = arg2 & 0x00000F00;
setAttribute(Qt::WA_DeleteOnClose);//in other case, does not release memory //setAttribute(Qt::WA_DeleteOnClose);//in other case, does not release memory
setContentsMargins(0,0,0,0); setContentsMargins(0,0,0,0);
setWindowTitle(param_name); setWindowTitle(param_name);
setObjectName(param_name); setObjectName(param_name);
...@@ -1490,6 +1504,7 @@ CvWindow::CvWindow(QString arg, int arg2) ...@@ -1490,6 +1504,7 @@ CvWindow::CvWindow(QString arg, int arg2)
CvWindow::~CvWindow() CvWindow::~CvWindow()
{ {
QLayoutItem *child; QLayoutItem *child;
if (myGlobalLayout) if (myGlobalLayout)
...@@ -1508,7 +1523,6 @@ CvWindow::~CvWindow() ...@@ -1508,7 +1523,6 @@ CvWindow::~CvWindow()
delete myBarLayout; delete myBarLayout;
} }
if (myStatusBar) if (myStatusBar)
{ {
delete myStatusBar; delete myStatusBar;
...@@ -1571,7 +1585,7 @@ CvWinProperties* CvWindow::createParameterWindow() ...@@ -1571,7 +1585,7 @@ CvWinProperties* CvWindow::createParameterWindow()
{ {
QString name_paraWindow =QFileInfo(QApplication::applicationFilePath()).fileName()+" settings"; QString name_paraWindow =QFileInfo(QApplication::applicationFilePath()).fileName()+" settings";
CvWinProperties *result = new CvWinProperties(name_paraWindow,this); CvWinProperties *result = new CvWinProperties(name_paraWindow,guiMainThread);
return result; return result;
} }
...@@ -1632,7 +1646,6 @@ void CvWindow::createActions() ...@@ -1632,7 +1646,6 @@ void CvWindow::createActions()
if (global_control_panel->myLayout->count() == 0) if (global_control_panel->myLayout->count() == 0)
vect_QActions[9]->setDisabled(true); vect_QActions[9]->setDisabled(true);
} }
...@@ -2138,12 +2151,10 @@ ViewPort::~ViewPort() ...@@ -2138,12 +2151,10 @@ ViewPort::~ViewPort()
cvReleaseImage(&image2Draw_ipl); cvReleaseImage(&image2Draw_ipl);
#if defined( HAVE_QT_OPENGL ) //#if defined( HAVE_QT_OPENGL )
if (myGL) // if (myGL)
delete myGL; // delete myGL;
#endif; //#endif;
qDebug()<<"kill vieport";
delete timerDisplay; delete timerDisplay;
} }
...@@ -2573,8 +2584,6 @@ void ViewPort::icvmouseProcessing(QPointF pt, int cv_event, int flags) ...@@ -2573,8 +2584,6 @@ void ViewPort::icvmouseProcessing(QPointF pt, int cv_event, int flags)
{ {
//to convert mouse coordinate //to convert mouse coordinate
qreal pfx, pfy; 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); matrixWorld_inv.map(pt.x(),pt.y(),&pfx,&pfy);
mouseCoordinate.rx()=floor(pfx/ratioX); mouseCoordinate.rx()=floor(pfx/ratioX);
...@@ -2588,12 +2597,9 @@ void ViewPort::icvmouseProcessing(QPointF pt, int cv_event, int flags) ...@@ -2588,12 +2597,9 @@ void ViewPort::icvmouseProcessing(QPointF pt, int cv_event, int flags)
QSize ViewPort::sizeHint() const QSize ViewPort::sizeHint() const
{ {
if(image2Draw_ipl) if(image2Draw_ipl)
{
//qDebug()<<centralWidget->param_name<<" "<<image2Draw_ipl->width<<" "<<image2Draw_ipl->height;
return QSize(image2Draw_ipl->width,image2Draw_ipl->height); return QSize(image2Draw_ipl->width,image2Draw_ipl->height);
} else { else
return QGraphicsView::sizeHint(); return QGraphicsView::sizeHint();
}
} }
void ViewPort::resizeEvent ( QResizeEvent *event) void ViewPort::resizeEvent ( QResizeEvent *event)
...@@ -2751,9 +2757,6 @@ void ViewPort::drawImgRegion(QPainter *painter) ...@@ -2751,9 +2757,6 @@ void ViewPort::drawImgRegion(QPainter *painter)
QPointF point1;//sorry, I do not know how to name it QPointF point1;//sorry, I do not know how to name it
QPointF point2;//idem 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<height()/param_matrixWorld.m11();j++)//-1 because display the pixels top rows left colums 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 for (int i=-1;i<width()/param_matrixWorld.m11();i++)//-1
{ {
......
...@@ -253,11 +253,23 @@ private: ...@@ -253,11 +253,23 @@ private:
}; };
class CvWinProperties : public QWidget //Both are top level window, so that a way to differenciate them.
//if (obj->metaObject ()->className () == "CvWindow") does not give me robust result
enum typeWindow{type_CvWindow = 0, type_CvWinProperties = 1};
class CvWinModel : public QWidget
{
public:
typeWindow type;
};
class CvWinProperties : public CvWinModel
{ {
Q_OBJECT Q_OBJECT
public: public:
CvWinProperties(QString name,QWidget* parent); CvWinProperties(QString name,QObject* parent);
~CvWinProperties(); ~CvWinProperties();
QPointer<QBoxLayout> myLayout; QPointer<QBoxLayout> myLayout;
...@@ -279,7 +291,7 @@ public: ...@@ -279,7 +291,7 @@ public:
}; };
class CvWindow : public QWidget class CvWindow : public CvWinModel
{ {
Q_OBJECT Q_OBJECT
public: public:
......
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