当前位置:网站首页>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(); }
边栏推荐
- Using multipleoutputs to output multiple files in MapReduce
- Functional modules and application scenarios covered by the productization of user portraits
- App global exception capture
- 【Transform】【实践】使用Pytorch的torch.nn.MultiheadAttention来实现self-attention
- redis单线程问题强制梳理门外汉扫盲
- Global and Chinese market of optical fiber connectors 2022-2028: Research Report on technology, participants, trends, market size and share
- Detailed comments on MapReduce instance code on the official website
- Explanation of time complexity and space complexity
- Use of Tex editor
- [cloud native training camp] module VIII kubernetes life cycle management and service discovery
猜你喜欢

求字符串函数和长度不受限制的字符串函数的详解

Introduction to redis master-slave, sentinel and cluster mode
![[probably the most complete in Chinese] pushgateway entry notes](/img/5a/6dcb75f5d713ff513ad6842ff53cc3.png)
[probably the most complete in Chinese] pushgateway entry notes

Halcon与Winform学习第二节

qt使用QZxing生成二维码

What is one hot encoding? In pytoch, there are two ways to turn label into one hot coding

Concurrency-02-visibility, atomicity, orderliness, volatile, CAS, atomic class, unsafe

视觉上位系统设计开发(halcon-winform)-5.相机

Characteristics of MySQL InnoDB storage engine -- Analysis of row lock

百度智能云助力石嘴山市升级“互联网+养老服务”智慧康养新模式
随机推荐
[set theory] inclusion exclusion principle (complex example)
使用Tengine解决负载均衡的Session问题
Kubernetes advanced training camp pod Foundation
Redis lock Optimization Practice issued by gaobingfa
什么是Label encoding?one-hot encoding ,label encoding两种编码该如何区分和使用?
Redis cache penetration, cache breakdown, cache avalanche solution
视觉上位系统设计开发(halcon-winform)
2022/02/14
Relationship between truncated random distribution and original distribution
【Transform】【NLP】首次提出Transformer,Google Brain团队2017年论文《Attention is all you need》
Explanation of time complexity and space complexity
Yolov5系列(一)——网络可视化工具netron
北京共有产权房出租新规实施的租赁案例
Analysis of development mode process based on SVN branch
Introduction, use and principle of synchronized
Center and drag linked global and Chinese markets 2022-2028: Research Report on technology, participants, trends, market size and share
[probably the most complete in Chinese] pushgateway entry notes
Kubernetes帶你從頭到尾捋一遍
Global and Chinese markets for indoor HDTV antennas 2022-2028: Research Report on technology, participants, trends, market size and share
Web server code parsing - thread pool