diff --git a/ViewModel/Configuration/AlgorithmConfigVM.cs b/ViewModel/Configuration/AlgorithmConfigVM.cs index be7de9c..86dfac2 100644 --- a/ViewModel/Configuration/AlgorithmConfigVM.cs +++ b/ViewModel/Configuration/AlgorithmConfigVM.cs @@ -1,4 +1,5 @@ using System.Data; +using System.IO; using System.Text; using System.Windows.Input; using HandyControl.Controls; @@ -44,20 +45,68 @@ public class AlgorithmConfigVM : BaseViewModel { try { - AlgorithmConfigJson = "{}"; - string sql = @"SELECT JSON as json FROM ALGORITHM_CONFIG ORDER BY JSON_ORDER"; - DataTable dataTable = DataBaseHelper.ExecuteQuery(sql); - StringBuilder sb = new StringBuilder(); - if (dataTable != null) + if (param == null) { - foreach (DataRow row in dataTable.Rows) + AlgorithmConfigJson = "{}"; + string sql = @"SELECT JSON as json FROM ALGORITHM_CONFIG ORDER BY JSON_ORDER"; + DataTable dataTable = DataBaseHelper.ExecuteQuery(sql); + StringBuilder sb = new StringBuilder(); + if (dataTable != null) { - sb.Append(row["json"].ToString()); + foreach (DataRow row in dataTable.Rows) + { + sb.Append(row["json"].ToString()); + } + } + if (sb.Length > 0) + { + AlgorithmConfigJson = JToken.Parse(sb.ToString()).ToString(); } } - if (sb.Length > 0) + else { - AlgorithmConfigJson = JToken.Parse(sb.ToString()).ToString(); + string[] types = param.ToString().Split(" "); + string filename = string.Empty; + if (types.Last().Equals("S4")) + { + filename = "p8p8s4.config"; + }else if (types.Last().Equals("S3")) + { + filename = "p8p8s3.config"; + }else if (types.Last().Equals("S2")) + { + filename = "p8p8s2.config"; + }else if (types.Last().Equals("S1")) + { + filename = "p8p8s1.config"; + }else + { + filename = "p8p8.config"; + } + string filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SparkCore", "config",filename); + if (!File.Exists(filePath)) + { + AlgorithmConfigJson = "{}"; + string sql = @"SELECT JSON as json FROM ALGORITHM_CONFIG ORDER BY JSON_ORDER"; + DataTable dataTable = DataBaseHelper.ExecuteQuery(sql); + StringBuilder sb = new StringBuilder(); + if (dataTable != null) + { + foreach (DataRow row in dataTable.Rows) + { + sb.Append(row["json"].ToString()); + } + } + if (sb.Length > 0) + { + AlgorithmConfigJson = JToken.Parse(sb.ToString()).ToString(); + } + } + else + { + string content = File.ReadAllText(filePath); + AlgorithmConfigJson = JToken.Parse(content).ToString(); + } } } catch (Exception ex) diff --git a/ViewModel/Grading/GradingLoadingVM.cs b/ViewModel/Grading/GradingLoadingVM.cs index 46bcc33..3563839 100644 --- a/ViewModel/Grading/GradingLoadingVM.cs +++ b/ViewModel/Grading/GradingLoadingVM.cs @@ -241,7 +241,7 @@ public class GradingLoadingVM : BaseViewModel,IDisposable //算法配置参数,初始化算法配置数据并获取 AlgorithmConfigJson var _algorithmConfigVM = new AlgorithmConfigVM(); - _algorithmConfigVM.InitAlgorithmData(null); + _algorithmConfigVM.InitAlgorithmData(_diamnondType); string algo_config = _algorithmConfigVM.AlgorithmConfigJson; string imageFileBasePath = string.Empty; diff --git a/Views/UserControl/Viewport3D.xaml.cs b/Views/UserControl/Viewport3D.xaml.cs index 407291c..7ee91fe 100644 --- a/Views/UserControl/Viewport3D.xaml.cs +++ b/Views/UserControl/Viewport3D.xaml.cs @@ -89,18 +89,16 @@ public partial class Viewport3D ViewportRightMenuShowDefectFace.IsChecked = false; //瑕疵面 ContextMenu.Items.Remove(ViewportRightMenuShowDefectFace); ViewportRightMenuShowLighting.IsChecked = false; //关灯 - + ViewportManager.DicValueParamToFacet.Clear(); if (ViewportManager.DiamondType.Split(" ").Contains("S1")) { //有效数据 - ViewportManager.DicValueParamToFacet.Clear(); ViewportManager.DicValueParamToFacet.Add("CROWN_ANGLE", PlaneType.CrownIncomplete); ViewportManager.DicValueParamToFacet.Add("CROWN_HEIGHT", PlaneType.CrownIncomplete); } if (ViewportManager.DiamondType.Split(" ").Contains("S2")) { //有效数据 - ViewportManager.DicValueParamToFacet.Clear(); ViewportManager.DicValueParamToFacet.Add("STAR_ANGLE", PlaneType.StarFacet); ViewportManager.DicValueParamToFacet.Add("STAR", PlaneType.StarFacet); }