dev_disp_textdev_disp_textDevDispTextDevDispTextdev_disp_text开发显示文本(算子)
名称
dev_disp_textdev_disp_textDevDispTextDevDispTextdev_disp_text — 在当前图形窗口中显示文本。
签名
Herror dev_disp_text(const char* String, const char* CoordSystem, const Hlong Row, const Hlong Column, const char* Color, const char* GenParamName, const char* GenParamValue)
Herror T_dev_disp_text(const Htuple String, const Htuple CoordSystem, const Htuple Row, const Htuple Column, const Htuple Color, const Htuple GenParamName, const Htuple GenParamValue)
void DevDispText(const HTuple& String, const HTuple& CoordSystem, const HTuple& Row, const HTuple& Column, const HTuple& Color, const HTuple& GenParamName, const HTuple& GenParamValue)
static void HWindow::DevDispText(const HTuple& String, const HString& CoordSystem, const HTuple& Row, const HTuple& Column, const HTuple& Color, const HTuple& GenParamName, const HTuple& GenParamValue)
static void HWindow::DevDispText(const HString& String, const HString& CoordSystem, Hlong Row, Hlong Column, const HString& Color, const HString& GenParamName, const HString& GenParamValue)
static void HWindow::DevDispText(const char* String, const char* CoordSystem, Hlong Row, Hlong Column, const char* Color, const char* GenParamName, const char* GenParamValue)
static void HWindow::DevDispText(const wchar_t* String, const wchar_t* CoordSystem, Hlong Row, Hlong Column, const wchar_t* Color, const wchar_t* GenParamName, const wchar_t* GenParamValue)
(
Windows only)
static void HOperatorSet.DevDispText(HTuple stringVal, HTuple coordSystem, HTuple row, HTuple column, HTuple color, HTuple genParamName, HTuple genParamValue)
static void HWindow.DevDispText(HTuple stringVal, string coordSystem, HTuple row, HTuple column, HTuple color, HTuple genParamName, HTuple genParamValue)
static void HWindow.DevDispText(string stringVal, string coordSystem, int row, int column, string color, string genParamName, string genParamValue)
def dev_disp_text(string: MaybeSequence[str], coord_system: str, row: MaybeSequence[Union[int, float, str]], column: MaybeSequence[Union[int, float, str]], color: MaybeSequence[str], gen_param_name: MaybeSequence[str], gen_param_value: MaybeSequence[Union[str, int, float]]) -> None
描述
dev_disp_textdev_disp_textDevDispTextDevDispTextDevDispTextdev_disp_text 在当前图形窗口的 (RowRowRowRowrowrow,ColumnColumnColumnColumncolumncolumn) 位置显示文本。
如果只定义了一个位置,则对于字符串 StringStringStringStringstringValstring 中的每个元素都会显示一行文本。此外,'\n'"\n""\n""\n""\n""\n" 将被解释为换行符,即执行换行操作。
如果定义了多个位置,则 StringStringStringStringstringValstring 中只能包含一个字符串,或者每个位置对应一个字符串。在这种情况下,必须使用 '\n'"\n""\n""\n""\n""\n" 强制换行。
StringStringStringStringstringValstring 末尾的换行符('\n'"\n""\n""\n""\n""\n")将被忽略。
文本的位置可以使用窗口坐标(CoordSystemCoordSystemCoordSystemCoordSystemcoordSystemcoord_system = 'window'"window""window""window""window""window")或图像坐标(CoordSystemCoordSystemCoordSystemCoordSystemcoordSystemcoord_system = 'image'"image""image""image""image""image")来指定,这在使用缩放后的图像时非常有用。
除了提供 (RowRowRowRowrowrow,ColumnColumnColumnColumncolumncolumn) 坐标外,还可以向 RowRowRowRowrowrow 和 ColumnColumnColumnColumncolumncolumn
传递预定义的值,以便将文本显示在窗口中的固定位置(仅当 CoordSystemCoordSystemCoordSystemCoordSystemcoordSystemcoord_system = 'window'"window""window""window""window""window" 时有效):
|
'top'"top""top""top""top""top", 'left'"left""left""left""left""left" |
'top'"top""top""top""top""top", 'center'"center""center""center""center""center" |
'top'"top""top""top""top""top", 'right'"right""right""right""right""right" |
|
'center'"center""center""center""center""center", 'left'"left""left""left""left""left" |
'center'"center""center""center""center""center", 'center'"center""center""center""center""center" |
'center'"center""center""center""center""center", 'right'"right""right""right""right""right" |
|
'bottom'"bottom""bottom""bottom""bottom""bottom", 'left'"left""left""left""left""left" |
'bottom'"bottom""bottom""bottom""bottom""bottom", 'center'"center""center""center""center""center" |
'bottom'"bottom""bottom""bottom""bottom""bottom", 'right'"right""right""right""right""right"
|
参数 ColorColorColorColorcolorcolor 也接受值元组。在这种情况下,指定的颜色将循环应用于每个新的文本位置;如果仅使用单一位置,则循环应用于每行新文本。
泛型参数
disp_textdisp_textDispTextDispTextDispTextdisp_text 可能会将 StringStringStringStringstringValstring 显示在框内(默认)。此行为以及框的外观由 GenParamNameGenParamNameGenParamNameGenParamNamegenParamNamegen_param_name 和 GenParamValueGenParamValueGenParamValueGenParamValuegenParamValuegen_param_value 中的泛型参数定义。
- 'box'
-
如果 'box'"box""box""box""box""box" 设置为 'true'"true""true""true""true""true",文本将显示在框内。框的外观及其可选阴影可通过下面的泛型参数进行配置。
可能值:'true'"true""true""true""true""true" 和
'false'"false""false""false""false""false"
默认值:'true'"true""true""true""true""true"
- 'box_color'
-
设置框的颜色。
可能值:包含颜色名称的字符串(例如 'white'"white""white""white""white""white"、'red'"red""red""red""red""red" 或 '#aa00bba0'"#aa00bba0""#aa00bba0""#aa00bba0""#aa00bba0""#aa00bba0")
默认值:'#fce9d4'"#fce9d4""#fce9d4""#fce9d4""#fce9d4""#fce9d4"(浅橙色)
- 'shadow'
-
如果将 'shadow'"shadow""shadow""shadow""shadow""shadow" 设置为 'true'"true""true""true""true""true",则会在框体下方显示额外的阴影(前提是 'box'"box""box""box""box""box" 为 'true'"true""true""true""true""true")。
可能值:'true'"true""true""true""true""true" 和
'false'"false""false""false""false""false"
默认值:如果 'box_color'"box_color""box_color""box_color""box_color""box_color" 设置为不含透明度的颜色,则为 'true'"true""true""true""true""true";否则为 'false'"false""false""false""false""false"
- 'shadow_color'
-
如果 'shadow'"shadow""shadow""shadow""shadow""shadow" 设置为 'true'"true""true""true""true""true",则设置阴影的颜色。
可能值:包含颜色名称的字符串(例如 'black'"black""black""black""black""black"、'red'"red""red""red""red""red" 或 '#aa00bba0'"#aa00bba0""#aa00bba0""#aa00bba0""#aa00bba0""#aa00bba0")
默认值:如果未设置 'box_color'"box_color""box_color""box_color""box_color""box_color",则为 '#f28d26'"#f28d26""#f28d26""#f28d26""#f28d26""#f28d26"(一种较深的橙色);否则为 'white'"white""white""white""white""white"
- 'border_radius'
-
控制框角的圆润程度。若要设置锐角,请将其设为 0;若要设置更圆润的角,请设为较大的数值。
可能值:正实数或 0
默认值:2
- 'box_padding'
-
控制文本周围的框向外扩展的像素数。
可能值:正实数
默认值:0
- 'shadow_sigma'
-
控制框下方阴影的模糊程度。将其设为 0 可获得清晰的阴影。
可能值:正实数或 0
默认值:1.5
- 'shadow_dx' and 'shadow_dy'
-
控制阴影在列('shadow_dx'"shadow_dx""shadow_dx""shadow_dx""shadow_dx""shadow_dx")和行('shadow_dy'"shadow_dy""shadow_dy""shadow_dy""shadow_dy""shadow_dy")方向上的偏移量(单位为像素)。
可能值:任意实数
默认值:2
注意
使用 HDevelop 的代码导出功能时,为该算子生成的代码的行为可能与相关的 HALCON 算子有所不同。有关 HDevelop 图形算子导出到不同编程语言的详细说明,请参阅
“HDevelop 用户指南” 中的 代码导出
-> 代码生成的通用方面
-> 图形窗口 一章。
参数
StringStringStringStringstringValstring (输入控制) string(-array) → HTupleMaybeSequence[str]HTupleHtuple (string) (string) (HString) (char*)
一个包含待显示文本消息的字符串元组。元组中的每个值都将显示在单独的一行中。
默认值:
'hello'
"hello"
"hello"
"hello"
"hello"
"hello"
CoordSystemCoordSystemCoordSystemCoordSystemcoordSystemcoord_system (输入控制) string → HTuplestrHTupleHtuple (string) (string) (HString) (char*)
如果设置为 'window',则文本位置相对于窗口坐标系给出。如果设置为 'image',则使用图像坐标(这在放大图像时可能很有用)。
默认值:
'window'
"window"
"window"
"window"
"window"
"window"
值列表:
'image'"image""image""image""image""image", 'window'"window""window""window""window""window"
RowRowRowRowrowrow (输入控制) point.y(-array) → HTupleMaybeSequence[Union[int, float, str]]HTupleHtuple (integer / real / string) (int / long / double / string) (Hlong / double / HString) (Hlong / double / char*)
文本的垂直对齐方式或目标文本位置的行坐标。
默认值:
12
值列表:
12, 'bottom'"bottom""bottom""bottom""bottom""bottom", 'center'"center""center""center""center""center", 'top'"top""top""top""top""top"
ColumnColumnColumnColumncolumncolumn (输入控制) point.x(-array) → HTupleMaybeSequence[Union[int, float, str]]HTupleHtuple (integer / real / string) (int / long / double / string) (Hlong / double / HString) (Hlong / double / char*)
文本的水平对齐方式或目标文本位置的列坐标。
默认值:
12
值列表:
12, 'center'"center""center""center""center""center", 'left'"left""left""left""left""left", 'right'"right""right""right""right""right"
ColorColorColorColorcolorcolor (输入控制) string(-array) → HTupleMaybeSequence[str]HTupleHtuple (string) (string) (HString) (char*)
定义文本颜色的字符串元组。
默认值:
'black'
"black"
"black"
"black"
"black"
"black"
值列表:
'black'"black""black""black""black""black", 'blue'"blue""blue""blue""blue""blue", 'coral'"coral""coral""coral""coral""coral", 'cyan'"cyan""cyan""cyan""cyan""cyan", 'forest green'"forest green""forest green""forest green""forest green""forest green", 'green'"green""green""green""green""green", 'lime green'"lime green""lime green""lime green""lime green""lime green", 'magenta'"magenta""magenta""magenta""magenta""magenta", 'red'"red""red""red""red""red", 'slate blue'"slate blue""slate blue""slate blue""slate blue""slate blue", 'yellow'"yellow""yellow""yellow""yellow""yellow"
GenParamNameGenParamNameGenParamNameGenParamNamegenParamNamegen_param_name (输入控制) attribute.name(-array) → HTupleMaybeSequence[str]HTupleHtuple (string) (string) (HString) (char*)
泛型参数的名称。
默认值:
[]
值列表:
'border_radius'"border_radius""border_radius""border_radius""border_radius""border_radius", 'box'"box""box""box""box""box", 'box_color'"box_color""box_color""box_color""box_color""box_color", 'box_padding'"box_padding""box_padding""box_padding""box_padding""box_padding", 'shadow'"shadow""shadow""shadow""shadow""shadow", 'shadow_color'"shadow_color""shadow_color""shadow_color""shadow_color""shadow_color", 'shadow_dx'"shadow_dx""shadow_dx""shadow_dx""shadow_dx""shadow_dx", 'shadow_dy'"shadow_dy""shadow_dy""shadow_dy""shadow_dy""shadow_dy", 'shadow_sigma'"shadow_sigma""shadow_sigma""shadow_sigma""shadow_sigma""shadow_sigma"
GenParamValueGenParamValueGenParamValueGenParamValuegenParamValuegen_param_value (输入控制) attribute.value(-array) → HTupleMaybeSequence[Union[str, int, float]]HTupleHtuple (string / integer / real) (string / int / long / double) (HString / Hlong / double) (char* / Hlong / double)
泛型参数的值。
默认值:
[]
值列表:
5.0, 'black'"black""black""black""black""black", 'blue'"blue""blue""blue""blue""blue", 'false'"false""false""false""false""false", 'forest green'"forest green""forest green""forest green""forest green""forest green", 'red'"red""red""red""red""red", 'true'"true""true""true""true""true", 'white'"white""white""white""white""white"
示例(HDevelop)
dev_open_window (0, 0, 512, 512, 'black', WindowHandle)
dev_disp_text ('Display some text in a box', 'window', 12, 12, \
'black', [], [])
结果
如果指定参数的值正确,dev_disp_textdev_disp_textDevDispTextDevDispTextDevDispTextdev_disp_text 返回 2 (H_MSG_TRUE)。否则,将抛出一个异常并返回错误代码。
可能的前趋
dev_open_windowdev_open_windowDevOpenWindowDevOpenWindowDevOpenWindowdev_open_window,
set_fontset_fontSetFontSetFontSetFontset_font,
get_string_extentsget_string_extentsGetStringExtentsGetStringExtentsGetStringExtentsget_string_extents
替代
disp_textdisp_textDispTextDispTextDispTextdisp_text,
write_stringwrite_stringWriteStringWriteStringWriteStringwrite_string
另见
get_string_extentsget_string_extentsGetStringExtentsGetStringExtentsGetStringExtentsget_string_extents,
set_fontset_fontSetFontSetFontSetFontset_font
模块
基础