open_window ( : : Row, Column, Width, Height, FatherWindow, Mode, Machine : WindowHandle )

Open a graphics window.

open_window opens a new window, which can be used to perform output of gray value data, regions, graphics as well as to perform textual output. All output (disp_region, disp_image, etc.) is redirected to this window, if the same logical window number WindowHandle is used.

The background of the created window is set to black in advance and it has a white border, which is 2 pixels wide (see also set_window_attr(::'border_width',<Breite>:).

Certain parameters used for the editing of output data are assigned to a window. These parameters are considered during the output itself (e.g., with disp_image or disp_region). They are not specified by an output procedure, but by "configuration procedures". If you want to set, e.g., the color red for the output of regions, you have to 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 a window as long as they will be overwritten. You may use the following configuration procedures:

Output of gray values
  set_paint, set_comprise (set_lut and set_lut_style after output)
Regions
  set_color, set_rgb, set_hsi, set_gray, set_pixel,
  set_shape, set_line_width, set_insert, set_line_style, set_draw
Image clipping
  set_part
Text
  set_font
You may query current set values by calling procedures like get_shape. As some parameters are specified through the hardware (Resolution/Colors), you may query current available ressources by calling query_color.

The origin of the coordinate system of the window resides in the upper left corner (coordinates: (0,0)). The row index grows downward (maximal: Height-1), the column index grows to the right (maximal: Width-1). You have to keep in mind, that the range of the coordinate system is independent of the window size. It is specified only through the image format (see reset_obj_db).

The parameter Machine indicates the name of the computer, which has to open the window. In case of a X-window, TCP-IP only sets the name, DEC-Net sets in addition a colon behind the name. The "server" resp. the "screen" are not specified. If the empty string is passed the environment variable DISPLAY is used. It indicates the target computer. At this the name is indicated in common syntax <Host>:0.0.

For windows of type 'X-Window' and 'WIN32-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 relates to the ID of a HALCON window, otherwise (set_check('~father')) it relates to the ID of an operating system window. If FatherWindow is passed the value 0 or 'root', then under Windows and Unix 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.

You may use the value "-1" for parameters Width and Height. This means, that the according value has to be specified automatically. In particular this is of importance, if the proportion of pixels is not 1.0 (see set_system): Is one of the two parameters set to "-1", it will be specified through the size which results out of the proportion of pixels. Are both parameters set to "-1", they will be set to the maximum image format, which is currently used (further information about the currently used maximum image format can be found in the description of get_system using "width" or "height").

Position and size of a window may change during runtime of a program. This may be achieved by calling set_window_extents, but also through external interferences (window manager). In the latter case the procedure set_window_extents is provided.

Opening a window causes the assignment of a called default font. It is used in connection with procedures like write_string and you may overwrite it by performing set_font after calling open_window. On the other hand you have the possibility to specify a default font by calling set_system(::'default_font',<Fontname>:) before opening a window (and all following windows; see also query_font).

You may set the color of graphics and font, which is used for output procedures like disp_region or disp_circle, by calling set_rgb, set_hsi, set_gray or set_pixel. Calling set_insert specifies how graphics is combined with the content of the image repeat memory. Thereto you may achieve by calling, e.g., set_insert(::'not':) to eliminate the font after writing text twice at the same position.

Normally every output (e.g., disp_image, disp_region, disp_circle, etc.) in a window is terminated by a called "flush". This causes the data to be fully visible on the display after termination of the output procedure. But this is not necessary in all cases, in particular if there are permanently output tasks or if there is a mouse procedure active. Therefore it is more favorable (i.e., more rapid) to store the data until sufficient data is available. You may stop this behavior by calling set_system(::'flush_graphic','false':).

The content of windows is saved (in case it is supported by special driver software); i.e., it is preserved, also if the window is hidden by other windows. But this is not necessary in all cases: If the content of a window is built up permanently new (copy_rectangle), you may suppress the security mechanism for that and hence you can save the necessary memory. This is done by calling set_system(::'backing_store','false':) before opening a window. In doing so you save not only memory but also time to compute. This is significant for the output of video clips (see copy_rectangle).

For graphical output (disp_image,disp_region, etc.) you may adjust the window by calling procedure set_part in order to represent a logical clipping of the image format. In particular this implicates that you obtain this clipping (with appropriate enlargement) of images and regions only.

Difference: graphical window - textual window
  - Using graphical windows the layout is not as variable as concerned to
    textual windows.
  - You may use textual windows for the input of user data only (read_string).
  - During the output of images, regions and graphics a "zooming" is
    performed using graphical windows: Independent on size and side ratio of
    the window images are transformed in that way, that they are displayed
    in the window by filling it completely.
    On the opposite side using textual windows the output does not care 
    about the size of the window (only if clipping is necessary).
  - Using graphical windows the coordinate system of the window corresponds
    to the coordinate system of the image format. Using textual windows, its
    coordinate system equals always to the display coordinates independent
    of image size.
The parameter Mode determines the mode of the window. It may have following values:
'visible'     Normal mode for graphical windows:
              The window is created according to the parameters and all
              input and output are possible.

'invisible'   Invisible windows are not displayed in the display.
              Parameters like Row, Column and FatherWindow do not have
              any meaning. Output to these windows has no effect.
              Input (read_string, mouse, etc.) is not possible.
              You may use these windows to query representation parameter
              for an output device without opening a (visible) window.
              Common queries are, e.g., query_color and get_string_extents.

'transparent' These windows are transparent: the window itself is not
              visible (edge and background), but all the other operations
              are possible and all output is displayed.
              A common use for this mode is the creation of mouse sensitive
              regions.

'buffer'      These are also not visible windows. The output of images, 
              regions and graphics is not visible on the display, but is
              stored in memory. Parameters like Row, Column, BorderWidth,
              BorderColor, BackgroundColor and FatherWindow do not have
              any meaning. 
              You may use buffer windows, if you prepare output (in the
              background) and copy it finally with copy_rectangle in a
              visible window.
              Another usage might be the rapid processing of image regions
              during interactive manipulations.
              Textual input and mouse interaction are not possible in this
              mode.


Attention

You may keep in mind that parameters as Row, Column, Width and Height are constrained by the output device. If you specify a father window (FatherWindow < > 'root') the coordinates are relative to this window.


Parameters

Row (input_control)
rectangle.origin.y -> integer
Row index of upper left corner.
Default value: 0
Typical range of values: 0 <= Row
Minimum increment: 1
Recommended increment: 1
Restriction: Row >= 0

Column (input_control)
rectangle.origin.x -> integer
Column index of upper left corner.
Default value: 0
Typical range of values: 0 <= Column
Minimum increment: 1
Recommended increment: 1
Restriction: Column >= 0

Width (input_control)
rectangle.extent.x -> integer
Width of the window.
Default value: 256
Typical range of values: 0 <= Width
Minimum increment: 1
Recommended increment: 1
Restriction: (Width > 0) || (Width == -1)

Height (input_control)
rectangle.extent.y -> integer
Height of the window.
Default value: 256
Typical range of values: 0 <= Height
Minimum increment: 1
Recommended increment: 1
Restriction: (Height > 0) || (Height == -1)

FatherWindow (input_control)
integer -> integer / string
Logical number of the father window. To specify the display as father you may enter 'root' or 0.
Default value: 0
Restriction: FatherWindow >= 0

Mode (input_control)
string -> string
Window mode.
Default value: 'visible'
List of values: 'visible', 'invisible', 'transparent', 'buffer'

Machine (input_control)
string -> string
Name of the computer on which you want to open the window. Otherwise the empty string.
Default value: ''

WindowHandle (output_control)
window -> integer
Window identifier.


Example
open_window(0,0,400,-1,'root','visible','',WindowHandle) 
read_image(Image,'fabrik') 
disp_image(Image,WindowHandle) 
write_string(WindowHandle,'File, fabrik.ima')
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(Row1,Column1,Row2,Column2) 
disp_image(Image,WindowHandle) 
new_line(WindowHandle).

Result

If the values of the specified parameters are correct open_window returns 2 (H_MSG_TRUE). If necessary an exception handling is raised.


Parallelization Information

open_window is reentrant, local, and processed without parallelization.


Possible Predecessors

reset_obj_db


Possible Successors

set_color, query_window_type, get_window_type, set_window_type, get_mposition, set_tposition, set_tshape, set_window_extents, get_window_extents, query_color, set_check, set_system


Alternatives

open_textwindow


See also

disp_region, disp_image, disp_color, set_lut, query_color, set_color, set_rgb, set_hsi, set_pixel, 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



Copyright © 1996-2008 MVTec Software GmbH