open_textwindowT_open_textwindowOpenTextwindowOpenTextwindowopen_textwindow (算子)

名称

open_textwindowT_open_textwindowOpenTextwindowOpenTextwindowopen_textwindow — 打开一个文本窗口。

警告

open_textwindowopen_textwindowOpenTextwindowOpenTextwindowOpenTextwindowopen_textwindow 已过时,仅出于向后兼容性考虑而保留。 New applications should use the operator open_windowopen_windowOpenWindowOpenWindowOpenWindowopen_window instead.

签名

open_textwindow( : : Row, Column, Width, Height, BorderWidth, BorderColor, BackgroundColor, FatherWindow, Mode, Machine : WindowHandle)

Herror T_open_textwindow(const Htuple Row, const Htuple Column, const Htuple Width, const Htuple Height, const Htuple BorderWidth, const Htuple BorderColor, const Htuple BackgroundColor, const Htuple FatherWindow, const Htuple Mode, const Htuple Machine, Htuple* WindowHandle)

void OpenTextwindow(const HTuple& Row, const HTuple& Column, const HTuple& Width, const HTuple& Height, const HTuple& BorderWidth, const HTuple& BorderColor, const HTuple& BackgroundColor, const HTuple& FatherWindow, const HTuple& Mode, const HTuple& Machine, HTuple* WindowHandle)

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

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

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

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

static void HOperatorSet.OpenTextwindow(HTuple row, HTuple column, HTuple width, HTuple height, HTuple borderWidth, HTuple borderColor, HTuple backgroundColor, HTuple fatherWindow, HTuple mode, HTuple machine, out HTuple windowHandle)

void HWindow.OpenTextwindow(int row, int column, int width, int height, int borderWidth, string borderColor, string backgroundColor, HTuple fatherWindow, string mode, string machine)

void HWindow.OpenTextwindow(int row, int column, int width, int height, int borderWidth, string borderColor, string backgroundColor, IntPtr fatherWindow, string mode, string machine)

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

描述

open_textwindowopen_textwindowOpenTextwindowOpenTextwindowOpenTextwindowopen_textwindow opens a new textual window, which can be used to perform textual input and output, as well as to perform output of images. All output (write_stringwrite_stringWriteStringWriteStringWriteStringwrite_string, read_stringread_stringReadStringReadStringReadStringread_string, disp_regiondisp_regionDispRegionDispRegionDispRegiondisp_region, etc.) is redirected to this window, if the same logical window number WindowHandleWindowHandleWindowHandleWindowHandlewindowHandlewindow_handle is used.

Besides the mouse cursor textual windows possess also a textual cursor which indicates the current writing position (more exactly: the lower left corner of the output string without consideration of descenders). Its position is indicated through an underscore or another type (the indication of this position may also be disabled (= default setting); cf. set_tshapeset_tshapeSetTshapeSetTshapeSetTshapeset_tshape). You may set or query the position by calling the operators set_tpositionset_tpositionSetTpositionSetTpositionSetTpositionset_tposition or get_tpositionget_tpositionGetTpositionGetTpositionGetTpositionget_tposition

After you opened a textual window the position of the cursor is set to (H,0). Whereby H signifies the height of the default font less the descenders. But the cursor is not shown. Hence the output starts for writing in the upper left corner of the window.

You may query the colors of the background and the image edges by calling query_colorquery_colorQueryColorQueryColorQueryColorquery_color。In the same way you may use query_colorquery_colorQueryColorQueryColorQueryColorquery_color in a window of type 'invisible'. During output (write_stringwrite_stringWriteStringWriteStringWriteStringwrite_string) you may set the clipping of text out of the window edges by calling set_check(::'~text':)set_check("~text")SetCheck("~text")SetCheck("~text")SetCheck("~text")set_check("~text")。This disables the creation of error messages, if text passes over the edge of the window.

The origin of the coordinate system of the window resides in the upper left corner (coordinates: (0,0)). The row index grows downward (maximal: HeightHeightHeightHeightheightheight-1), the column index grows to the right (maximal: WidthWidthWidthWidthwidthwidth-1).

The parameter MachineMachineMachineMachinemachinemachine 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” or the “screen”, respectively, 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 'WIN32-Window'"WIN32-Window""WIN32-Window""WIN32-Window""WIN32-Window""WIN32-Window" and 'X-Window'"X-Window""X-Window""X-Window""X-Window""X-Window" the parameter FatherWindowFatherWindowFatherWindowFatherWindowfatherWindowfather_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_checkSetCheckSetCheckSetCheckset_check, FatherWindowFatherWindowFatherWindowFatherWindowfatherWindowfather_window must be the ID of a HALCON window, otherwise (set_check(::'~father':)set_check("~father")SetCheck("~father")SetCheck("~father")SetCheck("~father")set_check("~father")) it can also be the ID of an operating system window. If FatherWindowFatherWindowFatherWindowFatherWindowfatherWindowfather_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_checkSetCheckSetCheckSetCheckset_check) is irrelevant. The caller must ensure that FatherWindowFatherWindowFatherWindowFatherWindowfatherWindowfather_window is a valid handle and not destroyed as long as the embedded HALCON window is used.

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

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

You may set the color of the font (write_stringwrite_stringWriteStringWriteStringWriteStringwrite_string, read_stringread_stringReadStringReadStringReadStringread_string) by calling set_colorset_colorSetColorSetColorSetColorset_color, set_rgbset_rgbSetRgbSetRgbSetRgbset_rgb, set_hsiset_hsiSetHsiSetHsiSetHsiset_hsi or set_grayset_graySetGraySetGraySetGrayset_gray。Calling set_insertset_insertSetInsertSetInsertSetInsertset_insert specifies how the text or the graphics, respectively, is combined with the content of the image repeat memory. So you may achieve by calling, e.g., set_insertset_insertSetInsertSetInsertSetInsertset_insert(::'not':) to eliminate the font after writing text twice at the same position.

Normally every output (e.g., write_stringwrite_stringWriteStringWriteStringWriteStringwrite_string, disp_regiondisp_regionDispRegionDispRegionDispRegiondisp_region, disp_circledisp_circleDispCircleDispCircleDispCircledisp_circle, etc.) in a window is terminated by a “flush”. This causes the data to be fully visible on the display after termination of the output operator. But this is not necessary in all cases, in particular if there are permanently output tasks or 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':)set_system("flush_graphic","false")SetSystem("flush_graphic","false")SetSystem("flush_graphic","false")SetSystem("flush_graphic","false")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 you use a textual window, e.g., as a parent window for other windows, you may suppress the security mechanism for it and save the necessary memory at the same moment. You achieve this before opening the window by calling set_system(::'backing_store','false':)set_system("backing_store","false")SetSystem("backing_store","false")SetSystem("backing_store","false")SetSystem("backing_store","false")set_system("backing_store","false")

Difference: graphical window - textual window

The parameter ModeModeModeModemodemode specifies the mode of the window. It can have following values:

'visible':

Normal mode for textual windows: The window is created according to the parameters and all inputs and outputs are possible.

'invisible':

Invisible windows are not displayed in the display. Parameters like RowRowRowRowrowrow, ColumnColumnColumnColumncolumncolumn, BorderWidthBorderWidthBorderWidthBorderWidthborderWidthborder_width, BorderColorBorderColorBorderColorBorderColorborderColorborder_color, BackgroundColorBackgroundColorBackgroundColorBackgroundColorbackgroundColorbackground_color and FatherWindowFatherWindowFatherWindowFatherWindowfatherWindowfather_window do not have any meaning. Output to these windows has no effect. Input (read_stringread_stringReadStringReadStringReadStringread_string, mouse, etc.) is not possible. You may use these windows to query representation parameter for an output device without opening a (visible) window. General queries are, e.g., query_colorquery_colorQueryColorQueryColorQueryColorquery_color and get_string_extentsget_string_extentsGetStringExtentsGetStringExtentsGetStringExtentsget_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. Parameters like BorderColorBorderColorBorderColorBorderColorborderColorborder_color and BackgroundColorBackgroundColorBackgroundColorBackgroundColorbackgroundColorbackground_color do not have any meaning. 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 RowRowRowRowrowrow, ColumnColumnColumnColumncolumncolumn, BorderWidthBorderWidthBorderWidthBorderWidthborderWidthborder_width, BorderColorBorderColorBorderColorBorderColorborderColorborder_color, BackgroundColorBackgroundColorBackgroundColorBackgroundColorbackgroundColorbackground_color and FatherWindowFatherWindowFatherWindowFatherWindowfatherWindowfather_window do not have any meaning. You may use buffer windows, if you prepare output (in the background) and copy it finally with copy_rectanglecopy_rectangleCopyRectangleCopyRectangleCopyRectanglecopy_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.

注意

You have to keep in mind that parameters like RowRowRowRowrowrow, ColumnColumnColumnColumncolumncolumn, WidthWidthWidthWidthwidthwidth and HeightHeightHeightHeightheightheight are restricted by the output device. Is a father window (FatherWindowFatherWindowFatherWindowFatherWindowfatherWindowfather_window <> 'root') specified, then the coordinates are relative to this window.

执行信息

此算子返回一个句柄。请注意,即使该句柄被用作特定算子的输入参数,这些算子仍可能改变此句柄类型的实例状态。

参数

RowRowRowRowrowrow (输入控制)  rectangle.origin.y HTupleintHTupleHtuple (integer) (int / long) (Hlong) (Hlong)

Row index of upper left corner.

默认值: 0

值范围: Row Row Row Row row row (lin)

最小增量: 1

建议增量: 1

ColumnColumnColumnColumncolumncolumn (输入控制)  rectangle.origin.x HTupleintHTupleHtuple (integer) (int / long) (Hlong) (Hlong)

Column index of upper left corner.

默认值: 0

值范围: Column Column Column Column column column (lin)

最小增量: 1

建议增量: 1

WidthWidthWidthWidthwidthwidth (输入控制)  rectangle.extent.x HTupleintHTupleHtuple (integer) (int / long) (Hlong) (Hlong)

Window's width.

默认值: 256

值范围: 0 ≤ Width Width Width Width width width (lin)

最小增量: 1

建议增量: 1

HeightHeightHeightHeightheightheight (输入控制)  rectangle.extent.y HTupleintHTupleHtuple (integer) (int / long) (Hlong) (Hlong)

Window's height.

默认值: 256

值范围: 0 ≤ Height Height Height Height height height (lin)

最小增量: 1

建议增量: 1

BorderWidthBorderWidthBorderWidthBorderWidthborderWidthborder_width (输入控制)  integer HTupleintHTupleHtuple (integer) (int / long) (Hlong) (Hlong)

Window border's width.

默认值: 2

值范围: 0 ≤ BorderWidth BorderWidth BorderWidth BorderWidth borderWidth border_width (lin)

最小增量: 1

建议增量: 1

BorderColorBorderColorBorderColorBorderColorborderColorborder_color (输入控制)  string HTuplestrHTupleHtuple (string) (string) (HString) (char*)

Window border's color.

默认值: 'white' "white" "white" "white" "white" "white"

BackgroundColorBackgroundColorBackgroundColorBackgroundColorbackgroundColorbackground_color (输入控制)  string HTuplestrHTupleHtuple (string) (string) (HString) (char*)

Background color.

默认值: 'black' "black" "black" "black" "black" "black"

FatherWindowFatherWindowFatherWindowFatherWindowfatherWindowfather_window (输入控制)  pointer HTupleUnion[int, str]HTupleHtuple (integer / string) (IntPtr / IntPtr) (Hlong / HString) (Hlong / char*)

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

默认值: 0

限制: FatherWindow >= 0

ModeModeModeModemodemode (输入控制)  string HTuplestrHTupleHtuple (string) (string) (HString) (char*)

Window mode.

默认值: 'visible' "visible" "visible" "visible" "visible" "visible"

值列表: 'buffer'"buffer""buffer""buffer""buffer""buffer", 'invisible'"invisible""invisible""invisible""invisible""invisible", 'transparent'"transparent""transparent""transparent""transparent""transparent", 'visible'"visible""visible""visible""visible""visible"

MachineMachineMachineMachinemachinemachine (输入控制)  string HTuplestrHTupleHtuple (string) (string) (HString) (char*)

Computer name, where the window has to be opened or empty string.

默认值: '' "" "" "" "" ""

WindowHandleWindowHandleWindowHandleWindowHandlewindowHandlewindow_handle (输出控制)  window HWindow, HTupleHHandleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)

窗口句柄。

示例(HDevelop)

open_textwindow(0,0,900,600,1,'black','slate blue','root','visible', \
              '',WindowHandle1)
open_textwindow(10,10,300,580,3,'red','blue',WindowHandle1,'visible', \
              '',WindowHandle2)
open_window(10,320,570,580,WindowHandle1,'visible','',WindowHandle)
set_color(WindowHandle,'red')
read_image(Image,'monkey')
disp_image(Image,WindowHandle)
Button := 0
repeat
  try
      get_mposition(WindowHandle,Row,Column,Button)
      get_grayval(Image,Row,Column,Gray)
      write_string(WindowHandle2,['  Position (',Row,',',Column,')  '])
      write_string(WindowHandle2,['Gray value (',Gray,')  '])
      new_line(WindowHandle2)
  catch (Exception)
  endtry
until(Button == 4)
close_window(WindowHandle1)

示例(C)

open_textwindow(0,0,900,600,1,"black","slate blue","root","visible",
                "",&WindowHandle1);
open_textwindow(10,10,300,580,3,"red","blue",Father,"visible",
                "",&WindowHandle2);
open_window(10,320,570,580,Father,"visible","",&WindowHandle);
set_color(WindowHandle,"red");
read_image(&Image,"monkey");
disp_image(Image,WindowHandle);
create_tuple(&String,1);
do {
  get_mposition(WindowHandle,&Row,&Column,&Button);
  get_grayval(Image,Row,Column,&Gray);
  sprintf(buf,"Position( %d,%d ) ",Row,Column);
  set_s(String,buf,0);
  T_fwrite_string(String);
  new_line(WindowHandle);
}
while(Button < 4);
close_window(WindowHandle);

示例(HDevelop)

open_textwindow(0,0,900,600,1,'black','slate blue','root','visible', \
              '',WindowHandle1)
open_textwindow(10,10,300,580,3,'red','blue',WindowHandle1,'visible', \
              '',WindowHandle2)
open_window(10,320,570,580,WindowHandle1,'visible','',WindowHandle)
set_color(WindowHandle,'red')
read_image(Image,'monkey')
disp_image(Image,WindowHandle)
Button := 0
repeat
  try
      get_mposition(WindowHandle,Row,Column,Button)
      get_grayval(Image,Row,Column,Gray)
      write_string(WindowHandle2,['  Position (',Row,',',Column,')  '])
      write_string(WindowHandle2,['Gray value (',Gray,')  '])
      new_line(WindowHandle2)
  catch (Exception)
  endtry
until(Button == 4)
close_window(WindowHandle1)

示例(HDevelop)

open_textwindow(0,0,900,600,1,'black','slate blue','root','visible', \
              '',WindowHandle1)
open_textwindow(10,10,300,580,3,'red','blue',WindowHandle1,'visible', \
              '',WindowHandle2)
open_window(10,320,570,580,WindowHandle1,'visible','',WindowHandle)
set_color(WindowHandle,'red')
read_image(Image,'monkey')
disp_image(Image,WindowHandle)
Button := 0
repeat
  try
      get_mposition(WindowHandle,Row,Column,Button)
      get_grayval(Image,Row,Column,Gray)
      write_string(WindowHandle2,['  Position (',Row,',',Column,')  '])
      write_string(WindowHandle2,['Gray value (',Gray,')  '])
      new_line(WindowHandle2)
  catch (Exception)
  endtry
until(Button == 4)
close_window(WindowHandle1)

示例(HDevelop)

open_textwindow(0,0,900,600,1,'black','slate blue','root','visible', \
              '',WindowHandle1)
open_textwindow(10,10,300,580,3,'red','blue',WindowHandle1,'visible', \
              '',WindowHandle2)
open_window(10,320,570,580,WindowHandle1,'visible','',WindowHandle)
set_color(WindowHandle,'red')
read_image(Image,'monkey')
disp_image(Image,WindowHandle)
Button := 0
repeat
  try
      get_mposition(WindowHandle,Row,Column,Button)
      get_grayval(Image,Row,Column,Gray)
      write_string(WindowHandle2,['  Position (',Row,',',Column,')  '])
      write_string(WindowHandle2,['Gray value (',Gray,')  '])
      new_line(WindowHandle2)
  catch (Exception)
  endtry
until(Button == 4)
close_window(WindowHandle1)

结果

If the values of the specified parameters are correct open_textwindowopen_textwindowOpenTextwindowOpenTextwindowOpenTextwindowopen_textwindow 返回 2 ( H_MSG_TRUE )。如有必要,则抛出异常。

可能的前趋

reset_obj_dbreset_obj_dbResetObjDbResetObjDbResetObjDbreset_obj_db

可能的后继

set_colorset_colorSetColorSetColorSetColorset_color, query_window_typequery_window_typeQueryWindowTypeQueryWindowTypeQueryWindowTypequery_window_type, get_window_typeget_window_typeGetWindowTypeGetWindowTypeGetWindowTypeget_window_type, set_window_typeset_window_typeSetWindowTypeSetWindowTypeSetWindowTypeset_window_type, get_mpositionget_mpositionGetMpositionGetMpositionGetMpositionget_mposition, set_tpositionset_tpositionSetTpositionSetTpositionSetTpositionset_tposition, set_tshapeset_tshapeSetTshapeSetTshapeSetTshapeset_tshape, set_window_extentsset_window_extentsSetWindowExtentsSetWindowExtentsSetWindowExtentsset_window_extents, get_window_extentsget_window_extentsGetWindowExtentsGetWindowExtentsGetWindowExtentsget_window_extents, query_colorquery_colorQueryColorQueryColorQueryColorquery_color, set_checkset_checkSetCheckSetCheckSetCheckset_check, set_systemset_systemSetSystemSetSystemSetSystemset_system

替代

open_windowopen_windowOpenWindowOpenWindowOpenWindowopen_window

另见

write_stringwrite_stringWriteStringWriteStringWriteStringwrite_string, read_stringread_stringReadStringReadStringReadStringread_string, new_linenew_lineNewLineNewLineNewLinenew_line, get_string_extentsget_string_extentsGetStringExtentsGetStringExtentsGetStringExtentsget_string_extents, get_tpositionget_tpositionGetTpositionGetTpositionGetTpositionget_tposition, set_colorset_colorSetColorSetColorSetColorset_color, query_window_typequery_window_typeQueryWindowTypeQueryWindowTypeQueryWindowTypequery_window_type, get_window_typeget_window_typeGetWindowTypeGetWindowTypeGetWindowTypeget_window_type, set_window_typeset_window_typeSetWindowTypeSetWindowTypeSetWindowTypeset_window_type, get_mpositionget_mpositionGetMpositionGetMpositionGetMpositionget_mposition, set_tpositionset_tpositionSetTpositionSetTpositionSetTpositionset_tposition, set_tshapeset_tshapeSetTshapeSetTshapeSetTshapeset_tshape, set_window_extentsset_window_extentsSetWindowExtentsSetWindowExtentsSetWindowExtentsset_window_extents, get_window_extentsget_window_extentsGetWindowExtentsGetWindowExtentsGetWindowExtentsget_window_extents, query_colorquery_colorQueryColorQueryColorQueryColorquery_color, set_checkset_checkSetCheckSetCheckSetCheckset_check, set_systemset_systemSetSystemSetSystemSetSystemset_system

模块

基础