1 /*M///////////////////////////////////////////////////////////////////////////////////////
2 //
3 //  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
4 //
5 //  By downloading, copying, installing or using the software you agree to this license.
6 //  If you do not agree to this license, do not download, install,
7 //  copy or use the software.
8 //
9 //
10 //                        Intel License Agreement
11 //                For Open Source Computer Vision Library
12 //
13 // Copyright (C) 2000, Intel Corporation, all rights reserved.
14 // Third party copyrights are property of their respective owners.
15 //
16 // Redistribution and use in source and binary forms, with or without modification,
17 // are permitted provided that the following conditions are met:
18 //
19 //   * Redistribution's of source code must retain the above copyright notice,
20 //     this list of conditions and the following disclaimer.
21 //
22 //   * Redistribution's in binary form must reproduce the above copyright notice,
23 //     this list of conditions and the following disclaimer in the documentation
24 //     and/or other materials provided with the distribution.
25 //
26 //   * The name of Intel Corporation may not be used to endorse or promote products
27 //     derived from this software without specific prior written permission.
28 //
29 // This software is provided by the copyright holders and contributors "as is" and
30 // any express or implied warranties, including, but not limited to, the implied
31 // warranties of merchantability and fitness for a particular purpose are disclaimed.
32 // In no event shall the Intel Corporation or contributors be liable for any direct,
33 // indirect, incidental, special, exemplary, or consequential damages
34 // (including, but not limited to, procurement of substitute goods or services;
35 // loss of use, data, or profits; or business interruption) however caused
36 // and on any theory of liability, whether in contract, strict liability,
37 // or tort (including negligence or otherwise) arising in any way out of
38 // the use of this software, even if advised of the possibility of such damage.
39 //
40 //M*/
41 
42 #ifndef OPENCV_HIGHGUI_H
43 #define OPENCV_HIGHGUI_H
44 
45 #include "opencv2/core/core_c.h"
46 #include "opencv2/imgproc/imgproc_c.h"
47 
48 #ifdef __cplusplus
49 extern "C" {
50 #endif /* __cplusplus */
51 
52 /** @addtogroup highgui_c
53   @{
54   */
55 
56 /****************************************************************************************\
57 *                                  Basic GUI functions                                   *
58 \****************************************************************************************/
59 //YV
60 //-----------New for Qt
61 /* For font */
62 enum {  CV_FONT_LIGHT           = 25,//QFont::Light,
63         CV_FONT_NORMAL          = 50,//QFont::Normal,
64         CV_FONT_DEMIBOLD        = 63,//QFont::DemiBold,
65         CV_FONT_BOLD            = 75,//QFont::Bold,
66         CV_FONT_BLACK           = 87 //QFont::Black
67 };
68 
69 enum {  CV_STYLE_NORMAL         = 0,//QFont::StyleNormal,
70         CV_STYLE_ITALIC         = 1,//QFont::StyleItalic,
71         CV_STYLE_OBLIQUE        = 2 //QFont::StyleOblique
72 };
73 /* ---------*/
74 
75 //for color cvScalar(blue_component, green_component, red_component[, alpha_component])
76 //and alpha= 0 <-> 0xFF (not transparent <-> transparent)
77 CVAPI(CvFont) cvFontQt(const char* nameFont, int pointSize CV_DEFAULT(-1), CvScalar color CV_DEFAULT(cvScalarAll(0)), int weight CV_DEFAULT(CV_FONT_NORMAL),  int style CV_DEFAULT(CV_STYLE_NORMAL), int spacing CV_DEFAULT(0));
78 
79 CVAPI(void) cvAddText(const CvArr* img, const char* text, CvPoint org, CvFont *arg2);
80 
81 CVAPI(void) cvDisplayOverlay(const char* name, const char* text, int delayms CV_DEFAULT(0));
82 CVAPI(void) cvDisplayStatusBar(const char* name, const char* text, int delayms CV_DEFAULT(0));
83 
84 CVAPI(void) cvSaveWindowParameters(const char* name);
85 CVAPI(void) cvLoadWindowParameters(const char* name);
86 CVAPI(int) cvStartLoop(int (*pt2Func)(int argc, char *argv[]), int argc, char* argv[]);
87 CVAPI(void) cvStopLoop( void );
88 
89 typedef void (CV_CDECL *CvButtonCallback)(int state, void* userdata);
90 enum {CV_PUSH_BUTTON = 0, CV_CHECKBOX = 1, CV_RADIOBOX = 2};
91 CVAPI(int) cvCreateButton( const char* button_name CV_DEFAULT(NULL),CvButtonCallback on_change CV_DEFAULT(NULL), void* userdata CV_DEFAULT(NULL) , int button_type CV_DEFAULT(CV_PUSH_BUTTON), int initial_button_state CV_DEFAULT(0));
92 //----------------------
93 
94 
95 /* this function is used to set some external parameters in case of X Window */
96 CVAPI(int) cvInitSystem( int argc, char** argv );
97 
98 CVAPI(int) cvStartWindowThread( void );
99 
100 // ---------  YV ---------
101 enum
102 {
103     //These 3 flags are used by cvSet/GetWindowProperty
104     CV_WND_PROP_FULLSCREEN = 0, //to change/get window's fullscreen property
105     CV_WND_PROP_AUTOSIZE   = 1, //to change/get window's autosize property
106     CV_WND_PROP_ASPECTRATIO= 2, //to change/get window's aspectratio property
107     CV_WND_PROP_OPENGL     = 3, //to change/get window's opengl support
108     CV_WND_PROP_VISIBLE    = 4,
109 
110     //These 2 flags are used by cvNamedWindow and cvSet/GetWindowProperty
111     CV_WINDOW_NORMAL       = 0x00000000, //the user can resize the window (no constraint)  / also use to switch a fullscreen window to a normal size
112     CV_WINDOW_AUTOSIZE     = 0x00000001, //the user cannot resize the window, the size is constrainted by the image displayed
113     CV_WINDOW_OPENGL       = 0x00001000, //window with opengl support
114 
115     //Those flags are only for Qt
116     CV_GUI_EXPANDED         = 0x00000000, //status bar and tool bar
117     CV_GUI_NORMAL           = 0x00000010, //old fashious way
118 
119     //These 3 flags are used by cvNamedWindow and cvSet/GetWindowProperty
120     CV_WINDOW_FULLSCREEN   = 1,//change the window to fullscreen
121     CV_WINDOW_FREERATIO    = 0x00000100,//the image expends as much as it can (no ratio constraint)
122     CV_WINDOW_KEEPRATIO    = 0x00000000//the ration image is respected.
123 };
124 
125 /* create window */
126 CVAPI(int) cvNamedWindow( const char* name, int flags CV_DEFAULT(CV_WINDOW_AUTOSIZE) );
127 
128 /* Set and Get Property of the window */
129 CVAPI(void) cvSetWindowProperty(const char* name, int prop_id, double prop_value);
130 CVAPI(double) cvGetWindowProperty(const char* name, int prop_id);
131 
132 #ifdef __cplusplus  // FIXIT remove in OpenCV 4.0
133 /* Get window image rectangle coordinates, width and height */
134 CVAPI(cv::Rect)cvGetWindowImageRect(const char* name);
135 #endif
136 
137 /* display image within window (highgui windows remember their content) */
138 CVAPI(void) cvShowImage( const char* name, const CvArr* image );
139 
140 /* resize/move window */
141 CVAPI(void) cvResizeWindow( const char* name, int width, int height );
142 CVAPI(void) cvMoveWindow( const char* name, int x, int y );
143 
144 
145 /* destroy window and all the trackers associated with it */
146 CVAPI(void) cvDestroyWindow( const char* name );
147 
148 CVAPI(void) cvDestroyAllWindows(void);
149 
150 /* get native window handle (HWND in case of Win32 and Widget in case of X Window) */
151 CVAPI(void*) cvGetWindowHandle( const char* name );
152 
153 /* get name of highgui window given its native handle */
154 CVAPI(const char*) cvGetWindowName( void* window_handle );
155 
156 
157 typedef void (CV_CDECL *CvTrackbarCallback)(int pos);
158 
159 /* create trackbar and display it on top of given window, set callback */
160 CVAPI(int) cvCreateTrackbar( const char* trackbar_name, const char* window_name,
161                              int* value, int count, CvTrackbarCallback on_change CV_DEFAULT(NULL));
162 
163 typedef void (CV_CDECL *CvTrackbarCallback2)(int pos, void* userdata);
164 
165 CVAPI(int) cvCreateTrackbar2( const char* trackbar_name, const char* window_name,
166                               int* value, int count, CvTrackbarCallback2 on_change,
167                               void* userdata CV_DEFAULT(0));
168 
169 /* retrieve or set trackbar position */
170 CVAPI(int) cvGetTrackbarPos( const char* trackbar_name, const char* window_name );
171 CVAPI(void) cvSetTrackbarPos( const char* trackbar_name, const char* window_name, int pos );
172 CVAPI(void) cvSetTrackbarMax(const char* trackbar_name, const char* window_name, int maxval);
173 CVAPI(void) cvSetTrackbarMin(const char* trackbar_name, const char* window_name, int minval);
174 
175 enum
176 {
177     CV_EVENT_MOUSEMOVE      =0,
178     CV_EVENT_LBUTTONDOWN    =1,
179     CV_EVENT_RBUTTONDOWN    =2,
180     CV_EVENT_MBUTTONDOWN    =3,
181     CV_EVENT_LBUTTONUP      =4,
182     CV_EVENT_RBUTTONUP      =5,
183     CV_EVENT_MBUTTONUP      =6,
184     CV_EVENT_LBUTTONDBLCLK  =7,
185     CV_EVENT_RBUTTONDBLCLK  =8,
186     CV_EVENT_MBUTTONDBLCLK  =9,
187     CV_EVENT_MOUSEWHEEL     =10,
188     CV_EVENT_MOUSEHWHEEL    =11
189 };
190 
191 enum
192 {
193     CV_EVENT_FLAG_LBUTTON   =1,
194     CV_EVENT_FLAG_RBUTTON   =2,
195     CV_EVENT_FLAG_MBUTTON   =4,
196     CV_EVENT_FLAG_CTRLKEY   =8,
197     CV_EVENT_FLAG_SHIFTKEY  =16,
198     CV_EVENT_FLAG_ALTKEY    =32
199 };
200 
201 
202 #define CV_GET_WHEEL_DELTA(flags) ((short)((flags >> 16) & 0xffff)) // upper 16 bits
203 
204 typedef void (CV_CDECL *CvMouseCallback )(int event, int x, int y, int flags, void* param);
205 
206 /* assign callback for mouse events */
207 CVAPI(void) cvSetMouseCallback( const char* window_name, CvMouseCallback on_mouse,
208                                 void* param CV_DEFAULT(NULL));
209 
210 /* wait for key event infinitely (delay<=0) or for "delay" milliseconds */
211 CVAPI(int) cvWaitKey(int delay CV_DEFAULT(0));
212 
213 // OpenGL support
214 
215 typedef void (CV_CDECL *CvOpenGlDrawCallback)(void* userdata);
216 CVAPI(void) cvSetOpenGlDrawCallback(const char* window_name, CvOpenGlDrawCallback callback, void* userdata CV_DEFAULT(NULL));
217 
218 CVAPI(void) cvSetOpenGlContext(const char* window_name);
219 CVAPI(void) cvUpdateWindow(const char* window_name);
220 
221 
222 /****************************************************************************************\
223 
224 *                              Obsolete functions/synonyms                               *
225 \****************************************************************************************/
226 
227 #define cvAddSearchPath(path)
228 #define cvvInitSystem cvInitSystem
229 #define cvvNamedWindow cvNamedWindow
230 #define cvvShowImage cvShowImage
231 #define cvvResizeWindow cvResizeWindow
232 #define cvvDestroyWindow cvDestroyWindow
233 #define cvvCreateTrackbar cvCreateTrackbar
234 #define cvvAddSearchPath cvAddSearchPath
235 #define cvvWaitKey(name) cvWaitKey(0)
236 #define cvvWaitKeyEx(name,delay) cvWaitKey(delay)
237 #define HG_AUTOSIZE CV_WINDOW_AUTOSIZE
238 #define set_preprocess_func cvSetPreprocessFuncWin32
239 #define set_postprocess_func cvSetPostprocessFuncWin32
240 
241 #if defined _WIN32
242 
243 CVAPI(void) cvSetPreprocessFuncWin32_(const void* callback);
244 CVAPI(void) cvSetPostprocessFuncWin32_(const void* callback);
245 #define cvSetPreprocessFuncWin32(callback) cvSetPreprocessFuncWin32_((const void*)(callback))
246 #define cvSetPostprocessFuncWin32(callback) cvSetPostprocessFuncWin32_((const void*)(callback))
247 
248 #endif
249 
250 /** @} highgui_c */
251 
252 #ifdef __cplusplus
253 }
254 #endif
255 
256 #endif
257