You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1472 lines
45 KiB
C#

1 month ago
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Design;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using DevExpress.Utils.UI;
using DevExpress.XtraEditors.Repository;
using GeoSigma;
using GeoSigma.SigmaDrawerStyle;
using GeoSigma.SigmaDrawerUtil;
using GeoSigmaDrawLib;
using Newtonsoft.Json;
using SigmaDrawerStyle;
namespace SigmaDrawerElement
{
/// <summary>
/// 三维场景的属性
/// </summary>
[Serializable]
public class VtkScene
{
/*
/// <summary>
/// 属性改变事件
/// </summary>
public event PropertyChangedEventHandler PropertyChanged;
/// <summary>
/// 属性改变事件
/// </summary>
/// <param name="propertyName"></param>
protected virtual void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
*/
private Color backgroundColor = Color.Black;
/// <summary>
/// 背景颜色
/// </summary>
[Category("常规"), DisplayName("背景颜色"), ReadOnly(false), PropertyOrder(10)]
[Editor(typeof(PropertyEditorColor), typeof(UITypeEditor))]
public Color BackgroundColor
{
get
{
return backgroundColor;
}
set
{
if (backgroundColor != value)
{
backgroundColor = value;
//OnPropertyChanged(nameof(BackgroundColor));
}
}
}
private double zScale = 10f;
/// <summary>
/// 垂直比例
/// </summary>
[Category("常规"), DisplayName("垂直比例"), ReadOnly(false), PropertyOrder(20)]
public double ZScale
{
get
{
return zScale;
}
set
{
if (zScale != value)
{
zScale = value;
//OnPropertyChanged(nameof(ZScale));
}
}
}
private double zMaxScale = 100f;
/// <summary>
/// 垂直比例
/// </summary>
[Category("常规"), DisplayName("最大垂直比例"), ReadOnly(false), PropertyOrder(21)]
public double ZMaxScale
{
get
{
return zMaxScale;
}
set
{
if (zMaxScale != value)
{
zMaxScale = value;
//OnPropertyChanged(nameof(ZScale));
}
}
}
private bool showCoordinateGrid = false;
/// <summary>
/// 坐标网
/// </summary>
[Category("常规"), DisplayName("坐标网"), ReadOnly(false), PropertyOrder(30)]
[TypeConverter(typeof(GeoSigma.SigmaDrawerStyle.Converter.YesNoConverter))]
public bool ShowCoordinateGrid
{
get
{
return showCoordinateGrid;
}
set
{
if (showCoordinateGrid != value)
{
showCoordinateGrid = value;
//OnPropertyChanged(nameof(ShowCoordinateGrid));
}
}
}
private bool showCoordinateGridLine = true;
/// <summary>
/// 显示坐标网网格线
/// </summary>
[Category("常规"), DisplayName("坐标网网格线"), ReadOnly(false), PropertyOrder(31)]
[TypeConverter(typeof(GeoSigma.SigmaDrawerStyle.Converter.YesNoConverter))]
public bool ShowCoordinateGridLine
{
get
{
return showCoordinateGridLine;
}
set
{
if (showCoordinateGridLine != value)
{
showCoordinateGridLine = value;
//OnPropertyChanged(nameof(ShowCoordinateGridLine));
}
}
}
private bool showScalarBar = false;
/// <summary>
/// 颜色标尺
/// </summary>
[Category("常规"), DisplayName("颜色标尺"), ReadOnly(false), PropertyOrder(33)]
[TypeConverter(typeof(GeoSigma.SigmaDrawerStyle.Converter.YesNoConverter))]
public bool ShowScalarBar
{
get
{
return showScalarBar;
}
set
{
if (showScalarBar != value)
{
showScalarBar = value;
//OnPropertyChanged(nameof(ShowScalarBar));
}
}
}
private FaultModeEnum faultMode = SigmaDrawerElement.FaultModeEnum.;
/// <summary>
/// 井显示模式
/// </summary>
[Category("常规"), DisplayName("断面显示"), ReadOnly(false), Browsable(true), PropertyOrder(34)]
public FaultModeEnum FaultMode
{
get
{
return faultMode;
}
set
{
if (faultMode != value)
{
faultMode = value;
//OnPropertyChanged(nameof(FaultModeEnum));
}
}
}
private bool singularValueFilterFlag = false;
/// <summary>
/// 颜色标尺
/// </summary>
[Category("常规"), DisplayName("面角度过滤"), ReadOnly(false), PropertyOrder(35)]
[TypeConverter(typeof(GeoSigma.SigmaDrawerStyle.Converter.YesNoConverter))]
public bool SingularValueFilterFlag
{
get
{
return singularValueFilterFlag;
}
set
{
if (singularValueFilterFlag != value)
{
singularValueFilterFlag = value;
//OnPropertyChanged(nameof(SingularValueFilterFlag));
}
}
}
private int singularThreshold = 65;
/// <summary>
/// 颜色标尺
/// </summary>
[Category("常规"), DisplayName("面角度最大值"), ReadOnly(false), PropertyOrder(37)]
public int SingularThreshold
{
get
{
return singularThreshold;
}
set
{
if (singularThreshold != value)
{
singularThreshold = value;
//OnPropertyChanged(nameof(SingularThreshold));
}
}
}
private bool showMeshEdge = true;
/// <summary>
/// 网格包围
/// </summary>
[Category("网格包围"), DisplayName("网格包围"), ReadOnly(false), PropertyOrder(51)]
[TypeConverter(typeof(GeoSigma.SigmaDrawerStyle.Converter.YesNoConverter))]
public bool ShowMeshEdge
{
get
{
return showMeshEdge;
}
set
{
if (showMeshEdge != value)
{
showMeshEdge = value;
//OnPropertyChanged(nameof(ShowMeshEdge));
}
}
}
private MeshEdgeModeEnum meshEdgeMode = SigmaDrawerElement.MeshEdgeModeEnum.;
/// <summary>
/// 网格包围模式
/// </summary>
[Category("网格包围"), DisplayName("网格包围模式"), ReadOnly(false), Browsable(true), PropertyOrder(53)]
public MeshEdgeModeEnum MeshEdgeMode
{
get
{
return meshEdgeMode;
}
set
{
if (meshEdgeMode != value)
{
meshEdgeMode = value;
//OnPropertyChanged(nameof(MeshEdgeMode));
}
}
}
private Color meshEdgeColor = Color.SeaGreen;
/// <summary>
/// 网格包围颜色
/// </summary>
[Category("网格包围"), DisplayName("网格包围颜色"), ReadOnly(false), PropertyOrder(55)]
[Editor(typeof(PropertyEditorColor), typeof(UITypeEditor))]
public Color MeshEdgeColor
{
get
{
return meshEdgeColor;
}
set
{
if (meshEdgeColor != value)
{
meshEdgeColor = value;
//OnPropertyChanged(nameof(MeshEdgeColor));
}
}
}
/// <summary>
/// 厚度
/// </summary>
[Category("网格包围"), DisplayName("垂向厚度"), ReadOnly(false), Browsable(true), PropertyOrder(57)]
public int Thickness { get; set; } = 300;
private bool showMeshEdgeColorGradient = false;
/// <summary>
/// 网格裙边颜色渐变
/// </summary>
[Category("网格包围"), DisplayName("网格包围颜色渐变"), ReadOnly(false), PropertyOrder(58)]
[TypeConverter(typeof(GeoSigma.SigmaDrawerStyle.Converter.YesNoConverter))]
public bool ShowMeshEdgeColorGradient
{
get
{
return showMeshEdgeColorGradient;
}
set
{
if (showMeshEdgeColorGradient != value)
{
showMeshEdgeColorGradient = value;
//OnPropertyChanged(nameof(ShowMeshEdgeColorGradient));
}
}
}
private LightModeEnum lightMode = SigmaDrawerElement.LightModeEnum.;
/// <summary>
/// 光照模式
/// </summary>
[Category("灯光"), DisplayName("灯光模式"), ReadOnly(false), Browsable(true), PropertyOrder(80)]
public LightModeEnum LightMode
{
get
{
return lightMode;
}
set
{
if (lightMode != value)
{
lightMode = value;
//OnPropertyChanged(nameof(LightMode));
}
}
}
private int lightIntensity = 70;
/// <summary>
/// 灯光强度
/// </summary>
[Category("灯光"), DisplayName("灯光强度"), ReadOnly(false), Browsable(true), PropertyOrder(81)]
public int LightIntensity
{
get
{
return lightIntensity;
}
set
{
if (lightIntensity != value)
{
lightIntensity = value;
//OnPropertyChanged(nameof(LightIntensity));
}
}
}
private Color lightColor = Color.White;
/// <summary>
/// 灯光颜色
/// </summary>
[Category("灯光"), DisplayName("灯光颜色"), ReadOnly(false), Browsable(true), PropertyOrder(83)]
[Editor(typeof(PropertyEditorColor), typeof(UITypeEditor))]
[TypeConverter(typeof(PropertyColorIndicatorConvert))]
public Color LightColor
{
get
{
return lightColor;
}
set
{
lightColor = value;
LightDiffusedCorlor = value;
LightSpecularColor = value;
//OnPropertyChanged(nameof(LightColor));
}
}
private double lightElevation = -60;
/// <summary>
/// 水平方位角
/// </summary>
[Category("灯光"), DisplayName("灯光仰角"), ReadOnly(false), Browsable(true), PropertyOrder(85)]
public double LightElevation
{
get
{
return lightElevation;
}
set
{
if (lightElevation != value)
{
lightElevation = value;
//OnPropertyChanged(nameof(LightElevation));
}
}
}
private double lightAzimuth = -30;
/// <summary>
/// 垂直方位角
/// </summary>
[Category("灯光"), DisplayName("灯光方位角"), ReadOnly(false), Browsable(true), PropertyOrder(87)]
public double LightAzimuth
{
get
{
return lightAzimuth;
}
set
{
if (lightAzimuth != value)
{
lightAzimuth = value;
//OnPropertyChanged(nameof(LightAzimuth));
}
}
}
private Color lightAmbientColor = Color.White;
/// <summary>
/// 环境光
/// </summary>
[Category("灯光"), DisplayName("环境光颜色"), ReadOnly(false), PropertyOrder(89)]
[Editor(typeof(PropertyEditorColor), typeof(UITypeEditor))]
[TypeConverter(typeof(PropertyColorIndicatorConvert))]
public Color LightAmbientColor
{
get
{
return lightAmbientColor;
}
set
{
if (lightAmbientColor != value)
{
lightAmbientColor = value;
//OnPropertyChanged(nameof(LightAmbientColor));
}
}
}
private Color lightDiffusedCorlor = Color.White;
/// <summary>
/// 漫射光
/// </summary>
[Category("灯光"), DisplayName("漫射光颜色"), ReadOnly(false), PropertyOrder(91)]
[Editor(typeof(PropertyEditorColor), typeof(UITypeEditor))]
[TypeConverter(typeof(PropertyColorIndicatorConvert))]
public Color LightDiffusedCorlor
{
get
{
return lightDiffusedCorlor;
}
set
{
if (lightDiffusedCorlor != value)
{
lightDiffusedCorlor = value;
//OnPropertyChanged(nameof(LightDiffusedCorlor));
}
}
}
private Color lightSpecularColor = Color.White;
/// <summary>
/// 反射光
/// </summary>
[Category("灯光"), DisplayName("反射光颜色"), ReadOnly(false), PropertyOrder(93)]
[Editor(typeof(PropertyEditorColor), typeof(UITypeEditor))]
[TypeConverter(typeof(PropertyColorIndicatorConvert))]
public Color LightSpecularColor
{
get
{
return lightSpecularColor;
}
set
{
if (LightSpecularColor != value)
{
lightSpecularColor = value;
//OnPropertyChanged(nameof(LightSpecularColor));
}
}
}
private Color actorAmbientColor = Color.White;
/// <summary>
/// 环境光颜色
/// </summary>
[Category("对象材质"), DisplayName("环境光颜色"), ReadOnly(false), PropertyOrder(110)]
[Editor(typeof(PropertyEditorColor), typeof(UITypeEditor))]
[TypeConverter(typeof(PropertyColorIndicatorConvert))]
public Color ActorAmbientColor
{
get
{
return actorAmbientColor;
}
set
{
if (actorAmbientColor != value)
{
actorAmbientColor = value;
//OnPropertyChanged(nameof(ActorAmbientColor));
}
}
}
private int actorAmbient = 10;
/// <summary>
/// 环境光系数
/// </summary>
[Category("对象材质"), DisplayName("环境光系数"), ReadOnly(false), PropertyOrder(111)]
public int ActorAmbient
{
get
{
return actorAmbient;
}
set
{
if (actorAmbient != value)
{
actorAmbient = value;
//OnPropertyChanged(nameof(ActorAmbient));
}
}
}
private Color actorDiffusedColor = Color.White;
/// <summary>
/// 漫射光颜色
/// </summary>
[Category("对象材质"), DisplayName("漫射光颜色"), ReadOnly(false), PropertyOrder(120)]
[Editor(typeof(PropertyEditorColor), typeof(UITypeEditor))]
[TypeConverter(typeof(PropertyColorIndicatorConvert))]
public Color ActorDiffusedColor
{
get
{
return actorDiffusedColor;
}
set
{
if (actorDiffusedColor != value)
{
actorDiffusedColor = value;
//OnPropertyChanged(nameof(ActorDiffusedColor));
}
}
}
private int actorDiffused = 80;
/// <summary>
/// 漫射光系数
/// </summary>
[Category("对象材质"), DisplayName("漫射光系数"), ReadOnly(false), PropertyOrder(121)]
public int ActorDiffused
{
get
{
return actorDiffused;
}
set
{
if (actorDiffused != value)
{
actorDiffused = value;
//OnPropertyChanged(nameof(ActorDiffused));
}
}
}
private Color actorSpecularColor = Color.White;
/// <summary>
/// 反射光颜色
/// </summary>
[Category("对象材质"), DisplayName("反射光颜色"), ReadOnly(false), PropertyOrder(130)]
[Editor(typeof(PropertyEditorColor), typeof(UITypeEditor))]
[TypeConverter(typeof(PropertyColorIndicatorConvert))]
public Color ActorSpecularColor
{
get
{
return actorSpecularColor;
}
set
{
if (actorSpecularColor != value)
{
actorSpecularColor = value;
//OnPropertyChanged(nameof(ActorSpecularColor));
}
}
}
private double actorSpecular = 10;
/// <summary>
/// 反射光系数
/// </summary>
[Category("对象材质"), DisplayName("反射光系数"), ReadOnly(false), PropertyOrder(131)]
public double ActorSpecular
{
get
{
return actorSpecular;
}
set
{
if (actorSpecular != value)
{
actorSpecular = value;
//OnPropertyChanged(nameof(ActorSpecular));
}
}
}
private WellModeEnum wellMode = SigmaDrawerElement.WellModeEnum.;
/// <summary>
/// 井显示模式
/// </summary>
[Category("井显示"), DisplayName("显示模式"), ReadOnly(false), Browsable(true), PropertyOrder(150)]
public WellModeEnum WellMode
{
get
{
return wellMode;
}
set
{
if (wellMode != value)
{
wellMode = value;
//OnPropertyChanged(nameof(MeshEdgeMode));
}
}
}
private double wellColumnHeight = 100;
/// <summary>
/// 颜色标尺
/// </summary>
[Category("井显示"), DisplayName("井柱高度"), ReadOnly(false), PropertyOrder(151)]
public double WellColumnHeight
{
get
{
return wellColumnHeight;
}
set
{
if (wellColumnHeight != value)
{
wellColumnHeight = value;
//OnPropertyChanged(nameof(SingularThreshold));
}
}
}
private double wellColumnRadius = 10;
/// <summary>
/// 井柱半径
/// </summary>
[Category("井显示"), DisplayName("井柱半径"), ReadOnly(false), PropertyOrder(152)]
public double WellColumnRadius
{
get
{
return wellColumnRadius;
}
set
{
if (wellColumnRadius != value)
{
wellColumnRadius = value;
//OnPropertyChanged(nameof(SingularThreshold));
}
}
}
private double wellSymbolRadius = 20;
/// <summary>
/// 井柱半径
/// </summary>
[Category("井显示"), DisplayName("井头半径"), ReadOnly(false), PropertyOrder(153)]
public double WellSymbolRadius
{
get
{
return wellSymbolRadius;
}
set
{
if (wellSymbolRadius != value)
{
wellSymbolRadius = value;
//OnPropertyChanged(nameof(SingularThreshold));
}
}
}
private Color wellColumnColor = Color.Yellow;
/// <summary>
/// 井柱颜色
/// </summary>
[Category("井显示"), DisplayName("井柱颜色"), ReadOnly(false), Browsable(false), PropertyOrder(155)]
[Editor(typeof(PropertyEditorColor), typeof(UITypeEditor))]
public Color WellColumnColor
{
get
{
return wellColumnColor;
}
set
{
if (wellColumnColor != value)
{
wellColumnColor = value;
//OnPropertyChanged(nameof(MeshEdgeColor));
}
}
}
private Color wellColumnNameColor = Color.Yellow;
/// <summary>
/// 井名颜色
/// </summary>
[Category("井显示"), DisplayName("井名颜色"), ReadOnly(false), PropertyOrder(156)]
[Editor(typeof(PropertyEditorColor), typeof(UITypeEditor))]
public Color WellColumnNameColor
{
get
{
return wellColumnNameColor;
}
set
{
if (wellColumnNameColor != value)
{
wellColumnNameColor = value;
//OnPropertyChanged(nameof(MeshEdgeColor));
}
}
}
private int wellColumnNameSize = 15;
/// <summary>
/// 井柱半径
/// </summary>
[Category("井显示"), DisplayName("井名大小"), ReadOnly(false), PropertyOrder(157)]
public int WellColumnNameSize
{
get
{
return wellColumnNameSize;
}
set
{
if (wellColumnNameSize != value)
{
wellColumnNameSize = value;
//OnPropertyChanged(nameof(SingularThreshold));
}
}
}
private int wellColumnNameGap = 10;
/// <summary>
/// 井柱半径
/// </summary>
[Category("井显示"), DisplayName("井名间距"), ReadOnly(false), PropertyOrder(158)]
public int WellColumnNameGap
{
get
{
return wellColumnNameGap;
}
set
{
if (wellColumnNameGap != value)
{
wellColumnNameGap = value;
//OnPropertyChanged(nameof(SingularThreshold));
}
}
}
private bool wellColumnThrough = true;
/// <summary>
/// 井柱半径
/// </summary>
[Category("井显示"), DisplayName("井柱穿透"), ReadOnly(false), PropertyOrder(159)]
public bool WellColumnThrough
{
get
{
return wellColumnThrough;
}
set
{
if (wellColumnThrough != value)
{
wellColumnThrough = value;
//OnPropertyChanged(nameof(wellColumnThrough));
}
}
}
private WellTypeColorCollection wellTypeList = new WellTypeColorCollection
{
new WellTypeColorItem("生产井", Color.Red),
new WellTypeColorItem("注水井", Color.Blue),
new WellTypeColorItem("观察井", Color.Green),
};
/// <summary>
/// 井别显示
/// </summary>
[Category("井显示"), ReadOnly(false), PropertyOrder(170)]
[DisplayName("井别颜色")]
[TypeConverter(typeof(WellTypeColorCollectionConverter))]
public WellTypeColorCollection WellTypeColorList
{
get
{
return wellTypeList;
}
set
{
if (wellTypeList != value)
{
wellTypeList = value;
//OnPropertyChanged(nameof(SingularThreshold));
}
}
}
private Random random = new Random();
/// <summary>
/// 使用层位字符串数据初始化井别颜色,一个层位视为一个井别
/// </summary>
/// <param name="layers">图层全路径</param>
public void InitWellTypeColors(string[] layers)
{
WellTypeColorList.Clear();
foreach (string item in layers)
{
// 生成 100-255 之间的随机红、绿、蓝值
int r = random.Next(100, 256);
int g = random.Next(100, 256);
int b = random.Next(100, 256);
// 创建随机颜色
Color randomColor = Color.FromArgb(r, g, b);
WellTypeColorItem colorItem = new WellTypeColorItem(item, randomColor);
if (string.IsNullOrEmpty(item))
{
continue;
}
foreach (WellTypeColorItem config in WellTypeColorConfig)
{
// 获取 GB2312 编码器
Encoding gb2312 = Encoding.GetEncoding("GB2312");
// 将字符串转换为 GB2312 编码的字节数组
byte[] gb2312Bytes = gb2312.GetBytes(config.Type);
// 可选:将字节数组还原为字符串进行验证
string decodedString = gb2312.GetString(gb2312Bytes);
if (item.Contains("\\"))
{
string[] segments = item.Split(new char[] { '\\' }, StringSplitOptions.RemoveEmptyEntries);
if (segments.Length > 0)
{
string temp = segments[segments.Length - 1];
if (temp.Equals(decodedString))
{
colorItem.Value = config.Value;
}
}
}
else
{
if (item.Equals(decodedString))
{
colorItem.Value = config.Value;
}
}
}
WellTypeColorList.Add(colorItem);
}
WellTypeColorsIsInitFlag = true;
}
[Browsable(false)]
public bool WellTypeColorsIsInitFlag { get; set; } = false;
/// <summary>
/// 井别颜色配置文件
/// </summary>
[Browsable(false)]
public BindingList<WellTypeColorItem> WellTypeColorConfig { get; set; }
/// <summary>
/// 水平方位角
/// </summary>
[Category("相机"), DisplayName("水平方位角"), ReadOnly(false), Browsable(false), PropertyOrder(560)]
public double CameraHAngle { get; set; } = 0;
/// <summary>
/// 垂直仰角
/// </summary>
[Category("相机"), DisplayName("垂直仰角"), ReadOnly(false), Browsable(false), PropertyOrder(570)]
public double CameraVAngle { get; set; } = 0;
[Browsable(false)]
[XmlElement("MeshColor")]
[TypeConverter(typeof(GeoSigma.SigmaDrawerStyle.Converter.BaseExpandableConverter))]
public SfMeshColor MeshColor { get; set; } = new SfMeshColor();
[NonSerialized]
private GradientColors colorItems = new GradientColors();
/// <summary>
/// 网格颜色
/// </summary>
[Category("常规"), DisplayName("网格颜色"), ReadOnly(false), Browsable(false), PropertyOrder(530)]
[TypeConverter(typeof(GeoSigma.SigmaDrawerStyle.Converter.BaseCollectionConverter))]
[Editor(
"GeoSigma.SigmaDrawerStyle.PropertyEditorGradientColor, SigmaDrawerStyle",
typeof(System.Drawing.Design.UITypeEditor))]
[XmlIgnore]
public GradientColors GridColorItems
{
get
{
if (colorItems == null)
{
colorItems = new GradientColors();
}
else
{
colorItems.Clear();
}
colorItems.AddRange(MeshColor.Items);
double dZMin = RangeZ.Zmin;
double dZMax = RangeZ.Zmax;
if (dZMin == dZMax)
{
CalculateRange(ref dZMin, ref dZMax);
}
colorItems.ZMin = RulerRangeZ.Zmin = dZMin;
colorItems.ZMax = RulerRangeZ.Zmax = dZMax;
return colorItems;
}
set
{
colorItems = value;
MeshColor.Items.CloneFrom(colorItems);
RulerRangeZ.Zmin = colorItems.ZMin;
RulerRangeZ.Zmax = colorItems.ZMax;
}
}
/// <summary>
/// 线宽
/// </summary>
[Category("常规"), DisplayName("线宽"), ReadOnly(false), Browsable(false), PropertyOrder(571)]
public int LineWidth { get; set; } = 2;
/// <summary>
/// 线颜色
/// </summary>
[Category("常规"), DisplayName("线颜色"), ReadOnly(false), Browsable(false), PropertyOrder(572)]
[Editor(typeof(PropertyEditorColor), typeof(UITypeEditor))]
[TypeConverter(typeof(PropertyColorIndicatorConvert))]
public Color LineColor { get; set; } = Color.Black;
/// <summary>
/// 井圈半径
/// </summary>
[Category("常规"), DisplayName("井圈半径"), ReadOnly(false), Browsable(false), PropertyOrder(573)]
public double WellRadius { get; set; } = 10f;
/// <summary>
/// 设置网格颜色
/// </summary>
/// <param name="colors"></param>
public void SetColors(GradientColors colors)
{
colorItems.CloneFrom(colors);
MeshColor.Items = colorItems;
RulerRangeZ.Zmin = colorItems.ZMin;
RulerRangeZ.Zmax = colorItems.ZMax;
}
private ValueRange rangeZ = new ValueRange();
[XmlIgnore]
[Category("曲面"), DisplayName("Z值范围"), Browsable(false)]
//[TypeConverter(typeof(PropertyRangeConvert))]
public ValueRange RangeZ
{
get
{
if (rangeZ == null)
{
rangeZ = new ValueRange(0, 100);
}
return rangeZ;
}
set
{
rangeZ.Zmin = value.Zmin;
rangeZ.Zmax = value.Zmax;
RulerRangeZ = rangeZ;
}
}
private ValueRange rulerRangeZ;
[XmlIgnore]
[Category("\t\t颜色标尺"), DisplayName("标注范围"), ReadOnly(false), PropertyOrder(577)]
[TypeConverter(typeof(PropertyRangeConvert))]
private ValueRange RulerRangeZ
{
get
{
if (rulerRangeZ == null)
{
rulerRangeZ = new ValueRange();
}
if (ColorRuler.RangeZ != null)
{
rulerRangeZ.Zmin = ColorRuler.RangeZ.Zmin;
rulerRangeZ.Zmax = ColorRuler.RangeZ.Zmax;
}
return rulerRangeZ;
}
set
{
rulerRangeZ = value;
ColorRuler.RangeZ.Zmin = rulerRangeZ.Zmin;
ColorRuler.RangeZ.Zmax = rulerRangeZ.Zmax;
}
}
[Serializable]
[DisplayName("颜色标尺")]
private class SfColorRuler
{
#region Coordinate
[Serializable]
public class SfCoordinate
{
//public class SfPoint
//{
// public double X { get; set; }
// public double Y { get; set; }
// public override string ToString()
// {
// return $"{X},{Y}";
// }
//}
//public class SfSize
//{
// [DisplayName("\t\t\t宽度")]
// public double Width { get; set; }
// [DisplayName("\t\t高度")]
// public double Height { get; set; }
// public override string ToString()
// {
// return $"{Width},{Height}";
// }
//}
[XmlText]
public string Text
{
get
{
return $"{Point.X},{Point.Y} {Point.X + RulerSize.Width},{Point.Y + RulerSize.Height}";
}
set
{
var arr = value.Split(new string[] { ",", " ", "\t" }, StringSplitOptions.RemoveEmptyEntries);
if (arr.Length == 4)
{
Point.X = Convert.ToDouble(arr[0]);
Point.Y = Convert.ToDouble(arr[1]);
var xMax = Convert.ToDouble(arr[2]);
var yMax = Convert.ToDouble(arr[3]);
this.RulerSize = new SizeF((float)(xMax - Point.X), (float)(yMax - Point.Y));
}
}
}
[XmlIgnore]
public PropertyPoint Point { get; set; } = new PropertyPoint();
[XmlIgnore]
public SizeF RulerSize { get; set; } = default(SizeF);
}
//[Browsable(false)]
[XmlElement("Coordinate")]
[TypeConverter(typeof(GeoSigma.SigmaDrawerStyle.Converter.BaseExpandableConverter)), ReadOnly(true)]
public SfCoordinate Coordinate { get; set; } = new SfCoordinate();
#endregion
[XmlElement("RangeZ")]
public SfcrRangeZ RangeZ { get; set; } = new SfcrRangeZ();
[XmlElement("Other")]
public SfcrOther Other { get; set; } = new SfcrOther();
[TypeConverter(typeof(GeoSigma.SigmaDrawerStyle.Converter.BaseExpandableConverter))]
[Serializable]
public class SfcrRangeZ
{
[DisplayName("\t\t最小")]
[XmlAttribute]
public double Zmin { get; set; }
[DisplayName("\t\t\t最大")]
[XmlAttribute]
public double Zmax { get; set; }
[DisplayName("\t步长")]
[XmlAttribute]
public double Delt { get; set; }
public override string ToString()
{
return $"{Zmin}, {Zmax}";
}
}
[Serializable]
[TypeConverter(typeof(GeoSigma.SigmaDrawerStyle.Converter.BaseExpandableConverter))]
public class SfcrOther
{
[XmlAttribute]
public double TextHeight { get; set; }
[XmlAttribute]
public int Style { get; set; }
[XmlAttribute]
public int Number { get; set; }
[XmlAttribute]
public int DF { get; set; }
}
}
[XmlElement("ColorRuler")]
[Browsable(false)]
[TypeConverter(typeof(GeoSigma.SigmaDrawerStyle.Converter.BaseExpandableConverter))]
private SfColorRuler ColorRuler { get; set; } = new SfColorRuler();
private void CalculateRange(ref double min, ref double max)
{
if (MeshColor.Items.Count > 0)
{
min = MeshColor.Items.Min(r => r.Z);
max = MeshColor.Items.Max(r => r.Z);
}
}
}
/// <summary>
/// 灯光模式
/// </summary>
[Serializable]
public enum LightModeEnum
{
= 0,
,
}
/// <summary>
/// 网格包围模式
/// </summary>
[Serializable]
public enum MeshEdgeModeEnum
{
= 0,
= 1,
}
/// <summary>
/// 井显示模式
/// </summary>
[Serializable]
public enum WellModeEnum
{
= 0,
= 1,
}
/// <summary>
/// 断面显示模式
/// </summary>
[Serializable]
public enum FaultModeEnum
{
= 0,
= 1,
}
[TypeConverter(typeof(WellTypeColorItemConverter))]
[JsonObject] //强制从对象反序列化
[Serializable]
public class WellTypeColorItem
{
[DisplayName("类别名称"), ReadOnly(false)]
public string Type { get; set; }
[DisplayName("颜色")]
public Color Value { get; set; }
/// <summary>
/// 构造函数
/// </summary>
/// <param name="type"></param>
/// <param name="value"></param>
public WellTypeColorItem(string type, Color value)
{
Type = type;
Value = value;
}
}
// This is a special type converter which will be associated with the WellTypeColorItem class.
internal class WellTypeColorItemConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is WellTypeColorItem)
{
WellTypeColorItem item = (WellTypeColorItem)value;
return item.Type;
}
return base.ConvertTo(context, culture, value, destType);
}
}
// This is a special type converter which will be associated with the EmployeeCollection class.
// It converts an EmployeeCollection object to a string representation for use in a property grid.
internal class WellTypeColorCollectionConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is WellTypeColorCollection)
{
return "井别颜色设置";
}
return base.ConvertTo(context, culture, value, destType);
}
}
/// <summary>
/// Type safe collection class for Employee objects. Extends the base class
/// CollectionBase to inherit base collection functionality.
/// Implementation of ICustomTypeDescvriptor to provide customized type description.
/// </summary>
[Serializable]
public class WellTypeColorCollection : BindingList<WellTypeColorItem>, ICustomTypeDescriptor
{
// Implementation of interface ICustomTypeDescriptor
#region ICustomTypeDescriptor impl
public String GetClassName()
{
return TypeDescriptor.GetClassName(this, true);
}
public AttributeCollection GetAttributes()
{
return TypeDescriptor.GetAttributes(this, true);
}
public String GetComponentName()
{
return TypeDescriptor.GetComponentName(this, true);
}
public TypeConverter GetConverter()
{
return TypeDescriptor.GetConverter(this, true);
}
public EventDescriptor GetDefaultEvent()
{
return TypeDescriptor.GetDefaultEvent(this, true);
}
public PropertyDescriptor GetDefaultProperty()
{
return TypeDescriptor.GetDefaultProperty(this, true);
}
public object GetEditor(Type editorBaseType)
{
return TypeDescriptor.GetEditor(this, editorBaseType, true);
}
public EventDescriptorCollection GetEvents(Attribute[] attributes)
{
return TypeDescriptor.GetEvents(this, attributes, true);
}
public EventDescriptorCollection GetEvents()
{
return TypeDescriptor.GetEvents(this, true);
}
public object GetPropertyOwner(PropertyDescriptor pd)
{
return this;
}
/// <summary>
/// Called to get the properties of this type. Returns properties with certain
/// attributes. this restriction is not implemented here.
/// </summary>
/// <param name="attributes"></param>
/// <returns></returns>
public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
{
return GetProperties();
}
/// <summary>
/// Called to get the properties of this type.
/// </summary>
/// <returns></returns>
public PropertyDescriptorCollection GetProperties()
{
// Create a collection object to hold property descriptors
PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null);
// Iterate the list of employees
for (int i = 0; i < this.Count; i++)
{
// Create a property descriptor for the employee item and add to the property descriptor collection
WellTypeColorCollectionPropertyDescriptor pd = new WellTypeColorCollectionPropertyDescriptor(this, i);
pds.Add(pd);
}
// return the property descriptor collection
return pds;
}
#endregion
}
/// <summary>
/// Summary description for CollectionPropertyDescriptor.
/// </summary>
public class WellTypeColorCollectionPropertyDescriptor : PropertyDescriptor
{
private WellTypeColorCollection collection = null;
private int index = -1;
public WellTypeColorCollectionPropertyDescriptor(WellTypeColorCollection coll, int idx) :
base("#" + idx.ToString(), null)
{
this.collection = coll;
this.index = idx;
}
public override AttributeCollection Attributes
{
get
{
return new AttributeCollection(null);
}
}
public override bool CanResetValue(object component)
{
return true;
}
public override Type ComponentType
{
get
{
return this.collection.GetType();
}
}
public override string DisplayName
{
get
{
WellTypeColorItem item = this.collection[index];
return item.Type;
}
}
public override string Description
{
get
{
WellTypeColorItem item = this.collection[index];
StringBuilder sb = new StringBuilder();
sb.Append(item.Type);
return sb.ToString();
}
}
public override object GetValue(object component)
{
return this.collection[index];
}
public override bool IsReadOnly
{
get { return false; }
}
public override string Name
{
get { return "#" + index.ToString(); }
}
public override Type PropertyType
{
get { return this.collection[index].GetType(); }
}
public override void ResetValue(object component)
{
}
public override bool ShouldSerializeValue(object component)
{
return true;
}
public override void SetValue(object component, object value)
{
this.collection[index] = (WellTypeColorItem)value;
}
}
}