|
|
using DevExpress.XtraEditors;
|
|
|
using DevExpress.XtraRichEdit.Import.Html;
|
|
|
using GeoSigmaDrawLib;
|
|
|
using MeshProcess;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.ComponentModel;
|
|
|
using System.Drawing;
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
namespace KepGridEditor
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// The form well adjust setting.
|
|
|
/// </summary>
|
|
|
public partial class FormWellAdjustSetting : DevExpress.XtraEditors.XtraForm
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// Gets or sets the well radius.
|
|
|
/// </summary>
|
|
|
public double WellRadius { get; set; } = 100;
|
|
|
/// <summary>
|
|
|
/// Gets or sets the value range.
|
|
|
/// </summary>
|
|
|
public double ValueRange { get; set; } = 10;
|
|
|
/// <summary>
|
|
|
/// Gets or sets the decreasing factor.
|
|
|
/// </summary>
|
|
|
public double DecreasingFactor { get; set; } = 0;
|
|
|
/// <summary>
|
|
|
/// Gets or sets the dilution factor (for RBF/IDW mode).
|
|
|
/// </summary>
|
|
|
public double DilutionFactor { get; set; } = 1.0;
|
|
|
|
|
|
/// <summary>
|
|
|
/// Gets the currently selected mode.
|
|
|
/// </summary>
|
|
|
public string SelectedMode => comboBoxEditMode.EditValue?.ToString() ?? "默认";
|
|
|
|
|
|
// 通用参数:羽化宽度
|
|
|
public int FeatherWidth
|
|
|
{
|
|
|
get => int.TryParse(txtFeatherWidth.Text, out int val) ? val : 0;
|
|
|
set => txtFeatherWidth.Text = value.ToString();
|
|
|
}
|
|
|
|
|
|
// 平滑区域 (0:无, 1:内, 2:外)
|
|
|
public int SmoothRegionIndex
|
|
|
{
|
|
|
get => rdoSmoothRegion.SelectedIndex;
|
|
|
set => rdoSmoothRegion.SelectedIndex = value;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 井点数据
|
|
|
/// </summary>
|
|
|
private BindingList<WellPointData> PointDatas = new BindingList<WellPointData>(); // 原始数据
|
|
|
|
|
|
/// <summary>
|
|
|
/// 用于存储选中的井点数据
|
|
|
/// </summary>
|
|
|
public List<PointDataInterop> SelectedWellPoints { get; private set; } = new List<PointDataInterop>();
|
|
|
|
|
|
/// <summary>
|
|
|
/// Initializes a new instance of the <see cref="FormWellAdjustSetting"/> class.
|
|
|
/// </summary>
|
|
|
public FormWellAdjustSetting()
|
|
|
{
|
|
|
InitializeComponent();
|
|
|
|
|
|
// 在窗体加载后初始化界面状态
|
|
|
this.Load += FormWellAdjustSetting_Load;
|
|
|
|
|
|
// 初始化文本框显示
|
|
|
this.txtRadius.Text = $"{WellRadius}";
|
|
|
this.txtDiffrence.Text = $"{ValueRange}";
|
|
|
this.txtFactor.Text = $"{DecreasingFactor}";
|
|
|
this.textEditDilution.Text = $"{DilutionFactor}";
|
|
|
|
|
|
this.gridControl.DataSource = PointDatas;
|
|
|
|
|
|
gridView.OptionsSelection.MultiSelect = true;
|
|
|
gridView.OptionsSelection.MultiSelectMode = DevExpress.XtraGrid.Views.Grid.GridMultiSelectMode.CheckBoxRowSelect;
|
|
|
gridView.OptionsSelection.CheckBoxSelectorColumnWidth = 30;
|
|
|
gridView.OptionsSelection.ShowCheckBoxSelectorInColumnHeader = DevExpress.Utils.DefaultBoolean.True;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// Initializes a new instance of the <see cref="FormWellAdjustSetting"/> class with initial values.
|
|
|
/// </summary>
|
|
|
/// <param name="wellRadius">The well radius.</param>
|
|
|
/// <param name="valueRange">The value range.</param>
|
|
|
/// <param name="decreasingFactor">The decreasing factor.</param>
|
|
|
public FormWellAdjustSetting(double wellRadius, double valueRange, double decreasingFactor)
|
|
|
: this()
|
|
|
{
|
|
|
this.WellRadius = wellRadius;
|
|
|
this.ValueRange = valueRange;
|
|
|
this.DecreasingFactor = decreasingFactor;
|
|
|
|
|
|
this.txtRadius.Text = $"{WellRadius}";
|
|
|
this.txtDiffrence.Text = $"{ValueRange}";
|
|
|
this.txtFactor.Text = $"{this.DecreasingFactor}";
|
|
|
}
|
|
|
|
|
|
public void LoadData(List<double> xList, List<double> yList, List<double> zList, List<double> tzList, List<string> nameList)
|
|
|
{
|
|
|
PointDatas.Clear();
|
|
|
|
|
|
int count = xList.Count;
|
|
|
if (yList.Count < count) count = yList.Count;
|
|
|
if (zList.Count < count) count = zList.Count;
|
|
|
// tzList 可能为空或长度不同,根据业务逻辑处理
|
|
|
|
|
|
for (int i = 0; i < count; i++)
|
|
|
{
|
|
|
string name = (nameList != null && i < nameList.Count) ? nameList[i] : $"井{i + 1}";
|
|
|
double tx = xList[i];
|
|
|
double ty = yList[i];
|
|
|
double tz = zList[i]; // 真实Z
|
|
|
double ttz = (tzList != null && i < tzList.Count) ? tzList[i] : 0; // 图Z
|
|
|
|
|
|
PointDatas.Add(new WellPointData
|
|
|
{
|
|
|
Name = name,
|
|
|
X = tx,
|
|
|
Y = ty,
|
|
|
Z = tz,
|
|
|
TZ = ttz
|
|
|
// Error 属性会自动计算,不需要手动赋值
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 刷新表格
|
|
|
gridControl.RefreshDataSource();
|
|
|
gridView.SelectAll();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 窗体加载事件:设置默认选项并更新UI
|
|
|
/// </summary>
|
|
|
private void FormWellAdjustSetting_Load(object sender, EventArgs e)
|
|
|
{
|
|
|
if (comboBoxEditMode.Properties.Items.Contains("默认"))
|
|
|
{
|
|
|
comboBoxEditMode.EditValue = "默认";
|
|
|
UpdateUIForCurrentMode();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 根据当前选择的模式,更新控件的启用状态
|
|
|
/// </summary>
|
|
|
private void UpdateUIForCurrentMode()
|
|
|
{
|
|
|
string mode = SelectedMode;
|
|
|
|
|
|
bool isDefault = mode == "默认";
|
|
|
bool isRfbOrIdw = (mode == "RBF" || mode == "IDW");
|
|
|
|
|
|
// --- 默认模式:启用前三个参数 ---
|
|
|
txtRadius.Enabled = isDefault;
|
|
|
txtFactor.Enabled = isDefault;
|
|
|
labelControl1.Enabled = isDefault;
|
|
|
labelControl3.Enabled = isDefault;
|
|
|
|
|
|
// --- RBF / IDW 模式:仅启用抽稀倍数 ---
|
|
|
textEditDilution.Enabled = isRfbOrIdw;
|
|
|
labelControl4.Enabled = isRfbOrIdw;
|
|
|
|
|
|
// 可选:让非活动控件看起来更不显眼
|
|
|
txtRadius.Properties.Appearance.BackColor = isDefault ? SystemColors.Window : SystemColors.Control;
|
|
|
txtFactor.Properties.Appearance.BackColor = isDefault ? SystemColors.Window : SystemColors.Control;
|
|
|
textEditDilution.Properties.Appearance.BackColor = isRfbOrIdw ? SystemColors.Window : SystemColors.Control;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 当算法模式改变时,更新界面控件的可用性
|
|
|
/// </summary>
|
|
|
private void comboBoxEditMode_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
{
|
|
|
UpdateUIForCurrentMode();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 确定按钮点击事件
|
|
|
/// </summary>
|
|
|
private void btnOK_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
SelectedWellPoints.Clear();
|
|
|
int[] selectedRows = gridView.GetSelectedRows();
|
|
|
if (selectedRows != null && selectedRows.Length > 0)
|
|
|
{
|
|
|
foreach (int rowHandle in selectedRows)
|
|
|
{
|
|
|
if (rowHandle >= 0)
|
|
|
{
|
|
|
var rowData = gridView.GetRow(rowHandle) as WellPointData;
|
|
|
if (rowData != null)
|
|
|
{
|
|
|
PointDataInterop interopPoint = new PointDataInterop();
|
|
|
|
|
|
// 赋值属性
|
|
|
interopPoint.Name = rowData.Name;
|
|
|
interopPoint.X = rowData.X;
|
|
|
interopPoint.Y = rowData.Y;
|
|
|
interopPoint.Z = rowData.Z;
|
|
|
interopPoint.TZ = rowData.TZ;
|
|
|
SelectedWellPoints.Add(interopPoint);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
string mode = SelectedMode;
|
|
|
|
|
|
if (mode == "默认")
|
|
|
{
|
|
|
this.WellRadius = Convert.ToDouble(this.txtRadius.Text);
|
|
|
this.ValueRange = Convert.ToDouble(this.txtDiffrence.Text);
|
|
|
this.DecreasingFactor = Convert.ToDouble(this.txtFactor.Text);
|
|
|
DilutionFactor = 0; // 不使用
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
// RBF 或 IDW 模式:只读取抽稀倍数
|
|
|
if (!double.TryParse(textEditDilution.Text.Trim(), out double dilution) || dilution < 1)
|
|
|
throw new ArgumentException($"【{mode}抽稀倍数】必须是大于1的数值。");
|
|
|
|
|
|
// 保存结果
|
|
|
DilutionFactor = dilution;
|
|
|
// 其他参数不保存或设为默认
|
|
|
this.ValueRange = Convert.ToDouble(this.txtDiffrence.Text);
|
|
|
DecreasingFactor = 0;
|
|
|
}
|
|
|
|
|
|
this.DialogResult = DialogResult.OK;
|
|
|
this.Close();
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
XtraMessageBox.Show(ex.Message, "输入错误", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 取消按钮点击事件
|
|
|
/// </summary>
|
|
|
private void btnCancel_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
this.DialogResult = DialogResult.Cancel;
|
|
|
this.Close();
|
|
|
}
|
|
|
}
|
|
|
} |