Skip to content

open_windowopen_windowOpenWindowOpenWindowopen_windowT_open_window🔗

Short description🔗

open_windowopen_windowOpenWindowOpenWindowopen_windowT_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 )open_window( : : Row, Column, Width, Height, FatherWindow, Mode, Machine : 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 )static void HOperatorSet.OpenWindow( HTuple row, HTuple column, HTuple width, HTuple height, HTuple fatherWindow, HTuple mode, HTuple machine, out HTuple windowHandle )def open_window( row: int, column: int, width: int, height: int, father_window: Union[int, str], mode: str, machine: str ) -> HHandle

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 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)

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

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 )

Description🔗

open_windowOpenWindow 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_regionDispRegion, disp_imageDispImage, etc.) is directed to this window if the same logical window number WindowHandlewindowHandlewindow_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_imageDispImage or disp_regionDispRegion). 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_regionDispRegion. These parameters are always set for the window with the logical window number WindowHandlewindowHandlewindow_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_shapeGetShape. Since some parameters are determined by the hardware (resolution/colors), you can query the currently available resources using operators such as query_colorQueryColor.

The origin of the window’s coordinate system is located in the upper left corner (coordinates: (0,0)). The row index increases downward (maximum: Heightheightheight-1), and the column index increases to the right (maximum: Widthwidthwidth-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_dbResetObjDb).

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

For windows of type 'WIN32-Window'"WIN32-Window" and 'X-Window'"X-Window" the parameter FatherWindowfatherWindowfather_window can be used to determine the father window for the window to be opened. In case the control ‘father’ is set via set_checkSetCheck, FatherWindowfatherWindowfather_window 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 FatherWindowfatherWindowfather_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_checkSetCheck) is irrelevant. The caller must ensure that FatherWindowfatherWindowfather_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 Widthwidthwidth and Heightheightheight. This tells open_windowOpenWindow to determine the value to use automatically. In particular this is of importance, if the proportion of pixels is not 1.0 (see set_systemSetSystem): 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_systemGetSystem 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_extentsSetWindowExtents, 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_stringWriteString and can be overridden by calling set_fontSetFont after calling open_windowOpenWindow. 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_fontQueryFont).

The color used for graphics and text by output procedures such as disp_regionDispRegion or disp_circleDispCircle is set using set_rgbSetRgb, set_hsiSetHsi, or set_graySetGray.

Normally, every output operation (e.g., disp_imageDispImage, disp_regionDispRegion, disp_circleDispCircle, 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_rectangleCopyRectangle), 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_rectangleCopyRectangle).

For graphical output (disp_imageDispImage, disp_regionDispRegion, etc.), the operator set_partSetPart 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_stringReadString).

  • 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 Modemodemode 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 Rowrowrow, Columncolumncolumn and FatherWindowfatherWindowfather_window have no effect. Output to these windows has no effect, and input (read_stringReadString, 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_colorQueryColor or get_string_extentsGetStringExtents.

  • ‘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 Rowrowrow, Columncolumncolumn and FatherWindowfatherWindowfather_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_rectangleCopyRectangle. 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 Rowrowrow, Columncolumncolumn, Widthwidthwidth and Heightheightheight are limited by the output device. If a father window is specified (FatherWindowfatherWindowfather_window \(< >\) ‘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🔗

Rowrowrow (input_control) rectangle.origin.y → (integer)(integer)HTuple (Hlong)HTuple (int / long)intHtuple (Hlong)

Row index of upper left corner.

Default: 00
Value range: Row (lin)
Minimum increment: 1
Recommended increment: 1

Columncolumncolumn (input_control) rectangle.origin.x → (integer)(integer)HTuple (Hlong)HTuple (int / long)intHtuple (Hlong)

Column index of upper left corner.

Default: 00
Value range: Column (lin)
Minimum increment: 1
Recommended increment: 1

Widthwidthwidth (input_control) rectangle.extent.x → (integer)(integer)HTuple (Hlong)HTuple (int / long)intHtuple (Hlong)

Width of the window.

Default: 256256
Value range: Width (lin)
Minimum increment: 1
Recommended increment: 1
Restriction: 0 <= Width <= 32768 || Width == -1

Heightheightheight (input_control) rectangle.extent.y → (integer)(integer)HTuple (Hlong)HTuple (int / long)intHtuple (Hlong)

Height of the window.

Default: 256256
Value range: Height (lin)
Minimum increment: 1
Recommended increment: 1
Restriction: 0 <= Height <= 32768 || Height == -1

FatherWindowfatherWindowfather_window (input_control) pointer → (integer / string)(integer / string)HTuple (Hlong / HString)HTuple (IntPtr / IntPtr)Union[int, str]Htuple (Hlong / char*)

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

Default: 00
Restriction: FatherWindow >= 0

Modemodemode (input_control) string → (string)(string)HTuple (HString)HTuple (string)strHtuple (char*)

Window mode.

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

Machinemachinemachine (input_control) string → (string)(string)HTuple (HString)HTuple (string)strHtuple (char*)

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

Default: ''""

WindowHandlewindowHandlewindow_handle (output_control) window → (handle)(handle)HTuple (HHandle)HWindow, HTuple (IntPtr)HHandleHtuple (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_windowOpenWindow returns 2 (H_MSG_TRUE). Otherwise, an exception is raised.

Combinations with other operators🔗

Combinations

Possible predecessors

reset_obj_dbResetObjDb

Possible successors

set_colorSetColor, query_window_typeQueryWindowType, get_window_typeGetWindowType, set_window_typeSetWindowType, get_mpositionGetMposition, set_tpositionSetTposition, set_window_extentsSetWindowExtents, get_window_extentsGetWindowExtents, query_colorQueryColor, set_checkSetCheck, set_systemSetSystem

See also

disp_regionDispRegion, disp_imageDispImage, disp_colorDispColor, set_lutSetLut, query_colorQueryColor, set_colorSetColor, set_rgbSetRgb, set_hsiSetHsi, set_graySetGray, set_partSetPart, set_part_styleSetPartStyle, query_window_typeQueryWindowType, get_window_typeGetWindowType, set_window_typeSetWindowType, get_mpositionGetMposition, set_tpositionSetTposition, set_window_extentsSetWindowExtents, get_window_extentsGetWindowExtents, set_window_attrSetWindowAttr, set_checkSetCheck, set_systemSetSystem

Module🔗

Foundation