master
Tongg 9 months ago
parent 93f7836aaf
commit 5f751bbcb5
  1. 67
      ViewModel/Configuration/AlgorithmConfigVM.cs
  2. 2
      ViewModel/Grading/GradingLoadingVM.cs
  3. 4
      Views/UserControl/Viewport3D.xaml.cs

@ -1,4 +1,5 @@
using System.Data; using System.Data;
using System.IO;
using System.Text; using System.Text;
using System.Windows.Input; using System.Windows.Input;
using HandyControl.Controls; using HandyControl.Controls;
@ -44,20 +45,68 @@ public class AlgorithmConfigVM : BaseViewModel
{ {
try try
{ {
AlgorithmConfigJson = "{}"; if (param == null)
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) 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) catch (Exception ex)

@ -241,7 +241,7 @@ public class GradingLoadingVM : BaseViewModel,IDisposable
//算法配置参数,初始化算法配置数据并获取 AlgorithmConfigJson //算法配置参数,初始化算法配置数据并获取 AlgorithmConfigJson
var _algorithmConfigVM = new AlgorithmConfigVM(); var _algorithmConfigVM = new AlgorithmConfigVM();
_algorithmConfigVM.InitAlgorithmData(null); _algorithmConfigVM.InitAlgorithmData(_diamnondType);
string algo_config = _algorithmConfigVM.AlgorithmConfigJson; string algo_config = _algorithmConfigVM.AlgorithmConfigJson;
string imageFileBasePath = string.Empty; string imageFileBasePath = string.Empty;

@ -89,18 +89,16 @@ public partial class Viewport3D
ViewportRightMenuShowDefectFace.IsChecked = false; //瑕疵面 ViewportRightMenuShowDefectFace.IsChecked = false; //瑕疵面
ContextMenu.Items.Remove(ViewportRightMenuShowDefectFace); ContextMenu.Items.Remove(ViewportRightMenuShowDefectFace);
ViewportRightMenuShowLighting.IsChecked = false; //关灯 ViewportRightMenuShowLighting.IsChecked = false; //关灯
ViewportManager.DicValueParamToFacet.Clear();
if (ViewportManager.DiamondType.Split(" ").Contains("S1")) if (ViewportManager.DiamondType.Split(" ").Contains("S1"))
{ {
//有效数据 //有效数据
ViewportManager.DicValueParamToFacet.Clear();
ViewportManager.DicValueParamToFacet.Add("CROWN_ANGLE", PlaneType.CrownIncomplete); ViewportManager.DicValueParamToFacet.Add("CROWN_ANGLE", PlaneType.CrownIncomplete);
ViewportManager.DicValueParamToFacet.Add("CROWN_HEIGHT", PlaneType.CrownIncomplete); ViewportManager.DicValueParamToFacet.Add("CROWN_HEIGHT", PlaneType.CrownIncomplete);
} }
if (ViewportManager.DiamondType.Split(" ").Contains("S2")) if (ViewportManager.DiamondType.Split(" ").Contains("S2"))
{ {
//有效数据 //有效数据
ViewportManager.DicValueParamToFacet.Clear();
ViewportManager.DicValueParamToFacet.Add("STAR_ANGLE", PlaneType.StarFacet); ViewportManager.DicValueParamToFacet.Add("STAR_ANGLE", PlaneType.StarFacet);
ViewportManager.DicValueParamToFacet.Add("STAR", PlaneType.StarFacet); ViewportManager.DicValueParamToFacet.Add("STAR", PlaneType.StarFacet);
} }

Loading…
Cancel
Save