using GeoSigmaDrawLib;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using System.Xml.Serialization;
namespace SigmaDrawerElement
{
///
/// 地震剖面类
///
[XmlRoot("Section")]
public class DrawerSeismicSection : ElementBase
{
///
/// Initializes a new instance of the class.
///
public DrawerSeismicSection()
{
ElementType = DrawElementType.ELEMENT_SECTION;
}
///
/// 坐标
///
[XmlElement("Coordinate")]
[Browsable(false)]
public string CoordinateData
{
get
{
return $"{Coordinate.X},{Coordinate.Y}";
}
set
{
if (!string.IsNullOrEmpty(value))
{
string[] xy = value.Split(new char[] { ' ', ',' }, StringSplitOptions.RemoveEmptyEntries);
if (xy.Length > 1)
{
Coordinate.X = Convert.ToDouble(xy[0]);
Coordinate.Y = Convert.ToDouble(xy[1]);
}
}
}
}
///
/// 坐标
///
[XmlIgnore]
[Category("\t基本"), DisplayName("\t\t\t\t坐标")]
[TypeConverter(typeof(GeoSigma.SigmaDrawerStyle.PropertyPointConvert))]
public GeoSigma.SigmaDrawerStyle.PropertyPoint Coordinate
{
get;
set;
} = new GeoSigma.SigmaDrawerStyle.PropertyPoint(0, 0);
///
/// 振幅归一化
///
[XmlIgnore]
[Browsable(false)]
public int NormalizeMode
{
get;
set;
}
///
/// 显示方式
///
[XmlIgnore]
[Category("\t基本"), DisplayName("\t\t\t显示方式")]
[TypeConverter(typeof(GeoSigma.SigmaDrawerElement.Converter.SectionDisplayTypeConvert))]
public int SolidMode
{
get
{
return ViewMode2SolidMode(Base.Flag & (int)SectionStyle.SECTION_VIEW_ALL);
}
set
{
int nViewMode = SolidMode2ViewMode(value);
Base.Flag &= ~((int)SectionStyle.SECTION_VIEW_ALL);
Base.Flag |= nViewMode;
}
}
///
/// 隔几道抽析显示
///
[XmlIgnore]
[Browsable(false)]
public int DisplayStep { get; set; }
///
/// 开始时间
///
[Browsable(false)]
[XmlIgnore]
public int BeginTime { get; set; }
///
/// 结束时间
///
[Browsable(false)]
[XmlIgnore]
public int EndTime { get; set; }
///
/// 道数量
///
[XmlIgnore]
[Category("\t基本"), DisplayName("\t\t道数")]
public int TraceCount
{
get
{
return Base.TraceCount;
}
}
///
/// 采样点数
///
[XmlIgnore]
[Category("\t基本"), DisplayName("\t采样点数")]
public int SampleCount
{
get
{
return Base.SampleCount;
}
}
///
/// 采样间隔
///
[XmlIgnore]
[Category("\t基本"), DisplayName("\t采样间隔")]
public double SampleStep
{
get
{
return Base.SampleStep;
}
}
///
/// 格式代码
///
[XmlIgnore]
[Category("\t基本"), DisplayName("数据编码")]
public int FormatCode
{
get
{
return Base.FormatCode;
}
}
///
/// 增益
///
///
[XmlIgnore]
[Category("\t基本"), DisplayName("增益")]
public double Times
{
get
{
return Base.Times;
}
set
{
Base.Times = value;
}
}
///
/// 基本属性
///
[Browsable(false)]
public DrawerSeismicSectionBase Base
{
get;
set;
} = new DrawerSeismicSectionBase();
///
/// 数据块
///
[XmlIgnore]
[Browsable(false)]
public BinaryBlock ValueBlock
{
get;
set;
}
public int SolidMode2ViewMode(int nSolidMode)
{
int dwViewMode = 0;
switch (nSolidMode)
{
case 0: dwViewMode |= (int)SectionStyle.SECTION_VIEW_WIGGLE; break; // 曲线
default:
case 1: dwViewMode |= (int)SectionStyle.SECTION_VIEW_POSITIVE_FILL; break; // 右变面积
case 2: dwViewMode |= (int)SectionStyle.SECTION_VIEW_NEGATIVE_FILL; break; // 左变面积
case 3: dwViewMode |= (int)SectionStyle.SECTION_VIEW_VARIABLE_DENSITY; break; // 变密度
case 4: dwViewMode |= ((int)SectionStyle.SECTION_VIEW_VARIABLE_DENSITY | (int)SectionStyle.SECTION_VIEW_WIGGLE); break; //变密度+曲线
case 5: // 变密度+右变面积
case 7: dwViewMode |= ((int)SectionStyle.SECTION_VIEW_VARIABLE_DENSITY | (int)SectionStyle.SECTION_VIEW_POSITIVE_FILL); break; //变密度+透明右变面积
case 6: // 变密度+左变面积
case 8: dwViewMode |= ((int)SectionStyle.SECTION_VIEW_VARIABLE_DENSITY | (int)SectionStyle.SECTION_VIEW_NEGATIVE_FILL); break; //变密度+透明左变面积
}
return dwViewMode;
}
public int ViewMode2SolidMode(int nViewMode)
{
int nSolidMode = 0;
if (nViewMode == (int)SectionStyle.SECTION_VIEW_WIGGLE) nSolidMode = 0;
else if (nViewMode == (int)SectionStyle.SECTION_VIEW_POSITIVE_FILL) nSolidMode = 1;
else if (nViewMode == (int)SectionStyle.SECTION_VIEW_NEGATIVE_FILL) nSolidMode = 2;
else if (nViewMode == (int)SectionStyle.SECTION_VIEW_VARIABLE_DENSITY) nSolidMode = 3;
else if (nViewMode == ((int)SectionStyle.SECTION_VIEW_VARIABLE_DENSITY | (int)SectionStyle.SECTION_VIEW_WIGGLE)) nSolidMode = 4;
else if (nViewMode == ((int)SectionStyle.SECTION_VIEW_VARIABLE_DENSITY | (int)SectionStyle.SECTION_VIEW_POSITIVE_FILL)) nSolidMode = 5;
else if (nViewMode == ((int)SectionStyle.SECTION_VIEW_VARIABLE_DENSITY | (int)SectionStyle.SECTION_VIEW_NEGATIVE_FILL)) nSolidMode = 6;
return nSolidMode;
}
}
///
/// 剖面基础属性
///
public class DrawerSeismicSectionBase
{
///
/// 道数量
///
[XmlAttribute]
public int TraceCount { get; set; }
///
/// 采样点数
///
[XmlAttribute]
public int SampleCount { get; set; }
///
/// 采样间隔
///
[XmlAttribute]
public double SampleStep { get; set; }
///
/// 数据类型--目前未使用
///
[XmlAttribute]
public int DataType { get; set; }
///
/// 格式代码
///
[XmlAttribute]
public int FormatCode { get; set; }
///
/// 是否PC格式
///
[XmlAttribute]
public int IsPC { get; set; }
///
/// 样式
///
[XmlAttribute]
public int Flag { get; set; } = (int)SectionStyle.SECTION_VIEW_POSITIVE_FILL | (int)SectionStyle.SECTION_DISPLAY_FAST | (int)SectionStyle.SECTION_READ_LOADALL | (int)SectionStyle.SECTION_UNIFORM_RMS;
///
/// 增益
///
[XmlAttribute]
public double Times { get; set; } = 1.3;
}
///
/// 剖面样式
///
public enum SectionStyle
{
SECTION_DISPLAY_FAST = 0x00000001, // 快速彩色显示,OLD
SECTION_DISPLAY_SLOW = 0x00000002, // 慢速彩色显示,OLD
SECTION_READ_DEFAULT = 0x00000004, // 缺省读方式
SECTION_READ_LOADALL = 0x00000008, // 全部装入内存方式
SECTION_ONLY_REFLASH = 0x00000010, // 仅重新显示一次,并不重新生成图像文件,该情况一般在人工设置好颜色后重新显示,为了加快速度
// 剖面归一化方式
SECTION_UNIFORM_MAX = 0x00000020, // 原始(max(fabs(minVal,maxVal));
SECTION_UNIFORM_RMS = 0x00000040, // 均方根
SECTION_UNIFORM_MEAN = 0x00000080, // 平均((最大值+最小值)/2)
SECTION_UNIFORM_ALL = (SECTION_UNIFORM_MAX | SECTION_UNIFORM_RMS | SECTION_UNIFORM_MEAN),
// 剖面显示方式
SECTION_VIEW_WIGGLE = 0x00000100, // 曲线 wiggle code
SECTION_VIEW_POSITIVE_FILL = 0x00000200, // 右变面积 positive VA fill code
SECTION_VIEW_NEGATIVE_FILL = 0x00000400, // 左变面积 negative VA fill code
SECTION_VIEW_VARIABLE_DENSITY = 0x00000800, // 变密度 variable density code
SECTION_VIEW_ALL = (SECTION_VIEW_WIGGLE | SECTION_VIEW_POSITIVE_FILL | SECTION_VIEW_NEGATIVE_FILL | SECTION_VIEW_VARIABLE_DENSITY),
}
}