feat: 面信息 - 需要检测结果实体变更

master
tongg 7 months ago
parent 7893c09262
commit 9452aca780
  1. 1
      SparkClient.sln.DotSettings.user
  2. 8
      ViewModel/Grading/GradingResultVM.cs
  3. 92
      Views/UserControl/ViewportData/Helper/ViewportHelperPro.cs
  4. 15
      Views/UserControl/ViewportData/Helper/ViewportManager.cs

@ -38,6 +38,7 @@
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AMethodBaseInvoker_002Ecs_002Fl_003AC_0021_003FUsers_003FAdministrator_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FSourcesCache_003Fd882146b4f265f10bcbec2663fce248db9ffec5fa1aeaf76e32a11ba5eafcd6_003FMethodBaseInvoker_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ARoutedEventArgs_002Ecs_002Fl_003AC_0021_003FUsers_003Ftongg_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FSourcesCache_003F1a88b4a860176dd5f825206bbebf3ee3d44ff3f058ceed9eb693c1eaa018_003FRoutedEventArgs_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ARuntimeType_002ECoreCLR_002Ecs_002Fl_003AC_0021_003FUsers_003Ftongg_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FSourcesCache_003F955ec549fe664629353c3b5424b6ad6c7dfcec4ab59bae709ab962c228cf45_003FRuntimeType_002ECoreCLR_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ARuntimeType_002Ecs_002Fl_003AC_0021_003FUsers_003Ftongg_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F5147b10c5a8c4522b56fba0a889139cfc8f908_003F45_003F2a5f113e_003FRuntimeType_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ASqliteCommand_002Ecs_002Fl_003AC_0021_003FUsers_003Ftongg_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fc7a59cb727594ed7a94648b2d66dbf702aa28_003F2f_003Fdc5f3094_003FSqliteCommand_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ATaskCompletionSource_00601_002Ecs_002Fl_003AC_0021_003FUsers_003Ftongg_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F5147b10c5a8c4522b56fba0a889139cfc8f908_003Ffc_003Fe9092391_003FTaskCompletionSource_00601_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ATextInfo_002Ecs_002Fl_003AC_0021_003FUsers_003Ftongg_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F68d37d16685244cf9996bf767117a771210200_003F3a_003Ff14dd285_003FTextInfo_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>

@ -19,6 +19,8 @@ using System.Windows;
using SharpDX;
using SparkClient.Views.UserControl.ViewportData.Entity;
using SparkClient.ViewModel.Configuration.SettingsPages;
using SparkClient.Views.UserControl.ViewportData.Helper;
namespace SparkClient.ViewModel.Grading;
public class GradingResultVM : BaseViewModel
@ -105,10 +107,10 @@ public class GradingResultVM : BaseViewModel
colorProperty.Add("TABLE_FACET_COLOR", "TableFacetColor");
colorProperty.Add("UPPER_MAIN_FACET_COLOR", "UpperMainFacetColor");
colorProperty.Add("STAR_FACET_COLOR", "StarFacetColor");
colorProperty.Add("UPPER_GIRDLE_FACET_COLOR", "UpperGridleFacetColor");
colorProperty.Add("UPPER_GIRDLE_FACET_COLOR", "UpperGirdleFacetColor");
colorProperty.Add("GIRDLE_FACET_COLOR", "GirdleFacetColor");
colorProperty.Add("PAVILION_MAIN_FACET_COLOR", "PavilionFacetColor");
colorProperty.Add("LOWER_GIRDLE_FACET_COLOR", "LowerGridleFacetColor");
colorProperty.Add("LOWER_GIRDLE_FACET_COLOR", "LowerGirdleFacetColor");
colorProperty.Add("CULET_COLOR", "CuletFacetColor");
ColorConfigEntity colorConfigEntity = new ColorConfigEntity();
@ -119,7 +121,7 @@ public class GradingResultVM : BaseViewModel
PropertyInfo? p = type.GetProperty(property.Value);
if (p != null && !string.IsNullOrEmpty(value))
{
p.SetValue(colorConfigEntity, value);
p.SetValue(colorConfigEntity, CommonHelper.HexToColor4(value));
}
}
string data = JsonConvert.SerializeObject(result);

@ -10,6 +10,7 @@ using System.Windows.Media.Imaging;
using System.Windows.Media.Media3D;
using System.Windows.Threading;
using HelixToolkit.Wpf.SharpDX;
using log4net;
using NPOI.OpenXmlFormats.Vml.Office;
using SharpDX;
using SharpDX.Direct3D11;
@ -23,6 +24,7 @@ namespace SparkClient.Views.UserControl.ViewportData.Helper;
public class ViewportHelperPro
{
private static readonly ILog Logger = LogManager.GetLogger(typeof(ViewportHelperPro));
/// <summary>
/// 对指定类型的面进行标色
/// </summary>
@ -421,6 +423,24 @@ public class ViewportHelperPro
return result;
}
public static List<GeometryModel3D> GenerateLineTextModelsByType(string type, Color4? textColor = null,
bool showAll = false)
{
var planType = ViewportManager.DicValueParamToFacet[type];
List<Viewport3DTriangleEntity> entities = new List<Viewport3DTriangleEntity>();
string planCode = "";
ViewportManager.ViewportTriangle.ForEach(e =>
{
if (e.PlaneType == planType && (e.PlaneCode==planCode || string.IsNullOrEmpty(planCode)))
{
planCode = e.PlaneCode;
entities.Add(e);
}
});
return GenerateLineTextModels(entities, textColor, showAll);
}
/// <summary>
/// 显示线段长度mm
/// </summary>
@ -431,43 +451,91 @@ public class ViewportHelperPro
public static List<GeometryModel3D> GenerateLineTextModels(List<Viewport3DTriangleEntity> entities,
Color4? textColor = null,bool showAll = false)
{
Logger.Info("【面文本生成】开始生成面相关文本信息");
var selFacet = entities;
var selFacetType = entities.First().PlaneType;
var result = new List<GeometryModel3D>();
if (selFacetType == PlaneType.Girdle)
{
if (ViewportManager.MainModelGirdleMaxLines != null || ViewportManager.MainModelGirdleMinLines != null ||
ViewportManager.MainModelGirdleAvgLines != null)
Logger.Info($"【面文本生成】 命中面{selFacetType},是腰");
// if (ViewportManager.MainModelGirdleMaxLines != null || ViewportManager.MainModelGirdleMinLines != null ||
// ViewportManager.MainModelGirdleAvgLines != null)
// {
// result.Add(DisplayLineModel3D(new List<Tuple<Vector3,Vector3>>(){ViewportManager.MainModelGirdleMaxLines}, new Color4(1f, 0, 0, 1f) ));
// result.Add(DisplayLineModel3D(new List<Tuple<Vector3,Vector3>>(){ViewportManager.MainModelGirdleMinLines}, new Color4(0f, 1f, 0, 1f) ));
// result.Add(DisplayLineModel3D(new List<Tuple<Vector3,Vector3>>(){ViewportManager.MainModelGirdleAvgLines}, new Color4(1f, 0.5f, 0, 1f) ));
// result.Add(DisplayText3D($"{CalculateLength(ViewportManager.MainModelGirdleMaxLines)}mm", ViewportManager.MainModelGirdleMaxLines.Item1, textColor));
// result.Add(DisplayText3D($"{CalculateLength(ViewportManager.MainModelGirdleMinLines)}mm", ViewportManager.MainModelGirdleMinLines.Item1, textColor));
// result.Add(DisplayText3D($"{CalculateLength(ViewportManager.MainModelGirdleAvgLines)}mm", ViewportManager.MainModelGirdleAvgLines.Item1, textColor));
// }
List<Viewport3DTriangleEntity> facetTypeAll =
ViewportManager.ViewportTriangle.FindAll(e => e.PlaneType == selFacetType);
var groupedDic = facetTypeAll.GroupBy(entity => entity.PlaneCode)
.ToDictionary(group => group.Key, group => group.ToList());
Logger.Info($"【面文本生成】 腰由{groupedDic.Count}个面组成");
foreach (var kv in groupedDic)
{
result.Add(DisplayLineModel3D(new List<Tuple<Vector3,Vector3>>(){ViewportManager.MainModelGirdleMaxLines}, new Color4(1f, 0, 0, 1f) ));
result.Add(DisplayLineModel3D(new List<Tuple<Vector3,Vector3>>(){ViewportManager.MainModelGirdleMinLines}, new Color4(0f, 1f, 0, 1f) ));
result.Add(DisplayLineModel3D(new List<Tuple<Vector3,Vector3>>(){ViewportManager.MainModelGirdleAvgLines}, new Color4(1f, 0.5f, 0, 1f) ));
result.Add(DisplayText3D($"{CalculateLength(ViewportManager.MainModelGirdleMaxLines)}mm", ViewportManager.MainModelGirdleMaxLines.Item1, textColor));
result.Add(DisplayText3D($"{CalculateLength(ViewportManager.MainModelGirdleMinLines)}mm", ViewportManager.MainModelGirdleMinLines.Item1, textColor));
result.Add(DisplayText3D($"{CalculateLength(ViewportManager.MainModelGirdleAvgLines)}mm", ViewportManager.MainModelGirdleAvgLines.Item1, textColor));
var value = kv.Value;
var key = kv.Key;
var facetIndex = -1;
int.TryParse(key.Split("_")[1], out facetIndex);
List<Vector3> facetPoints = new List<Vector3>();
value.ForEach(e => { facetPoints.Add(e.Point1); facetPoints.Add(e.Point2); facetPoints.Add(e.Point3); });
/***
* 0 1 2 3
* 4 5 6 7
* id-loop4 = 0 - 线 - -
* id-loop4 = 1 - 线 -
* id-loop4 = 2 - 线 -
* id-loop4 = 3 - 线 -
*/
}
}
else
{
Logger.Info($"【面文本生成】 命中面{selFacetType},不是腰");
//查找同类面
List<Viewport3DTriangleEntity> facetTypeAll =
ViewportManager.ViewportTriangle.FindAll(e => e.PlaneType == selFacetType);
var groupedDic = facetTypeAll.GroupBy(entity => entity.PlaneCode)
.ToDictionary(group => group.Key, group => group.ToList());
Logger.Info($"【面文本生成】 同类面{groupedDic.Count}个");
foreach (var kv in groupedDic)
{
var value = kv.Value;
var key = kv.Key;
var facetIndex = key.Split("_")[1];
var facetIndex = -1;
int.TryParse(key.Split("_")[1], out facetIndex);
List<Vector3> facetPoints = new List<Vector3>();
value.ForEach(e => { facetPoints.Add(e.Point1); facetPoints.Add(e.Point2); facetPoints.Add(e.Point3); });
if (ViewportManager.DiamondData.Count > 1 && facetIndex != -1)
{
Logger.Info($"【面文本生成】 钻石数据有效,Index有效");
facetIndex += 1;
var param = ViewportManager.DicFacetToValueParam[selFacetType];
var detail = ViewportManager.DiamondData[$"{param}_DETAIL"];
if (detail == null)
{
Logger.Info($"【面文本生成】 {param}_DETAIL Key不存在");
continue;
}
Logger.Info($"【面文本生成】 {param}_DETAIL == {detail}");
var paramValue = detail[$"{param}_{facetIndex}"];
if (paramValue == null)
{
Logger.Info($"【面文本生成】 {param}_DETAIL.{param}_{facetIndex} Key不存在");
continue;
}
Logger.Info($"【面文本生成】 {param}_DETAIL.{param}_{facetIndex} ==={paramValue}");
var valueFloat = Math.Round(float.Parse(paramValue.ToString()), MidpointRounding.ToZero);
Logger.Info($"【面文本生成】 {valueFloat} -- {facetIndex}");
var facetTextPoint = GetOffsetCenter(facetPoints, ViewportManager.CenterVector);
result.Add(DisplayText3D($"{key.Split("_")[1]} \r\n 12334", facetTextPoint, textColor));
result.Add(DisplayText3D($" {facetIndex} \r\n {valueFloat}", facetTextPoint, textColor));
}
}
/***

@ -134,6 +134,21 @@ public class ViewportManager
}
ChooseAddModels.Clear();
}
#region 面 - 数据固定绑定
// 选中面 -> 数据
public static Dictionary<PlaneType, string> DicFacetToValueParam = new Dictionary<PlaneType, string>()
{
{ PlaneType.UpperMainFacet,"CROWN_ANGLE"},
{ PlaneType.LowerGirdleFact, "PAV_ANGLE"},
};
// 数据 -> 面
public static Dictionary<string, PlaneType> DicValueParamToFacet = new Dictionary<string, PlaneType>()
{
{"CROWN_ANGLE", PlaneType.UpperMainFacet},
{"PAV_ANGLE", PlaneType.LowerGirdleFact},
};
#endregion
#endregion
#region 统一控制方法

Loading…
Cancel
Save