当前位置:网站首页>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(); }
边栏推荐
- What is machine reading comprehension? What are the applications? Finally someone made it clear
- Yolov5 series (I) -- network visualization tool netron
- Qt常用语句备忘
- 视觉上位系统设计开发(halcon-winform)-2.全局变量设计
- Mmdetection learning rate and batch_ Size relationship
- Besides lying flat, what else can a 27 year old do in life?
- [pytorch learning notes] transforms
- Using Tengine to solve the session problem of load balancing
- Chapter 04_ Logical architecture
- C语言刷题~Leetcode与牛客网简单题
猜你喜欢

Besides lying flat, what else can a 27 year old do in life?
![[Yu Yue education] scientific computing and MATLAB language reference materials of Central South University](/img/83/922efb4f88843f1b7feaccf2b515b9.jpg)
[Yu Yue education] scientific computing and MATLAB language reference materials of Central South University

Solve the problem that pushgateway data will be overwritten by multiple push
![MySQL reports an error: [error] mysqld: file '/ mysql-bin. 010228‘ not found (Errcode: 2 “No such file or directory“)](/img/cd/2e4f5884d034ff704809f476bda288.png)
MySQL reports an error: [error] mysqld: file '/ mysql-bin. 010228‘ not found (Errcode: 2 “No such file or directory“)

【Transform】【实践】使用Pytorch的torch.nn.MultiheadAttention来实现self-attention

Introduction to redis master-slave, sentinel and cluster mode

Yolov5系列(一)——网络可视化工具netron

Kubernetes advanced training camp pod Foundation

Jvm-05-object, direct memory, string constant pool

Jvm-08-garbage collector
随机推荐
Leetcode the smallest number of the rotation array of the offer of the sword (11)
[pytorch learning notes] datasets and dataloaders
Basic SQL tutorial
Jvm-09 byte code introduction
【云原生训练营】模块七 Kubernetes 控制平面组件:调度器与控制器
What is label encoding? How to distinguish and use one hot encoding and label encoding?
Markdown file titles are all reduced by one level
Unity hierarchical bounding box AABB tree
What is one hot encoding? In pytoch, there are two ways to turn label into one hot coding
Use of Tex editor
Concurrency-01-create thread, sleep, yield, wait, join, interrupt, thread state, synchronized, park, reentrantlock
什么是one-hot encoding?Pytorch中,将label变成one hot编码的两种方式
B2020 points candy
Influxdb2 sources add data sources
Construction of operation and maintenance system
What are the composite types of Blackhorse Clickhouse, an OLAP database recognized in the industry
Yolov5系列(一)——网络可视化工具netron
Yolov5 series (I) -- network visualization tool netron
Global and Chinese market of transfer case 2022-2028: Research Report on technology, participants, trends, market size and share
Global and Chinese markets for sterile packaging 2022-2028: Research Report on technology, participants, trends, market size and share