加入立体缩放比例设置,用于立体视图显示超出范围的航点

修复自动编号寻找的bug
开始修改通讯了---还没改完
This commit is contained in:
xu 2020-02-21 23:58:14 +08:00
parent e3f4e557dd
commit 7fb0bcf60e
6 changed files with 73 additions and 27 deletions

View File

@ -104,6 +104,14 @@ namespace Plane.FormationCreator.Formation
public List<ICopter> ShowCopter = new List<ICopter>();
//3维视图显示比例有些大的图案显示不出来可以缩小
private float _scale3d = 1.0f;
public float scale3d
{
get { return _scale3d; }
set { Set(nameof(scale3d), ref _scale3d, value); }
}
public CopterCollection Copters { get;} = new CopterCollection();

View File

@ -95,7 +95,7 @@ namespace Plane.FormationCreator.ViewModels
FlightTaskManager _flightTaskManager = ServiceLocator.Current.GetInstance<FlightTaskManager>();
float StepDis_Row = _flightTaskManager.ColumnDistance; //行内间距-列间距
float StepDis_Col = _flightTaskManager.RowDistance ; //列间距-行间距
float FindDis =Math.Min(StepDis_Row, StepDis_Col); //查找半径
float FindDis =Math.Min(StepDis_Row, StepDis_Col)*0.8f; //查找半径
if (_copterManager.AcceptingControlCopters.Count() >= 2)
{
var copters = _copterManager.AcceptingControlCopters.ToList();

View File

@ -125,7 +125,16 @@ namespace Plane.FormationCreator.ViewModels
set { Set(nameof(CopterNum), ref _CopterNum, value); }
}
public float scale3d
{
get { return _copterManager.scale3d ; }
set { _copterManager.scale3d = value;}
}
private int _CopterSum=100;
public int CopterSum
{

View File

@ -1155,7 +1155,8 @@ namespace Plane.FormationCreator.ViewModels
//循环3次 发送起飞命令 避免通信问题
for (int i = 0; i < 10; i++)
{
await _commModuleManager.DoMissionStartAsync(utchour,
await _commModuleManager.DoMissionStartAsync(_copterManager.Copters,
utchour,
utcminute,
utcsecond,
_flightTaskManager.OriginLng,
@ -1384,7 +1385,7 @@ namespace Plane.FormationCreator.ViewModels
}
}
var targetCopter = _copterManager.Copters.FirstOrDefault(o => o.VirtualId == (i+1));
bool result = await _commModuleManager.WriteMissionListAsync(short.Parse(targetCopter.Id), missions);
bool result = await _commModuleManager.WriteMissionListAsync(targetCopter, missions);
//CommWriteMissinState state = new CommWriteMissinState(result);
//_commModuleManager.missionWriteState.Add(int.Parse(_copterManager.Copters[i].Id), state);
if (!result)

View File

@ -24,7 +24,7 @@ namespace Plane.FormationCreator.ViewModels
{
private FlightTaskManager _flightTaskManager;
private CopterManager _copterManager;
private View3DManager _view3DManager = ServiceLocator.Current.GetInstance<View3DManager>();
public View3DViewModel(FlightTaskManager flightTaskManager, CopterManager copterManager)
@ -144,7 +144,7 @@ namespace Plane.FormationCreator.ViewModels
//meshBuilderwaypoint.AddTriangle(new Point3D(-0.1, -0.1, 0), new Point3D(0.1, -0.1, 0), new Point3D(0, 0.2, 0));
//飞机点的大小形状
meshBuilderwaypoint.AddSphere(new Point3D(0, 0, 0), 0.3);
meshBuilderwaypoint.AddSphere(new Point3D(0, 0, 0), 0.3* _copterManager.scale3d);
var meshwaypoint = meshBuilderwaypoint.ToMesh(true);
double y = GeographyUtils.CalcDistance(0, observationLatLng.Item1, 0, 0, copter.Latitude, 0) / 2;
@ -153,12 +153,17 @@ namespace Plane.FormationCreator.ViewModels
double x = GeographyUtils.CalcDistance(observationLatLng.Item2, 0, 0, copter.Longitude, 0, 0) / 2;
if (observationLatLng.Item2 > copter.Longitude) x = -x;
double z = copter.Altitude + 0.1;
x *= _copterManager.scale3d;
y *= _copterManager.scale3d;
z *= _copterManager.scale3d;
var model3D = new GeometryModel3D
{
Geometry = meshwaypoint,
Transform = new TranslateTransform3D(x, y, copter.Altitude + 0.1),
Transform = new TranslateTransform3D(x, y, z),
Material = MaterialHelper.CreateMaterial(Color.FromRgb(238, 210, 238)),
BackMaterial = MaterialHelper.CreateMaterial(Color.FromRgb(238, 210, 238))
};
@ -181,7 +186,9 @@ namespace Plane.FormationCreator.ViewModels
double z = Math.Round(copter.Altitude / 2, 2);
GeometryModel3D panle3D = planeModel3Ds[copter];
x *= _copterManager.scale3d;
y *= _copterManager.scale3d;
z *= _copterManager.scale3d;
if (x != panle3D.Transform.Value.OffsetX || y != panle3D.Transform.Value.OffsetY || z != panle3D.Transform.Value.OffsetZ)
{
panle3D.Transform = new TranslateTransform3D(x, y, z);
@ -208,7 +215,7 @@ namespace Plane.FormationCreator.ViewModels
private void SelectTask()
{
{
if (waypointGroup == null) waypointGroup = new Model3DGroup();
waypointGroup.Children.Clear();
if (_flightTaskManager.SelectedTaskIndex > 0)
@ -227,7 +234,8 @@ namespace Plane.FormationCreator.ViewModels
//modelGroup.Children.Clear();
var meshBuilderwaypoint = new MeshBuilder(false, false);
meshBuilderwaypoint.AddSphere(new Point3D(0, 0, 0), 0.2);
//航点的大小形状
meshBuilderwaypoint.AddSphere(new Point3D(0, 0, 0), 0.2* _copterManager.scale3d);
var meshwaypoint = meshBuilderwaypoint.ToMesh(true);
var greenMaterial = MaterialHelper.CreateMaterial(Color.FromRgb(0,255,0));
@ -239,12 +247,16 @@ namespace Plane.FormationCreator.ViewModels
double x = GeographyUtils.CalcDistance(observationLatLng.Item2, 0, 0, info.TargetLng, 0, 0)/2;
if (observationLatLng.Item2 > info.TargetLng) x = -x;
double z = info.TargetAlt / 2;
x *= _copterManager.scale3d;
y *= _copterManager.scale3d;
z *= _copterManager.scale3d;
waypointGroup.Children.Add(new GeometryModel3D
{
Geometry = meshwaypoint,
Transform = new TranslateTransform3D(x, y, info.TargetAlt/2),
Transform = new TranslateTransform3D(x, y, z),
Material = greenMaterial,
BackMaterial = greenMaterial
});

View File

@ -23,6 +23,9 @@
<RowDefinition Height="40" />
<RowDefinition Height="40" />
<RowDefinition Height="40" />
<RowDefinition Height="40" />
<RowDefinition Height="50" />
<RowDefinition Height="30" />
</Grid.RowDefinitions>
@ -35,23 +38,11 @@
<StackPanel Orientation="Horizontal"
HorizontalAlignment="Left"
Grid.Row="0"
Name="panel2" >
<TextBlock Margin="5" VerticalAlignment="Center" Text="总数:" />
<TextBox Width="45" VerticalContentAlignment="Center" Text="{Binding CopterSum}" Margin="5,5,5,5" />
<Button Content="设置总数" Width="90" Margin="5,5,5,5" Command="{Binding Path=SendCommand}" />
<Button Content="切换写航点" Width="90" Margin="5,5,5,5" Command="{Binding Path=ChangeWriteMissionCommand}" />
<Button Content="通信状态" Width="90" Margin="5,5,5,5" Command="{Binding StateInquireCommand}"/>
</StackPanel>
<StackPanel Orientation="Horizontal"
HorizontalAlignment="Left"
Grid.Row="1" >
Grid.Row="0" >
<TextBlock Margin="5" VerticalAlignment="Center" Text="ID:" />
<TextBox Width="30" VerticalContentAlignment="Center" Text="{Binding CopterNum}" Margin="5,5,5,5" />
<TextBlock Margin="5" VerticalAlignment="Center" Text="参数:" />
<TextBox Width="56" VerticalContentAlignment="Center" Text="{Binding CopterColor}" Margin="5,5,5,5"/>
<TextBox Width="56" VerticalContentAlignment="Center" Text="{Binding CopterColor}" Margin="5,5,5,5"/>
<Button Content="对频" Width="67" Margin="5,5,5,5" Command="{Binding Path=WriteIdCommand}" />
<Button Content="闪灯 " Width="67" Margin="5,5,5,5" Command="{Binding CommDataAsync}"/>
<Button Content="拉烟" Width="67" Margin="5,5,5,5" Command="{Binding TestFireCommandAsync}"/>
@ -59,16 +50,41 @@
</StackPanel>
<StackPanel Orientation="Horizontal"
HorizontalAlignment="Left"
Grid.Row="1"
Name="panel4" >
<Button Content="立体缩放" Width="90" Margin="5,5,5,5" Command="{Binding UpdateAllCopterCommand}"></Button>
<TextBlock Margin="5" VerticalAlignment="Center" Text="比例:" />
<TextBox Width="30" VerticalContentAlignment="Center" Text="{Binding scale3d}" Margin="5,5,5,5" />
</StackPanel>
<StackPanel Orientation="Horizontal"
HorizontalAlignment="Left"
Grid.Row="2"
Name="panel2" >
<TextBlock Margin="5" VerticalAlignment="Center" Text="总数:" />
<TextBox Width="45" VerticalContentAlignment="Center" Text="{Binding CopterSum}" Margin="5,5,5,5" />
<Button Content="设置总数" Width="90" Margin="5,5,5,5" Command="{Binding Path=SendCommand}" />
<Button Content="切换写航点" Width="90" Margin="5,5,5,5" Command="{Binding Path=ChangeWriteMissionCommand}" />
<Button Content="通信状态" Width="90" Margin="5,5,5,5" Command="{Binding StateInquireCommand}"/>
</StackPanel>
<StackPanel Orientation="Horizontal"
HorizontalAlignment="Left"
Grid.Row="3"
Name="panel3" >
<Button Content="空中升级" Width="90" Margin="5,5,5,5" Command="{Binding UpdateAllCopterCommand}"></Button>
<Button Content="搜索飞机" Width="90" Margin="5,5,5,5" Command="{Binding QueryAllCopterCommand}"/>
</StackPanel>
<Image Margin="0,0,0,0" x:Name="image1" Grid.RowSpan="2" Grid.Row="3" Source="/Resources/Logo_small.png" HorizontalAlignment="Left" />
<TextBlock Margin="5" Grid.Row="3" x:Name="about_ver" HorizontalAlignment="Right" VerticalAlignment="Bottom" Text="版本V2.0.1213" />
<TextBlock Margin="5" Grid.Row="4" HorizontalAlignment="Right" x:Name="about_buildtm" VerticalAlignment="Bottom" Text="编译日期2020.12.12" />
<Image Margin="0,0,0,0" x:Name="image1" Grid.RowSpan="2" Grid.Row="4" Source="/Resources/Logo_small.png" HorizontalAlignment="Left" />
<TextBlock Margin="5" Grid.Row="4" x:Name="about_ver" HorizontalAlignment="Right" VerticalAlignment="Bottom" Text="版本V2.0.1213" />
<TextBlock Margin="5" Grid.Row="5" HorizontalAlignment="Right" x:Name="about_buildtm" VerticalAlignment="Bottom" Text="编译日期2020.12.12" />