QT new functions:
- Finished toolbar: the last icon opens an external window with the trackbars inside
This commit is contained in:
parent
f5ab36f4df
commit
0c9eca7922
@ -75,7 +75,7 @@ enum { CV_STYLE_NORMAL = 0,//QFont::StyleNormal,
|
|||||||
//the first bit is for normal or autoresize
|
//the first bit is for normal or autoresize
|
||||||
//CV_WINDOW_NORMAL = 0x00000000 and CV_WINDOW_AUTOSIZE = 0x00000001
|
//CV_WINDOW_NORMAL = 0x00000000 and CV_WINDOW_AUTOSIZE = 0x00000001
|
||||||
//the secont bit is for the gui mode (normal or extended)
|
//the secont bit is for the gui mode (normal or extended)
|
||||||
enum {CV_GUI_EXTENDED = 0x00000000, CV_GUI_NORMAL = 0x00000010};
|
enum {CV_GUI_EXPANDED = 0x00000000, CV_GUI_NORMAL = 0x00000010};
|
||||||
|
|
||||||
//for color cvScalar(blue_component, green_component, red\_component[, alpha_component])
|
//for color cvScalar(blue_component, green_component, red\_component[, alpha_component])
|
||||||
//and alpha= 0 <-> 0xFF (not transparent <-> transparent)
|
//and alpha= 0 <-> 0xFF (not transparent <-> transparent)
|
||||||
|
@ -59,7 +59,7 @@ static const unsigned int threshold_zoom_img_region = 15;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
CV_IMPL CvFont cvFont_Qt(const char* nameFont, int pointSize,CvScalar color,int weight,int style, int spacing)
|
CvFont cvFont_Qt(const char* nameFont, int pointSize,CvScalar color,int weight,int style, int spacing)
|
||||||
{
|
{
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -81,7 +81,7 @@ CV_IMPL CvFont cvFont_Qt(const char* nameFont, int pointSize,CvScalar color,int
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
CV_IMPL void cvAddText( CvArr* img, const char* text, CvPoint org, CvFont* font)
|
void cvAddText( CvArr* img, const char* text, CvPoint org, CvFont* font)
|
||||||
{
|
{
|
||||||
QMetaObject::invokeMethod(&guiMainThread,
|
QMetaObject::invokeMethod(&guiMainThread,
|
||||||
"putText",
|
"putText",
|
||||||
@ -155,7 +155,7 @@ double cvGetModeWindow_QT(const char* name)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
CV_IMPL void cvDisplayOverlay(const char* name, const char* text, int delayms)
|
void cvDisplayOverlay(const char* name, const char* text, int delayms)
|
||||||
{
|
{
|
||||||
|
|
||||||
QMetaObject::invokeMethod(&guiMainThread,
|
QMetaObject::invokeMethod(&guiMainThread,
|
||||||
@ -168,7 +168,7 @@ CV_IMPL void cvDisplayOverlay(const char* name, const char* text, int delayms)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CV_IMPL void cvSaveWindowParameters(const char* name)
|
void cvSaveWindowParameters(const char* name)
|
||||||
{
|
{
|
||||||
QMetaObject::invokeMethod(&guiMainThread,
|
QMetaObject::invokeMethod(&guiMainThread,
|
||||||
"saveWindowParameters",
|
"saveWindowParameters",
|
||||||
@ -176,7 +176,7 @@ CV_IMPL void cvSaveWindowParameters(const char* name)
|
|||||||
Q_ARG(QString, QString(name)));
|
Q_ARG(QString, QString(name)));
|
||||||
}
|
}
|
||||||
|
|
||||||
CV_IMPL void cvLoadWindowParameters(const char* name)
|
void cvLoadWindowParameters(const char* name)
|
||||||
{
|
{
|
||||||
QMetaObject::invokeMethod(&guiMainThread,
|
QMetaObject::invokeMethod(&guiMainThread,
|
||||||
"loadWindowParameters",
|
"loadWindowParameters",
|
||||||
@ -184,7 +184,7 @@ CV_IMPL void cvLoadWindowParameters(const char* name)
|
|||||||
Q_ARG(QString, QString(name)));
|
Q_ARG(QString, QString(name)));
|
||||||
}
|
}
|
||||||
|
|
||||||
CV_IMPL void cvDisplayStatusBar(const char* name, const char* text, int delayms)
|
void cvDisplayStatusBar(const char* name, const char* text, int delayms)
|
||||||
{
|
{
|
||||||
|
|
||||||
QMetaObject::invokeMethod(&guiMainThread,
|
QMetaObject::invokeMethod(&guiMainThread,
|
||||||
@ -197,12 +197,12 @@ CV_IMPL void cvDisplayStatusBar(const char* name, const char* text, int delayms)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CV_IMPL int cvInitSystem( int, char** )
|
int cvInitSystem( int, char** )
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
CV_IMPL int cvWaitKey( int arg )
|
int cvWaitKey( int arg )
|
||||||
{
|
{
|
||||||
int result = -1;
|
int result = -1;
|
||||||
|
|
||||||
@ -262,11 +262,11 @@ CV_IMPL int cvWaitKey( int arg )
|
|||||||
waitCondition.wait(&dummy, 2);
|
waitCondition.wait(&dummy, 2);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined WIN32 || defined _WIN32 || defined WIN64 || defined _WIN64
|
#if defined WIN32 || defined _WIN32 || defined WIN64 || defined _WIN64
|
||||||
sleep(2);
|
sleep(2);
|
||||||
#else
|
#else
|
||||||
usleep(2);//to decrease CPU usage
|
usleep(2);//to decrease CPU usage
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -279,17 +279,19 @@ CV_IMPL int cvWaitKey( int arg )
|
|||||||
//Yannick Verdie
|
//Yannick Verdie
|
||||||
//This function is experimental and some functions (such as cvSet/getWindowProperty will not work)
|
//This function is experimental and some functions (such as cvSet/getWindowProperty will not work)
|
||||||
//We recommend not using this function for now
|
//We recommend not using this function for now
|
||||||
CV_IMPL int cvStartLoop(int (*pt2Func)(int argc, char *argv[]), int argc, char* argv[])
|
int cvStartLoop(int (*pt2Func)(int argc, char *argv[]), int argc, char* argv[])
|
||||||
{
|
{
|
||||||
multiThreads = true;
|
multiThreads = true;
|
||||||
QFuture<int> future = QtConcurrent::run(pt2Func,argc,argv);
|
QFuture<int> future = QtConcurrent::run(pt2Func,argc,argv);
|
||||||
return guiMainThread.start();
|
return guiMainThread.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
CV_IMPL void cvStopLoop()
|
void cvStopLoop()
|
||||||
{
|
{
|
||||||
qApp->exit();
|
qApp->exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CvWindow* icvFindWindowByName( const char* arg )
|
CvWindow* icvFindWindowByName( const char* arg )
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -302,6 +304,7 @@ CvWindow* icvFindWindowByName( const char* arg )
|
|||||||
QPointer<CvWindow> w;
|
QPointer<CvWindow> w;
|
||||||
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;
|
w = (CvWindow*) widget;
|
||||||
@ -334,9 +337,9 @@ CvTrackbar* icvFindTrackbarByName( const char* name_trackbar, const char* name_w
|
|||||||
start_index = 2;
|
start_index = 2;
|
||||||
//Warning ---- , asume the location 0 is toolbar, 1 is myview and max-1 the status bar
|
//Warning ---- , asume the location 0 is toolbar, 1 is myview and max-1 the status bar
|
||||||
//done three times in the code, in loadtrackbars, savetrackbar and in findtrackbar
|
//done three times in the code, in loadtrackbars, savetrackbar and in findtrackbar
|
||||||
for (int i = start_index; i < w->layout->layout()->count()-1; ++i)
|
for (int i = start_index; i < w->myLayout->layout()->count()-1; ++i)
|
||||||
{
|
{
|
||||||
t = (CvTrackbar*) w->layout->layout()->itemAt(i);
|
t = (CvTrackbar*) w->myLayout->layout()->itemAt(i);
|
||||||
if (t->trackbar_name==nameQt)
|
if (t->trackbar_name==nameQt)
|
||||||
{
|
{
|
||||||
result = t;
|
result = t;
|
||||||
@ -347,7 +350,7 @@ CvTrackbar* icvFindTrackbarByName( const char* name_trackbar, const char* name_w
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
CV_IMPL int icvInitSystem()
|
int icvInitSystem()
|
||||||
{
|
{
|
||||||
static int wasInitialized = 0;
|
static int wasInitialized = 0;
|
||||||
|
|
||||||
@ -359,15 +362,15 @@ CV_IMPL int icvInitSystem()
|
|||||||
wasInitialized = 1;
|
wasInitialized = 1;
|
||||||
qDebug()<<"init done";
|
qDebug()<<"init done";
|
||||||
|
|
||||||
#if defined(OPENCV_GL)//OK tested !
|
#if defined(OPENCV_GL)//OK tested !
|
||||||
qDebug()<<"opengl support available";
|
qDebug()<<"opengl support available";
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
CV_IMPL int cvNamedWindow( const char* name, int flags )
|
int cvNamedWindow( const char* name, int flags )
|
||||||
{
|
{
|
||||||
|
|
||||||
if (multiThreads)
|
if (multiThreads)
|
||||||
@ -385,7 +388,7 @@ CV_IMPL int cvNamedWindow( const char* name, int flags )
|
|||||||
return 1;//Dummy value
|
return 1;//Dummy value
|
||||||
}
|
}
|
||||||
|
|
||||||
CV_IMPL void cvDestroyWindow( const char* name )
|
void cvDestroyWindow( const char* name )
|
||||||
{
|
{
|
||||||
|
|
||||||
QMetaObject::invokeMethod(&guiMainThread,
|
QMetaObject::invokeMethod(&guiMainThread,
|
||||||
@ -397,7 +400,7 @@ CV_IMPL void cvDestroyWindow( const char* name )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CV_IMPL void cvDestroyAllWindows(void)
|
void cvDestroyAllWindows(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
QMetaObject::invokeMethod(&guiMainThread,
|
QMetaObject::invokeMethod(&guiMainThread,
|
||||||
@ -408,7 +411,7 @@ CV_IMPL void cvDestroyAllWindows(void)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CV_IMPL void* cvGetWindowHandle( const char* name )
|
void* cvGetWindowHandle( const char* name )
|
||||||
{
|
{
|
||||||
if( !name )
|
if( !name )
|
||||||
CV_Error( CV_StsNullPtr, "NULL name string" );
|
CV_Error( CV_StsNullPtr, "NULL name string" );
|
||||||
@ -416,7 +419,7 @@ CV_IMPL void* cvGetWindowHandle( const char* name )
|
|||||||
return (void*) icvFindWindowByName( name );
|
return (void*) icvFindWindowByName( name );
|
||||||
}
|
}
|
||||||
|
|
||||||
CV_IMPL const char* cvGetWindowName( void* window_handle )
|
const char* cvGetWindowName( void* window_handle )
|
||||||
{
|
{
|
||||||
|
|
||||||
if( !window_handle )
|
if( !window_handle )
|
||||||
@ -425,7 +428,7 @@ CV_IMPL const char* cvGetWindowName( void* window_handle )
|
|||||||
return ((CvWindow*)window_handle)->windowTitle().toLatin1().data();
|
return ((CvWindow*)window_handle)->windowTitle().toLatin1().data();
|
||||||
}
|
}
|
||||||
|
|
||||||
CV_IMPL void cvMoveWindow( const char* name, int x, int y )
|
void cvMoveWindow( const char* name, int x, int y )
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
@ -440,7 +443,7 @@ CV_IMPL void cvMoveWindow( const char* name, int x, int y )
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CV_IMPL void cvResizeWindow(const char* name, int width, int height )
|
void cvResizeWindow(const char* name, int width, int height )
|
||||||
{
|
{
|
||||||
|
|
||||||
QMetaObject::invokeMethod(&guiMainThread,
|
QMetaObject::invokeMethod(&guiMainThread,
|
||||||
@ -454,18 +457,18 @@ CV_IMPL void cvResizeWindow(const char* name, int width, int height )
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CV_IMPL int cvCreateTrackbar2( const char* trackbar_name, const char* window_name, int* val, int count, CvTrackbarCallback2 on_notify, void* userdata )
|
int cvCreateTrackbar2( const char* trackbar_name, const char* window_name, int* val, int count, CvTrackbarCallback2 on_notify, void* userdata )
|
||||||
{
|
{
|
||||||
//TODO: implement the real one, not a wrapper
|
//TODO: implement the real one, not a wrapper
|
||||||
return cvCreateTrackbar( trackbar_name, window_name, val, count, (CvTrackbarCallback)on_notify );
|
return cvCreateTrackbar( trackbar_name, window_name, val, count, (CvTrackbarCallback)on_notify );
|
||||||
}
|
}
|
||||||
|
|
||||||
CV_IMPL int cvStartWindowThread()
|
int cvStartWindowThread()
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
CV_IMPL int cvCreateTrackbar( const char* trackbar_name, const char* window_name, int* value, int count, CvTrackbarCallback on_change)
|
int cvCreateTrackbar( const char* trackbar_name, const char* window_name, int* value, int count, CvTrackbarCallback on_change)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (multiThreads)
|
if (multiThreads)
|
||||||
@ -484,7 +487,7 @@ CV_IMPL int cvCreateTrackbar( const char* trackbar_name, const char* window_name
|
|||||||
return 1;//dummy value
|
return 1;//dummy value
|
||||||
}
|
}
|
||||||
|
|
||||||
CV_IMPL void cvCreateOpenGLCallback( const char* window_name, CvOpenGLCallback callbackOpenGL, void* userdata)
|
void cvCreateOpenGLCallback( const char* window_name, CvOpenGLCallback callbackOpenGL, void* userdata)
|
||||||
{
|
{
|
||||||
QMetaObject::invokeMethod(&guiMainThread,
|
QMetaObject::invokeMethod(&guiMainThread,
|
||||||
"setOpenGLCallback",
|
"setOpenGLCallback",
|
||||||
@ -495,7 +498,7 @@ CV_IMPL void cvCreateOpenGLCallback( const char* window_name, CvOpenGLCallback c
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
CV_IMPL int cvGetTrackbarPos( const char* trackbar_name, const char* window_name )
|
int cvGetTrackbarPos( const char* trackbar_name, const char* window_name )
|
||||||
{
|
{
|
||||||
int result = -1;
|
int result = -1;
|
||||||
|
|
||||||
@ -507,7 +510,7 @@ CV_IMPL int cvGetTrackbarPos( const char* trackbar_name, const char* window_name
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
CV_IMPL void cvSetTrackbarPos( const char* trackbar_name, const char* window_name, int pos )
|
void cvSetTrackbarPos( const char* trackbar_name, const char* window_name, int pos )
|
||||||
{
|
{
|
||||||
|
|
||||||
QPointer<CvTrackbar> t = icvFindTrackbarByName( trackbar_name, window_name );
|
QPointer<CvTrackbar> t = icvFindTrackbarByName( trackbar_name, window_name );
|
||||||
@ -518,7 +521,7 @@ CV_IMPL void cvSetTrackbarPos( const char* trackbar_name, const char* window_nam
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* assign callback for mouse events */
|
/* assign callback for mouse events */
|
||||||
CV_IMPL void cvSetMouseCallback( const char* window_name, CvMouseCallback on_mouse,void* param )
|
void cvSetMouseCallback( const char* window_name, CvMouseCallback on_mouse,void* param )
|
||||||
{
|
{
|
||||||
QPointer<CvWindow> w = icvFindWindowByName( window_name );
|
QPointer<CvWindow> w = icvFindWindowByName( window_name );
|
||||||
|
|
||||||
@ -529,7 +532,7 @@ CV_IMPL void cvSetMouseCallback( const char* window_name, CvMouseCallback on_mou
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CV_IMPL void cvShowImage( const char* name, const CvArr* arr )
|
void cvShowImage( const char* name, const CvArr* arr )
|
||||||
{
|
{
|
||||||
|
|
||||||
QMetaObject::invokeMethod(&guiMainThread,
|
QMetaObject::invokeMethod(&guiMainThread,
|
||||||
@ -653,11 +656,11 @@ void GuiReceiver::setPropWindow(QString name, double arg2 )
|
|||||||
switch(flags)
|
switch(flags)
|
||||||
{
|
{
|
||||||
case CV_WINDOW_NORMAL:
|
case CV_WINDOW_NORMAL:
|
||||||
w->layout->setSizeConstraint(QLayout::SetMinAndMaxSize);
|
w->myLayout->setSizeConstraint(QLayout::SetMinAndMaxSize);
|
||||||
w->param_flags = flags;
|
w->param_flags = flags;
|
||||||
break;
|
break;
|
||||||
case CV_WINDOW_AUTOSIZE:
|
case CV_WINDOW_AUTOSIZE:
|
||||||
w->layout->setSizeConstraint(QLayout::SetFixedSize);
|
w->myLayout->setSizeConstraint(QLayout::SetFixedSize);
|
||||||
w->param_flags = flags;
|
w->param_flags = flags;
|
||||||
break;
|
break;
|
||||||
default:;
|
default:;
|
||||||
@ -931,6 +934,83 @@ CvTrackbar::~CvTrackbar()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//here CvWinProperties class
|
||||||
|
CvWinProperties::CvWinProperties(QString name_paraWindow, QWidget* parent)
|
||||||
|
{
|
||||||
|
setParent(parent);
|
||||||
|
setWindowFlags(Qt::Tool);
|
||||||
|
setContentsMargins(0,0,0,0);
|
||||||
|
setWindowTitle(name_paraWindow);
|
||||||
|
setObjectName(name_paraWindow);
|
||||||
|
//parameters_window->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
|
||||||
|
resize(100,50);
|
||||||
|
|
||||||
|
myLayout = new QBoxLayout(QBoxLayout::TopToBottom);
|
||||||
|
myLayout->setObjectName(QString::fromUtf8("boxLayout"));
|
||||||
|
myLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
myLayout->setSpacing(0);
|
||||||
|
myLayout->setMargin(0);
|
||||||
|
myLayout->setSizeConstraint(QLayout::SetFixedSize);
|
||||||
|
setLayout(myLayout);
|
||||||
|
|
||||||
|
hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CvWinProperties::closeEvent ( QCloseEvent * e )
|
||||||
|
{
|
||||||
|
e->accept();//intersept the close event (not sure I really need it)
|
||||||
|
//an hide event is also sent. I will intercept it and do some processing
|
||||||
|
}
|
||||||
|
|
||||||
|
void CvWinProperties::showEvent ( QShowEvent * event )
|
||||||
|
{
|
||||||
|
//why -1,-1 ?: do this trick because the first time the code is run,
|
||||||
|
//no value pos was saved so we let Qt move the window in the middle of its parent (event ignored).
|
||||||
|
//then hide will save the last position and thus, we want to retreive it (event accepted).
|
||||||
|
QPoint mypos(-1,-1);
|
||||||
|
QSettings settings("OpenCV2", this->windowTitle());
|
||||||
|
mypos = settings.value("pos", mypos).toPoint();
|
||||||
|
|
||||||
|
if (mypos.x()>=0)
|
||||||
|
{
|
||||||
|
move(mypos);
|
||||||
|
event->accept();
|
||||||
|
}else{
|
||||||
|
event->ignore();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CvWinProperties::hideEvent ( QHideEvent * event )
|
||||||
|
{
|
||||||
|
QSettings settings("OpenCV2", this->windowTitle());
|
||||||
|
settings.setValue("pos", pos());
|
||||||
|
event->accept();
|
||||||
|
}
|
||||||
|
|
||||||
|
CvWinProperties::~CvWinProperties()
|
||||||
|
{
|
||||||
|
//clear the setting pos
|
||||||
|
QSettings settings("OpenCV2", this->windowTitle());
|
||||||
|
settings.clear();
|
||||||
|
|
||||||
|
QLayoutItem *child;
|
||||||
|
if (myLayout)
|
||||||
|
{
|
||||||
|
while ((child = myLayout->takeAt(0)) != 0)
|
||||||
|
delete child;
|
||||||
|
|
||||||
|
delete myLayout;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Here CvWindow class
|
//Here CvWindow class
|
||||||
CvWindow::CvWindow(QString arg, int arg2)
|
CvWindow::CvWindow(QString arg, int arg2)
|
||||||
{
|
{
|
||||||
@ -939,8 +1019,8 @@ CvWindow::CvWindow(QString arg, int arg2)
|
|||||||
|
|
||||||
//the first bit is for normal or autoresize
|
//the first bit is for normal or autoresize
|
||||||
//CV_WINDOW_NORMAL = 0x00000000 and CV_WINDOW_AUTOSIZE = 0x00000001
|
//CV_WINDOW_NORMAL = 0x00000000 and CV_WINDOW_AUTOSIZE = 0x00000001
|
||||||
//the secont bit is for the gui mode (normal or extended)
|
//the secont bit is for the gui mode (normal or EXPANDED)
|
||||||
//CV_GUI_EXTENDED = 0x00000000 and CV_GUI_NORMAL = 0x00000010
|
//CV_GUI_EXPANDED = 0x00000000 and CV_GUI_NORMAL = 0x00000010
|
||||||
param_flags = arg2 & 0x0000000F;
|
param_flags = arg2 & 0x0000000F;
|
||||||
param_gui_mode = arg2 & 0x000000F0;
|
param_gui_mode = arg2 & 0x000000F0;
|
||||||
|
|
||||||
@ -964,22 +1044,23 @@ CvWindow::CvWindow(QString arg, int arg2)
|
|||||||
createShortcuts();
|
createShortcuts();
|
||||||
|
|
||||||
//toolBar and statusbar
|
//toolBar and statusbar
|
||||||
if (param_gui_mode == CV_GUI_EXTENDED)
|
if (param_gui_mode == CV_GUI_EXPANDED)
|
||||||
{
|
{
|
||||||
createToolBar();
|
createToolBar();
|
||||||
createStatusBar();
|
createStatusBar();
|
||||||
|
createParameterWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
//Now attach everything
|
//Now attach everything
|
||||||
if (myToolBar)
|
if (myToolBar)
|
||||||
layout->addWidget(myToolBar,Qt::AlignCenter);
|
myLayout->addWidget(myToolBar,Qt::AlignCenter);
|
||||||
|
|
||||||
layout->addWidget(myview,Qt::AlignCenter);
|
myLayout->addWidget(myview,Qt::AlignCenter);
|
||||||
|
|
||||||
if (myStatusBar)
|
if (myStatusBar)
|
||||||
layout->addWidget(myStatusBar,Qt::AlignCenter);
|
myLayout->addWidget(myStatusBar,Qt::AlignCenter);
|
||||||
|
|
||||||
setLayout(layout);
|
setLayout(myLayout);
|
||||||
show();
|
show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -987,24 +1068,44 @@ CvWindow::~CvWindow()
|
|||||||
{
|
{
|
||||||
QLayoutItem *child;
|
QLayoutItem *child;
|
||||||
|
|
||||||
if (layout)
|
if (myLayout)
|
||||||
{
|
{
|
||||||
while ((child = layout->takeAt(0)) != 0)
|
while ((child = myLayout->takeAt(0)) != 0)
|
||||||
delete child;
|
delete child;
|
||||||
|
|
||||||
delete layout;
|
delete myLayout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (myStatusBar)
|
||||||
|
{
|
||||||
delete myStatusBar;
|
delete myStatusBar;
|
||||||
delete myStatusBar_msg;
|
delete myStatusBar_msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (myToolBar)
|
||||||
for (int i=0;i<vect_QShortcuts.count();i++)
|
{
|
||||||
delete vect_QShortcuts[i];
|
|
||||||
|
|
||||||
for (int i=0;i<vect_QActions.count();i++)
|
for (int i=0;i<vect_QActions.count();i++)
|
||||||
delete vect_QActions[i];
|
delete vect_QActions[i];
|
||||||
|
|
||||||
|
delete myToolBar;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i=0;i<vect_QShortcuts.count();i++)
|
||||||
|
delete vect_QShortcuts[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
void CvWindow::createParameterWindow()
|
||||||
|
{
|
||||||
|
QString name_paraWindow=param_name+" window parameters";
|
||||||
|
parameters_window = new CvWinProperties(name_paraWindow,this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CvWindow::displayPropertiesWin()
|
||||||
|
{
|
||||||
|
if (parameters_window->isHidden())
|
||||||
|
parameters_window->show();
|
||||||
|
else
|
||||||
|
parameters_window->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CvWindow::createToolBar()
|
void CvWindow::createToolBar()
|
||||||
@ -1055,7 +1156,7 @@ void CvWindow::createToolBar()
|
|||||||
myToolBar->addAction(vect_QActions[8]);
|
myToolBar->addAction(vect_QActions[8]);
|
||||||
|
|
||||||
vect_QActions[9] = new QAction(QIcon(":/properties-icon"),tr("Display properties window (CTRL+P)"),this);
|
vect_QActions[9] = new QAction(QIcon(":/properties-icon"),tr("Display properties window (CTRL+P)"),this);
|
||||||
QObject::connect( vect_QActions[9],SIGNAL(triggered()),myview, SLOT( displayPropertiesWin() ));
|
QObject::connect( vect_QActions[9],SIGNAL(triggered()),this, SLOT( displayPropertiesWin() ));
|
||||||
myToolBar->addAction(vect_QActions[9]);
|
myToolBar->addAction(vect_QActions[9]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1072,14 +1173,14 @@ void CvWindow::createStatusBar()
|
|||||||
|
|
||||||
void CvWindow::createLayout()
|
void CvWindow::createLayout()
|
||||||
{
|
{
|
||||||
layout = new QBoxLayout(QBoxLayout::TopToBottom);
|
myLayout = new QBoxLayout(QBoxLayout::TopToBottom);
|
||||||
layout->setObjectName(QString::fromUtf8("boxLayout"));
|
myLayout->setObjectName(QString::fromUtf8("boxLayout"));
|
||||||
layout->setContentsMargins(0, 0, 0, 0);
|
myLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
layout->setSpacing(0);
|
myLayout->setSpacing(0);
|
||||||
layout->setMargin(0);
|
myLayout->setMargin(0);
|
||||||
|
|
||||||
if (param_flags == CV_WINDOW_AUTOSIZE)
|
if (param_flags == CV_WINDOW_AUTOSIZE)
|
||||||
layout->setSizeConstraint(QLayout::SetFixedSize);
|
myLayout->setSizeConstraint(QLayout::SetFixedSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CvWindow::createShortcuts()
|
void CvWindow::createShortcuts()
|
||||||
@ -1106,7 +1207,7 @@ void CvWindow::createShortcuts()
|
|||||||
vect_QShortcuts[8] = new QShortcut(shortcut_save_img, this);
|
vect_QShortcuts[8] = new QShortcut(shortcut_save_img, this);
|
||||||
QObject::connect( vect_QShortcuts[8], SIGNAL( activated ()),myview, SLOT( saveView( ) ));
|
QObject::connect( vect_QShortcuts[8], SIGNAL( activated ()),myview, SLOT( saveView( ) ));
|
||||||
vect_QShortcuts[9] = new QShortcut(shortcut_properties_win, this);
|
vect_QShortcuts[9] = new QShortcut(shortcut_properties_win, this);
|
||||||
QObject::connect( vect_QShortcuts[9], SIGNAL( activated ()),myview, SLOT( displayPropertiesWin() ));
|
QObject::connect( vect_QShortcuts[9], SIGNAL( activated ()),this, SLOT( displayPropertiesWin() ));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CvWindow::createView(int mode)
|
void CvWindow::createView(int mode)
|
||||||
@ -1150,12 +1251,26 @@ void CvWindow::addSlider(QString name, int* value, int count,CvTrackbarCallback
|
|||||||
{
|
{
|
||||||
QPointer<CvTrackbar> t = new CvTrackbar(this,name,value, count, on_change);
|
QPointer<CvTrackbar> t = new CvTrackbar(this,name,value, count, on_change);
|
||||||
t->setAlignment(Qt::AlignHCenter);
|
t->setAlignment(Qt::AlignHCenter);
|
||||||
int position_insert = layout->count();
|
|
||||||
|
int position_insert;
|
||||||
|
if (param_gui_mode == CV_GUI_NORMAL)
|
||||||
|
{
|
||||||
|
position_insert = myLayout->count();
|
||||||
|
|
||||||
if (myStatusBar)
|
if (myStatusBar)
|
||||||
position_insert--;//max-1 means add trackbar between myview and statusbar
|
position_insert--;//max-1 means add trackbar between myview and statusbar
|
||||||
|
|
||||||
layout->insertLayout(position_insert,t);
|
myLayout->insertLayout(position_insert,t);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (param_gui_mode == CV_GUI_EXPANDED)
|
||||||
|
{
|
||||||
|
position_insert = parameters_window->myLayout->count();
|
||||||
|
parameters_window->myLayout->insertLayout(position_insert,t);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Need more test here !
|
//Need more test here !
|
||||||
@ -1191,6 +1306,7 @@ void CvWindow::keyPressEvent(QKeyEvent *event)
|
|||||||
QWidget::keyPressEvent(event);
|
QWidget::keyPressEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO: load CV_GUI flag (done) and act accordingly (create win property if needed and attach trackbars)
|
||||||
void CvWindow::readSettings()
|
void CvWindow::readSettings()
|
||||||
{
|
{
|
||||||
//organisation and application's name
|
//organisation and application's name
|
||||||
@ -1199,6 +1315,7 @@ void CvWindow::readSettings()
|
|||||||
QSize size = settings.value("size", QSize(400, 400)).toSize();
|
QSize size = settings.value("size", QSize(400, 400)).toSize();
|
||||||
//param_name = settings.value("name_window",param_name).toString();
|
//param_name = settings.value("name_window",param_name).toString();
|
||||||
param_flags = settings.value("mode_resize",param_flags).toInt();
|
param_flags = settings.value("mode_resize",param_flags).toInt();
|
||||||
|
param_gui_mode = settings.value("mode_gui",param_gui_mode).toInt();
|
||||||
myview->param_keepRatio = settings.value("view_aspectRatio",myview->param_keepRatio).toInt();
|
myview->param_keepRatio = settings.value("view_aspectRatio",myview->param_keepRatio).toInt();
|
||||||
|
|
||||||
param_flags = settings.value("mode_resize",param_flags).toInt();
|
param_flags = settings.value("mode_resize",param_flags).toInt();
|
||||||
@ -1228,6 +1345,7 @@ void CvWindow::writeSettings()
|
|||||||
settings.setValue("pos", pos());
|
settings.setValue("pos", pos());
|
||||||
settings.setValue("size", size());
|
settings.setValue("size", size());
|
||||||
settings.setValue("mode_resize",param_flags);
|
settings.setValue("mode_resize",param_flags);
|
||||||
|
settings.setValue("mode_gui",param_gui_mode);
|
||||||
settings.setValue("view_aspectRatio",myview->param_keepRatio);
|
settings.setValue("view_aspectRatio",myview->param_keepRatio);
|
||||||
|
|
||||||
settings.setValue("matrix_view.m11",myview->param_matrixWorld.m11());
|
settings.setValue("matrix_view.m11",myview->param_matrixWorld.m11());
|
||||||
@ -1257,7 +1375,7 @@ void CvWindow::icvLoadTrackbars(QSettings *settings)
|
|||||||
if (myToolBar)
|
if (myToolBar)
|
||||||
start_index ++;//index 0 is statusbar, 1 is myview
|
start_index ++;//index 0 is statusbar, 1 is myview
|
||||||
|
|
||||||
int stop_index = layout->layout()->count() - start_index ;
|
int stop_index = myLayout->layout()->count() - start_index ;
|
||||||
if (myStatusBar)
|
if (myStatusBar)
|
||||||
stop_index --;// index max-1 is the statusbar
|
stop_index --;// index max-1 is the statusbar
|
||||||
|
|
||||||
@ -1267,7 +1385,7 @@ void CvWindow::icvLoadTrackbars(QSettings *settings)
|
|||||||
for (int i = start_index; i < size+start_index; ++i)
|
for (int i = start_index; i < size+start_index; ++i)
|
||||||
{
|
{
|
||||||
settings->setArrayIndex(i-start_index);
|
settings->setArrayIndex(i-start_index);
|
||||||
t = (CvTrackbar*) layout->layout()->itemAt(i);
|
t = (CvTrackbar*) myLayout->layout()->itemAt(i);
|
||||||
|
|
||||||
if (t->trackbar_name == settings->value("name").toString())
|
if (t->trackbar_name == settings->value("name").toString())
|
||||||
{
|
{
|
||||||
@ -1290,8 +1408,8 @@ void CvWindow::icvSaveTrackbars(QSettings *settings)
|
|||||||
if (myToolBar)
|
if (myToolBar)
|
||||||
start_index=3;
|
start_index=3;
|
||||||
|
|
||||||
for (int i = start_index; i < layout->layout()->count()-1; ++i) {
|
for (int i = start_index; i < myLayout->layout()->count()-1; ++i) {
|
||||||
t = (CvTrackbar*) layout->layout()->itemAt(i);
|
t = (CvTrackbar*) myLayout->layout()->itemAt(i);
|
||||||
settings->setArrayIndex(i-start_index);
|
settings->setArrayIndex(i-start_index);
|
||||||
settings->setValue("name", t->trackbar_name);
|
settings->setValue("name", t->trackbar_name);
|
||||||
settings->setValue("value", t->slider->value());
|
settings->setValue("value", t->slider->value());
|
||||||
@ -1401,10 +1519,6 @@ void ViewPort::saveView()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViewPort::displayPropertiesWin()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void ViewPort::setRatio(int flags)
|
void ViewPort::setRatio(int flags)
|
||||||
{
|
{
|
||||||
@ -1492,7 +1606,7 @@ void ViewPort::updateImage(void* arr)
|
|||||||
{
|
{
|
||||||
//if (!arr)
|
//if (!arr)
|
||||||
//CV_Error(CV_StsNullPtr, "NULL arr pointer (in showImage)" );
|
//CV_Error(CV_StsNullPtr, "NULL arr pointer (in showImage)" );
|
||||||
CV_Assert(arr);
|
CV_Assert(arr)
|
||||||
|
|
||||||
IplImage* tempImage = (IplImage*)arr;
|
IplImage* tempImage = (IplImage*)arr;
|
||||||
|
|
||||||
|
@ -158,6 +158,22 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class CvWinProperties : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
CvWinProperties(QString name,QWidget* parent);
|
||||||
|
~CvWinProperties();
|
||||||
|
QPointer<QBoxLayout> myLayout;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void closeEvent ( QCloseEvent * e );
|
||||||
|
void showEvent ( QShowEvent * event ) ;
|
||||||
|
void hideEvent ( QHideEvent * event ) ;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class CvWindow : public QWidget
|
class CvWindow : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -174,7 +190,7 @@ public:
|
|||||||
void setOpenGLCallback(CvOpenGLCallback arg1,void* userdata);
|
void setOpenGLCallback(CvOpenGLCallback arg1,void* userdata);
|
||||||
ViewPort* getView();
|
ViewPort* getView();
|
||||||
|
|
||||||
QPointer<QBoxLayout> layout;
|
QPointer<QBoxLayout> myLayout;
|
||||||
QPointer<QStatusBar> myStatusBar;
|
QPointer<QStatusBar> myStatusBar;
|
||||||
QPointer<QToolBar> myToolBar;
|
QPointer<QToolBar> myToolBar;
|
||||||
QPointer<QLabel> myStatusBar_msg;
|
QPointer<QLabel> myStatusBar_msg;
|
||||||
@ -189,6 +205,7 @@ protected:
|
|||||||
virtual void keyPressEvent(QKeyEvent *event);
|
virtual void keyPressEvent(QKeyEvent *event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
QPointer<CvWinProperties> parameters_window ;
|
||||||
QPointer<ViewPort> myview;
|
QPointer<ViewPort> myview;
|
||||||
QVector<QAction*> vect_QActions;
|
QVector<QAction*> vect_QActions;
|
||||||
QVector<QShortcut*> vect_QShortcuts;
|
QVector<QShortcut*> vect_QShortcuts;
|
||||||
@ -201,6 +218,10 @@ private:
|
|||||||
void createView(int mode);
|
void createView(int mode);
|
||||||
void createStatusBar();
|
void createStatusBar();
|
||||||
void createLayout();
|
void createLayout();
|
||||||
|
void createParameterWindow();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void displayPropertiesWin();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -256,7 +277,7 @@ public slots:
|
|||||||
void siftWindowOnDown();
|
void siftWindowOnDown();
|
||||||
void resizeEvent ( QResizeEvent * );
|
void resizeEvent ( QResizeEvent * );
|
||||||
void saveView();
|
void saveView();
|
||||||
void displayPropertiesWin();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPoint mouseCoordinate;
|
QPoint mouseCoordinate;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user