open_windowT_open_windowOpenWindowOpenWindowopen_window (Operator)

Name

open_windowT_open_windowOpenWindowOpenWindowopen_window — Open a graphics window.

Signature

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

Herror T_open_window(const Htuple Row, const Htuple Column, const Htuple Width, const Htuple Height, const Htuple FatherWindow, const Htuple Mode, const Htuple Machine, Htuple* WindowHandle)

void OpenWindow(const HTuple& Row, const HTuple& Column, const HTuple& Width, const HTuple& Height, const HTuple& FatherWindow, const HTuple& Mode, const HTuple& Machine, HTuple* WindowHandle)

void HWindow::HWindow(Hlong Row, Hlong Column, Hlong Width, Hlong Height, const HTuple& FatherWindow, const HString& Mode, const HString& Machine)

void HWindow::HWindow(Hlong Row, Hlong Column, Hlong Width, Hlong Height, void* FatherWindow, const HString& Mode, const HString& Machine)

void HWindow::HWindow(Hlong Row, Hlong Column, Hlong Width, Hlong Height, void* FatherWindow, const char* Mode, const char* Machine)

void HWindow::HWindow(Hlong Row, Hlong Column, Hlong Width, Hlong Height, void* FatherWindow, const wchar_t* Mode, const wchar_t* Machine)   ( Windows only)

void HWindow::OpenWindow(Hlong Row, Hlong Column, Hlong Width, Hlong Height, const HTuple& FatherWindow, const HString& Mode, const HString& Machine)

void HWindow::OpenWindow(Hlong Row, Hlong Column, Hlong Width, Hlong Height, void* FatherWindow, const HString& Mode, const HString& Machine)

void HWindow::OpenWindow(Hlong Row, Hlong Column, Hlong Width, Hlong Height, void* FatherWindow, const char* Mode, const char* Machine)

void HWindow::OpenWindow(Hlong Row, Hlong Column, Hlong Width, Hlong Height, void* FatherWindow, const wchar_t* Mode, const wchar_t* Machine)   ( Windows only)

static void HOperatorSet.OpenWindow(HTuple row, HTuple column, HTuple width, HTuple height, HTuple fatherWindow, HTuple mode, HTuple machine, out HTuple windowHandle)

public HWindow(int row, int column, int width, int height, HTuple fatherWindow, string mode, string machine)

public HWindow(int row, int column, int width, int height, IntPtr fatherWindow, string mode, string machine)

void HWindow.OpenWindow(int row, int column, int width, int height, HTuple fatherWindow, string mode, string machine)

void HWindow.OpenWindow(int row, int column, int width, int height, IntPtr fatherWindow, string mode, string machine)

def open_window(row: int, column: int, width: int, height: int, father_window: Union[int, str], mode: str, machine: str) -> HHandle

Description

open_windowopen_windowOpenWindowOpenWindowopen_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_regiondisp_regionDispRegionDispRegiondisp_region, disp_imagedisp_imageDispImageDispImagedisp_image, etc.) is directed to this window if the same logical window number WindowHandleWindowHandleWindowHandlewindowHandlewindow_handle 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_imagedisp_imageDispImageDispImagedisp_image or disp_regiondisp_regionDispRegionDispRegiondisp_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_regiondisp_regionDispRegionDispRegiondisp_region. These parameters are always set for the window with the logical window number WindowHandleWindowHandleWindowHandlewindowHandlewindow_handle and remain assigned to that window until they are overwritten. Among others, the following configuration procedures are available:

The currently set values can be queried using operators such as get_shapeget_shapeGetShapeGetShapeget_shape. Since some parameters are determined by the hardware (resolution/colors), you can query the currently available resources using operators such as query_colorquery_colorQueryColorQueryColorquery_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: HeightHeightHeightheightheight-1), and the column index increases to the right (maximum: WidthWidthWidthwidthwidth-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_dbreset_obj_dbResetObjDbResetObjDbreset_obj_db).

The parameter MachineMachineMachinemachinemachine 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 <Host>:0.0.

For windows of type 'WIN32-Window'"WIN32-Window""WIN32-Window""WIN32-Window""WIN32-Window" and 'X-Window'"X-Window""X-Window""X-Window""X-Window" the parameter FatherWindowFatherWindowFatherWindowfatherWindowfather_window can be used to determine the father window for the window to be opened. In case the control 'father' is set via set_checkset_checkSetCheckSetCheckset_check, FatherWindowFatherWindowFatherWindowfatherWindowfather_window must be the ID of a HALCON window, otherwise (set_check(::'~father':) ) it can also be the ID of an operating system window. If FatherWindowFatherWindowFatherWindowfatherWindowfather_window 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_checkset_checkSetCheckSetCheckset_check) is irrelevant. The caller must ensure that FatherWindowFatherWindowFatherWindowfatherWindowfather_window is a valid handle and not destroyed as long as the embedded HALCON window is used.

You may use the value “-1” for parameters WidthWidthWidthwidthwidth and HeightHeightHeightheightheight. This tells open_windowopen_windowOpenWindowOpenWindowopen_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_systemset_systemSetSystemSetSystemset_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_systemget_systemGetSystemGetSystemget_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_extentsset_window_extentsSetWindowExtentsSetWindowExtentsset_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_stringwrite_stringWriteStringWriteStringwrite_string and can be overridden by calling set_fontset_fontSetFontSetFontset_font after calling open_windowopen_windowOpenWindowOpenWindowopen_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_fontquery_fontQueryFontQueryFontquery_font).

The color used for graphics and text by output procedures such as disp_regiondisp_regionDispRegionDispRegiondisp_region or disp_circledisp_circleDispCircleDispCircledisp_circle is set using set_rgbset_rgbSetRgbSetRgbset_rgb, set_hsiset_hsiSetHsiSetHsiset_hsi, or set_grayset_graySetGraySetGrayset_gray.

Normally, every output operation (e.g., disp_imagedisp_imageDispImageDispImagedisp_image, disp_regiondisp_regionDispRegionDispRegiondisp_region, disp_circledisp_circleDispCircleDispCircledisp_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_rectanglecopy_rectangleCopyRectangleCopyRectanglecopy_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_rectanglecopy_rectangleCopyRectangleCopyRectanglecopy_rectangle).

For graphical output (disp_imagedisp_imageDispImageDispImagedisp_image, disp_regiondisp_regionDispRegionDispRegiondisp_region, etc.), the operator set_partset_partSetPartSetPartset_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

The parameter ModeModeModemodemode 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 RowRowRowrowrow, ColumnColumnColumncolumncolumn and FatherWindowFatherWindowFatherWindowfatherWindowfather_window have no effect. Output to these windows has no effect, and input (read_stringread_stringReadStringReadStringread_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_colorquery_colorQueryColorQueryColorquery_color or get_string_extentsget_string_extentsGetStringExtentsGetStringExtentsget_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 RowRowRowrowrow, ColumnColumnColumncolumncolumn and FatherWindowFatherWindowFatherWindowfatherWindowfather_window have no effect. Buffer windows are used, for example, to prepare output (in the background) and then copy it into a visible window using copy_rectanglecopy_rectangleCopyRectangleCopyRectanglecopy_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 RowRowRowrowrow, ColumnColumnColumncolumncolumn, WidthWidthWidthwidthwidth and HeightHeightHeightheightheight are limited by the output device. If a father window is specified (FatherWindowFatherWindowFatherWindowfatherWindowfather_window < > 'root') the coordinates are relative to this window.

Execution Information

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

RowRowRowrowrow (input_control)  rectangle.origin.y → HTupleintHTupleHtuple (integer) (int / long) (Hlong) (Hlong)

Row index of upper left corner.

Default: 0

Value range: Row Row Row row row (lin)

Minimum increment: 1

Recommended increment: 1

ColumnColumnColumncolumncolumn (input_control)  rectangle.origin.x → HTupleintHTupleHtuple (integer) (int / long) (Hlong) (Hlong)

Column index of upper left corner.

Default: 0

Value range: Column Column Column column column (lin)

Minimum increment: 1

Recommended increment: 1

WidthWidthWidthwidthwidth (input_control)  rectangle.extent.x → HTupleintHTupleHtuple (integer) (int / long) (Hlong) (Hlong)

Width of the window.

Default: 256

Value range: Width Width Width width width (lin)

Minimum increment: 1

Recommended increment: 1

Restriction: 0 <= Width <= 32768 || Width == -1

HeightHeightHeightheightheight (input_control)  rectangle.extent.y → HTupleintHTupleHtuple (integer) (int / long) (Hlong) (Hlong)

Height of the window.

Default: 256

Value range: Height Height Height height height (lin)

Minimum increment: 1

Recommended increment: 1

Restriction: 0 <= Height <= 32768 || Height == -1

FatherWindowFatherWindowFatherWindowfatherWindowfather_window (input_control)  pointer → HTupleUnion[int, str]HTupleHtuple (integer / string) (IntPtr / IntPtr) (Hlong / HString) (Hlong / char*)

Logical number of the father window. To specify the display as father you may enter 'root' or 0.

Default: 0

Restriction: FatherWindow >= 0

ModeModeModemodemode (input_control)  string → HTuplestrHTupleHtuple (string) (string) (HString) (char*)

Window mode.

Default: 'visible' "visible" "visible" "visible" "visible"

List of values: 'buffer'"buffer""buffer""buffer""buffer", 'invisible'"invisible""invisible""invisible""invisible", 'transparent'"transparent""transparent""transparent""transparent", 'visible'"visible""visible""visible""visible"

MachineMachineMachinemachinemachine (input_control)  string → HTuplestrHTupleHtuple (string) (string) (HString) (char*)

Name of the computer on which you want to open the window. Otherwise the empty string.

Default: '' "" "" "" ""

WindowHandleWindowHandleWindowHandlewindowHandlewindow_handle (output_control)  window → HWindow, HTupleHHandleHTupleHtuple (handle) (IntPtr) (HHandle) (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)

Example (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);

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)

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)

Result

If the parameter values are correct, open_windowopen_windowOpenWindowOpenWindowopen_window returns 2 ( H_MSG_TRUE) . Otherwise, an exception is raised.

Possible Predecessors

reset_obj_dbreset_obj_dbResetObjDbResetObjDbreset_obj_db

Possible Successors

set_colorset_colorSetColorSetColorset_color, query_window_typequery_window_typeQueryWindowTypeQueryWindowTypequery_window_type, get_window_typeget_window_typeGetWindowTypeGetWindowTypeget_window_type, set_window_typeset_window_typeSetWindowTypeSetWindowTypeset_window_type, get_mpositionget_mpositionGetMpositionGetMpositionget_mposition, set_tpositionset_tpositionSetTpositionSetTpositionset_tposition, set_window_extentsset_window_extentsSetWindowExtentsSetWindowExtentsset_window_extents, get_window_extentsget_window_extentsGetWindowExtentsGetWindowExtentsget_window_extents, query_colorquery_colorQueryColorQueryColorquery_color, set_checkset_checkSetCheckSetCheckset_check, set_systemset_systemSetSystemSetSystemset_system

See also

disp_regiondisp_regionDispRegionDispRegiondisp_region, disp_imagedisp_imageDispImageDispImagedisp_image, disp_colordisp_colorDispColorDispColordisp_color, set_lutset_lutSetLutSetLutset_lut, query_colorquery_colorQueryColorQueryColorquery_color, set_colorset_colorSetColorSetColorset_color, set_rgbset_rgbSetRgbSetRgbset_rgb, set_hsiset_hsiSetHsiSetHsiset_hsi, set_grayset_graySetGraySetGrayset_gray, set_partset_partSetPartSetPartset_part, set_part_styleset_part_styleSetPartStyleSetPartStyleset_part_style, query_window_typequery_window_typeQueryWindowTypeQueryWindowTypequery_window_type, get_window_typeget_window_typeGetWindowTypeGetWindowTypeget_window_type, set_window_typeset_window_typeSetWindowTypeSetWindowTypeset_window_type, get_mpositionget_mpositionGetMpositionGetMpositionget_mposition, set_tpositionset_tpositionSetTpositionSetTpositionset_tposition, set_window_extentsset_window_extentsSetWindowExtentsSetWindowExtentsset_window_extents, get_window_extentsget_window_extentsGetWindowExtentsGetWindowExtentsget_window_extents, set_window_attrset_window_attrSetWindowAttrSetWindowAttrset_window_attr, set_checkset_checkSetCheckSetCheckset_check, set_systemset_systemSetSystemSetSystemset_system

Module

Foundation