Commit d0e6394a by liulongfei

1. 调整跟踪框命中逻辑

2. 3D鼠标添加是否准备完毕属性
parent 6f7d995a
...@@ -20,6 +20,6 @@ namespace VIZ.Framework.Common ...@@ -20,6 +20,6 @@ namespace VIZ.Framework.Common
/// <summary> /// <summary>
/// 命中的跟踪框信息 /// 命中的跟踪框信息
/// </summary> /// </summary>
public List<TrackingBoxInfo> HitTrackingBoxInfos { get; set; } public TrackingBoxInfo HitTrackingBoxInfo { get; set; }
} }
} }
...@@ -32,5 +32,6 @@ namespace VIZ.Framework.Common ...@@ -32,5 +32,6 @@ namespace VIZ.Framework.Common
/// 绘制边框宽度 /// 绘制边框宽度
/// </summary> /// </summary>
public float DrawingBorderWidth { get; set; } public float DrawingBorderWidth { get; set; }
} }
} }
...@@ -50,18 +50,23 @@ namespace VIZ.Framework.Common ...@@ -50,18 +50,23 @@ namespace VIZ.Framework.Common
/// <param name="trackingBoxInfos">跟踪框信息结合</param> /// <param name="trackingBoxInfos">跟踪框信息结合</param>
/// <param name="point">视频坐标</param> /// <param name="point">视频坐标</param>
/// <returns>命中的跟踪框</returns> /// <returns>命中的跟踪框</returns>
public static List<TrackingBoxInfo> HitTest(List<TrackingBoxInfo> trackingBoxInfos, System.Windows.Point point) public static TrackingBoxInfo HitTest(List<TrackingBoxInfo> trackingBoxInfos, System.Windows.Point point)
{ {
List<TrackingBoxInfo> result = new List<TrackingBoxInfo>();
if (trackingBoxInfos == null || trackingBoxInfos.Count == 0) if (trackingBoxInfos == null || trackingBoxInfos.Count == 0)
return result; return null;
TrackingBoxInfo result = null;
double min = double.MaxValue;
foreach (TrackingBoxInfo item in trackingBoxInfos) foreach (TrackingBoxInfo item in trackingBoxInfos)
{ {
if (point.X >= item.SrcRect.Left && point.X <= item.SrcRect.Right && point.Y >= item.SrcRect.Top && point.Y <= item.SrcRect.Bottom) System.Windows.Point center = new System.Windows.Point((item.SrcRect.Right - item.SrcRect.Left) / 2d, (item.SrcRect.Bottom - item.SrcRect.Top) / 2d);
double dist = Math.Pow((point.Y - center.Y), 2) + Math.Pow((point.X - center.X), 2);
if (dist < min)
{ {
result.Add(item); min = dist;
result = item;
} }
} }
......
using SharpDX.Direct2D1; using SharpDX.Direct2D1;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
...@@ -112,7 +113,10 @@ namespace VIZ.Framework.Common ...@@ -112,7 +113,10 @@ namespace VIZ.Framework.Common
TrackingBoxClickEventArgs args = new TrackingBoxClickEventArgs(); TrackingBoxClickEventArgs args = new TrackingBoxClickEventArgs();
args.MousePoint = uiPoint; args.MousePoint = uiPoint;
args.HitTrackingBoxInfos = TrackingBoxExpand.HitTest(this.trackingBoxInfos, bmpPoint); args.HitTrackingBoxInfo = TrackingBoxExpand.HitTest(this.trackingBoxInfos, bmpPoint);
if (args.HitTrackingBoxInfo == null)
return;
// 触发视频矩形框点击事件 // 触发视频矩形框点击事件
this.TrackingBoxClick.Invoke(this, args); this.TrackingBoxClick.Invoke(this, args);
......
...@@ -42,6 +42,11 @@ namespace VIZ.Framework.Core ...@@ -42,6 +42,11 @@ namespace VIZ.Framework.Core
public bool IsUseSmooth { get; set; } = true; public bool IsUseSmooth { get; set; } = true;
/// <summary> /// <summary>
/// 是否准备完毕
/// </summary>
public bool IsReady { get; set; } = true;
/// <summary>
/// 平滑处理器 /// 平滑处理器
/// </summary> /// </summary>
private Navigation3DSmooth Smooth = new Navigation3DSmooth(); private Navigation3DSmooth Smooth = new Navigation3DSmooth();
......
...@@ -100,7 +100,7 @@ namespace VIZ.Framework.Module ...@@ -100,7 +100,7 @@ namespace VIZ.Framework.Module
if (setup.Setup(context)) if (setup.Setup(context))
{ {
stopwatch.Stop(); stopwatch.Stop();
Debug.WriteLine($"Setup || {setup.Detail} ==> {stopwatch.ElapsedMilliseconds}"); Debug.WriteLine($"Setup || {setup.Detail} ==> {stopwatch.ElapsedMilliseconds} ms");
continue; continue;
} }
...@@ -164,7 +164,7 @@ namespace VIZ.Framework.Module ...@@ -164,7 +164,7 @@ namespace VIZ.Framework.Module
setup.Shutdown(context); setup.Shutdown(context);
stopwatch.Stop(); stopwatch.Stop();
Debug.WriteLine($"ShutDown || {setup.Detail} ==> {stopwatch.ElapsedMilliseconds}"); Debug.WriteLine($"ShutDown || {setup.Detail} ==> {stopwatch.ElapsedMilliseconds} ms");
} }
catch (Exception ex) catch (Exception ex)
{ {
...@@ -197,7 +197,7 @@ namespace VIZ.Framework.Module ...@@ -197,7 +197,7 @@ namespace VIZ.Framework.Module
if (setup.Setup(context)) if (setup.Setup(context))
{ {
stopwatch.Stop(); stopwatch.Stop();
Debug.WriteLine($"Load || {setup.Detail} ==> {stopwatch.ElapsedMilliseconds}"); Debug.WriteLine($"Load || {setup.Detail} ==> {stopwatch.ElapsedMilliseconds} ms");
continue; continue;
} }
context.IsSuccess = false; context.IsSuccess = false;
...@@ -243,7 +243,7 @@ namespace VIZ.Framework.Module ...@@ -243,7 +243,7 @@ namespace VIZ.Framework.Module
setup.Shutdown(context); setup.Shutdown(context);
stopwatch.Stop(); stopwatch.Stop();
Debug.WriteLine($"UnLoad || {setup.Detail} ==> {stopwatch.ElapsedMilliseconds}"); Debug.WriteLine($"UnLoad || {setup.Detail} ==> {stopwatch.ElapsedMilliseconds} ms");
} }
catch (Exception ex) catch (Exception ex)
{ {
......
...@@ -91,11 +91,10 @@ namespace VIZ.Framework.WpfTest ...@@ -91,11 +91,10 @@ namespace VIZ.Framework.WpfTest
private void TrackingBoxPlugin_TrackingBoxClick(object sender, TrackingBoxClickEventArgs e) private void TrackingBoxPlugin_TrackingBoxClick(object sender, TrackingBoxClickEventArgs e)
{ {
TrackingBoxInfo info = e.HitTrackingBoxInfos.FirstOrDefault(); if (e.HitTrackingBoxInfo == null)
if (info == null)
return; return;
Rect rect = info.SrcRect.ToRect(); Rect rect = e.HitTrackingBoxInfo.SrcRect.ToRect();
Debug.WriteLine($"Click: [{rect.X}, {rect.Y}, {rect.Width}, {rect.Height}]"); Debug.WriteLine($"Click: [{rect.X}, {rect.Y}, {rect.Width}, {rect.Height}]");
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment