Commit f4a9c5e9 by liulongfei

添加触碰摇杆时自动切换至手动模式

parent a7bea142
......@@ -45,8 +45,6 @@ namespace VIZ.H2V.Module
if (this.focusNDIViewModel == null)
return;
this.focusNDIViewModel.IsFocus = true;
// 切换为手动模式
ChangeStrategyContext context = new ChangeStrategyContext();
context.IsUseClip = this.focusNDIViewModel.IsUseClip;
......@@ -72,8 +70,6 @@ namespace VIZ.H2V.Module
context.TriggerScene = NDIViewScene.SpaceHotkey;
this.focusNDIViewModel.ChangeStrategyMode(context);
this.focusNDIViewModel.IsFocus = false;
this.focusNDIViewModel = null;
}
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VIZ.H2V.Module
{
/// <summary>
/// 3D鼠标支持
/// </summary>
public interface INavigation3DCheckSupport
{
}
}
using log4net;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VIZ.Framework.Core;
using VIZ.H2V.Domain;
using VIZ.H2V.Storage;
namespace VIZ.H2V.Module
{
/// <summary>
/// 3D鼠标检测控制器
/// </summary>
public class Navigation3DCheckController : IDisposable
{
/// <summary>
/// 日志
/// </summary>
private readonly static ILog log = LogManager.GetLogger(typeof(Navigation3DCheckController));
/// <summary>
/// 3D鼠标检测控制器
/// </summary>
/// <param name="support">支持</param>
public Navigation3DCheckController(INavigation3DCheckSupport support)
{
// 注册到对象池
ApplicationDomainEx.ObjectPoolManager.Add("Navigation3DCheckController", this);
this.Support = support;
this.taskInfo = new TaskInfo();
this.executeTask = Task.Run(this.ExecuteCheck);
}
/// <summary>
/// 支持
/// </summary>
public INavigation3DCheckSupport Support { get; private set; }
/// <summary>
/// 是否启用
/// </summary>
public bool IsEnabled { get; set; }
/// <summary>
/// 任务信息
/// </summary>
private TaskInfo taskInfo;
/// <summary>
/// 执行任务
/// </summary>
private Task executeTask;
/// <summary>
/// 执行检测
/// </summary>
private void ExecuteCheck()
{
TaskInfo info = this.taskInfo;
while (!info.IsCancel)
{
try
{
this._executeCheck();
Task.Delay(100).Wait();
}
catch (Exception ex)
{
log.Error(ex);
}
}
}
/// <summary>
/// 执行检测
/// </summary>
private void _executeCheck()
{
// 如果未启用,那么不处理
if (!this.IsEnabled)
return;
List<Navigation3DMapping> mappingList = ApplicationDomainEx.Navigation3DMapping.Mappings;
// 如果没有映射信息,那么不处理
if (mappingList == null)
return;
int value = Math.Abs(Navigation3DManager.Info.rz);
Navigation3DMapping first = mappingList.FirstOrDefault();
// 如果移动值在最小值以内,那么不处理
if (value < first.MinValue)
return;
List<INDIViewService> services = ApplicationDomainEx.ServiceManager.GetServiceList<INDIViewService>();
if (services == null)
return;
// 当前激活的视图
INDIViewService service = services.FirstOrDefault(p => p.IsActive);
// 如果当前模式不处于算法模式,那么不处理
if (service.StrategyMode != AlgorithmStrategyMode.auto_mode)
return;
// 如果当前状态不处于裁切状态或,检测状态那么不处理
if (service.ViewStatus != NDIViewStatus.CropRoi && service.ViewStatus != NDIViewStatus.Detect)
return;
WPFHelper.BeginInvoke(() =>
{
ChangeStrategyContext context = new ChangeStrategyContext();
context.IsUseClip = service.IsUseClip;
context.Mode = AlgorithmStrategyMode.manual_mode;
context.IsNeedRestart = false;
context.TriggerScene = NDIViewScene.Navigation3D;
service.ChangeStrategyMode(context);
});
}
/// <summary>
/// 销毁
/// </summary>
public void Dispose()
{
if (this.taskInfo != null)
{
this.taskInfo.IsCancel = true;
}
this.taskInfo = null;
this.executeTask = null;
}
}
}
......@@ -17,5 +17,11 @@ namespace VIZ.H2V.Module
/// 热键配置
/// </summary>
HotkeyConfig HotkeyConfig { get; set; }
/// <summary>
/// 设置3D鼠标检测是否生效
/// </summary>
/// <param name="isEnabled">是否生效</param>
void SetNavigation3DCheckEnabled(bool isEnabled);
}
}
......@@ -21,7 +21,7 @@ namespace VIZ.H2V.Module
/// <summary>
/// NDI主视图模型
/// </summary>
public class NDIMainViewModel : ViewModelBase, INDIMainViewService, IHotkeySupport, IGpioSupport
public class NDIMainViewModel : ViewModelBase, INDIMainViewService, IHotkeySupport, IGpioSupport, INavigation3DCheckSupport
{
/// <summary>
/// 日志
......@@ -91,6 +91,7 @@ namespace VIZ.H2V.Module
{
this.hotkeyController = new HotkeyController(this);
this.gpioController = new GpioController(this);
this.navigation3DCheckController = new Navigation3DCheckController(this);
}
/// <summary>
......@@ -127,6 +128,11 @@ namespace VIZ.H2V.Module
/// </summary>
private GpioController gpioController;
/// <summary>
/// 3D鼠标检测控制器
/// </summary>
private Navigation3DCheckController navigation3DCheckController;
// ======================================================================================
// === Property ===
// ======================================================================================
......@@ -324,7 +330,20 @@ namespace VIZ.H2V.Module
#endregion
// ======================================================================================
// === Privatee Function ===
// === Public Function ===
// ======================================================================================
/// <summary>
/// 设置3D鼠标检测是否生效
/// </summary>
/// <param name="isEnabled">是否生效</param>
public void SetNavigation3DCheckEnabled(bool isEnabled)
{
this.navigation3DCheckController.IsEnabled = isEnabled;
}
// ======================================================================================
// === Private Function ===
// ======================================================================================
/// <summary>
......
......@@ -26,6 +26,10 @@ namespace VIZ.H2V.Module
/// <summary>
/// 空格热键
/// </summary>
SpaceHotkey
SpaceHotkey,
/// <summary>
/// 摇杆触发
/// </summary>
Navigation3D
}
}
......@@ -131,8 +131,7 @@
MaxWidth="300"></TextBlock>
</Grid>
<!-- 算法 -->
<Grid Grid.RowSpan="2" Margin="0,20,0,0"
IsEnabled="{Binding Path=IsFocus,Converter={StaticResource Bool2BoolConverter}}">
<Grid Grid.RowSpan="2" Margin="0,20,0,0">
<Grid IsEnabled="{Binding Path=ViewStatus,Converter={StaticResource NDIViewStatus2IsEnabledConverter}}">
<Grid.RowDefinitions>
<RowDefinition Height="60"></RowDefinition>
......
......@@ -361,20 +361,6 @@ namespace VIZ.H2V.Module
#endregion
#region IsFocus -- 是否聚焦
private bool isFocus;
/// <summary>
/// 是否聚焦
/// </summary>
public bool IsFocus
{
get { return isFocus; }
set { isFocus = value; this.RaisePropertyChanged(nameof(IsFocus)); }
}
#endregion
// --------------------------------------------------------------------------------------
#region IsUseClip -- 是否使用裁切
......
......@@ -148,6 +148,16 @@
Minimum="0.001" Maximum="0.2" Increment="0.001"
Value="{Binding Path=ManualSmoothCoeff,Mode=TwoWay}"></toolkit:DoubleUpDown>
</Grid>
<!-- 是否在触碰摇杆时切换至手动模式 -->
<Grid Grid.Row="9">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="500"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Text="是否在触碰摇杆时由自动模式切换至手动模式" Foreground="White" FontSize="18" VerticalAlignment="Center" Grid.Row="2"></TextBlock>
<CheckBox Grid.Column="1" Style="{StaticResource CheckBox_Setting}" HorizontalAlignment="Right"
IsChecked="{Binding Path=IsWhenNavigationTouchedChangeToManualMode,Mode=TwoWay}"></CheckBox>
</Grid>
</Grid>
</Border>
</UserControl>
\ No newline at end of file
......@@ -174,6 +174,20 @@ namespace VIZ.H2V.Module
#endregion
#region IsWhenNavigationTouchedChangeToManualMode -- 是否当触碰到摇杆时由自动模式切换至手动模式
private bool isWhenNavigationTouchedChangeToManualMode;
/// <summary>
/// 是否当触碰到摇杆时由自动模式切换至手动模式
/// </summary>
public bool IsWhenNavigationTouchedChangeToManualMode
{
get { return isWhenNavigationTouchedChangeToManualMode; }
set { isWhenNavigationTouchedChangeToManualMode = value; this.RaisePropertyChanged(nameof(IsWhenNavigationTouchedChangeToManualMode)); }
}
#endregion
// ======================================================================================
// === Commond ===
// ======================================================================================
......@@ -203,6 +217,7 @@ namespace VIZ.H2V.Module
this.ClipCenterAxisColor = (Color)ColorConverter.ConvertFromString(this.SystemConfig.ClipCenterAxisColor);
this.ManualSmoothCoeff = this.SystemConfig.ManualSmoothCoeff;
this.IsWhenNavigationTouchedChangeToManualMode = this.SystemConfig.IsWhenNavigationTouchedChangeToManualMode;
// 加载3D鼠标映射模型
this.Load3DNavigationMapping();
......@@ -268,6 +283,9 @@ namespace VIZ.H2V.Module
if (this.Navigation3DMappingMultiple != this.SystemConfig.ManualNavigation3DMappingMultiple)
return true;
if (this.IsWhenNavigationTouchedChangeToManualMode != this.SystemConfig.IsWhenNavigationTouchedChangeToManualMode)
return true;
return false;
}
......@@ -287,6 +305,7 @@ namespace VIZ.H2V.Module
this.SystemConfig.ManualSmoothCoeff = this.ManualSmoothCoeff;
this.SystemConfig.ManualNavigation3DMappingName = this.SelectedNavigation3DMappingGroupModel.Name;
this.SystemConfig.ManualNavigation3DMappingMultiple = this.Navigation3DMappingMultiple;
this.SystemConfig.IsWhenNavigationTouchedChangeToManualMode = this.IsWhenNavigationTouchedChangeToManualMode;
ApplicationDomainEx.LiteDbContext.SystemConfig.Update(this.SystemConfig);
......@@ -299,6 +318,7 @@ namespace VIZ.H2V.Module
ApplicationDomainEx.Navigation3DMapping.Name = this.SelectedNavigation3DMappingGroupModel.Name;
ApplicationDomainEx.Navigation3DMapping.Multiple = this.Navigation3DMappingMultiple;
ApplicationDomainEx.Navigation3DMapping.Mappings = this.SelectedNavigation3DMappingGroupModel.Mappings;
ApplicationDomainEx.ServiceManager.GetService<INDIMainViewService>(NDIViewKeys.MainView).SetNavigation3DCheckEnabled(this.IsWhenNavigationTouchedChangeToManualMode);
// 返回
return true;
......
......@@ -202,6 +202,8 @@
<Compile Include="NDIMainView\Controller\Gpio\IGpioSupport.cs" />
<Compile Include="NDIMainView\Controller\Hotkey\HotkeyController.cs" />
<Compile Include="NDIMainView\Controller\Hotkey\IHotkeySupport.cs" />
<Compile Include="NDIMainView\Controller\Navigation3DCheck\INavigation3DCheckSupport.cs" />
<Compile Include="NDIMainView\Controller\Navigation3DCheck\Navigation3DCheckController.cs" />
<Compile Include="NDIMainView\Service\INDIMainViewService.cs" />
<Compile Include="NDISettingView\ViewModel\Algorithm\AlgorithmCablewayPanelViewModel.cs" />
<Compile Include="NDISettingView\ViewModel\Algorithm\AlgorithmTacticsPanelViewModel.cs" />
......
......@@ -66,6 +66,11 @@ namespace VIZ.H2V.Storage
public double ManualNavigation3DMappingMultiple { get; set; } = 1d;
/// <summary>
/// 是否当触碰到摇杆时由自动模式切换至手动模式
/// </summary>
public bool IsWhenNavigationTouchedChangeToManualMode { get; set; } = false;
/// <summary>
/// Tally信息 -- 窗口1
/// </summary>
public TallyInfo TallyInfo1 { get; set; } = new TallyInfo();
......
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