当前位置:网站首页>Visual upper system design and development (Halcon WinForm) -1 Process node design
Visual upper system design and development (Halcon WinForm) -1 Process node design
2022-07-03 15:18:00 【11eleven】
If a worker wants to do a good job, he must sharpen his tools first , A good system cannot be separated from a good process design , Design before development , The entity in which the whole system operates , The basic relationship between objects .
This chapter explains the relevant contents of process design .
One 、 Actual operation brings design ideas
Looking at other systems, we can see , On the left side of the layout is the process node , In the middle is process editing , Image preview on the right .
The whole operation depends on one scheme , The relationship between scheme and process is one to many , The relationship between process and node is one to many . Such as below

Therefore, when designing entities, there will be scheme objects , Record the basic information of the scheme , The scheme object contains the process collection , Represents that a scheme corresponds to multiple processes , The process object information also includes node geometry , There can be multiple nodes in the representative process , In the node object, there is the relationship between fields and their parents .
Two 、 Design of process entities
At the bottom of the article
3、 ... and 、 Node to process panel Drag and drop layout
In this paper, the UI Is based on WINFORM Drawn ,winform in panel It's kind of like web Of div Concept of container , panel There can be relative coordinates based on the parent container , And it can be based on mousedown Wait for the mouse operation event to change the position of some columns , Follow the mouse to change the position of the container . Dragging a node from a fixed container to another container uses... In the control DragDrop,DragEnter event , Yes, you need to drag nodes Button Set up MouseDown event , Activate when the trigger is pressed btn.DoDragDrop(btn, DragDropEffects.Copy | DragDropEffects.Move); ,DoDragDrop Methods correspond to the contents of process nodes . The code snippet is as follows :
The place marked in red is the core of dragging the control to another container and generating a new control , After getting the new control, you can assemble the entity object .

/// <summary>
/// The toolbar
/// </summary>
private async void LoadToolButtonAsync()
{
var toolNodes = await VisionTaskService.LoadNodeButtonAsync();
FlowPanelToolMenu.Controls.Clear();
toolNodes = toolNodes.OrderBy(x => x.Id).ToList();
toolNodes.ForEach(tool =>
{
Button button = new Button();
button.FlatStyle = FlatStyle.Flat;
button.Text = tool.Name;
button.Tag = tool;
button.Width = 150;
//button.AllowDrop = true;
button.MouseDown += ToolButton_MouseDown;
button.Height = 40;
button.ForeColor = Color.White;
button.BackColor = ColorTranslator.FromHtml("#7a7374");
button.Click += ToolButton_Click;
button.ImageAlign = ContentAlignment.MiddleLeft;
button.Image = VisionTaskService.GetButtonImage(tool.Code);
FlowPanelToolMenu.Controls.Add(button);
});
}
private void ToolButton_MouseDown(object sender, MouseEventArgs e)
{
Button btn = (Button)sender;
// Left click , Sign bit is true( Indicates the start of dragging )
if ((e.Button == System.Windows.Forms.MouseButtons.Left))
{
btn.DoDragDrop(btn, DragDropEffects.Copy | DragDropEffects.Move);
// Form a drag effect , Move + Combined effect of copy
}
}
/// <summary>
/// Loading process
/// </summary>
private void LoadFlow()
{
TabFlow.TabPages.Clear();
this.LabelSchemeName.Text = SchemeConfig.Scheme.Name;
// Cyclic loading PageFlow
SchemeConfig.Scheme.FlowList.ForEach(flow =>
{
// Add a new one by default Tab
var page = new TabPage()
{
};
page.AllowDrop = true;
page.Paint += Page_Paint;
page.DragEnter += Page_DragEnter;
page.DragDrop += Page_DragDrop;
page.Text = flow.Name;
page.AutoScroll = true;
page.Tag = flow;
page.BackColor = Color.FromArgb(70, 71, 74);
if (!flow.FlowNodeList.IsListNullOrEmpty()) {
// Load nodes on the process
// establish FlowPanel
//List<SchemeFlowNodeEntity> tempNodeList = new List<SchemeFlowNodeEntity>();
flow.FlowNodeList.ForEach(node =>
{
AddFlowNodePanel(page, node, new Point(node.LocationX, node.LocationY));
});
// flow.FlowNodeList = tempNodeList;
}
TabFlow.TabPages.Add(page);
});
}
private void Page_DragEnter(object sender, DragEventArgs e)
{
e.Effect = DragDropEffects.Copy;
bMouseDown = true;
}
private void Page_DragDrop(object sender, DragEventArgs e)
{
if (bMouseDown)
{
// From event parameters DragEventArgs Get the dragged element
Button btn = (Button)e.Data.GetData(typeof(Button));
var basicData = btn.Tag as BasicToolNodeEntity;
var nodeType = (ToolNodeTypeEnum)basicData.NodeType.Value;
SchemeFlowNodeEntity flowNodeData = null;
switch (nodeType) {
case ToolNodeTypeEnum.ImageSource:
flowNodeData = basicData.MapTo<ImageSourceContentModel>();
break;
case ToolNodeTypeEnum.Geometry:
flowNodeData = basicData.MapTo<GeometryContentModel>();
break;
case ToolNodeTypeEnum.Blob:
flowNodeData = basicData.MapTo<BlobContentModel>();
break;
case ToolNodeTypeEnum.ConditionResult:
flowNodeData = basicData.MapTo<ConditionResultContentModel>();
break;
case ToolNodeTypeEnum.ColorRgb:
flowNodeData = basicData.MapTo<ColorRgbContentModel>();
break;
case ToolNodeTypeEnum.MatchTemplate:
flowNodeData = basicData.MapTo<MatchTemplateContentModel>();
break;
default:
flowNodeData = basicData.MapTo<ImageSourceContentModel>();
break;
}
flowNodeData.InitData();
var page = ((TabPage)sender);
var flow = page.Tag as SchemeFlowInfoEntity;
flowNodeData.Id = GeneratePrimaryKeyIdHelper.GetPrimaryKeyId();
flowNodeData.SchemeId = flow.SchemeId;
flowNodeData.FlowId = flow.Id;
flow.FlowNodeList.Add(flowNodeData);
var point = this.PointToClient(Control.MousePosition);
var position = new Point(point.X - 200, point.Y - 140);// Remove the left side of the container Distance from the top
flowNodeData.LocationX = position.X;
flowNodeData.LocationY = position.Y;
AddFlowNodePanel(page, flowNodeData, position);
//RefreshControls(new Control[] { grp, (GroupBox)sender });
bMouseDown = false;
}
}
/// <summary> /// Program information /// </summary> public class SchemeInfo : BaseField, IEntity<long> { public SchemeInfo() { Id = GeneratePrimaryKeyIdHelper.GetPrimaryKeyId(); } public long Id { get; set; } /// <summary> /// Scheme code /// </summary> public string Code { get; set; } /// <summary> /// Program name /// </summary> public string Name { get; set; } /// <summary> /// remarks /// </summary> public string Remark { get; set; } /// <summary> /// Process nodes /// </summary> public List<SchemeFlowInfoEntity> FlowList { set; get; } /// <summary> /// Global variables /// </summary> public List<GlobalVariableModel> GlobalVariableList { set; get; } /// <summary> /// Device configuration /// </summary> public GlobalDeviceConfig GlobalDeviceConfig { set; get; } } /// <summary> /// Process information /// </summary> [MyTableName("Scheme_FlowInfo")] [MyPrimaryKey("Id", AutoIncrement = false)] public class SchemeFlowInfoEntity : BaseField, IEntity<long> { public SchemeFlowInfoEntity() { Id = GeneratePrimaryKeyIdHelper.GetPrimaryKeyId(); } public long Id { get; set; } /// <summary> /// Process code /// </summary> public string Code { get; set; } /// <summary> /// Process name /// </summary> public string Name { get; set; } /// <summary> /// Running interval ms /// </summary> public int? RunInterval { get; set; } /// <summary> /// The order /// </summary> public int? SortNum { get; set; } /// <summary> /// programme ID /// </summary> public long? SchemeId { get; set; } /// <summary> /// remarks /// </summary> public string Remark { get; set; } /// <summary> /// Node information /// </summary> [MyResultColumn] public List<SchemeFlowNodeEntity> FlowNodeList { set; get; } } /// <summary> /// Node information /// </summary> [MyTableName("Scheme_FlowNode")] [MyPrimaryKey("Id", AutoIncrement = false)] public abstract class SchemeFlowNodeEntity : BaseField, IEntity<long> { /// <summary> /// /// </summary> public virtual void InitData() { } public SchemeFlowNodeEntity() { Id = GeneratePrimaryKeyIdHelper.GetPrimaryKeyId(); } public long Id { get; set; } /// <summary> /// Node type /// </summary> public long? NodeType { get; set; } /// <summary> /// The name of the node /// </summary> public string Code { get; set; } /// <summary> /// Process name /// </summary> public string Name { get; set; } /// <summary> /// Custom name /// </summary> public string CustomName { get; set; } /// <summary> /// Running interval ms /// </summary> public int? RunInterval { get; set; } /// <summary> /// The order /// </summary> public int? SortNum { get; set; } /// <summary> /// programme ID /// </summary> public long? SchemeId { get; set; } /// <summary> /// technological process ID /// </summary> public long? FlowId { get; set; } /// <summary> /// Last step /// </summary> public string LastStep { get; set; } /// <summary> /// Next step /// </summary> public string NextStep { get; set; } /// <summary> /// remarks /// </summary> public string Remark { get; set; } public int LocationX { set; get; } public int LocationY { set; get; } /// <summary> /// Trigger settings ! /// </summary> [MyResultColumn] public List<GlobalVariableModel> TriggerConditions { set; get; } = new List<GlobalVariableModel>(); /// <summary> /// Write back settings ! /// </summary> [MyResultColumn] public List<GlobalVariableModel> AfterRunConditions { set; get; } = new List<GlobalVariableModel>(); /// <summary> /// Node result data /// </summary> [MyResultColumn] public List<NodeResultModel> NodeResultModels { set; get; } = new List<NodeResultModel>(); [Newtonsoft.Json.JsonIgnore()] public List<HImageData> HImageDataList { set; get; } /// <summary> /// Operator parameters /// </summary> public AlgorithmToolPar ToolPar { set; get; } = new AlgorithmToolPar(); }
边栏推荐
- Didi off the shelf! Data security is national security
- 【Transform】【NLP】首次提出Transformer,Google Brain团队2017年论文《Attention is all you need》
- 在MapReduce中利用MultipleOutputs输出多个文件
- 使用Tengine解决负载均衡的Session问题
- Enable multi-threaded download of chrome and edge browsers
- 什么是one-hot encoding?Pytorch中,将label变成one hot编码的两种方式
- Kubernetes带你从头到尾捋一遍
- 406. Reconstruct the queue according to height
- The state does not change after the assignment of El switch
- Leasing cases of the implementation of the new regulations on the rental of jointly owned houses in Beijing
猜你喜欢
![[wechat applet] wxss template style](/img/28/f9d12bf761e25f9564d92697cf049d.png)
[wechat applet] wxss template style
![[cloud native training camp] module VIII kubernetes life cycle management and service discovery](/img/87/92638402820b32a15383f19f6f8b91.png)
[cloud native training camp] module VIII kubernetes life cycle management and service discovery

The markdown file obtains the pictures of the network and stores them locally and modifies the URL

Besides lying flat, what else can a 27 year old do in life?

Introduction to redis master-slave, sentinel and cluster mode

Construction of operation and maintenance system

Introduction, use and principle of synchronized

视觉上位系统设计开发(halcon-winform)-5.相机
![Mysql报错:[ERROR] mysqld: File ‘./mysql-bin.010228‘ not found (Errcode: 2 “No such file or directory“)](/img/cd/2e4f5884d034ff704809f476bda288.png)
Mysql报错:[ERROR] mysqld: File ‘./mysql-bin.010228‘ not found (Errcode: 2 “No such file or directory“)

运维体系的构建
随机推荐
Leetcode the smallest number of the rotation array of the offer of the sword (11)
使用JMeter对WebService进行压力测试
Jvm-05-object, direct memory, string constant pool
Pytoch deep learning and target detection practice notes
Global and Chinese market of iron free motors 2022-2028: Research Report on technology, participants, trends, market size and share
[combinatorics] permutation and combination (set permutation, step-by-step processing example)
Leetcode sword offer find the number I (nine) in the sorted array
Kubernetes 进阶训练营 Pod基础
在MapReduce中利用MultipleOutputs输出多个文件
Jvm-02-class loading subsystem
Construction of operation and maintenance system
What are the composite types of Blackhorse Clickhouse, an OLAP database recognized in the industry
socket.io搭建分布式Web推送服务器
视觉上位系统设计开发(halcon-winform)-6.节点与宫格
redis缓存穿透,缓存击穿,缓存雪崩解决方案
Zero copy underlying analysis
The first character of leetcode sword offer that only appears once (12)
TPS61170QDRVRQ1
整形和浮点型是如何在内存中的存储
开启 Chrome 和 Edge 浏览器多线程下载