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.

1509 lines
50 KiB
C#

using GeoSigma.SigmaDrawerElement;
using GeoSigma.SigmaDrawerStyle;
using GeoSigma.UCDraw;
using GeoSigma.UCDraw.WellAndSection;
using GeoSigmaDrawLib;
using InterfaceWorkAreaData;
using InterfaceWorkAreaData.LoadCurveData;
using Newtonsoft.Json.Serialization;
using SigmaDrawerElement;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlTypes;
using System.Drawing;
using System.Linq;
using System.Windows.Automation;
using System.Windows.Forms;
using WellWorkDataUI;
using static GeoSigmaDrawLib.GeoSigmaWellPoleXY;
namespace UCDraw
{
public class WellBaseDrawView : UserControl
{
public DrawerViewChangeLayerEvent ChangeLayerEvent;
public EmptyNameCurveLoadHandler ENCurveLoadHandler;
public MainViewInfoHandler GetLengthAngleEvent;
protected GeoSigmaXY geoSigma;
protected Drawer drawer1;
// public string m_WorkAreaPath = "";
public GeoSigmaXY.eViewType mViewType;
public GeoSigmaWellPoleXY.NewWellInfo mNewWellInfo = new GeoSigmaWellPoleXY.NewWellInfo();
protected bool bShowGrid = false;
protected static List<DrawViewer> All = new List<DrawViewer>();
public static DrawViewer Current
{
get
{
foreach (DrawViewer drawViewer in All)
{
if (drawViewer.Visible)
return drawViewer;
}
return null;
}
}
public WellBaseDrawView()
{
}
public GeoSigmaXY Geo
{
get
{
return geoSigma;
}
set
{
geoSigma = value;
}
}
public int ID { get; set; }
/// <summary>
/// 添加点数据
/// </summary>
/// <param name="layerName">图层名</param>
/// <param name="pts">点列表</param>
public void AddDrawPoints(string layerName, List<DrawerPoint> pts)
{
Drawer.AddPoints(layerName, pts);
}
public Drawer Drawer
{
get
{
return drawer1;
}
set
{
drawer1 = value;
}
}
public bool OpenFile(string filePath, GeoSigmaXY.eViewType vType = GeoSigmaXY.eViewType.plane)
{
try
{
geoSigma = drawer1.OpenFile(filePath, vType);
if (geoSigma == null)
{
return false;
}
// geoSigma.EnableMeshPackage(this.enableMeshPack);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
return false;
}
// SetScrollBar();
if (geoSigma == null)
{
return false;
}
return true;
}
public DrawerChangedViewWindowEventHandler DrawerChangedViewWindowEvent
{
get
{
return Drawer?.DrawerChangedViewWindowEvent;
}
set
{
Drawer.DrawerChangedViewWindowEvent = value;
}
}
public DrawerMouseMoveEventHandler DrawerOnMouseMoveEvent
{
get
{
return Drawer?.DrawerOnMouseMoveEvent;
}
set
{
Drawer.DrawerOnMouseMoveEvent = value;
}
}
public WaitProgressEventHandler WaitProgressEvent
{
get
{
return Drawer?.WaitProgressEvent;
}
set
{
if (Drawer != null)
{
Drawer.WaitProgressEvent = value;
}
}
}
public DrawerElementMovedEventHandler ElementMovedEvent
{
get
{
return Drawer?.ElementMovedEvent;
}
set
{
if (Drawer != null)
{
Drawer.ElementMovedEvent = value;
}
}
}
public IntPtr DrawerXY
{
get => (drawer1?.DrawerXY).Value;
}
// GeoSigmaXY geoSigma;
public EventHandler<EventArgs> DrawerGotFocus
{
get
{
return drawer1?.DrawerGotFocus;
}
set
{
drawer1.DrawerGotFocus = value;
}
}
public EventHandler<ElementArgs> SelectedElementChanged
{
get
{
if (drawer1 == null)
{
return null;
}
return drawer1.SelectedElementChanged;
}
set
{
if (drawer1 != null)
{
drawer1.SelectedElementChanged = value;
}
}
}
public EventHandler<MultiElementArgs> SelectedMultiElements
{
get
{
if (drawer1 == null)
{
return null;
}
return drawer1.SelectedMultiElements;
}
set
{
if (drawer1 != null)
{
drawer1.SelectedMultiElements = value;
}
}
}
public long SelectedElementPosition
{
get
{
if (drawer1 == null)
{
return 0;
}
return drawer1.SelectedElementPosition;
}
}
public event StatusColumnInfo MouseMoveEvent;
//public ViewerTipMessageHandler TipMessageHandler;
public CommandExecutionHandler ViewerCommandStart
{
get
{
return Drawer?.DrawerCommandStart;
}
set
{
if (Drawer != null)
{
Drawer.DrawerCommandStart = value;
}
}
}
//public CommandExecutionHandler ViewerCommandFinish;
public CommandExecutionHandler ViewerCommandFinish
{
get
{
return Drawer?.DrawerCommandFinish;
}
set
{
if (Drawer != null)
{
Drawer.DrawerCommandFinish = value;
}
}
}
/// <summary>
/// 显示导航信息事件.
/// </summary>
/// <param name="elementTypes">图元类型.</param>
/// <param name="eventHandler">处理事件.</param>
public void SetNavigationEvent(List<DrawElementType> elementTypes, ShowNavigationEventHandler eventHandler)
{
Drawer?.SetNavigationEvent(elementTypes, eventHandler);
}
protected void drawer1_MouseMove(object sender, MouseEventArgs e)
{
if (!string.IsNullOrWhiteSpace(drawer1.MouseMoveInfo))
{
MouseMoveEvent?.Invoke(drawer1.MouseMoveInfo);
}
else
{
string mouseXY = string.Empty;
if (geoSigma != null)
{
geoSigma.GetMouseMoveXY(e.X, e.Y, ref mouseXY);
MouseMoveEvent?.Invoke(mouseXY);
}
}
}
public List<DrawerElementProperty> GetDataByLayer(string layerName)
{
return drawer1?.GetDataByLayer(layerName);
}
public List<DrawerElementProperty> GetLayerCurve(string layerName)
{
return drawer1?.GetLayerCurve(layerName);
}
public int SelectByNames(string nameData)
{
return Drawer.SelectByNames(nameData);
}
public int FindElementByName(string content, bool matchAll = false, bool matchCase = false, int elementType = 0, bool editableOnly = true)
{
return Drawer.FindElementByName(content, matchAll, matchCase, elementType, editableOnly);
}
public string GetCurrentLayer()
{
if (geoSigma == null)
{
return string.Empty;
}
return geoSigma.GetCurrentLayer();
}
public void SetCurrentLayer(string layerName)
{
geoSigma?.SetCurrentLayer(layerName);
}
public bool RemoveCurveStyle(string layerName, int index)
{
if (geoSigma.RemoveCurveStyle(layerName, index))
{
geoSigma.EnableRedraw(true);
return true;
}
return false;
}
public bool SetLayerHowtoViewPoint(string layerName, string data, bool replace)
{
if (geoSigma.SetLayerHowtoViewPoint(layerName, data, replace))
{
geoSigma.EnableRedraw(true);
return true;
}
return false;
}
public bool SetLayerStyle(CurveView curveStyle, string layerName, int propertyIndex)
{
string strCurveStyle = ((CurveView)curveStyle).SerialXml();
strCurveStyle = strCurveStyle.Replace("true", "1");
strCurveStyle = strCurveStyle.Replace("false", "0");
return this.SetLayerHowtoViewCurve(layerName, strCurveStyle, propertyIndex - 1);
}
public bool SetLayerHowtoViewCurve(string layerName, string data, int index)
{
if (geoSigma.SetLayerHowtoViewCurve(layerName, data, index))
{
geoSigma.EnableRedraw(true);
return true;
}
return false;
}
public bool SetLayerMoveUpCurveStyle(string layerName, int index)
{
if (geoSigma.SetLayerMoveUpCurveStyle(layerName, index))
{
geoSigma.EnableRedraw(true);
return true;
}
return false;
}
public bool SetLayerMoveDownCurveStyle(string layerName, int index)
{
if (geoSigma.SetLayerMoveDownCurveStyle(layerName, index))
{
geoSigma.EnableRedraw(true);
return true;
}
return false;
}
public bool CreateLayerCurveStyle(string layerName, CurveStyleType type, string data)
{
if (geoSigma.CreateLayerCurveStyle(layerName, type, data))
{
geoSigma.EnableRedraw(true);
return true;
}
return false;
}
public bool AddLayerCurveStyle(string layerName, CurveStyleType type, string data)
{
if (geoSigma.AddLayerCurveStyle(layerName, type, data))
{
geoSigma.EnableRedraw(true);
return true;
}
return false;
}
public bool CreateLayerPointStyle(string layerName, string data)
{
if (geoSigma.CreateLayerPointStyle(layerName, data))
{
geoSigma.EnableRedraw(true);
return true;
}
return false;
}
/// <summary>
/// 添加点数据
/// </summary>
/// <param name="layerName">图层名称</param>
/// <param name="drawPoint">点数据</param>
public void AddDrawPoint(string layerName, DrawerPoint drawPoint)
{
Drawer?.AddPoint(layerName, drawPoint);
}
public bool RemovePointStyle(string layerName)
{
if (geoSigma.RemovePointStyle(layerName))
{
geoSigma.EnableRedraw(true);
return true;
}
return false;
}
public int ResetCurveStyle(string curveName, string layerName, CurveView curveStyle)
{
string strStyleData = curveStyle.SerialXml();
int nCount = geoSigma.ResetCurveStyle(curveName, layerName, (int)curveStyle.StyleType, strStyleData);
if (nCount > 0)
{
Drawer.UpdateElementSelected();
}
return 0;
}
/// <summary>
/// 获得选中点的样式
/// </summary>
/// <param name="data">数据</param>
/// <returns>是否成功</returns>
public bool SelectCreatePointStyle(string data)
{
if (geoSigma.SelectCreatePointStyle(SelectedElementPosition, data))
{
geoSigma.EnableRedraw(true);
return true;
}
return false;
}
public bool SelectGetLayerName(out string layer)
{
if (SelectedElementPosition <= 0)
{
layer = string.Empty;
return false;
}
return geoSigma.SelectGetLayerName(SelectedElementPosition, out layer);
}
public bool SelectSetLayerByName(string layer)
{
if (geoSigma.SelectSetLayerByName(SelectedElementPosition, layer))
{
geoSigma.EnableRedraw(true);
return true;
}
return false;
}
public void EnableCrossLine(bool enable)
{
drawer1.EnableCrossLine = enable;
//if (this.drawer1.mViewType == GeoSigmaWellPoleXY.eViewType.wellpole)
//{
// if (enable == true)
// {
// drawer1.InitializeTooltip();
// }
// else
// {
// drawer1.ReleaseTooltip();
// }
//}
}
/// <summary>
/// 添加并激活新图层
/// </summary>
/// <param name="strLayerName"></param>
/// <param name="doActive">是否激活</param>
public void FindAddLayer(string strLayerName, bool doActive = true)
{
geoSigma.FindAddLayer(strLayerName, doActive);
}
public void LayerRename(string oldName, string newName)
{
geoSigma.LayerRename(oldName, newName);
}
public void DeleteLayer(List<string> layers, bool withSubLayer = false)
{
geoSigma.DeleteLayer(layers.ToArray(), withSubLayer);
}
public bool DeleteLayerEmpty()
{
return geoSigma.DeleteLayerEmpty();
}
public bool GetLayerStyleData(string layerName, ref string curveStyle, ref string pointStyle)
{
return geoSigma.GetLayerStyleData(layerName, ref curveStyle, ref pointStyle);
}
public void ReDrawWindow()
{
drawer1.ReDrawWindow();
}
public void Redraw()
{
drawer1?.ReDraw(); //TODO:drawer1重命名
}
//通过DrawView调用Undo/Redo功能 因为有的Undo/Redo需要用到HDC
public int Undo()
{
return (drawer1?.Undo()).Value;
}
public int Redo()
{
return (drawer1?.Redo()).Value;
}
public GeoSigmaXY GetGeoSigma()
{
return geoSigma;
}
public GeoSigmaXY GeoSigma
{
get
{
return geoSigma;
}
}
public void SelectAll()
{
drawer1?.SelectAll();
}
public void SelectAllPoint()
{
drawer1?.SelectAllPoint();
}
public void SelectAllCurve()
{
drawer1?.SelectAllCurve();
}
public void ToolRestore()
{
drawer1?.RestoreTool();
}
public void RestoreToolDefault()
{
drawer1?.RestoreToolDefault();
}
//private DrawToolType activeTool; // active drawing tool
//private DrawTool[] tools; // array of tools
/// <summary>
/// Active drawing tool.
/// </summary>
public DrawToolType ActiveTool
{
get
{
return drawer1.ActiveTool;
}
set
{
drawer1.ActiveTool = value;
}
}
/// <summary>
/// 获得选中的所有图元
/// </summary>
/// <returns>选中图元的列表</returns>
public List<DrawerElementProperty> GetSelectedElements()
{
return drawer1?.GetSelectedElements();
}
public void SetDrawerMouseLocation(double dx, double dy)
{
drawer1?.SetMouseLocation(dx, dy);
}
public void Draw2Image(string outputFile, double left = 0, double top = 0, double right = 0, double bottom = 0)
{
drawer1?.Geo?.Draw2Image(outputFile, left, top, right, bottom);
}
public bool SetPointZColor()
{
return drawer1.SetPointZColor();
}
public string GetLayers(bool withStatus = false)
{
return geoSigma != null ? geoSigma.GetLayers(withStatus) : string.Empty;
}
public bool Export2Image(string fileFullPath)
{
return this.Drawer.Export2Image(fileFullPath);
}
public void GetLengthAngle(string info)
{
GetLengthAngleEvent?.Invoke(info);
}
/// <summary>
/// 曲线加密
/// </summary>
public void CurveExcuteDensity()
{
this.Drawer?.CurveExcuteDensity();
}
/// <summary>
/// 多边形连接.
/// </summary>
/// <returns>An int.</returns>
public int CurveConnect(bool deleteOrignalCurves = false)
{
if (this.Drawer == null)
{
return 0;
}
return this.Drawer.CurveConnect(deleteOrignalCurves);
}
/// <summary>
/// 曲线冗余处理
/// </summary>
public void CurveRedundancy()
{
this.Drawer?.CurveRedundancy();
}
/// <summary>
/// 添加线
/// </summary>
/// <param name="layerName">图层</param>
/// <param name="name">线名</param>
/// <param name="pts">坐标点</param>
public void AddDrawCurve(string layerName, string name, List<PointD> pts)
{
if (this.Drawer == null)
{
return;
}
this.Drawer.AddCurve(layerName, name, pts);
}
/// <summary>
/// 添加地震剖面
/// </summary>
/// <param name="sectionData">属性数据</param>
/// <returns>图元索引</returns>
public long AddSeismicSection(string sectionData, float[] values)
{
return this.Drawer.AddSeismicSection(sectionData, values);
}
public void DeleteSectionAll()
{
this.Drawer.DeleteSeismicSection();
}
/// <summary>
/// 删除剖面
/// </summary>
/// <param name="pos">图元</param>
/// <returns>是否成功</returns>
public bool DeleteSeismicSection(long pos)
{
return this.Drawer.DeleteSeismicSection(pos);
}
/// <summary>
/// 删除图元
/// </summary>
/// <param name="layerName">图层名称</param>
/// <param name="eleName">图元名称</param>
/// <returns>删除的数量</returns>
public int DeleteElement(string layerName, string eleName)
{
return this.Drawer.DeleteElement(layerName, eleName);
}
/// <summary>
/// 删除点图元
/// </summary>
/// <param name="layerName">层名</param>
/// <param name="eleName">点名称</param>
/// <returns>删除个数</returns>
public int DeletePoint(string layerName, string eleName)
{
return this.Drawer.DeletePoint(layerName, eleName);
}
/// <summary>
/// 删除点数据
/// </summary>
/// <param name="layerName">图层名称</param>
/// <param name="eleNames">点数据名称列表</param>
public void DeletePoints(string layerName, List<string> eleNames)
{
foreach (string name in eleNames)
{
this.Drawer.DeletePoint(layerName, name);
}
}
public void DeletePoints(string layerName, List<DrawerPoint> pts)
{
this.Drawer.DeletePoints(layerName, pts);
}
public void SetLayerState(string layerName, LayerStatus status)
{
geoSigma.SetLayerState(layerName, status);
geoSigma.EnableRedraw(true);
}
/// <summary>
/// 按图层名称获取层数据
/// </summary>
/// <param name="name"></param>
/// <param name="holes"></param>
/// <param name="boundarys"></param>
/// <param name="wells"></param>
/// <returns></returns>
public IntPtr GetLayerData(string name, string holes, string boundarys, string wells)
{
IntPtr ret = IntPtr.Zero;
// 使用 Split 方法按分号分割字符串,并存储到数组中
string[] holeArr = holes.Split(';');
string[] boundaryArr = boundarys.Split(';');
string[] wellArr = wells.Split(';');
bool bHole = false;
bool bBoundary = false;
bool bWell = false;
// 打印每个分割后的字符串
foreach (string hole in holeArr)
{
if (hole == name)
{
bHole = true;
break;
}
}
// 打印每个分割后的字符串
foreach (string boundary in boundaryArr)
{
if (boundary == name)
{
bBoundary = true;
break;
}
}
foreach (string well in wellArr)
{
if (well == name)
{
bWell = true;
break;
}
}
ret = geoSigma.GetLayerData(name, bHole, bBoundary, bWell);
return ret;
}
/// <summary>
/// Processes the mesh fault area.
/// </summary>
/// <param name="pRoot">The p root.</param>
/// <param name="pMainMesh">The p main mesh.</param>
public void ProcessMeshFaultArea(IntPtr pRoot, IntPtr pMainMesh)
{
geoSigma.ProcessMeshFaultArea(pRoot, pMainMesh);
}
/// <summary>
/// 按边界处理网格
/// </summary>
/// <param name="pRoot"></param>
/// <param name="pMainMesh"></param>
public void ProcessMeshBoundary(IntPtr pRoot, IntPtr pMainMesh)
{
geoSigma.ProcessMeshBoundary(pRoot, pMainMesh);
}
/// <summary>
/// Sets the VTK data node checked.
/// </summary>
/// <param name="pNodeData">The p node data.</param>
/// <param name="isChecked">if set to <c>true</c> [is checked].</param>
public void SetVtkDataNodeChecked(IntPtr pNodeData, bool isChecked)
{
geoSigma.SetVtkDataNodeChecked(pNodeData, isChecked);
}
/// <summary>
/// Sets the VTK data node hide.
/// </summary>
/// <param name="pNodeData">The p node data.</param>
/// <param name="isHide">if set to <c>true</c> [is hide].</param>
public void SetVtkDataNodeHide(IntPtr pNodeData, bool isHide)
{
geoSigma.SetVtkDataNodeChecked(pNodeData, isHide);
}
/// <summary>
///
/// </summary>
/// <param name="pParent"></param>
/// <param name="pChild"></param>
public void AddVtkDataNodeChild(IntPtr pParent, IntPtr pChild)
{
geoSigma.AddVtkDataNodeChild(pParent, pChild);
}
/// <summary>
/// Adds the data as symble.
/// </summary>
/// <param name="data">The data.</param>
/// <param name="symbolName">The symbol name.</param>
/// <param name="overwrite">If true, overwrite.</param>
/// <returns>An int.</returns>
public int AddDataAsSymble(string data, string symbolName, bool overwrite = false)
{
return Drawer.Geo.AddDataAsSymble(data, symbolName, overwrite);
}
/// <summary>
/// Autos the join curves.
/// </summary>
/// <returns>An int.</returns>
public int AutoJoinCurves()
{
FrmJoinCurves frmJoin = new FrmJoinCurves();
if (frmJoin.ShowDialog(this) != DialogResult.OK)
{
return 0;
}
double dMaxError = frmJoin.MaxError;
bool bOnlySameName = frmJoin.OnlySameName;
return Drawer.Geo.Curve_AutoJoin(dMaxError, bOnlySameName);
}
public bool SetElementProperty(string elementData)
{
if (geoSigma.SelectSetElement(elementData, SelectedElementPosition)) // , data, index
{
geoSigma.EnableRedraw(true);
return true;
}
return false;
}
/// <summary>
/// 将选中图元保存为模版.
/// </summary>
/// <param name="outputFile">The output file.</param>
/// <returns>是否成功</returns>
public bool SelectWriteTemplate(string outputFile)
{
if (geoSigma == null)
{
return false;
}
return geoSigma.SelectWriteTemplate(outputFile);
}
public bool SelectRemoveCurveStyle(int index)
{
if (geoSigma.SelectRemoveCurveStyle(SelectedElementPosition, index))
{
geoSigma.EnableRedraw(true);
return true;
}
return false;
}
public bool SelectRemovePointStyle()
{
if (geoSigma.SelectRemovePointStyle(SelectedElementPosition))
{
geoSigma.EnableRedraw(true);
return true;
}
return false;
}
public bool SelectMoveUpCurveStyle(int index)
{
if (geoSigma.SelectMoveUpCurveStyle(SelectedElementPosition, index))
{
geoSigma.EnableRedraw(true);
return true;
}
return false;
}
public bool SelectMoveDownCurveStyle(int index)
{
if (geoSigma.SelectMoveDownCurveStyle(SelectedElementPosition, index))
{
geoSigma.EnableRedraw(true);
return true;
}
return false;
}
public bool SelectCreateCurveStyle(CurveStyleType type, string data)
{
if (geoSigma.SelectCreateCurveStyle(SelectedElementPosition, type, data))
{
geoSigma.EnableRedraw(true);
return true;
}
return false;
}
/// <summary>
/// 重命名图元
/// </summary>
/// <param name="oldName">旧名称</param>
/// <param name="newName">新名称</param>
/// <param name="layerName">图层</param>
/// <returns>替换的数量</returns>
public int RenameElement(string oldName, string newName, string layerName)
{
return geoSigma.RenameElement(oldName, newName, layerName);
}
public bool ReloadFile()
{
try
{
geoSigma = drawer1.ReloadFile();
// hRuler1.InitGeo(geoSigma);
// vRuler1.InitGeo(geoSigma);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
return false;
}
if (geoSigma == null)
{
return false;
}
// Geo.EnableMeshPackage(EnableMeshPack);
Redraw();
return true;
}
public void ClearGeo()
{
drawer1.ClearGeo();
}
public bool OpenXy(IntPtr pxy)
{
try
{
geoSigma = drawer1.OpenXy(pxy);
// geoSigma.EnableMeshPackage(this.enableMeshPack);
// hRuler1.InitGeo(geoSigma);
// vRuler1.InitGeo(geoSigma);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
return false;
}
// SetScrollBar();
if (geoSigma == null)
{
return false;
}
return true;
}
public void SetBackColor(int r, int g, int b)
{
if (geoSigma == null)
{
return;
}
drawer1.ViewBackColor = Color.FromArgb(r, g, b);
//geoSigma.SetViewBackcolor(r, g, b);
}
public void SetSymbolView(bool isSymbolView)
{
if (geoSigma == null)
{
return;
}
geoSigma.SetSymbolView(isSymbolView);
}
public bool SaveFile(string fileName)
{
if (geoSigma == null) return false;
return geoSigma.SaveDocument(fileName);
}
public bool SaveFile(string fileName, double leftMargin, double rightMargin,
double topMargin, double bottomMargin, int paperSizeType, int pdfAHType, int pdfPapertDirectionType)
{
if (geoSigma == null) return false;
return geoSigma.SavePdfDocument(fileName, leftMargin, rightMargin,
topMargin, bottomMargin, paperSizeType, pdfAHType, pdfPapertDirectionType);
}
public virtual bool NewFile(string fileName, GeoSigmaXY.eViewType vType = GeoSigmaXY.eViewType.wellpole)
{
return false;
}
public void ViewExtendCenter()
{
drawer1.ViewExtendCenter();
}
public void ViewExtendWidth()
{
drawer1.ViewExtendWidth();
}
public void GridGenerateContour()
{
drawer1?.GridGenerateContour();
}
public void GridSmooth()
{
drawer1?.GridSmooth();
}
public void GridStatics()
{
drawer1.GridStatics();
}
/// <summary>
/// Creates the mesh by data async.
/// </summary>
/// <returns>A System.Threading.Tasks.Task.</returns>
public async System.Threading.Tasks.Task CreateMeshByDataAsync()
{
await drawer1.CreateMeshByDataAsync();
}
/// <summary>
/// Creates the mesh by Image async.
/// </summary>
/// <returns>A System.Threading.Tasks.Task.</returns>
public async System.Threading.Tasks.Task CreateMeshByImageAsync()
{
await drawer1.CreateMeshByImageAsync();
}
public void ZoomIn()
{
drawer1.ZoomIn();
}
public void ZoomOut()
{
drawer1.ZoomOut();
}
public void ViewAll()
{
drawer1.ViewAll();
}
public void Extend(RectangleF rect)
{
drawer1.Extend(rect);
}
public void InitlizePaint(RectangleF rect)
{
drawer1.InitlizePaint(rect);
}
public ViewOperationKind GetViewOperationKind()
{
return drawer1.ViewOpKind;
}
public void SetViewOperationKind(ViewOperationKind kind)
{
drawer1.SetViewOperationKind(kind);
}
public void CutX()//fbw
{
drawer1?.Cutx();
}
public void Copy()//fbw
{
drawer1?.Copy();
}
public void Paste()//fbw
{
drawer1?.Paste();
}
/// <summary>
/// 截取窗口图形.
/// </summary>
public void ImageCutWindow()
{
drawer1?.ImageCutWindow();
drawer1?.ShowClipboardSketch();
}
public void ImageCutAll()
{
drawer1?.ImageCutAll(1);
drawer1?.ShowClipboardSketch();
}
public void SwitchGrid()
{
bShowGrid = !bShowGrid;
geoSigma.SigmaView_ShowBKGrid(bShowGrid ? 1 : 0);
drawer1.ReDraw();
}
public void DisplayBackgroundGrid(bool show)
{
geoSigma.SigmaView_ShowBKGrid(show ? 1 : 0);
drawer1.ReDraw();
}
public void EnableHeighLight(bool enable)
{
drawer1?.EnableHeighLight(enable);
}
#region 打印
public virtual void PreviewPrint()
{
}
#endregion
/// <summary>
/// 创建泰森图.
/// </summary>
/// <returns>块数</returns>
public int CreateVoronoi()
{
return geoSigma.CreateVoronoi();
}
public int CreateVoronoi2()
{
return 0;
}
/// <summary>
/// 创建三角网
/// </summary>
/// <returns>块数</returns>
public int CreateDelaunay()
{
return 0;
}
/// <summary>
/// 创建三角网
/// </summary>
/// <returns>块数</returns>
public int CreateDelaunayConstraint()
{
return 0;
}
/// <summary>
/// 为常用菜单添加命令.
/// </summary>
/// <param name="text">The text.</param>
/// <param name="handler">The handler.</param>
/// <param name="needElement">if set to <c>true</c> [need element].</param>
public void InsertCommonCommand(string text, EventHandler handler, bool needElement = true
, DrawElementType elementType = DrawElementType.ELEMENT_UNKNOWN)
{
drawer1?.InsertCommonCommand(text, handler, needElement
, elementType);
}
public virtual void AddPictureToWellTrack()
{
}
public virtual void SetLockWellHead()
{
}
public virtual void SetAddFaultPoint()
{
}
public virtual bool IsAddFaultPoint()
{
return false;
}
protected void readStratumDivisionFromWorkArea(UInt64 wellHandle)
{
string strStraifi = "";
List<cWellStratification> wellStratis = workAreaDb.Instance.workData.getWellStratification();//获取井分层级别数据。
WellDataConvert.getWellStratificationJson(ref strStraifi, wellStratis);
if (strStraifi != "")
{//设置井分层级别数据
GeoSigmaWellPoleXY.SetWellStratificationJson(wellHandle, strStraifi);
}
string strStratums = "";
List<cStratumDivision> stratums = workAreaDb.Instance.workData.getStratumDivisions(); //获取地质分层级别
WellDataConvert.getStratumDivisionJson(ref strStratums, stratums);
if (strStratums != "")
{
GeoSigmaWellPoleXY.SetStratumDivisionJson(wellHandle, strStratums);
}
}
protected void readAllWellTableFromWorkArea(UInt64 wellHandle, string wellName)
{
List<cWellTrackPoint> wellTrajcectory = workAreaDb.Instance.workData.getWellTrajectory(wellName);
string trajStr = "";
WellDataConvert.getWellTrajectoryJson(ref trajStr, wellTrajcectory);
if (trajStr != "")//读取井轨迹数据
{
GeoSigmaWellPoleXY.SetWellTrajectoryDatasJson(wellHandle, trajStr);
}
readStratumDivisionFromWorkArea(wellHandle);
string strReservesLayers = "";
List<cWellReservesLayer> reservesLayers = workAreaDb.Instance.workData.getReservesLayers(wellName); //获取储层数据
WellDataConvert.getReservesLayerJson(ref strReservesLayers, reservesLayers);
if (strReservesLayers != "")
{
GeoSigmaWellPoleXY.SetWellReservesLayersJson(wellHandle, strReservesLayers, false);
}
string strSandSet = "";
List<cWellSandSet> wellSandSets = workAreaDb.Instance.workData.getWellSandSets(wellName); //获取井分层数据
WellDataConvert.getWellSandSetsJson(ref strSandSet, wellSandSets);
if (strSandSet != "")
{
GeoSigmaWellPoleXY.SetWellSandSetsJson(wellHandle, strSandSet, false);
}
string strFaultPoints = "";
List<cFaultPoint> wellFaults = workAreaDb.Instance.workData.getWellFaultPoints(wellName);//获取断点数据
WellDataConvert.getWellFaultPointsJson(ref strFaultPoints, wellFaults);
if (strFaultPoints != "")
{
GeoSigmaWellPoleXY.SetWellFaultDatasJson(wellHandle, strFaultPoints, true);
}
}
protected void readOneWellTableFromWorkArea(UInt64 wellHandle, string wellName, string tableId)
{
if (tableId == "SandSet")
{
string strSandSet = "";
List<cWellSandSet> wellSandSets = workAreaDb.Instance.workData.getWellSandSets(wellName); //获取井分层数据
WellDataConvert.getWellSandSetsJson(ref strSandSet, wellSandSets);
if (strSandSet != "")
{
GeoSigmaWellPoleXY.SetWellSandSetsJson(wellHandle, strSandSet, false);
}
}
else if (tableId == "FaultPoint")
{
string strFaultPoints = "";
List<cFaultPoint> wellFaults = workAreaDb.Instance.workData.getWellFaultPoints(wellName);//获取断点数据
WellDataConvert.getWellFaultPointsJson(ref strFaultPoints, wellFaults);
if (strFaultPoints != "")
{
GeoSigmaWellPoleXY.SetWellFaultDatasJson(wellHandle, strFaultPoints, true);
}
}
else if (tableId == "ReservesLayer")
{
string strReservesLayers = "";
List<cWellReservesLayer> reservesLayers = workAreaDb.Instance.workData.getReservesLayers(wellName); //获取储层数据
WellDataConvert.getReservesLayerJson(ref strReservesLayers, reservesLayers);
if (strReservesLayers != "")
{
GeoSigmaWellPoleXY.SetWellReservesLayersJson(wellHandle, strReservesLayers, false);
}
}
}
protected void readTrackWorkAreaData(ulong trackHandle, int ttype, string wellName, bool breadWellTable = true)
{
GeoSigmaWellPoleXY geoSigmaWellPoleXY = (GeoSigmaWellPoleXY)geoSigma;
if ((GeoSigmaWellPoleXY.eWellExtType)(ttype) == GeoSigmaWellPoleXY.eWellExtType.Track_Lith)
{
List<cWellLithology> lstLiths = workAreaDb.Instance.workData.getWellLithologys(wellName);
string jsonStr = "";
WellDataConvert.getWellLithologysJson(ref jsonStr, lstLiths);
geoSigmaWellPoleXY.SetWellTrackDataJson(trackHandle, jsonStr);
}
else if ((GeoSigmaWellPoleXY.eWellExtType)(ttype) == GeoSigmaWellPoleXY.eWellExtType.Track_Shot)
{
List<cPerforation> listPerforations = workAreaDb.Instance.workData.getWellPerforations(wellName);
string jsonStr = "";
WellDataConvert.getWellPerforationsJson(ref jsonStr, listPerforations);
geoSigmaWellPoleXY.SetWellTrackDataJson(trackHandle, jsonStr);
}
else if ((GeoSigmaWellPoleXY.eWellExtType)(ttype) == GeoSigmaWellPoleXY.eWellExtType.Track_Cycle)
{
string strSource, strCol;
strSource = strCol = "";
GeoSigmaWellPoleXY.TrackGetDataSourceID(trackHandle, ref strSource, ref strCol);
WellDataConvert.setWellCycleDataToTrack(geoSigmaWellPoleXY, wellName, trackHandle, strSource);
}
else if ((GeoSigmaWellPoleXY.eWellExtType)(ttype) == GeoSigmaWellPoleXY.eWellExtType.Track_InnerLayer)
{
List<cWellInnerLayer> lstInnerLayers = workAreaDb.Instance.workData.getInnerLayers(wellName);
string jsonStr = "";
WellDataConvert.getInnerLayersJson(ref jsonStr, lstInnerLayers);
geoSigmaWellPoleXY.SetWellTrackDataJson(trackHandle, jsonStr);
}
else if((GeoSigmaWellPoleXY.eWellExtType)(ttype) == GeoSigmaWellPoleXY.eWellExtType.Track_OilTest)
{
List<cWellOilTest> listOilTest = workAreaDb.Instance.workData.getWellOilTests(wellName);
string jsonStr = "";
WellDataConvert.getWellOilTestJson(ref jsonStr, listOilTest);
geoSigmaWellPoleXY.SetWellTrackDataJson(trackHandle, jsonStr);
}
else if ((GeoSigmaWellPoleXY.eWellExtType)(ttype) == GeoSigmaWellPoleXY.eWellExtType.Track_CorePosition)
{
List<cWellCoring> list = workAreaDb.Instance.workData.getWellCorings(wellName);
string jsonStr = "";
WellDataConvert.getWellCoringJson(ref jsonStr, list);
geoSigmaWellPoleXY.SetWellTrackDataJson(trackHandle, jsonStr);
}
else if ((GeoSigmaWellPoleXY.eWellExtType)(ttype) == GeoSigmaWellPoleXY.eWellExtType.Track_CoreWell)
{
List<cWellSideWallCoring> list = workAreaDb.Instance.workData.getWellSideWallCorings(wellName);
string jsonStr = "";
WellDataConvert.getWellSideWallCoringsJson(ref jsonStr, list);
geoSigmaWellPoleXY.SetWellTrackDataJson(trackHandle, jsonStr);
}
else if ((GeoSigmaWellPoleXY.eWellExtType)(ttype) == GeoSigmaWellPoleXY.eWellExtType.Track_CommonData)
{
string strXml = "";
bool b = geoSigmaWellPoleXY.GetWellObjectAttributesXml(trackHandle, (int)GeoSigmaWellPoleXY.eWellExtType.KEP_TRACK, ttype, ref strXml);
if (strXml != "")
{
Type trackType = typeof(WellCommonDataTrack);
WellCommonDataTrack tObjTrack = (WellCommonDataTrack)XmlHelper.Deserialize(trackType, strXml);
if (tObjTrack != null)
{
WellDataConvert.setDataToWellCommonDataTrack(geoSigmaWellPoleXY, wellName, trackHandle,
tObjTrack.dataItems.RefTableId, tObjTrack.dataItems);
}
}
}
else if((GeoSigmaWellPoleXY.eWellExtType)(ttype) == GeoSigmaWellPoleXY.eWellExtType.Track_Text)
{
string tableId="";
string colName="";
GeoSigmaWellPoleXY.TrackGetDataSourceID(trackHandle, ref tableId, ref colName);
WellDataConvert.setWellTableDataToTrack(geoSigmaWellPoleXY,wellName, trackHandle, tableId, colName);
}
else if ((GeoSigmaWellPoleXY.eWellExtType)(ttype) == GeoSigmaWellPoleXY.eWellExtType.Track_Symbol)
{
string tableId = "";
string colName = "";
GeoSigmaWellPoleXY.TrackGetDataSourceID(trackHandle, ref tableId, ref colName);
WellDataConvert.setWellTableDataToTrack(geoSigmaWellPoleXY,wellName, trackHandle, tableId, colName);
}
else
{
if (geoSigmaWellPoleXY.TrackIsWellTableDataSource(trackHandle) == true)
{//井内管理数据就直接读取井内数据。
if (breadWellTable)
{
UInt64 wellHandle = 0;
if (geoSigmaWellPoleXY.GetSelectedWell(ref wellHandle))
{
string tableId = "";
string colId = "";
GeoSigmaWellPoleXY.TrackGetDataSourceID(trackHandle, ref tableId, ref colId);
readOneWellTableFromWorkArea(wellHandle, wellName, tableId);
if (tableId != "")
GeoSigmaWellPoleXY.RefreshAllInTrackObjsForOneWellTable(wellHandle, tableId);
}
}
else
geoSigmaWellPoleXY.TrackReadWellTableData(trackHandle); //读取井内管理的数据
}
else
{//非井内管理数据,就先获得数据源,然后再设置
string sourceId, strColId;
sourceId = strColId = "";
bool b = GeoSigmaWellPoleXY.TrackGetDataSourceID(trackHandle, ref sourceId, ref strColId);
if (b)
{
string jsonStr = "";
WellDataConvert.getDataJson(wellName, sourceId, ref jsonStr);
geoSigmaWellPoleXY.SetWellTrackDataJson(trackHandle, jsonStr);
}
}
}
}
protected void readWorkAreaDataForWell(string wellName, UInt64 wellHandle)
{
GeoSigmaWellPoleXY GeoSigmaWellPoleXY = (GeoSigmaWellPoleXY)geoSigma;
if (GeoSigmaWellPoleXY.GetWellTracks(wellHandle, out ulong[] trackHandles, out int[] ttypes, out string[] dataStrRef))
{
int trackNum = trackHandles.Length;
readAllWellTableFromWorkArea(wellHandle, wellName);//读取井柱的所有井管理数据
DataTable curvesTable = new DataTable();
InterfaceWorkAreaData.LoadCurveData.ResultDataInfo qCurveResult = new InterfaceWorkAreaData.LoadCurveData.ResultDataInfo();
for (int i = 0; i < trackNum; i++)//因为曲线数据是以文件的形式整体存储的,所以先将井的曲线数据都拿出来,然后去匹配。
{
if ((GeoSigmaWellPoleXY.eWellExtType)(ttypes[i]) == GeoSigmaWellPoleXY.eWellExtType.Track_Curve)
{
qCurveResult = workAreaDb.Instance.workData.getCurvesData(wellName, ref curvesTable);
break;
}
}
for (int i = 0; i < trackNum; i++)
{
if ((GeoSigmaWellPoleXY.eWellExtType)(ttypes[i]) == GeoSigmaWellPoleXY.eWellExtType.Track_Curve)
{ //曲线数据
WellDataConvert.getWellCurveValueForNewWell(curvesTable, GeoSigmaWellPoleXY, wellHandle, trackHandles[i], dataStrRef[i]);
continue;
}
readTrackWorkAreaData(trackHandles[i], ttypes[i], wellName, false);
}
}
}
protected void InitDrawer()
{
this.drawer1.ActiveTool = UCDraw.DrawToolType.Default;
this.drawer1.BackColor = System.Drawing.Color.White;
this.drawer1.Bmp = null;
this.drawer1.ChangeLayerEvent = null;
this.drawer1.CurveAddNode = null;
this.drawer1.CurveDeleteNode = null;
this.drawer1.Dock = System.Windows.Forms.DockStyle.Fill;
this.drawer1.DrawerCommandFinish = null;
this.drawer1.DrawerCommandStart = null;
this.drawer1.DrawerEnd = null;
this.drawer1.DrawerGotFocus = null;
this.drawer1.DrawerOnPaint = null;
this.drawer1.DrawerOperation = 0;
this.drawer1.DrawerPrintPreview = null;
this.drawer1.DrawerScroll = null;
this.drawer1.DrawerViewAll = null;
this.drawer1.DrawerViewPan = null;
this.drawer1.DrawerWheel = null;
this.drawer1.DrawerZoomIn = null;
this.drawer1.DrawerZoomOut = null;
this.drawer1.DrawFileName = "";
this.drawer1.EnableCrossLine = false;
this.drawer1.EnableRedraw = true;
this.drawer1.ENCurveLoadHandler = null;
this.drawer1.Geo = null;
this.drawer1.GetLengthAngleEvent = null;
this.drawer1.ImgLocation = new System.Drawing.Point(0, 0);
this.drawer1.IsTextInputing = false;
this.drawer1.IsViewStatusChanged = false;
this.drawer1.Location = new System.Drawing.Point(0, 0);
this.drawer1.Margin = new System.Windows.Forms.Padding(0);
this.drawer1.MouseDownHandler = null;
this.drawer1.MouseMoveInfo = null;
this.drawer1.Name = "drawer1";
this.drawer1.NeedOverlayEvent = null;
this.drawer1.NeedShowMenu = true;
this.drawer1.PaintGraphics = null;
this.drawer1.PaintingImage = null;
this.drawer1.RecoverMode = false;
this.drawer1.RedrawedEvent = null;
this.drawer1.ScreenLocationChanged = null;
this.drawer1.SelectedElementChanged = null;
this.drawer1.SelectedMultiElements = null;
this.drawer1.SelectedWell = null;
this.drawer1.SetVtkMainMeshEvent = null;
this.drawer1.ShowNavigationEvent = null;
this.drawer1.Size = new System.Drawing.Size(507, 312);
this.drawer1.SymbolViewFlag = false;
this.drawer1.TabIndex = 6;
this.drawer1.ViewBackColor = System.Drawing.Color.White;
this.drawer1.WaitProgressEvent = null;
this.drawer1.MouseMove += new System.Windows.Forms.MouseEventHandler(this.drawer1_MouseMove);
}
}
}