Halcon算子翻译——dev_open_window

名称

dev_open_window - 打开一个新的图形窗口。

用法

dev_open_window( : : Row, Column, Width, Height, Background : WindowHandle)

描述

  dev_open_window打开一个新的图形窗口,可以用来显示images,regions和lines等图形对象以及显示输出文本。 该窗口自动变为活动状态,这意味着所有输出(dev_display和自动显示等算子的结果)都被重定向到此窗口。 活动按钮上的朗光灯表示该窗口是否处于活动状态。

  标准HALCON显示,绘图,鼠标,文本输出和可视化参数算子(如disp_image,disp_region,draw_circle,get_mbutton,write_string,set_rgb等)需要在参数WindowHandle中返回的逻辑窗口号,它显示在图形窗口的标题栏。

  Background中指定的颜色为创建的窗口背景颜色。 该参数不适用于算子open_window。 在那里,需要通过预先调用set_window_attr(::'background_color',Background :)可以实现相同的行为。

  关闭图形窗口可以通过按下窗口框的关闭按钮或通过可视化菜单,或者通过调用dev_close_window。

  图形窗口的原点是坐标为(0,0)的左上角。 x值(column)从左到右增加,y值(row)从上到下增加。 默认情况下,坐标系的设置方式是在不剪切图像的情况下显示图像,并完全适合图形窗口。 对于在程序重置或新程序加载之后显示的第一图像,或者如果当前图像具有与之前显示的图像不同的图像大小,根据此规则,坐标系会适应于窗口大小。 窗口的大小不会自动调整,因此,如果图像的宽高比与窗口的长宽比不同,则图像会变形以适合窗口。 这可以通过“窗口大小”菜单进行更改。

  通过滚动鼠标滚轮,使用“移动”或“缩放”模式,通过“图像大小”菜单,借助“可视化参数”对话框上的“缩放”选项卡或使用操作符dev_set_part,可以交互式更改可见图像部分。

  每个图形窗口都有一个历史记录,包含:

    objects 

    显示参数

  历史记录会记录从最近的清除动作或显示全图像以来已经显示或改变了的图形。 如果窗口的重绘被触发,例如在改变窗口尺寸之后,为了重建完整的窗口内容会利用历史记录。 其他使用HALCON算子(如disp_image或disp_region,text(write_string)或geometric对象(disp_line,disp_circle等))显示的图形输出不是历史记录的一部分,因此不能重绘。 只有使用HDevelop操作符dev_display或HDevelop操作(如双击图标)显示的对象类image,region和XLD才是历史记录的一部分。

  按清空按钮清除图形窗口的内容和窗口的历史。 这也可以通过使用算子dev_clear_window来实现。 这不会影响当前的显示参数。

    图形窗口的大小可以通过用鼠标拖动窗口边界交互地改变。 此外,可以通过“窗口大小”菜单将窗口大小调整为图像大小(或其一部分或它的多倍)。 之后,使用与以前相同的可视部分自动重新显示窗口内容(Afterwards, the window content is redisplayed automatically using the same visible part as before.)。

  图形窗口的显示参数可以通过其context menu,可视化菜单,可视化参数对话框或适当的HDevelop算子(如dev_set_color,dev_set_line_width,dev_set_draw)来指定。 根据“立即应用”首选项,参数更改将应用于最后显示的对象,或者从现在开始应用于所有后续对象。 与标准的HALCON窗口算子相反,新的设置也用于所有新的图形窗口。

  有关HALCON窗口的更多底层信息,请参见“HDevelop Reference Manual”以及“HDevelop用户指南”的Graphical User Interface -> Graphics Window一章。

注意

  使用HDevelop的代码导出功能,为该算子生成的代码可能与相关的HALCON算子具有不同的行为。 有关将HDevelop图形算子导出为不同编程语言的代码的详细说明,请参阅“HDevelop User's Guide”中的 Code Export -> General Aspects of Code Generation -> Graphics Windows一章。

参数

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)


Background (input_control) integer → (integer / string)
  Color of the background of the new window.
  Default value: 'black'


WindowHandle (output_control) window → (integer)
  Window identifier.

示例(HDevelop)

dev_close_window ()
read_image (For5, 'for5')
get_image_size (For5, Width, Height)
dev_open_window (0, 0, Width, Height, 'black', WindowHandle)
dev_display (For5)
dev_set_lut ('rainbow')
dev_display (For5)
stop ()
dev_set_lut ('default')
dev_display (For5)
stop ()
dev_set_part (100, 100, 300, 300)
dev_display (For5)

结果

如果指定参数的值正确,则dev_open_window返回2(H_MSG_TRUE)。 否则会引发异常并返回错误代码。

Possible Successors

dev_display, dev_set_lut, dev_set_color, dev_set_draw, dev_set_part

备选算子

open_window

See also

query_color

模块

Foundation

HDevelop例程

stamp_catalogue.hdev      Segment and group characters on a cluttered page
pm_illu_rectify.hdev           Find a rotated pattern using a gray-value template and align the image to the pattern
measure_screw.hdev         Measure several features of a screw
fit_ellipse_tooth_rim_xld.hdev   Approximate the contour of a tooth rim with an ellipse to find its center
find_pads.hdev             Find pads on a die
display_operators.hdev          Visualize results
dev_open_window.hdev         Open graphics windows in HDevelop
dev_close_window.hdev         Close graphics windows in HDevelop
critical_points_sub_pix.hdev     Detect critical points with subpixel accuracy
clip_contours_xld.hdev          Clip an XLD contour

原文地址:https://www.cnblogs.com/xhiong/p/7842852.html