Fix for #5495 : add setTrackbarMin
This commit is contained in:
parent
37ce3b8cfe
commit
b0209ad7f7
@ -526,6 +526,21 @@ panel.
|
|||||||
*/
|
*/
|
||||||
CV_EXPORTS_W void setTrackbarMax(const String& trackbarname, const String& winname, int maxval);
|
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
|
//! @addtogroup highgui_opengl OpenGL support
|
||||||
//! @{
|
//! @{
|
||||||
|
|
||||||
|
@ -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(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) 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) 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
|
enum
|
||||||
{
|
{
|
||||||
|
@ -216,6 +216,11 @@ void cv::setTrackbarMax(const String& trackbarName, const String& winName, int m
|
|||||||
cvSetTrackbarMax(trackbarName.c_str(), winName.c_str(), maxval);
|
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 )
|
int cv::getTrackbarPos( const String& trackbarName, const String& winName )
|
||||||
{
|
{
|
||||||
return cvGetTrackbarPos(trackbarName.c_str(), winName.c_str());
|
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_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_IMPL void* cvGetWindowHandle( const char* )
|
||||||
{
|
{
|
||||||
CV_NO_GUI_ERROR( "cvGetWindowHandle" );
|
CV_NO_GUI_ERROR( "cvGetWindowHandle" );
|
||||||
|
@ -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);
|
QPointer<CvTrackbar> t = icvFindTrackBarByName(name_bar, window_name);
|
||||||
if (t)
|
if (t)
|
||||||
{
|
{
|
||||||
|
int minval = t->slider->getMinimum();
|
||||||
|
maxval = (maxval>minval)?maxval:minval;
|
||||||
t->slider->setMaximum(maxval);
|
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 */
|
/* assign callback for mouse events */
|
||||||
CV_IMPL void cvSetMouseCallback(const char* window_name, CvMouseCallback on_mouse, void* param)
|
CV_IMPL void cvSetMouseCallback(const char* window_name, CvMouseCallback on_mouse, void* param)
|
||||||
{
|
{
|
||||||
|
@ -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 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 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 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 void* cvGetWindowHandle( const char* name ) {return NULL;}
|
||||||
CV_IMPL const char* cvGetWindowName( void* window_handle ) {return NULL;}
|
CV_IMPL const char* cvGetWindowName( void* window_handle ) {return NULL;}
|
||||||
CV_IMPL int cvNamedWindow( const char* name, int flags ) {return 0; }
|
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_IMPL void cvSetTrackbarMax(const char* trackbar_name, const char* window_name, int maxval)
|
||||||
{
|
{
|
||||||
CV_FUNCNAME("cvSetTrackbarPos");
|
CV_FUNCNAME("cvSetTrackbarMax");
|
||||||
|
|
||||||
CVWindow *window = nil;
|
CVWindow *window = nil;
|
||||||
CVSlider *slider = nil;
|
CVSlider *slider = nil;
|
||||||
@ -454,7 +455,37 @@ CV_IMPL void cvSetTrackbarMax(const char* trackbar_name, const char* window_name
|
|||||||
__END__;
|
__END__;
|
||||||
}
|
}
|
||||||
|
|
||||||
CV_IMPL void* cvGetWindowHandle( const char* name )
|
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__;
|
||||||
|
//cout << "cvSetTrackbarPos" << endl;
|
||||||
|
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) {
|
||||||
|
[[slider slider] setMinValue:minval];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[localpool5 drain];
|
||||||
|
|
||||||
|
__END__;
|
||||||
|
}
|
||||||
|
|
||||||
|
CV_IMPL void* cvGetWindowHandle( const char* name )k
|
||||||
{
|
{
|
||||||
//cout << "cvGetWindowHandle" << endl;
|
//cout << "cvGetWindowHandle" << endl;
|
||||||
return cvGetWindow(name);
|
return cvGetWindow(name);
|
||||||
|
@ -508,6 +508,7 @@ typedef struct CvTrackbar
|
|||||||
int* data;
|
int* data;
|
||||||
int pos;
|
int pos;
|
||||||
int maxval;
|
int maxval;
|
||||||
|
int minval;
|
||||||
CvTrackbarCallback notify;
|
CvTrackbarCallback notify;
|
||||||
CvTrackbarCallback2 notify2;
|
CvTrackbarCallback2 notify2;
|
||||||
void* userdata;
|
void* userdata;
|
||||||
@ -1607,7 +1608,7 @@ CV_IMPL void cvSetTrackbarMax(const char* trackbar_name, const char* window_name
|
|||||||
trackbar = icvFindTrackbarByName(window, trackbar_name);
|
trackbar = icvFindTrackbarByName(window, trackbar_name);
|
||||||
if (trackbar)
|
if (trackbar)
|
||||||
{
|
{
|
||||||
trackbar->maxval = maxval;
|
trackbar->maxval = (trackbar->minval>maxval)?trackbar->minval:maxval;
|
||||||
|
|
||||||
CV_LOCK_MUTEX();
|
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 )
|
CV_IMPL void* cvGetWindowHandle( const char* window_name )
|
||||||
{
|
{
|
||||||
void* widget = 0;
|
void* widget = 0;
|
||||||
|
@ -2325,7 +2325,7 @@ CV_IMPL void cvSetTrackbarMax(const char* trackbar_name, const char* window_name
|
|||||||
if (trackbar)
|
if (trackbar)
|
||||||
{
|
{
|
||||||
// The position will be min(pos, maxval).
|
// 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);
|
SendMessage(trackbar->hwnd, TBM_SETRANGEMAX, (WPARAM)TRUE, (LPARAM)maxval);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2335,6 +2335,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 (maxval >= 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 )
|
CV_IMPL void* cvGetWindowHandle( const char* window_name )
|
||||||
{
|
{
|
||||||
void* hwnd = 0;
|
void* hwnd = 0;
|
||||||
|
@ -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)
|
CV_IMPL int cvGetTrackbarPos(const char* trackbar_name, const char* window_name)
|
||||||
{
|
{
|
||||||
int pos = -1;
|
int pos = -1;
|
||||||
|
@ -171,12 +171,23 @@ void CvTrackbar::setPosition(double pos)
|
|||||||
|
|
||||||
void CvTrackbar::setMaxPosition(double pos)
|
void CvTrackbar::setMaxPosition(double pos)
|
||||||
{
|
{
|
||||||
if (pos < 0)
|
//slider->Minimum is initialized with 0
|
||||||
pos = 0;
|
if (pos < slider->Minimum)
|
||||||
|
pos = slider->Minimum;
|
||||||
|
|
||||||
slider->Maximum = pos;
|
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) {
|
void CvTrackbar::setSlider(Slider^ slider) {
|
||||||
if (slider)
|
if (slider)
|
||||||
this->slider = slider;
|
this->slider = slider;
|
||||||
@ -192,6 +203,11 @@ double CvTrackbar::getMaxPosition()
|
|||||||
return slider->Maximum;
|
return slider->Maximum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double CvTrackbar::getMinPosition()
|
||||||
|
{
|
||||||
|
return slider->Minimum;
|
||||||
|
}
|
||||||
|
|
||||||
Slider^ CvTrackbar::getSlider()
|
Slider^ CvTrackbar::getSlider()
|
||||||
{
|
{
|
||||||
return slider;
|
return slider;
|
||||||
|
@ -151,6 +151,8 @@ public:
|
|||||||
void setPosition(double pos);
|
void setPosition(double pos);
|
||||||
double getMaxPosition();
|
double getMaxPosition();
|
||||||
void setMaxPosition(double pos);
|
void setMaxPosition(double pos);
|
||||||
|
double getMinPosition();
|
||||||
|
void setMinPosition(double pos);
|
||||||
Slider^ getSlider();
|
Slider^ getSlider();
|
||||||
void setSlider(Slider^ pos);
|
void setSlider(Slider^ pos);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user