open_window🔗
Short description🔗
open_window — Open a graphics window.
Signature🔗
open_window( rectangle.origin.y Row, rectangle.origin.x Column, rectangle.extent.x Width, rectangle.extent.y Height, pointer FatherWindow, string Mode, string Machine, out window WindowHandle )
Description🔗
open_window opens a new window that can be used to output gray
value data, regions, and graphics, as well as for text output. All output
(disp_region, disp_image, etc.) is directed to this window
if the same logical window number WindowHandle is used.
The background of the created window is preset to black, and it has a
white border 2 pixels wide (see
set_window_attr(::'border_width',<Width>:)).
A window is assigned certain parameters that control how the data to be
output is processed; these parameters are taken into account during the
actual output (e.g., by disp_image or disp_region).
However, these parameters are not set by the output procedure itself, but
by “configuration procedures”. For example, if you want to set the
color red for the output of regions, you must call
set_color(::WindowHandle,'red':) before calling
disp_region. These parameters are always set for the window with
the logical window number WindowHandle and remain assigned to
that window until they are overwritten.
Among others, the following configuration procedures are available:
-
Regions:
set_color,set_rgb,set_hsi,set_gray,set_shape,set_line_width,set_line_style,set_draw -
Image clipping:
set_part -
Text:
set_font
The currently set values can be queried using operators such as
get_shape. Since some parameters are determined by the hardware
(resolution/colors), you can query the currently available resources
using operators such as query_color.
The origin of the window’s coordinate system is located in the upper left
corner (coordinates: (0,0)). The row index increases downward (maximum:
Height-1), and the column index increases to the right
(maximum: Width-1). Note that the range of the coordinate system
is independent of the window size; it is determined only by the image
format (see reset_obj_db).
The parameter Machine specifies the name of the computer on
which the window is to be opened. For X-Window, only the name is given
for TCP/IP; for DEC-Net, a colon is appended after the name. The
“server” and the “screen” are not specified.
If you pass the empty string, the environment variable DISPLAY is used
to determine the target computer, with the name given in the usual
syntax
For windows of type 'WIN32-Window' and 'X-Window'
the parameter FatherWindow can be used to determine the father
window for the window to be opened. In case the control ‘father’ is set via
set_check, FatherWindow must be the ID of a HALCON window,
otherwise (texttt{set_check(::’~father’:)})
it can also be the ID of an operating system window. If FatherWindow
is passed the value 0 or ‘root’, then under Windows and Unix-like systems the
desktop and the root window become the father window, respectively. In this
case, the value of the control ‘father’ (set via set_check) is
irrelevant. The caller must ensure that FatherWindow is a valid
handle and not destroyed as long as the embedded HALCON window is used.
You may use the value “-1” for parameters Width and
Height. This tells open_window to determine the
value to use automatically. In particular this is of importance, if the
proportion of pixels is not 1.0 (see set_system):
If only one of the two parameters is set to “-1”, the value is determined
by the size resulting from the pixel aspect ratio. If both parameters are set
to “-1”, width and height will be set to the current maximum image format
(further information about the current maximum image format can be found in
the description of get_system for the parameters “width” or
“height”).
Position and size of a window may change during runtime of a program. This
can happen by calling set_window_extents, or externally through the
windowing system.
When a window is opened, it is assigned a default font. This font is used
by operators such as write_string and can be overridden by calling
set_font after calling open_window. Alternatively, you can
specify the default font before opening a window (and all subsequent
windows) by calling set_system(::'default_font',<Fontname>:)
(see also query_font).
The color used for graphics and text by output procedures such as
disp_region or disp_circle is set using set_rgb,
set_hsi, or set_gray.
Normally, every output operation (e.g., disp_image,
disp_region, disp_circle, etc.) to a window is completed
with a so-called “flush”. This ensures that the data is fully visible
on the screen once the output operation has finished. However, this is
not always necessary, especially if output is performed continuously or
a mouse procedure is active. In such cases it is more efficient (i.e.,
faster) to buffer the data until enough data has accumulated. This
behavior can be configured by calling
set_system(::'flush_graphic','false':).
The content of a window is saved (if supported by the driver software);
i.e., it is preserved even if the window is overlapped by other windows.
However, this is not necessary in all cases. If the content of a window
is continually redrawn (copy_rectangle), this backing mechanism
can be disabled for that window, saving the memory it would otherwise
require. This is done by calling
set_system(::'backing_store','false':) before opening the
window. Doing so saves not only memory but also computation time, which
is significant, for example, when displaying video clips (see
copy_rectangle).
For graphical output (disp_image, disp_region, etc.), the
operator set_part can be used to configure the window to display
a logical section of the image format. As a result, only this section of
images and regions is output (scaled accordingly).
Graphics window vs. text window🔗
-
For graphics windows, the layout is not as flexible as for text windows.
-
Only text windows can be used to read in user data (
read_string). -
When outputting images, regions, and graphics, graphics windows perform “zooming”: regardless of the window’s size and aspect ratio, the images are transformed so that they completely fill the window. Text windows, on the other hand, disregard the window size during output (except when clipping is required).
-
For graphics windows, the window’s coordinate system always matches the coordinate system of the image format, whereas for text windows the coordinate system always corresponds to the screen coordinates, independent of the image size.
The parameter Mode determines the window’s mode. It can take
the following values:
-
‘visible’: This is the normal mode for graphics windows: the window is created according to the specified parameters, and all input and output operations are possible.
-
‘invisible’: Invisible windows are not displayed on the screen. The parameters
Row,ColumnandFatherWindowhave no effect. Output to these windows has no effect, and input (read_string, mouse, etc.) is not possible. These windows are used to query display parameters for an output device without opening a (visible) window. Typical queries are, e.g.,query_colororget_string_extents. -
‘transparent’: These windows are transparent: the window itself (border and background) is not visible, but all other operations are possible and all output is displayed. A typical use for this mode is creating mouse-sensitive areas.
-
‘buffer’: These are also invisible windows. The output of images, regions and graphics is not visible on the screen but is buffered in memory. The parameters
Row,ColumnandFatherWindowhave no effect. Buffer windows are used, for example, to prepare output (in the background) and then copy it into a visible window usingcopy_rectangle. Another use case is the fast processing of image sections during interactive manipulations. Text input and mouse interaction are not possible in ‘buffer’ mode.
Attention🔗
Note that the parameters Row, Column,
Width and Height are limited by the output device.
If a father window is specified (FatherWindow \(< >\) ‘root’)
the coordinates are relative to this window.
Execution information🔗
Execution information
-
Multithreading type: reentrant (runs in parallel with non-exclusive operators).
-
Multithreading scope: global (may be called from any thread).
-
Processed without parallelization.
This operator returns a handle. Note that the state of an instance of this handle type may be changed by specific operators even though the handle is used as an input parameter by those operators.
Parameters🔗
Row (input_control) rectangle.origin.y → (integer)
Row index of upper left corner.
Default: 0
Value range: Row (lin)
Minimum increment: 1
Recommended increment: 1
Column (input_control) rectangle.origin.x → (integer)
Column index of upper left corner.
Default: 0
Value range: Column (lin)
Minimum increment: 1
Recommended increment: 1
Width (input_control) rectangle.extent.x → (integer)
Width of the window.
Default: 256
Value range: Width (lin)
Minimum increment: 1
Recommended increment: 1
Restriction: 0 <= Width <= 32768
|| Width == -1
Height (input_control) rectangle.extent.y → (integer)
Height of the window.
Default: 256
Value range: Height (lin)
Minimum increment: 1
Recommended increment: 1
Restriction: 0 <= Height <= 32768
|| Height == -1
FatherWindow (input_control) pointer → (integer / string)
Logical number of the father window. To specify the display as father you may enter ‘root’ or 0.
Default: 0
Restriction: FatherWindow >= 0
Mode (input_control) string → (string)
Window mode.
Default: 'visible'
List of values: 'buffer', 'invisible', 'transparent', 'visible'
Machine (input_control) string → (string)
Name of the computer on which you want to open the window. Otherwise the empty string.
Default: ''
WindowHandle (output_control) window → (handle)
Window handle.
Example🔗
(HDevelop)
open_window(0,0,400,-1,'root','visible','',WindowHandle)
read_image(Image,'fabrik')
disp_image(Image,WindowHandle)
write_string(WindowHandle,'File, fabrik')
new_line(WindowHandle)
get_mbutton(WindowHandle,_,_,_)
set_lut(WindowHandle,'temperature')
set_color(WindowHandle,'blue')
write_string(WindowHandle,'temperature')
new_line(WindowHandle)
write_string(WindowHandle,'Draw Rectangle')
new_line(WindowHandle)
draw_rectangle1(WindowHandle,Row1,Column1,Row2,Column2)
set_part(WindowHandle,Row1,Column1,Row2,Column2)
disp_image(Image,WindowHandle)
new_line(WindowHandle)
(C)open_window(0,0,400,-1,"root","visible","",&WindowHandle)\;
read_image(&Image,"fabrik")\;
disp_image(Image,WindowHandle)\;
write_string(WindowHandle,"File: fabrik")\;
new_line(WindowHandle)\;
get_mbutton(WindowHandle,NULL,NULL,NULL)\;
set_lut(WindowHandle,"temperature")\;
set_color(WindowHandle,"blue")\;
write_string(WindowHandle,"temperature")\;
new_line(WindowHandle)\;
write_string(WindowHandle,"Draw Rectangle")\;
new_line(WindowHandle)\;
draw_rectangle1(WindowHandle,&Row1,&Column1,&Row2,&Column2)\;
set_part(Row1,Column1,Row2,Column2)\;
disp_image(Image,WindowHandle)\;
new_line(WindowHandle)\;
Result🔗
If the parameter values are correct, open_window returns
2 (H_MSG_TRUE). Otherwise, an exception is raised.
Combinations with other operators🔗
Combinations
Possible predecessors
Possible successors
set_color, query_window_type, get_window_type, set_window_type, get_mposition, set_tposition, set_window_extents, get_window_extents, query_color, set_check, set_system
See also
disp_region, disp_image, disp_color, set_lut, query_color, set_color, set_rgb, set_hsi, set_gray, set_part, set_part_style, query_window_type, get_window_type, set_window_type, get_mposition, set_tposition, set_window_extents, get_window_extents, set_window_attr, set_check, set_system
Module🔗
Foundation