Merge pull request #5543 from aman11dhanpat:master

This commit is contained in:
Vadim Pisarevsky 2015-10-21 11:44:35 +00:00
commit f820df2ea0
10 changed files with 187 additions and 5 deletions

View File

@ -526,6 +526,21 @@ panel.
*/
CV_EXPORTS_W void setTrackbarMax(const String& trackbarname, const String& winname, int maxval);
/** @brief Sets the trackbar minimum position.
The function sets the minimum position of the specified trackbar in the specified window.
@note
[__Qt Backend Only__] winname can be empty (or NULL) if the trackbar is attached to the control
panel.
@param trackbarname Name of the trackbar.
@param winname Name of the window that is the parent of trackbar.
@param minval New maximum position.
*/
CV_EXPORTS_W void setTrackbarMin(const String& trackbarname, const String& winname, int minval);
//! @addtogroup highgui_opengl OpenGL support
//! @{

View File

@ -166,6 +166,7 @@ CVAPI(int) cvCreateTrackbar2( const char* trackbar_name, const char* window_name
CVAPI(int) cvGetTrackbarPos( const char* trackbar_name, const char* window_name );
CVAPI(void) cvSetTrackbarPos( const char* trackbar_name, const char* window_name, int pos );
CVAPI(void) cvSetTrackbarMax(const char* trackbar_name, const char* window_name, int maxval);
CVAPI(void) cvSetTrackbarMin(const char* trackbar_name, const char* window_name, int minval);
enum
{

View File

@ -216,6 +216,11 @@ void cv::setTrackbarMax(const String& trackbarName, const String& winName, int m
cvSetTrackbarMax(trackbarName.c_str(), winName.c_str(), maxval);
}
void cv::setTrackbarMin(const String& trackbarName, const String& winName, int minval)
{
cvSetTrackbarMin(trackbarName.c_str(), winName.c_str(), minval);
}
int cv::getTrackbarPos( const String& trackbarName, const String& winName )
{
return cvGetTrackbarPos(trackbarName.c_str(), winName.c_str());
@ -589,6 +594,11 @@ CV_IMPL void cvSetTrackbarMax(const char*, const char*, int)
CV_NO_GUI_ERROR( "cvSetTrackbarMax" );
}
CV_IMPL void cvSetTrackbarMin(const char*, const char*, int)
{
CV_NO_GUI_ERROR( "cvSetTrackbarMin" );
}
CV_IMPL void* cvGetWindowHandle( const char* )
{
CV_NO_GUI_ERROR( "cvGetWindowHandle" );

View File

@ -664,12 +664,29 @@ CV_IMPL void cvSetTrackbarMax(const char* name_bar, const char* window_name, int
QPointer<CvTrackbar> t = icvFindTrackBarByName(name_bar, window_name);
if (t)
{
int minval = t->slider->getMinimum();
maxval = (maxval>minval)?maxval:minval;
t->slider->setMaximum(maxval);
}
}
}
CV_IMPL void cvSetTrackbarMin(const char* name_bar, const char* window_name, int minval)
{
if (minval >= 0)
{
QPointer<CvTrackbar> t = icvFindTrackBarByName(name_bar, window_name);
if (t)
{
int maxval = t->slider->getMaximum();
minval = (maxval<minval)?maxval:minval;
t->slider->setMinimum(minval);
}
}
}
/* assign callback for mouse events */
CV_IMPL void cvSetMouseCallback(const char* window_name, CvMouseCallback on_mouse, void* param)
{

View File

@ -62,6 +62,7 @@ CV_IMPL void cvSetMouseCallback( const char* name, CvMouseCallback function, voi
CV_IMPL int cvGetTrackbarPos( const char* trackbar_name, const char* window_name ) {return 0;}
CV_IMPL void cvSetTrackbarPos(const char* trackbar_name, const char* window_name, int pos) {}
CV_IMPL void cvSetTrackbarMax(const char* trackbar_name, const char* window_name, int maxval) {}
CV_IMPL void cvSetTrackbarMin(const char* trackbar_name, const char* window_name, int minval) {}
CV_IMPL void* cvGetWindowHandle( const char* name ) {return NULL;}
CV_IMPL const char* cvGetWindowName( void* window_handle ) {return NULL;}
CV_IMPL int cvNamedWindow( const char* name, int flags ) {return 0; }
@ -426,7 +427,7 @@ CV_IMPL void cvSetTrackbarPos(const char* trackbar_name, const char* window_name
CV_IMPL void cvSetTrackbarMax(const char* trackbar_name, const char* window_name, int maxval)
{
CV_FUNCNAME("cvSetTrackbarPos");
CV_FUNCNAME("cvSetTrackbarMax");
CVWindow *window = nil;
CVSlider *slider = nil;
@ -445,6 +446,8 @@ CV_IMPL void cvSetTrackbarMax(const char* trackbar_name, const char* window_name
slider = [[window sliders] valueForKey:[NSString stringWithFormat:@"%s", trackbar_name]];
if(slider) {
if(maxval >= 0) {
int minval = [[slider slider] minValue];
maxval = (minval>maxval)?minval:maxval;
[[slider slider] setMaxValue:maxval];
}
}
@ -454,6 +457,37 @@ CV_IMPL void cvSetTrackbarMax(const char* trackbar_name, const char* window_name
__END__;
}
CV_IMPL void cvSetTrackbarMin(const char* trackbar_name, const char* window_name, int minval)
{
CV_FUNCNAME("cvSetTrackbarMin");
CVWindow *window = nil;
CVSlider *slider = nil;
NSAutoreleasePool* localpool5 = nil;
__BEGIN__;
if(trackbar_name == NULL || window_name == NULL)
CV_ERROR( CV_StsNullPtr, "NULL trackbar or window name" );
if (localpool5 != nil) [localpool5 drain];
localpool5 = [[NSAutoreleasePool alloc] init];
window = cvGetWindow(window_name);
if(window) {
slider = [[window sliders] valueForKey:[NSString stringWithFormat:@"%s", trackbar_name]];
if(slider) {
if(minval >= 0) {
int maxval = [[slider slider] maxValue];
minval = (minval<maxval)?minval:maxval;
[[slider slider] setMinValue:minval];
}
}
}
[localpool5 drain];
__END__;
}
CV_IMPL void* cvGetWindowHandle( const char* name )
{
//cout << "cvGetWindowHandle" << endl;

View File

@ -508,6 +508,7 @@ typedef struct CvTrackbar
int* data;
int pos;
int maxval;
int minval;
CvTrackbarCallback notify;
CvTrackbarCallback2 notify2;
void* userdata;
@ -1607,7 +1608,7 @@ CV_IMPL void cvSetTrackbarMax(const char* trackbar_name, const char* window_name
trackbar = icvFindTrackbarByName(window, trackbar_name);
if (trackbar)
{
trackbar->maxval = maxval;
trackbar->maxval = (trackbar->minval>maxval)?trackbar->minval:maxval;
CV_LOCK_MUTEX();
@ -1622,6 +1623,43 @@ CV_IMPL void cvSetTrackbarMax(const char* trackbar_name, const char* window_name
}
CV_IMPL void cvSetTrackbarMin(const char* trackbar_name, const char* window_name, int minval)
{
CV_FUNCNAME("cvSetTrackbarMin");
__BEGIN__;
if (minval >= 0)
{
CvWindow* window = 0;
CvTrackbar* trackbar = 0;
if (trackbar_name == 0 || window_name == 0)
{
CV_ERROR( CV_StsNullPtr, "NULL trackbar or window name");
}
window = icvFindWindowByName( window_name );
if (window)
{
trackbar = icvFindTrackbarByName(window, trackbar_name);
if (trackbar)
{
trackbar->minval = (minval<trackbar->maxval)?minval:trackbar->maxval;
CV_LOCK_MUTEX();
gtk_range_set_range(GTK_RANGE(trackbar->widget), minval, trackbar->maxval);
CV_UNLOCK_MUTEX();
}
}
}
__END__;
}
CV_IMPL void* cvGetWindowHandle( const char* window_name )
{
void* widget = 0;

View File

@ -138,6 +138,7 @@ typedef struct CvTrackbar
int* data;
int pos;
int maxval;
int minval;
void (*notify)(int);
void (*notify2)(int, void*);
void* userdata;
@ -2325,7 +2326,7 @@ CV_IMPL void cvSetTrackbarMax(const char* trackbar_name, const char* window_name
if (trackbar)
{
// The position will be min(pos, maxval).
trackbar->maxval = maxval;
trackbar->maxval = (trackbar->minval>maxval)?trackbar->minval:maxval;
SendMessage(trackbar->hwnd, TBM_SETRANGEMAX, (WPARAM)TRUE, (LPARAM)maxval);
}
}
@ -2335,6 +2336,38 @@ CV_IMPL void cvSetTrackbarMax(const char* trackbar_name, const char* window_name
}
CV_IMPL void cvSetTrackbarMin(const char* trackbar_name, const char* window_name, int minval)
{
CV_FUNCNAME( "cvSetTrackbarMin" );
__BEGIN__;
if (minval >= 0)
{
CvWindow* window = 0;
CvTrackbar* trackbar = 0;
if (trackbar_name == 0 || window_name == 0)
{
CV_ERROR(CV_StsNullPtr, "NULL trackbar or window name");
}
window = icvFindWindowByName(window_name);
if (window)
{
trackbar = icvFindTrackbarByName(window, trackbar_name);
if (trackbar)
{
// The position will be min(pos, maxval).
trackbar->minval = (minval<trackbar->maxval)?minval:trackbar->maxval;
SendMessage(trackbar->hwnd, TBM_SETRANGEMIN, (WPARAM)TRUE, (LPARAM)minval);
}
}
}
__END__;
}
CV_IMPL void* cvGetWindowHandle( const char* window_name )
{
void* hwnd = 0;

View File

@ -170,6 +170,22 @@ CV_IMPL void cvSetTrackbarMax(const char* trackbar_name, const char* window_name
}
}
CV_IMPL void cvSetTrackbarMin(const char* trackbar_name, const char* window_name, int minval)
{
CV_FUNCNAME("cvSetTrackbarMin");
if (minval >= 0)
{
if (trackbar_name == 0 || window_name == 0)
CV_ERROR(CV_StsNullPtr, "NULL trackbar or window name");
CvTrackbar* trackbar = HighguiBridge::getInstance().findTrackbarByName(trackbar_name, window_name);
if (trackbar)
trackbar->setMinPosition(minval);
}
}
CV_IMPL int cvGetTrackbarPos(const char* trackbar_name, const char* window_name)
{
int pos = -1;

View File

@ -171,12 +171,23 @@ void CvTrackbar::setPosition(double pos)
void CvTrackbar::setMaxPosition(double pos)
{
if (pos < 0)
pos = 0;
//slider->Minimum is initialized with 0
if (pos < slider->Minimum)
pos = slider->Minimum;
slider->Maximum = pos;
}
void CvTrackbar::setMinPosition(double pos)
{
if (pos < 0)
pos = 0;
//Min is always less than Max.
if ((pos > slider->Maximum)
pos = slider->Maximum;
slider->Minimum = pos;
}
void CvTrackbar::setSlider(Slider^ slider) {
if (slider)
this->slider = slider;
@ -192,6 +203,11 @@ double CvTrackbar::getMaxPosition()
return slider->Maximum;
}
double CvTrackbar::getMinPosition()
{
return slider->Minimum;
}
Slider^ CvTrackbar::getSlider()
{
return slider;

View File

@ -151,6 +151,8 @@ public:
void setPosition(double pos);
double getMaxPosition();
void setMaxPosition(double pos);
double getMinPosition();
void setMinPosition(double pos);
Slider^ getSlider();
void setSlider(Slider^ pos);