赞
踩
1.1.函数汇总:
方法 | 说明 |
explicit HWindow(Hlong handle); | |
HLong GetHandle()const | 获取窗口句柄 |
HWindow(Hlong Row, Hlong Column, Hlong Width, Hlong Height, void* FatherWindow, const HString& Mode, const HString& Machine); | |
void OpenWindow(Hlong Row,Column,Width, Height, const HTuple& FatherWindow, const HString& Mode, const HString& Machine); | |
void CloseWindow() const; | |
void ClearWindow() const; | |
void FlushBuffer() const; | 刷新窗口内容 |
w.Click(); | |
参数设置 | |
HTuple GetWindowParam(const HString& Param) const; | 获取窗口参数 |
void SetWindowParam(const HString& Param, const HString& Value) const; | 设置窗口参数const HTuple& Value |
void SetPart(Hlong Row1, Hlong Column1, Hlong Row2, Hlong Column2) const; | 修改显示部分图像 |
double GetLineWidth() const; | 获取显示轮廓的当前线条宽度 |
void SetLineWidth(double Width) const; | 设置区域轮廓输出的线宽 |
HTuple GetLineStyle() const; | 获取轮廓线的当前图形模式 |
void SetLineStyle(const HTuple& Style) const; | 定义一个轮廓线输出模式 |
HString GetShape() const; | 设置区域输出形状 |
void SetShape(const HString& Shape) const; | 定义区域输出形状 |
HString GetDraw() const; | 获取当前区域填充模式 |
void SetDraw(const HString& Mode) const; | 设置当前区域填充模式 ['margin','fill'] |
void SetColor(const HTuple& Color="white") const; | 设置窗口区域输出的颜色 str or str数组 |
void SetColored(Hlong NumberOfColors=12) const; | 设置为不同颜色的区域(3,6,12) |
显示函数 | |
HString ReadString(const HString& InString, Hlong Length) const; | 窗口指定位置读文本 const char* |
void WriteString(const HTuple& String) const; | 窗口写文本 HString& String |
void GetTposition(Hlong* Row, Hlong* Column) const; | |
void SetTposition(Hlong Row, Hlong Column) const; | 设置光标位置 |
void DispText(const HTuple& String, const HString& CoordSystem, const HTuple& Row,Column,Color,GenParamName,GenParamValue) const; | |
void DispText(const HString& String, const HString& CoordSystem, Hlong Row, Hlong Column, const HString& Color, const HTuple& GenParamName, const HTuple& GenParamValue) const; | |
void DispText(const char* String, const char* CoordSystem, Hlong Row, Hlong Column, const char* Color, const HTuple& GenParamName, const HTuple& GenParamValue) const; | |
HTuple QueryFont() const; | Query the available fonts |
HString GetFont() const; | 获取当前文本字体 |
void SetFont(const HString& Font) const; | 设置文本字体 |
void DispArrow(const HTuple& Row1,Column1,Row2,Column2,Size) const;//double | |
void DispCross(const HTuple& Row, const HTuple& Column, double Size, double Angle) const; | |
void DispLine(double Row1, double Column1, double Row2, double Column2) const; | |
void DispCircle(const HTuple& Row,Column,Radius) const;//double | |
void DispArc(const HTuple& CenterRow,CenterCol,Angle,BeginRow,BeginCol) const; | |
void DispArc(double CenterRow, double CenterCol, double Angle, Hlong BeginRow, Hlong BeginCol) const; | |
void DispEllipse(const HTuple& CenterRow,CenterCol,Phi,Radius1,Radius2) const; | |
void DispEllipse(Hlong CenterRow, Hlong CenterCol, double Phi, double Radius1, double Radius2) const; | |
void DispRectangle1(const HTuple& Row1,Column1,Row2,Column2) const;矩形double | |
void DispRectangle2(const HTuple& CenterRow,CenterCol,Phi,Length1, Length2) const;显示任意方向的矩形double | |
void DispPolygon(const HTuple& Row, const HTuple& Column) const; | |
void DispObj(const HObject& Object) const; | 显示图像区域轮廓 |
鼠标绘图 | |
void DrawPoint(double* Row, double* Column) const; | |
void DrawLine(double* Row1, double* Column1, double* Row2, double* Column2) const; | |
void DrawCircle(double* Row, double* Column, double* Radius) const; | |
void DrawEllipse(double* Row, double* Column, double* Phi, double* Radius1, double* Radius2) const; | |
void DrawRectangle1(double* Row1, double* Column1, double* Row2, double* Column2) const; | |
void DrawRectangle2(double* Row, double* Column, double* Phi, double* Length1, double* Length2) const; | |
HRegion DrawPolygon() const; | 多边形行的交互式图形 |
HRegion DrawRegion() const; | |
HXLDCont DrawXld(const HString& Rotate, const HString& Move, const HString& Scale, const HString& KeepRatio) const;//const char* |
1.2.函数:
open_window( : : Row, Column, Width, Height, FatherWindow, Mode, Machine : WindowHandle)
用途:打开新窗口显示灰度值数据,区域,图形及文本 背景黑色,白边框(2像素)
参数:
Row=0,Column=0(整数)→左上角行列索引
Width=256,Height=256 (整数)→窗口的宽度高度
FatherWindow=0 指针(整数/str)→父窗口逻辑编号 ['root',>=0]
Mode='visible' str(str)→窗口模式['buffer', 'invisible', 'transparent', 'visible']
Machine ='' str(字符串)→计算机名称
void SetWindowParam(const HString& Param, const HString& Value) const;
用途:设置窗口参数const HTuple& Value
参数:
'flush' ='ture' 显示对象后启用或禁用刷新窗口 “ true”,“ false”
'region_quality'='low' 渲染质量 values: 'low', 'good'
'background_color' 设置窗口背景色 color name (e.g. 'black', 'red')
'window_title' 设置窗口标题栏文本
'anti_aliasing' ='ture' 启用或禁用轮廓和区域抗锯齿 “ true”,“ false”
'graphics_stack'='false' 启用或禁用窗口图形堆栈(启用会更新)
'graphics_stack_max_element_num'=50 图形堆栈最大元素数 对HDevelop图形堆栈无效 正数或'unlimited'
'graphics_stack_max_memory_size'='unlimited'限制图形堆栈内存消耗 bytes or 'unlimited'
'angle_of_view'=1.22173 70度 设置显示3D图虚拟相机视角 弧度[0,PI)0表示正交投影 'orthogonal' or或角度
'axis_captions'=['','',''] 元组设置行列和高度轴标题['row','col','height']
'caption_color'='black' 行列和高度轴标题颜色 字符串或元组
'plot_quality'='medium' 影响3D图质量: 'low', 'medium', 'good', 'best'
'scale_plot' ='true' true图像高度值在显示前转为间隔[0,255]
false考虑行/列和高度之间长宽比.字节,循环或方向类型图像不缩放忽略此参数
'display_grid' ='true' 在高度0处显示一网格
'display_axes'='true' 显示坐标轴
============================================================================================
设置窗口输出颜色
set_color(WindowHandle,['red','#00ff00a0'])
disp_circle(WindowHandle,[100,200,300],[200,300,100],[100,100,100])
set_shape( : : WindowHandle, Shape= 'original': )
用途:定义区域输出形状
模式:
'original': 形状不变-然而可通过set_line_width进行修改
'outer_circle':区域以最小外接圆显示
'inner_circle':区域均以最大内接圆显示
'ellipse': 每个区域都由一椭圆形显示,椭圆有相同矩和方向
'rectangle1': 每个区域均由平行于坐标轴最小外接矩形显示
'rectangle2': 每个区域均以最小外接矩形显示
'convex': 每个区域均以其凸包显示
'icon' 每个区域都由在重心中设置的图标显示
void SetLineStyle(const HTuple& Style) const;
用途:定义一轮廓线输出模式
参数:Style=[]整数数组(整数)→轮廓图案 典型值范围:1 ≤ Style ≤ 120
void SetPart(Hlong Row1, Hlong Column1, Hlong Row2, Hlong Column2) const;
函数用途:修改显示部分图像(左上角右下角)
特殊模式:
Row1 = Column1 = Row2 = Column2 = -1: 窗口大小作为图像部分不执行图像缩放
Row1, Column1 > -1 and Row2 = Column2 = -1:最后显示图像大小,图像可被缩放
Row1 = Column1 = 0 and Row2 = Column2 = -2:最后显示图像大小,保留长宽比可被缩放
============================================================================================
2.示例:
实例1:open_window
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)
============================================================================================
实例2:set_window_param
read_image (Image, 'printer_chip/printer_chip_01')
threshold (Image, Region, 128, 255)
dev_open_window (0, 0, 512, 512, 'black', WindowHandle)
set_window_param (WindowHandle, 'flush', 'false')
dev_display (Image)
dev_display (Region)
disp_text (WindowHandle, 'Result of threshold', 'window', 12, 12, 'black', [], [])
* 在调用flush_buffer之前不显示任何内容
flush_buffer (WindowHandle)
============================================================================================
实例3:set_shape
read_image(Image,'fabrik')
regiongrowing(Image,Seg,5,5,6,100)
set_colored(WindowHandle,12)
set_shape(WindowHandle,'rectangle2')
disp_region(Seg,WindowHandle)
============================================================================================
实例4:set_line_style
* stroke line: 描边线 X-Windows
set_line_style(WindowHandle,[20,7])
* point-stroke line:笔划线 X-Windows
set_line_style(WindowHandle,[20,7,3,7])
* passing line (standard)通过线(标准)
set_line_style(WindowHandle,[])
============================================================================================
实例5:SetPart
get_system('width',Width)
get_system('height',Height)
set_part(WindowHandle,0,0,Height-1,Width-1)
disp_image(Image,WindowHandle)
draw_rectangle1(WindowHandle,Row1,Column1,Row2,Column2)
set_part(WindowHandle,Row1,Column1,Row2,Column2)
disp_image(Image,WindowHandle)
============================================================================================
实例6:C++
#include "Test.h"
/*************************************************************************
*测试程序开始:
**************************************************************************/
void test_win_system() {
double start_time = HSystem::CountSeconds();
HSystem::WaitSeconds(1);
double end_time = HSystem::CountSeconds();
cout << "program run time=" << (end_time - start_time) * 1000 << "ms" << endl;
}
HImage get_image(Hlong& width,Hlong& height,const char* file= "/data/girl.jpg") {
HImage image(file);
image.GetImageSize(&width, &height);
return image;
}
void test_mouse_show_text(const HImage& image, HWindow& win);
void test_window_show_image() {
//HSystem::SetSystem("use_window_thread", "true");
//HSystem::SetSystem("flush_graphic", "true");
//HSystem::SetWindowAttr("border_width", HTuple(0));
Hlong width, height;
HImage image=get_image(width, height);
//显示窗口:方法1 图片
HWindow win(16, 16, width, height, 0, "visible", "");
win.SetWindowParam("window_title","Girl_1");
win.SetPart(0, 0, height - 1, width - 1);
win.DispObj(image);
win.Click();
//显示窗口:方法2 图片
HWindow win2;
win2.OpenWindow(0, 0, width, height, 0, "visible", "");
win2.SetWindowParam("window_title", "Girl_2");
win2.SetWindowExtents(0, 0, width, height);
//win2.DispObj(image);//显示彩色图像
image.DispImage(win2);//显示灰度图像
win2.Click();
//显示窗口:方法3 区域
HWindow win3(0, 0, width, height, 0, "visible", "");
win3.SetWindowParam("window_title", "Girl_3");
HRegion rectangle(0, 0, 50, 50);
HRegion rectangle1(50, 50, 100, 100);
HRegion rectangle2(100, 100, 300, 300);
double center_row, center_column;
rectangle.AreaCenter(¢er_row, ¢er_column);
cout << "rect.x=" << center_row << ",rect.y=" << center_column << endl;
HImage image_reduced = image.ReduceDomain(rectangle2);
win3.SetLineWidth(3);
win3.SetColor("blue");
win3.SetDraw("margin");
win3.DispObj(rectangle);
win3.SetColor("green");
win3.SetDraw("fill");
win3.DispObj(rectangle1);
win3.DispObj(image_reduced);
win3.Click();
//显示窗口:方法4 鼠标单击显示文本
HWindow win4(0, 0, width, height, 0, "visible", "");
win4.SetWindowParam("window_title", "Girl_4");
win4.DispObj(image);
//win4.Click();
test_mouse_show_text(image,win4);
}
void test_mouse_show_text(const HImage& image, HWindow& win) {
Hlong mrow, mcolumn, mbutton;
while (1) {
win.Click();
//win.SetWindowParam("flush", "false");
//HSystem::SetSystem("flush_graphic", "false");
//win.FlushBuffer();
win.GetMposition(&mrow, &mcolumn, &mbutton);
string str = "[(x,y):(" + std::to_string(mrow) + "," +
std::to_string(mcolumn) + "),(mbutton):(" +
std::to_string(mbutton) + ")]";
std::cout << str << std::endl;
//win.ClearWindow();
win.DispObj(image);
//win.WriteString(str.c_str());
win.DispText(str.c_str(), "window", mrow, mcolumn, "green", "box", "false");
}
}
void test_window_draw() {
HImage image("/data/girl.jpg");
HWindow win(0, 0, image.Width(), image.Height());
TWindow d; d.win = win;
//绘图:
d.text("Tom", 10, 10, tc::winTextColor.green);
d.arrow(60, 10, 60, 50, tc::winColor.red, false);
d.cross(100, 10, tc::winColor.blue);
d.point(150, 10, tc::winColor.blue);
d.line(180, 10, 180, 60, tc::winColor.blue);
d.circle(220, 40, 40, tc::winColor.blue);
d.circle(260, 80, 40, tc::winColor.blue, true);
d.arc(30, 100, 45, 50, 150);
d.rectangle1(200, 200, 250, 250);
d.rectangle2(200, 200, 45, 250, 250);
HTuple Rows, Cols;
tc::tuple_append(Rows, {0,10,30,80});
tc::tuple_append(Cols, {10,50,100,100 });
/*Rows[0] = 1; Rows[2] = 10; Rows[2] = 30; Rows[3] = 80;
Cols[0] = 111; Cols[2] = 50; Cols[2] = 130; Cols[3] = 180;*/
d.polygon(Rows, Cols);
//鼠标绘图:
tc::VectorTuple v1 = d.point(tc::winColor.green);
tc::VectorTuple v2 = d.line(tc::winColor.red);
tc::VectorTuple v3 = d.circle(tc::winColor.yellow);
tc::VectorTuple v4 = d.ellipse(tc::winColor.gray);
tc::VectorTuple v5 = d.rectangle1(tc::winColor.gold);
tc::VectorTuple v6 = d.rectangle2(tc::winColor.blue_cornflower);
d.polygon(tc::winColor.gray_light);
cout << "v1=" << v1 << endl;
cout << "v2=" << v2 << endl;
cout << "v3=" << v3 << endl;
cout << "v4=" << v4 << endl;
cout << "v5=" << v5 << endl;
cout << "v6=" << v6 << endl;
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。