| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- using System;
- using System.Collections.Generic;
- namespace TeamAAS.Vision
- {
- /// <summary>图层内容类型(决定显示控件如何渲染)。</summary>
- public enum LayerKind
- {
- /// <summary>底图(图像)。</summary>
- Image = 0,
- /// <summary>区域(Region)。</summary>
- Region = 1,
- /// <summary>轮廓/边界(XLD 等)。</summary>
- Contour = 2,
- /// <summary>几何对象(矩形/圆/线等,由各平台自行解释)。</summary>
- Geometry = 3,
- /// <summary>文字/标注。</summary>
- Text = 4,
- /// <summary>其他(平台自定义)。</summary>
- Other = 99,
- }
- /// <summary>
- /// 一个图层项:视觉节点运行后产出的可显示对象。
- /// <see cref="Content"/> 为平台对象(HObject / GenImage / Vm 对象等),所有权由 <see cref="Owned"/> 标记:
- /// Owned=true 表示该对象由图层库创建(图层被淘汰时负责释放);false 表示归流程注册表所有,图层只引用不释放。
- /// </summary>
- public sealed class LayerItem
- {
- /// <summary>图层显示名(ComboBox 里显示的文案,如 “H阈值分割.区域”)。</summary>
- public string Name { get; set; }
- /// <summary>图层类型。</summary>
- public LayerKind Kind { get; set; }
- /// <summary>平台显示对象。</summary>
- public object Content { get; set; }
- /// <summary>是否为图层库自有对象(淘汰时需要释放)。</summary>
- public bool Owned { get; set; }
- /// <summary>建议颜色(如 "red"/"#FF0000"),null 用显示控件默认。</summary>
- public string Color { get; set; }
- public LayerItem() { }
- public LayerItem(string name, LayerKind kind, object content, bool owned = false, string color = null)
- {
- Name = name; Kind = kind; Content = content; Owned = owned; Color = color;
- }
- }
- /// <summary>一次发布 = 某节点一次运行的完整图层集(整体替换,不做增量叠加,避免内存堆积)。</summary>
- public sealed class LayerPublishArgs
- {
- /// <summary>流程 Id(子流程用子图 GraphId)。</summary>
- public string FlowId { get; set; }
- /// <summary>节点名(DisplayName)。</summary>
- public string NodeName { get; set; }
- /// <summary>节点显示名(与 NodeName 相同,冗余给 UI 绑定用)。</summary>
- public string NodeDisplay => NodeName;
- /// <summary>运行批次号(同批次整体替换旧图层;跨批次自动淘汰)。</summary>
- public string RunStamp { get; set; }
- /// <summary>
- /// 发布方推荐的显示图层(节点属性「输出图层」里配置的那一项)。
- /// 显示端在"节点级/最新运行"视图下优先显示它;null=用发布方默认(根记录/底图)。
- /// </summary>
- public string PreferredLayer { get; set; }
- /// <summary>本批次图层(顺序 = 叠加顺序;[0] 通常是底图/根记录)。</summary>
- public List<LayerItem> Layers { get; } = new List<LayerItem>();
- }
- /// <summary>
- /// 视觉图层发布器契约:节点运行后把自己的渲染图层发布进来;显示端(编辑器大预览窗/主页画面)订阅消费。
- /// 三平台(Halcon/Vm/Vpp)共用同一契约,显示控件按 LayerKind + 平台自行解释 Content。
- /// </summary>
- public interface ILayerPublisher
- {
- /// <summary>发布一个节点的图层集(整体替换该节点当前批次的图层;后台线程调用安全)。</summary>
- void Publish(LayerPublishArgs args);
- /// <summary>清除指定流程(或节点,nodeName 为 null 时全流程)的所有图层并释放 owned 对象。</summary>
- void Clear(string flowId, string nodeName = null);
- }
- }
|