|
|
// <copyright file="DrawView.cs" company="PlaceholderCompany">
|
|
|
// Copyright (c) PlaceholderCompany. All rights reserved.
|
|
|
// </copyright>
|
|
|
|
|
|
using Detria;
|
|
|
using DevExpress.XtraSpreadsheet.Model;
|
|
|
using GeoSigma.SigmaDrawerElement;
|
|
|
using GeoSigma.SigmaDrawerStyle;
|
|
|
using GeoSigma.UCDraw;
|
|
|
using GeoSigma.UCDraw.WellAndSection;
|
|
|
using GeoSigmaDrawLib;
|
|
|
using InterfaceWorkAreaData;
|
|
|
//using DQ.Construction.NewLook.Utility;
|
|
|
using InterfaceWorkAreaData.LoadCurveData;
|
|
|
using NetTopologySuite;
|
|
|
using NetTopologySuite.Algorithm;
|
|
|
using NetTopologySuite.Geometries;
|
|
|
using NetTopologySuite.Operation.Distance;
|
|
|
using NetTopologySuite.Operation.Overlay;
|
|
|
using NetTopologySuite.Operation.OverlayNG;
|
|
|
using NetTopologySuite.Precision;
|
|
|
using SigmaDrawerElement;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Data;
|
|
|
using System.Diagnostics;
|
|
|
using System.Drawing;
|
|
|
using System.IO;
|
|
|
using System.Linq;
|
|
|
using System.Text;
|
|
|
using System.Threading;
|
|
|
using System.Windows.Forms;
|
|
|
using System.Xml;
|
|
|
using WellWorkDataUI;
|
|
|
using WorkData;
|
|
|
using WorkData.Entity;
|
|
|
using Math = System.Math;
|
|
|
|
|
|
namespace UCDraw
|
|
|
{
|
|
|
//public delegate void StatusColumnInfo(string msg);
|
|
|
//public delegate void EmptyNameCurveLoadHandler(string itemString);
|
|
|
//public delegate void ViewerTipMessageHandler(string tipMessage);
|
|
|
//public delegate void DrawerViewChangeLayerEvent(string eventKind);
|
|
|
//public delegate void MainViewInfoHandler(string info);
|
|
|
|
|
|
/* 基类中 Drawer1在 WellSectionDrawView.designer.cs使用,但是每次修改此设计,会导致Draw1代码被删除,因此需要手动恢复,具体参考WellPoleDrawView.designer.cs中的Draw1*/
|
|
|
public partial class WellPoleDrawViewer : WellBaseDrawView
|
|
|
{
|
|
|
|
|
|
private double smallScollFactor = 0.02;
|
|
|
private double largeScrollFactor = 0.9;
|
|
|
private int scrollPositionYLast = 0;
|
|
|
private bool needHScrollToEnd = false;
|
|
|
private bool needHScrollToBegin = false;
|
|
|
private bool needVScrollToTop = false;
|
|
|
private bool needVScrollToBottom = false;
|
|
|
|
|
|
#region 打印
|
|
|
private PrinterStatus printerStatus = null;
|
|
|
private PrinterDrawer printerDrawer;
|
|
|
private PrintPreviewControl printPreview;
|
|
|
private ViewFactor viewFactor; //进入打印预览后,可能会改变视图。待退出打印预览后,恢复原来的视图。
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
public WellPoleDrawViewer(GeoSigmaXY.eViewType vType = GeoSigmaXY.eViewType.plane)
|
|
|
{
|
|
|
mViewType = vType;
|
|
|
System.Security.Cryptography.RNGCryptoServiceProvider csp = new System.Security.Cryptography.RNGCryptoServiceProvider();
|
|
|
byte[] byteCsp = new byte[10];
|
|
|
csp.GetBytes(byteCsp);
|
|
|
ID = BitConverter.ToInt32(byteCsp, 0);
|
|
|
|
|
|
InitializeComponent();
|
|
|
InitDrawer();
|
|
|
|
|
|
this.Drawer.mViewType = vType;
|
|
|
this.BorderStyle = BorderStyle.None;
|
|
|
//.Dock = DockStyle.Fill;
|
|
|
//pnlMain.Controls.Add(draw1);
|
|
|
//HRuler.Size = new Size(HRuler.Size.Width, 20);
|
|
|
pnlMain.Refresh();
|
|
|
|
|
|
////hRuler1.InitTransform(drawer1.GetRangeGetter());
|
|
|
////vRuler1.InitTransform(drawer1.GetRangeGetter());
|
|
|
|
|
|
////drawer1.MouseMove += hRuler1.ProcessMouseMove;
|
|
|
////drawer1.DrawerZoomIn += hRuler1.Zoom;
|
|
|
////drawer1.DrawerZoomOut += hRuler1.Zoom;
|
|
|
////drawer1.DrawerViewAll += hRuler1.Zoom;
|
|
|
////drawer1.DrawerViewPan += hRuler1.ReDraw;
|
|
|
////drawer1.DrawerOnPaint += hRuler1.ReDraw;
|
|
|
|
|
|
////drawer1.MouseMove += vRuler1.ProcessMouseMove;
|
|
|
////drawer1.DrawerZoomIn += vRuler1.Zoom;
|
|
|
////drawer1.DrawerZoomOut += vRuler1.Zoom;
|
|
|
////drawer1.DrawerViewAll += vRuler1.Zoom;
|
|
|
////drawer1.DrawerViewPan += vRuler1.ReDraw;
|
|
|
////drawer1.DrawerOnPaint += vRuler1.ReDraw;
|
|
|
////drawer1.DrawerPrintPreview += PreviewPrint;
|
|
|
|
|
|
////drawer1.DrawerChangedViewBySynchronizeEvent += (drawer, e) =>
|
|
|
////{
|
|
|
//// vRuler1.Invalidate();
|
|
|
//// hRuler1.Invalidate();
|
|
|
////};
|
|
|
|
|
|
////this.MouseWheel+=Viewer_MouseWheel;
|
|
|
////this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
|
|
|
////this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
|
|
|
|
|
|
this.drawer1.SetScrollBar += SetScrollBar;
|
|
|
this.drawer1.DrawerScroll += ScrollScreenAndBar;
|
|
|
this.drawer1.DrawerWheel += ScrollByWheel;
|
|
|
|
|
|
// drawer1.DrawerGotFocus += drawer1_DrawerGotFocus;
|
|
|
drawer1.ENCurveLoadHandler += HandleEmptyNameCurve;
|
|
|
|
|
|
#region 打印
|
|
|
//NewMethod();
|
|
|
#endregion
|
|
|
|
|
|
// drawer1.DrawerCommandStart += OnCommandStart;
|
|
|
// drawer1.DrawerCommandFinish += OnCommandFinish;
|
|
|
//drawer1.TipMessageHandler += ShowTipMessage;
|
|
|
drawer1.ChangeLayerEvent += OnChangeLayer;
|
|
|
drawer1.GetLengthAngleEvent += GetLengthAngle;
|
|
|
|
|
|
drawer1.m_GetWellPoleDocContextMenu = new Drawer.DeletateGetWellPoleDocContextMenu(this.getWellPoleDocContextMenu);// WellPoleDrawViewer.getWellPoleDocContextMenu);
|
|
|
}
|
|
|
//public void SetDrawerMouseLocation(double dx, double dy)
|
|
|
//{
|
|
|
// drawer1?.SetMouseLocation(dx, dy);
|
|
|
//}
|
|
|
/// <summary>
|
|
|
/// 导出到图片
|
|
|
/// </summary>
|
|
|
/// <param name="fileFullPath">文件路径</param>
|
|
|
/// <returns>是否成功</returns>
|
|
|
//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);
|
|
|
//}
|
|
|
private void InitPrint()
|
|
|
{
|
|
|
if (printerStatus != null) return;
|
|
|
viewFactor = new ViewFactor();
|
|
|
viewFactor.zoomFactor = 1;
|
|
|
|
|
|
printerStatus = new PrinterStatus();
|
|
|
|
|
|
printPreview = new PrintPreviewControl();
|
|
|
printerDrawer = new PrinterDrawer(printerStatus, printPreview);
|
|
|
pnlMain.Controls.Add(printPreview);
|
|
|
}
|
|
|
|
|
|
//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();
|
|
|
// 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);
|
|
|
//}
|
|
|
//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;
|
|
|
// }
|
|
|
//}
|
|
|
//private bool enableMeshPack = true;
|
|
|
//public bool EnableMeshPack
|
|
|
//{
|
|
|
// get
|
|
|
// {
|
|
|
// return enableMeshPack;
|
|
|
// }
|
|
|
// set
|
|
|
// {
|
|
|
// enableMeshPack = value;
|
|
|
// }
|
|
|
//}
|
|
|
//public ViewOperationKind GetViewOperationKind()
|
|
|
//{
|
|
|
// return drawer1.ViewOpKind;
|
|
|
//}
|
|
|
//public void SetViewOperationKind(ViewOperationKind kind)
|
|
|
//{
|
|
|
// drawer1.SetViewOperationKind(kind);
|
|
|
//}
|
|
|
private void SetStateOfControls()
|
|
|
{
|
|
|
if (needHScrollToEnd)
|
|
|
{
|
|
|
scrollH.Value = scrollH.Maximum - scrollH.LargeChange + 1;
|
|
|
needHScrollToEnd = false;
|
|
|
}
|
|
|
if (needHScrollToBegin)
|
|
|
{
|
|
|
scrollH.Value = scrollH.Minimum;
|
|
|
needHScrollToBegin = false;
|
|
|
}
|
|
|
if (needVScrollToBottom)
|
|
|
{
|
|
|
int nCurValue = scrollV.Maximum - scrollV.LargeChange + 1;
|
|
|
if (nCurValue > scrollV.Maximum)
|
|
|
{
|
|
|
nCurValue = scrollV.Maximum;
|
|
|
}
|
|
|
scrollV.Value = nCurValue;
|
|
|
needVScrollToBottom = false;
|
|
|
}
|
|
|
if (needVScrollToTop)
|
|
|
{
|
|
|
scrollV.Value = scrollV.Minimum;
|
|
|
needVScrollToTop = false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
protected override void OnHandleCreated(EventArgs e)
|
|
|
{
|
|
|
base.OnHandleCreated(e);
|
|
|
//Application.Idle += Application_Idle;
|
|
|
}
|
|
|
|
|
|
protected override void OnHandleDestroyed(EventArgs e)
|
|
|
{
|
|
|
base.OnHandleDestroyed(e);
|
|
|
|
|
|
//Application.Idle -= Application_Idle;
|
|
|
}
|
|
|
private void Application_Idle(object sender, EventArgs e)
|
|
|
{
|
|
|
SetStateOfControls();
|
|
|
}
|
|
|
|
|
|
//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 override 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 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 override bool NewFile(string fileName, GeoSigmaXY.eViewType vType = GeoSigmaXY.eViewType.wellpole)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
if (drawer1 == null)
|
|
|
{
|
|
|
MessageBox.Show("drawer1 == null");
|
|
|
}
|
|
|
geoSigma = drawer1.NewFile(fileName, this.mNewWellInfo, vType);
|
|
|
|
|
|
if (vType != GeoSigmaXY.eViewType.wellpole)
|
|
|
return true;
|
|
|
|
|
|
if (workAreaDb.Instance.workData.isConn() == false)
|
|
|
return true;
|
|
|
|
|
|
UInt64 wellHandle = 0;
|
|
|
GeoSigmaWellPoleXY GeoSigmaWellPoleXY = (GeoSigmaWellPoleXY)geoSigma;
|
|
|
if (mNewWellInfo.tid != -1 && GeoSigmaWellPoleXY.GetSelectedWell(ref wellHandle) == true)
|
|
|
{
|
|
|
readWorkAreaDataForWell(this.mNewWellInfo.wellName,wellHandle);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
Console.WriteLine(ex.Message);
|
|
|
return false;
|
|
|
}
|
|
|
if (geoSigma == null)
|
|
|
{
|
|
|
return false;
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 将全部内容当前分辨率保存到指定输出文件.
|
|
|
/// </summary>
|
|
|
/// <param name="outputFile">The output file.</param>
|
|
|
/// <param name="left"></param>
|
|
|
/// <param name="top"></param>
|
|
|
/// <param name="right"></param>
|
|
|
/// <param name="bottom"></param>
|
|
|
//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;
|
|
|
//}
|
|
|
#region 打印
|
|
|
public override void PreviewPrint()
|
|
|
{
|
|
|
InitPrint();
|
|
|
// vRuler1.Hide();
|
|
|
// hRuler1.Hide();
|
|
|
pnlScrollV.Hide();
|
|
|
pnlScrollH.Hide();
|
|
|
drawer1.Hide();
|
|
|
|
|
|
printerStatus.Init(drawer1.Geo);
|
|
|
printerDrawer.Init(drawer1.Geo);
|
|
|
|
|
|
// drawer1.MouseMove -= hRuler1.ProcessMouseMove;
|
|
|
// drawer1.MouseMove -= vRuler1.ProcessMouseMove;
|
|
|
drawer1.Anchor = AnchorStyles.None;
|
|
|
drawer1.Geo.GetViewFactors(ref viewFactor);
|
|
|
|
|
|
LayoutPreviewPrintCtrl();
|
|
|
}
|
|
|
|
|
|
public void OnClosePreviewWindow(object sender, EventArgs e)
|
|
|
{
|
|
|
// vRuler1.Show();
|
|
|
// hRuler1.Show();
|
|
|
pnlScrollV.Show();
|
|
|
pnlScrollH.Show();
|
|
|
//previewPrintBar.Hide();
|
|
|
printPreview.Visible = false;
|
|
|
|
|
|
// drawer1.MouseMove += hRuler1.ProcessMouseMove;
|
|
|
// drawer1.MouseMove += vRuler1.ProcessMouseMove;
|
|
|
drawer1.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
|
|
|
|
|
drawer1.RecoverView(viewFactor);
|
|
|
drawer1.Show();
|
|
|
}
|
|
|
|
|
|
protected void LayoutPreviewPrintCtrl()
|
|
|
{
|
|
|
//int previewHeight = Height - previewPrintBar.Height;
|
|
|
//int previewWidth = PrintTool.GetWidthOfPreviewPrintCanvas(printerStatus.PaperName, printerStatus.Orientation, previewHeight);
|
|
|
// int previewX = (Width - previewWidth) / 2;
|
|
|
//printPreview.Location = new Point(previewX, previewPrintBar.Height);
|
|
|
//printPreview.Width = previewWidth;
|
|
|
//printPreview.Height = Height; //previewHeight;
|
|
|
//printPreview.Visible = true;
|
|
|
printerDrawer.Redraw();
|
|
|
}
|
|
|
|
|
|
protected override void OnResize(EventArgs e)
|
|
|
{
|
|
|
base.OnResize(e);
|
|
|
if (printPreview == null || printPreview.Visible == false)
|
|
|
return;
|
|
|
|
|
|
LayoutPreviewPrintCtrl();
|
|
|
}
|
|
|
#endregion
|
|
|
//public int SelectByNames(string nameData)
|
|
|
//{
|
|
|
// return Drawer.SelectByNames(nameData);
|
|
|
//}
|
|
|
/// <summary>
|
|
|
/// 根据名称查找并激活图元
|
|
|
/// </summary>
|
|
|
/// <param name="content">图元名称</param>
|
|
|
/// <param name="matchAll">全字匹配</param>
|
|
|
/// <param name="matchCase">匹配大小写</param>
|
|
|
/// <param name="elementType">图元类型</param>
|
|
|
/// <param name="editableOnly">是否只查找可编辑图元</param>
|
|
|
/// <returns>查找结果</returns>
|
|
|
//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;
|
|
|
//}
|
|
|
|
|
|
//public void InvokeSelectedChanged(string elementData, long position)
|
|
|
//{
|
|
|
// this.SelectedElementPosition=position;
|
|
|
// if (SelectedElementChanged!=null)
|
|
|
// {
|
|
|
// SelectedElementChanged(this, new ElementArgs(elementData, position));
|
|
|
// }
|
|
|
//}
|
|
|
|
|
|
///// <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;
|
|
|
//}
|
|
|
/// <summary>
|
|
|
/// Sets the state of the layer.
|
|
|
/// </summary>
|
|
|
/// <param name="layerName">Name of the layer.</param>
|
|
|
/// <param name="status">The status.</param>
|
|
|
//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);
|
|
|
//}
|
|
|
//private void Viewer_MouseWheel(object sender, MouseEventArgs e)
|
|
|
//{
|
|
|
// if (geoSigma==null) return;
|
|
|
// // 屏幕坐标偏移量
|
|
|
// int nOffsetScreen = this.VerticalScroll.Value -this.scrollPositionYLast;
|
|
|
|
|
|
// int nScreenAllVert = this.VerticalScroll.Maximum-this.VerticalScroll.Minimum;
|
|
|
// // 实际坐标偏移量
|
|
|
// double dOffsetReal = ((double)nOffsetScreen/nScreenAllVert)* this.mapRange.Height;
|
|
|
|
|
|
// geoSigma.Scroll((int)ScrollOrientation.VerticalScroll, dOffsetReal);
|
|
|
|
|
|
// scrollPositionYLast=this.VerticalScroll.Value;
|
|
|
|
|
|
// geoSigma.EnableRedraw(true);
|
|
|
//}
|
|
|
private void SetScrollBar(object sender, EventArgs e)
|
|
|
{
|
|
|
if (mViewType == GeoSigmaXY.eViewType.wellpole)
|
|
|
{
|
|
|
SetScrollBarForWellPole(sender, e);
|
|
|
return;
|
|
|
}
|
|
|
if (geoSigma == null)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
ScrollArgs args = e as ScrollArgs;
|
|
|
int hMax = 0, vMax = 0, hPage = 0, vPage = 0, hPos = 0, vPos = 0;
|
|
|
geoSigma.SetScrollBar(ref hMax, ref vMax, ref hPage, ref vPage, ref hPos, ref vPos);
|
|
|
if (hMax < 100)
|
|
|
{
|
|
|
hMax = 100;
|
|
|
}
|
|
|
if (vMax < 100)
|
|
|
{
|
|
|
vMax = 100;
|
|
|
}
|
|
|
if (hPos == 0)
|
|
|
{
|
|
|
//scrollH.Visible = false;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
scrollH.Visible = true;
|
|
|
}
|
|
|
if (vPos == 0)
|
|
|
{
|
|
|
//scrollV.Visible = false;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
scrollV.Visible = true;
|
|
|
}
|
|
|
|
|
|
if (hMax < args.ScreenRect.Width)
|
|
|
{
|
|
|
hMax = args.ScreenRect.Width;
|
|
|
hPage = hMax;
|
|
|
hPos = 0;
|
|
|
}
|
|
|
if (vMax < args.ScreenRect.Height)
|
|
|
{
|
|
|
vMax = args.ScreenRect.Height;
|
|
|
vPage = vMax;
|
|
|
vPos = 0;
|
|
|
}
|
|
|
// nMin、nPage、nPos与控件Min,LargeChange、value类似
|
|
|
// 但nMax相当于Max+LargeChange-1
|
|
|
int nMaxValueH = hMax; // hMax-hPage+1;
|
|
|
int nMaxValueV = vMax;
|
|
|
this.scrollH.Minimum = 0;
|
|
|
this.scrollH.Maximum = nMaxValueH;
|
|
|
this.scrollH.LargeChange = (int)((hPage * largeScrollFactor) + 0.5);
|
|
|
this.scrollH.SmallChange = (int)((hPage * 0.2) + 0.5);
|
|
|
if (hPos >= this.scrollH.Minimum && hPos <= this.scrollH.Maximum)
|
|
|
{
|
|
|
this.scrollH.Value = hPos;
|
|
|
}
|
|
|
|
|
|
this.scrollV.Minimum = 0;
|
|
|
this.scrollV.Maximum = nMaxValueV;
|
|
|
this.scrollV.LargeChange = vPage;
|
|
|
this.scrollV.SmallChange = (int)((vPage * 0.2) + 0.5);
|
|
|
if (vPos >= this.scrollV.Minimum && vPos <= this.scrollV.Maximum)
|
|
|
{
|
|
|
this.scrollV.Value = vPos;
|
|
|
}
|
|
|
|
|
|
this.drawer1.ScreenLocationChanged?.Invoke();
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
}
|
|
|
///// <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);
|
|
|
//}
|
|
|
/// <summary>
|
|
|
/// 滚动条事件
|
|
|
/// </summary>
|
|
|
/// <param name="sender"></param>
|
|
|
/// <param name="e"></param>
|
|
|
private void Viewer_Scroll(object sender, ScrollEventArgs e)
|
|
|
{
|
|
|
if (e.Type == ScrollEventType.EndScroll)
|
|
|
{
|
|
|
//Scroll2(800);
|
|
|
return;
|
|
|
}
|
|
|
if (geoSigma == null) return;
|
|
|
|
|
|
if (e.ScrollOrientation == ScrollOrientation.HorizontalScroll)
|
|
|
{
|
|
|
if (Viewer_ScrollHori(sender, e) == true)
|
|
|
{
|
|
|
drawer1.IsViewStatusChanged = true;
|
|
|
}
|
|
|
}
|
|
|
else if (e.ScrollOrientation == ScrollOrientation.VerticalScroll)
|
|
|
{
|
|
|
if (Viewer_ScrollVert(sender, e))
|
|
|
{
|
|
|
drawer1.IsViewStatusChanged = true;
|
|
|
}
|
|
|
}
|
|
|
scrollPositionYLast = this.VerticalScroll.Value;
|
|
|
// 通知相关控件
|
|
|
drawer1.ScreenLocationChanged?.Invoke();
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 水平滚动条
|
|
|
/// </summary>
|
|
|
/// <param name="sender">sender</param>
|
|
|
/// <param name="e">参数</param>
|
|
|
private bool Viewer_ScrollHori(object sender, ScrollEventArgs e)
|
|
|
{
|
|
|
if (this.mViewType == GeoSigmaXY.eViewType.wellpole)
|
|
|
return ScrollHoriForWellPole((int)(e.ScrollOrientation), (int)e.Type, e.NewValue - e.OldValue);
|
|
|
else
|
|
|
return ScrollHori((int)(e.ScrollOrientation), (int)e.Type, e.NewValue - e.OldValue);
|
|
|
}
|
|
|
|
|
|
/// <param name="nOrientation">纵向、横向</param>
|
|
|
/// <param name="nType">ScrollEventType</param>
|
|
|
/// <param name="nValue">滚动条变化量</param>
|
|
|
private bool ScrollHori(int nOrientation, int nType, int nValue)
|
|
|
{
|
|
|
//geoSigma.HScroll(nType, e.NewValue, scrollH.Maximum-scrollH.LargeChange+1);
|
|
|
|
|
|
// 屏幕总宽度
|
|
|
int nScreenAllHor = this.scrollH.Maximum - this.scrollH.Minimum;
|
|
|
// 屏幕宽度 Ws
|
|
|
int nWs = drawer1.Width;
|
|
|
// 屏幕实际距离 Wr
|
|
|
double dWtest = geoSigma.GetRealWidth(nValue);
|
|
|
double dWs = geoSigma.GetRealWidth(nWs);
|
|
|
// dOffset = Wr*nValue/Ws;
|
|
|
double dOffset = 0;
|
|
|
if (Math.Abs(nValue) < 0.01)
|
|
|
{
|
|
|
// TODO:需要进一步修改屏幕滚动范围
|
|
|
if (nType == (int)ScrollEventType.SmallIncrement)
|
|
|
{
|
|
|
nValue = this.scrollH.SmallChange;
|
|
|
scrollH.Maximum = scrollH.Maximum + nValue;
|
|
|
double dF = (double)nValue / nWs;
|
|
|
dOffset = dWs * dF;
|
|
|
//drawer1.enlargeRight(dOffset);
|
|
|
needHScrollToEnd = true;
|
|
|
}
|
|
|
else if (nType == (int)ScrollEventType.SmallDecrement)
|
|
|
{
|
|
|
nValue = -this.scrollH.SmallChange;
|
|
|
scrollH.Minimum = scrollH.Minimum + nValue;
|
|
|
double dF = (double)nValue / nWs;
|
|
|
dOffset = dWs * dF;
|
|
|
//drawer1.enlargeLeft(Math.Abs(dOffset));
|
|
|
needHScrollToBegin = true;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
// 计算实际坐标变化量
|
|
|
// 变化比例
|
|
|
//double dF = (double)nValue/(nScreenAllHor-this.scrollH.LargeChange+1);
|
|
|
//dOffset=dF*drawer1.MapRange.Width;
|
|
|
double dF = (double)nValue / nWs;
|
|
|
dOffset = dWs * dF;
|
|
|
}
|
|
|
//Console.WriteLine(string.Format("offset {0}", dOffset));
|
|
|
geoSigma.Scroll(nOrientation, dOffset);
|
|
|
drawer1.EnableRedraw = true;
|
|
|
drawer1.Invalidate();
|
|
|
return true;
|
|
|
}
|
|
|
public void Scroll2(int scrollValue)
|
|
|
{
|
|
|
scrollH.Value = scrollValue;
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 垂直滚动条
|
|
|
/// </summary>
|
|
|
/// <param name="sender"></param>
|
|
|
/// <param name="e"></param>
|
|
|
private bool Viewer_ScrollVert(object sender, ScrollEventArgs e)
|
|
|
{
|
|
|
if (this.mViewType == GeoSigmaXY.eViewType.wellpole)
|
|
|
return ScrollVertForWellPole((int)e.ScrollOrientation, (int)e.Type, e.NewValue - e.OldValue);
|
|
|
else
|
|
|
return ScrollVert((int)e.ScrollOrientation, (int)e.Type, e.NewValue - e.OldValue);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 竖向滚动.
|
|
|
/// </summary>
|
|
|
/// <param name="nOrientation">The n orientation.</param>
|
|
|
/// <param name="nType">The n type.</param>
|
|
|
/// <param name="nValue">The n value.</param>
|
|
|
/// <returns>A bool.</returns>
|
|
|
private bool ScrollVert(int nOrientation, int nType, int nValue)
|
|
|
{
|
|
|
int nScreenAllVert = this.scrollV.Maximum - this.scrollV.Minimum;
|
|
|
// 屏幕高度 Ws
|
|
|
int nHs = drawer1.Height;
|
|
|
// 屏幕实际距离 Wr
|
|
|
double dHs = geoSigma.GetRealHeight(nHs);
|
|
|
|
|
|
double dOffset = 0;
|
|
|
if (Math.Abs(nValue) < 0.01)
|
|
|
{
|
|
|
if (nType == (int)ScrollEventType.SmallIncrement)
|
|
|
{
|
|
|
nValue = this.scrollV.SmallChange;
|
|
|
scrollV.Maximum = scrollV.Maximum + nValue;
|
|
|
double dF = (double)nValue / nHs;
|
|
|
dOffset = dHs * dF;
|
|
|
//dOffset=((double)nValue/nScreenAllVert)*drawer1.MapRange.Height;
|
|
|
//drawer1.enlargeBottom(dOffset);
|
|
|
needVScrollToBottom = true;
|
|
|
}
|
|
|
else if (nType == (int)ScrollEventType.SmallDecrement)
|
|
|
{
|
|
|
nValue = -this.scrollV.SmallChange;
|
|
|
scrollV.Minimum = scrollV.Minimum + nValue;
|
|
|
double dF = (double)nValue / nHs;
|
|
|
dOffset = dHs * dF;
|
|
|
//dOffset=((double)nValue/nScreenAllVert)*drawer1.MapRange.Height;
|
|
|
//drawer1.enlargeTop(dOffset);
|
|
|
needVScrollToTop = true;
|
|
|
}
|
|
|
else { return false; }
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//double dF = (double)nValue/(nScreenAllVert-this.scrollV.LargeChange+1);
|
|
|
//dOffset=dF* drawer1.MapRange.Height;
|
|
|
double dF = (double)nValue / nHs;
|
|
|
dOffset = dHs * dF;
|
|
|
}
|
|
|
geoSigma.Scroll(nOrientation, -dOffset);
|
|
|
drawer1.EnableRedraw = true;
|
|
|
drawer1.Invalidate();
|
|
|
return true;
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 更新属性界面
|
|
|
/// </summary>
|
|
|
public void RefreshProperty()
|
|
|
{
|
|
|
drawer1?.RefreshProperty();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// //通过滑轮滚动图形
|
|
|
/// </summary>
|
|
|
/// <param name="bUp">true向上滚动图形 false向下滚动图形</param>
|
|
|
private void ScrollByWheel(bool bUp)
|
|
|
{
|
|
|
if (mViewType == GeoSigmaXY.eViewType.wellpole)
|
|
|
{
|
|
|
ScrollByWheelForWellPole(bUp);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (geoSigma == null)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
int nValue = this.scrollV.SmallChange;
|
|
|
|
|
|
if (bUp == false)
|
|
|
{
|
|
|
int v = scrollV.Value + nValue;
|
|
|
if (v > scrollV.Maximum)
|
|
|
{
|
|
|
scrollV.Maximum = v;
|
|
|
}
|
|
|
scrollV.Value = v;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
int v = scrollV.Value - nValue;
|
|
|
if (v < scrollV.Minimum)
|
|
|
{
|
|
|
scrollV.Minimum = v;
|
|
|
}
|
|
|
scrollV.Value = v;
|
|
|
}
|
|
|
|
|
|
int nHs = drawer1.Height; // 屏幕高度
|
|
|
|
|
|
double dHs = geoSigma.GetRealHeight(nHs); // 屏幕实际距离
|
|
|
double dF = (double)nValue / nHs;
|
|
|
double dOffset = dHs * dF;
|
|
|
|
|
|
if (bUp)
|
|
|
{
|
|
|
//1--ScrollOrientation.VerticalScroll
|
|
|
geoSigma.Scroll(1, dOffset);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
geoSigma.Scroll(1, -dOffset);
|
|
|
}
|
|
|
|
|
|
drawer1.EnableRedraw = true;
|
|
|
drawer1.Invalidate();
|
|
|
// 通知相关控件
|
|
|
drawer1.ScreenLocationChanged?.Invoke();
|
|
|
}
|
|
|
//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);
|
|
|
//}
|
|
|
private void Viewer_Resize(object sender, EventArgs e)
|
|
|
{
|
|
|
//drawer1.ReDraw();
|
|
|
}
|
|
|
//public void ReDrawWindow()
|
|
|
//{
|
|
|
// drawer1.ReDrawWindow();
|
|
|
//}
|
|
|
|
|
|
//private void ShowTipMessage(string tipMessage)
|
|
|
//{
|
|
|
// TipMessageHandler?.Invoke(tipMessage);
|
|
|
//}
|
|
|
private void drawer1_DrawerGotFocus(object sender, EventArgs e)
|
|
|
{
|
|
|
if (DrawerGotFocus != null)
|
|
|
{
|
|
|
DrawerGotFocus(sender, e);
|
|
|
}
|
|
|
}
|
|
|
///// <summary>
|
|
|
///// 创建泰森图.
|
|
|
///// </summary>
|
|
|
///// <returns>块数</returns>
|
|
|
//public int CreateVoronoi()
|
|
|
//{
|
|
|
// return geoSigma.CreateVoronoi();
|
|
|
//}
|
|
|
//public int CreateVoronoi2()
|
|
|
//{
|
|
|
// return 0;
|
|
|
//}
|
|
|
|
|
|
private bool ptInRange(IEnumerable<Coordinate> coors, Coordinate coor, GeometryFactory gf)
|
|
|
{
|
|
|
Coordinate coorStart = coors.First();//[0];
|
|
|
Coordinate coorEnd = coors.Last();//[coors.Count - 1];
|
|
|
double dDist = DistanceOp.Distance(gf.CreatePoint(coorStart), gf.CreatePoint(coorEnd));
|
|
|
LineString line = new LineString(coors.ToArray());
|
|
|
double dLength = line.Length;
|
|
|
// 不是闭合多边形
|
|
|
if (dDist > dLength * 0.1)
|
|
|
{
|
|
|
return false;
|
|
|
}
|
|
|
Polygon poly = null;
|
|
|
if (coorStart.X != coorEnd.X || coorStart.X != coorEnd.Y)
|
|
|
{
|
|
|
Coordinate[] caCoor = new Coordinate[coors.Count() + 1];
|
|
|
coors.ToArray().CopyTo(caCoor, 0);
|
|
|
caCoor[caCoor.Length - 1] = caCoor[0];
|
|
|
poly = gf.CreatePolygon(caCoor);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
poly = gf.CreatePolygon(coors.ToArray());
|
|
|
}
|
|
|
return poly.Covers(gf.CreatePoint(coor));
|
|
|
}
|
|
|
|
|
|
///// <summary>
|
|
|
///// 创建三角网
|
|
|
///// </summary>
|
|
|
///// <returns>块数</returns>
|
|
|
//public int CreateDelaunay()
|
|
|
//{
|
|
|
// return 0;
|
|
|
//}
|
|
|
///// <summary>
|
|
|
///// 创建三角网
|
|
|
///// </summary>
|
|
|
///// <returns>块数</returns>
|
|
|
//public int CreateDelaunayConstraint()
|
|
|
//{
|
|
|
// return 0;
|
|
|
//}
|
|
|
private List<Polygon> safeUnion(List<Geometry> polygons)
|
|
|
{
|
|
|
if (polygons == null || polygons.Count == 0)
|
|
|
{
|
|
|
return new List<Polygon>();
|
|
|
}
|
|
|
if (polygons.Count == 1)
|
|
|
{
|
|
|
return new List<Polygon>() { (Polygon)polygons[0] };
|
|
|
}
|
|
|
|
|
|
var unionResult = new List<Polygon>();
|
|
|
var current = polygons[0];
|
|
|
|
|
|
for (int i = 1; i < polygons.Count; i++)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
current = current.Union(polygons[i]);
|
|
|
}
|
|
|
catch (TopologyException ex)
|
|
|
{
|
|
|
// 分步失败时尝试修复后合并
|
|
|
var cleaned2 = polygons[i].Buffer(0);
|
|
|
var pm = new PrecisionModel(1000); // 1e3 = 3位小数
|
|
|
var geom2Prec = GeometryPrecisionReducer.Reduce(cleaned2, pm);
|
|
|
current = OverlayNG.Overlay(current, geom2Prec, SpatialFunction.Union);
|
|
|
//double eps = 1e-6;
|
|
|
//var bufA = current.Buffer(eps);
|
|
|
//var bufB = polygons[i].Buffer(eps);
|
|
|
|
|
|
//var tmp = bufA.Union(bufB);
|
|
|
//current = tmp.Buffer(-eps);
|
|
|
|
|
|
Trace.WriteLine($"断层合并出错:{ex.Message}");
|
|
|
}
|
|
|
}
|
|
|
if (current is MultiPolygon muit)
|
|
|
{
|
|
|
return muit.Geometries.Cast<Polygon>().ToList();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
unionResult.Add(current as Polygon);
|
|
|
}
|
|
|
return unionResult;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 将两个仅在单一顶点相连的多边形合并为一个连通 Polygon
|
|
|
/// </summary>
|
|
|
public static Polygon MergeAtSharedVertex(Polygon poly1, Polygon poly2)
|
|
|
{
|
|
|
// 1. 提取外环坐标并检测/修正方向
|
|
|
var coords1 = poly1.ExteriorRing.Coordinates;
|
|
|
var coords2 = poly2.ExteriorRing.Coordinates;
|
|
|
if (!NetTopologySuite.Algorithm.Orientation.IsCCWArea(coords1))
|
|
|
{
|
|
|
Array.Reverse(coords1);
|
|
|
}
|
|
|
|
|
|
if (!NetTopologySuite.Algorithm.Orientation.IsCCWArea(coords2))
|
|
|
{
|
|
|
Array.Reverse(coords2);
|
|
|
}
|
|
|
|
|
|
// 2. 定位唯一共享顶点
|
|
|
var shared = coords1.FirstOrDefault(c1 =>
|
|
|
coords2.Any(c2 => c1.Equals2D(c2)));
|
|
|
if (shared == null)
|
|
|
{
|
|
|
throw new InvalidOperationException("两多边形无共享顶点。");
|
|
|
}
|
|
|
|
|
|
int idx1 = Array.FindIndex(coords1, c => c.Equals2D(shared));
|
|
|
int idx2 = Array.FindIndex(coords2, c => c.Equals2D(shared));
|
|
|
|
|
|
// 3. 滚动坐标序列,使共享点为起点
|
|
|
CoordinateArrays.Scroll(coords1, idx1);
|
|
|
CoordinateArrays.Scroll(coords2, idx2);
|
|
|
|
|
|
// 4. 拼接两段序列并去重
|
|
|
var mergedCoords = coords1
|
|
|
.Concat(coords2.Skip(1))
|
|
|
.ToArray();
|
|
|
mergedCoords = CoordinateArrays.RemoveRepeatedPoints(mergedCoords);
|
|
|
|
|
|
// 5. 闭合环:首尾坐标必须相同
|
|
|
if (!mergedCoords[0].Equals2D(mergedCoords[mergedCoords.Length - 1]))
|
|
|
{
|
|
|
mergedCoords = mergedCoords
|
|
|
.Concat(new[] { mergedCoords[0] })
|
|
|
.ToArray();
|
|
|
}
|
|
|
|
|
|
// 6. 构造 LinearRing 并修复几何
|
|
|
var factory = NtsGeometryServices.Instance.CreateGeometryFactory();
|
|
|
var ring = factory.CreateLinearRing(mergedCoords);
|
|
|
var rawPoly = factory.CreatePolygon(ring);
|
|
|
return rawPoly;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 判断两个 Polygon 是否共享至少一个顶点
|
|
|
/// </summary>
|
|
|
private static bool PolygonsShareVertex(Polygon a, Polygon b)
|
|
|
{
|
|
|
return a.ExteriorRing.Coordinates
|
|
|
.Any(c1 => b.ExteriorRing.Coordinates
|
|
|
.Any(c2 => c1.Equals2D(c2))); // :contentReference[oaicite:8]{index=8}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 对多个仅在顶点相连的 Polygon 进行合并,返回合并后的连通面列表
|
|
|
/// </summary>
|
|
|
public static List<Polygon> MergeMultipleAtSharedVertex(IEnumerable<Geometry> polygons)
|
|
|
{
|
|
|
var list = polygons.ToList();
|
|
|
var visited = new bool[list.Count];
|
|
|
var result = new List<Polygon>();
|
|
|
|
|
|
for (int i = 0; i < list.Count; i++)
|
|
|
{
|
|
|
if (visited[i]) continue;
|
|
|
|
|
|
// 广度优先搜索构建连通分量
|
|
|
var queue = new Queue<int>();
|
|
|
queue.Enqueue(i);
|
|
|
visited[i] = true;
|
|
|
Polygon merged = list[i] as Polygon;
|
|
|
|
|
|
while (queue.Any())
|
|
|
{
|
|
|
int idx = queue.Dequeue();
|
|
|
for (int j = 0; j < list.Count; j++)
|
|
|
{
|
|
|
if (visited[j]) continue;
|
|
|
// 若与当前 merged 多边形或其成分共享顶点,则合并
|
|
|
if (PolygonsShareVertex(merged, list[j] as Polygon))
|
|
|
{
|
|
|
merged = MergeAtSharedVertex(merged, list[j] as Polygon);
|
|
|
visited[j] = true;
|
|
|
queue.Enqueue(j);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
result.Add(merged);
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 辅助方法:在交叉点处分割线段
|
|
|
/// </summary>
|
|
|
/// <param name="line">线</param>
|
|
|
/// <param name="splitPoint">分割点</param>
|
|
|
/// <returns>分割后线</returns>
|
|
|
private static LineString splitLineAtPoint(LineString line, Coordinate splitPoint)
|
|
|
{
|
|
|
List<Coordinate> coords = line.Coordinates.ToList();
|
|
|
int index = coords.FindIndex(c => c.Equals2D(splitPoint, 1e-6));
|
|
|
|
|
|
// 如果交叉点已是顶点,无需拆分
|
|
|
if (index != -1)
|
|
|
{
|
|
|
return line;
|
|
|
}
|
|
|
PrecisionModel pm = new PrecisionModel(1e6); // 保留6位小数
|
|
|
Coordinate scaledSplitPoint = new Coordinate(pm.MakePrecise(splitPoint.X), pm.MakePrecise(splitPoint.Y));
|
|
|
// 插入新顶点并拆分
|
|
|
List<Coordinate> newCoords = new List<Coordinate>();
|
|
|
for (int i = 0; i < coords.Count - 1; i++)
|
|
|
{
|
|
|
newCoords.Add(coords[i]);
|
|
|
|
|
|
Coordinate coorA = new Coordinate(pm.MakePrecise(coords[i].X), pm.MakePrecise(coords[i].Y));
|
|
|
Coordinate coorB = new Coordinate(pm.MakePrecise(coords[i + 1].X), pm.MakePrecise(coords[i + 1].Y));
|
|
|
|
|
|
bool inRange2 =
|
|
|
splitPoint.X > Math.Min(coorA.X, coorB.X) && splitPoint.X < Math.Max(coorA.X, coorB.X) &&
|
|
|
splitPoint.Y > Math.Min(coorA.Y, coorB.Y) && splitPoint.Y < Math.Max(coorA.Y, coorB.Y);
|
|
|
if (inRange2 == false)
|
|
|
{
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
double dx1 = coorB.X - coorA.X, dy1 = coorB.Y - coorA.Y;
|
|
|
double dx2 = splitPoint.X - coorA.X, dy2 = splitPoint.Y - coorA.Y;
|
|
|
double det = (dx1 * dy2) - (dy1 * dx2);
|
|
|
// 自定义阈值
|
|
|
double EPS = 1e-3;
|
|
|
OrientationIndex orient;
|
|
|
if (Math.Abs(det) <= EPS)
|
|
|
{
|
|
|
orient = OrientationIndex.Straight;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
orient = det > 0
|
|
|
? OrientationIndex.CounterClockwise
|
|
|
: OrientationIndex.Clockwise;
|
|
|
}
|
|
|
|
|
|
//OrientationIndex orient = NetTopologySuite.Algorithm.Orientation.Index(coorA, coorB, splitPoint);
|
|
|
if (orient == OrientationIndex.Straight)
|
|
|
{
|
|
|
newCoords.Add(splitPoint);
|
|
|
}
|
|
|
}
|
|
|
newCoords.Add(coords[coords.Count - 1]);
|
|
|
|
|
|
// 生成拆分后的线段
|
|
|
return new LineString(newCoords.ToArray());
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// creates the index line.
|
|
|
/// </summary>
|
|
|
/// <param name="geoSource">The geo source.</param>
|
|
|
/// <param name="ptsDest">The pts dest.</param>
|
|
|
/// <returns>A list of int.</returns>
|
|
|
private List<int> createIndexLine(Geometry geoSource, List<Vec2> ptsDest)
|
|
|
{
|
|
|
List<int> lstLine = new List<int>();
|
|
|
foreach (Coordinate coor in geoSource.Coordinates)
|
|
|
{
|
|
|
int nIndexFind = ptsDest.FindIndex((it) => { return it.x == coor.X && it.y == coor.Y; });
|
|
|
if (nIndexFind < 0)
|
|
|
{
|
|
|
ptsDest.Add(new Vec2(coor.X, coor.Y));
|
|
|
lstLine.Add(ptsDest.Count - 1);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
lstLine.Add(nIndexFind);
|
|
|
}
|
|
|
}
|
|
|
return lstLine;
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 判断线是否闭合.
|
|
|
/// </summary>
|
|
|
/// <param name="line">The line.</param>
|
|
|
/// <returns>A bool.</returns>
|
|
|
private bool isLineRing(LineString line)
|
|
|
{
|
|
|
double dDistance = line[0].Distance(line[line.Count - 1]);
|
|
|
double dLength = line.Length;
|
|
|
if (dDistance < dLength * 0.075)
|
|
|
{
|
|
|
return true;
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
private void HandleEmptyNameCurve(string xmlOfEmptyNameCurves)
|
|
|
{
|
|
|
ENCurveLoadHandler?.Invoke(xmlOfEmptyNameCurves);
|
|
|
}
|
|
|
///// <summary>
|
|
|
///// 选择图元事件
|
|
|
///// </summary>
|
|
|
///// <param name="sender">发送者</param>
|
|
|
///// <param name="e">事件参数</param>
|
|
|
//private void drawer1_SelectedElementChanged(object sender, ElementArgs e)
|
|
|
//{
|
|
|
// if (e == null)
|
|
|
// {
|
|
|
// this.SelectedElementPosition = -1;
|
|
|
// SelectedElementChanged?.Invoke(sender, null);
|
|
|
// return;
|
|
|
// }
|
|
|
|
|
|
// this.SelectedElementPosition = e.Position;
|
|
|
// SelectedElementChanged?.Invoke(sender, e);
|
|
|
//}
|
|
|
//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);
|
|
|
//}
|
|
|
/// <summary>
|
|
|
/// 设置线的属性
|
|
|
/// </summary>
|
|
|
/// <param name="curveName">名称</param>
|
|
|
/// <param name="layerName">图层</param>
|
|
|
/// <param name="curveStyle">属性</param>
|
|
|
/// <returns>应用数量</returns>
|
|
|
//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;
|
|
|
//}
|
|
|
// 窗口尺寸变化
|
|
|
private void DrawViewer_SizeChanged(object sender, EventArgs e)
|
|
|
{
|
|
|
ReDrawWindow();
|
|
|
}
|
|
|
|
|
|
private void ScrollScreenAndBar(ScrollKind kind)
|
|
|
{
|
|
|
int offset = 30;
|
|
|
if (kind == ScrollKind.Left)
|
|
|
{
|
|
|
if (scrollH.Minimum == scrollH.Value) //说明上一次按向右的箭头
|
|
|
return;
|
|
|
|
|
|
int v = scrollH.Value - offset; //直接减的话 scrollH.Value可能为负数 如果为负数 程序就崩溃了 所以做了一个判断
|
|
|
if (v < scrollH.Minimum) //第一次到达最左侧 滚动一次。不然 总是看不到最顶部的图形
|
|
|
{
|
|
|
v = scrollH.Minimum;
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
scrollH.Value = v;
|
|
|
ScrollHori((int)ScrollOrientation.HorizontalScroll, (int)ScrollEventType.LargeDecrement, -offset);
|
|
|
}
|
|
|
else if (kind == ScrollKind.Right)
|
|
|
{
|
|
|
int v = scrollH.Value + offset;
|
|
|
if (v > scrollH.Maximum)
|
|
|
{
|
|
|
scrollH.Value = scrollH.Maximum;
|
|
|
return;
|
|
|
}
|
|
|
scrollH.Value = v;
|
|
|
ScrollHori((int)ScrollOrientation.HorizontalScroll, (int)ScrollEventType.LargeDecrement, offset);
|
|
|
}
|
|
|
else if (kind == ScrollKind.Up)
|
|
|
{
|
|
|
if (scrollV.Minimum == scrollV.Value)
|
|
|
return;
|
|
|
|
|
|
int v = scrollV.Value - offset;
|
|
|
if (v < scrollV.Minimum)
|
|
|
{
|
|
|
v = scrollV.Minimum;
|
|
|
}
|
|
|
|
|
|
scrollV.Value = v;
|
|
|
ScrollVert((int)ScrollOrientation.VerticalScroll, (int)ScrollEventType.LargeDecrement, -offset);
|
|
|
}
|
|
|
else if (kind == ScrollKind.Down)
|
|
|
{
|
|
|
int v = scrollV.Value + offset;
|
|
|
if (v > scrollV.Maximum)
|
|
|
{
|
|
|
scrollV.Value = scrollV.Maximum;
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
scrollV.Value = v;
|
|
|
ScrollVert((int)ScrollOrientation.VerticalScroll, (int)ScrollEventType.LargeDecrement, offset);
|
|
|
}
|
|
|
else if (kind == ScrollKind.PageDown)
|
|
|
{
|
|
|
if (scrollV.Value == scrollV.Maximum)
|
|
|
return;
|
|
|
|
|
|
double offsetW;
|
|
|
int offsetS;
|
|
|
CalculateVOffset(out offsetW, out offsetS);
|
|
|
int v = scrollV.Value + offsetS;
|
|
|
if (v > scrollV.Maximum)
|
|
|
{
|
|
|
v = scrollV.Maximum;
|
|
|
}
|
|
|
|
|
|
scrollV.Value = v;
|
|
|
ScrollVert((int)ScrollOrientation.VerticalScroll, (int)ScrollEventType.LargeDecrement, offsetS);
|
|
|
}
|
|
|
else if (kind == ScrollKind.PageUp)
|
|
|
{
|
|
|
if (scrollV.Value == scrollV.Minimum)
|
|
|
return;
|
|
|
|
|
|
double offsetW;
|
|
|
int offsetS;
|
|
|
CalculateVOffset(out offsetW, out offsetS);
|
|
|
int v = scrollV.Value - offsetS;
|
|
|
if (v < scrollV.Minimum)
|
|
|
{
|
|
|
v = scrollV.Minimum;
|
|
|
}
|
|
|
|
|
|
scrollV.Value = v;
|
|
|
ScrollVert((int)ScrollOrientation.VerticalScroll, (int)ScrollEventType.LargeDecrement, -offsetS);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void CalculateVOffset(out double offsetW, out int offsetS)
|
|
|
{
|
|
|
offsetW = 0;
|
|
|
offsetS = 0;
|
|
|
// 屏幕高度 Ws
|
|
|
double totalHWolrd = Math.Abs(geoSigma.GetRealHeight(scrollV.Maximum)); //图纸的总高度
|
|
|
if (totalHWolrd < 1)
|
|
|
return;
|
|
|
|
|
|
double hWorld = Math.Abs(geoSigma.GetRealHeight(drawer1.Height)); //屏幕高度对应的图纸中的高度
|
|
|
double offsetScroll = scrollV.Maximum * hWorld / totalHWolrd;
|
|
|
offsetS = (int)offsetScroll; // (int)(drawer1.Height * offsetScroll / (double)scrollV.Maximum);
|
|
|
offsetW = hWorld;
|
|
|
}
|
|
|
|
|
|
|
|
|
private void OnChangeLayer(string eventKind)
|
|
|
{
|
|
|
ChangeLayerEvent?.Invoke(eventKind);
|
|
|
}
|
|
|
|
|
|
//private 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);
|
|
|
// }
|
|
|
// }
|
|
|
//}
|
|
|
|
|
|
///// <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);
|
|
|
//}
|
|
|
/// <summary>
|
|
|
/// 获得图层的数据
|
|
|
/// </summary>
|
|
|
/// <param name="layerName">图层名称</param>
|
|
|
/// <returns>数据列表</returns>
|
|
|
//public List<DrawerElementProperty> GetDataByLayer(string layerName)
|
|
|
//{
|
|
|
// return drawer1?.GetDataByLayer(layerName);
|
|
|
//}
|
|
|
//public List<DrawerElementProperty> GetLayerCurve(string layerName)
|
|
|
//{
|
|
|
// return drawer1?.GetLayerCurve(layerName);
|
|
|
//}
|
|
|
///// <summary>
|
|
|
///// 获得选中的所有图元
|
|
|
///// </summary>
|
|
|
///// <returns>选中图元的列表</returns>
|
|
|
//public List<DrawerElementProperty> GetSelectedElements()
|
|
|
//{
|
|
|
// return drawer1?.GetSelectedElements();
|
|
|
//}
|
|
|
///// <summary>
|
|
|
/////
|
|
|
///// </summary>
|
|
|
///// <param name="Bitmap"></param>
|
|
|
///// <returns></returns>
|
|
|
//private static Image Bitmap2Image(System.Drawing.Bitmap Bi)
|
|
|
//{
|
|
|
// MemoryStream ms = new MemoryStream();
|
|
|
// Bi.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
|
|
|
// BitmapImage bImage = new BitmapImage();
|
|
|
// bImage.BeginInit();
|
|
|
// bImage.StreamSource=new MemoryStream(ms.ToArray());
|
|
|
// bImage.EndInit();
|
|
|
// ms.Dispose();
|
|
|
// Bi.Dispose();
|
|
|
// Image i = new Image();
|
|
|
// i.Source=bImage;
|
|
|
// return i;
|
|
|
//}
|
|
|
private void SetScrollBarForWellPole(object sender, EventArgs e)
|
|
|
{
|
|
|
if (geoSigma == null)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
ScrollArgs args = e as ScrollArgs;
|
|
|
int hMax = 0, vMax = 0, hPage = 0, vPage = 0, hPos = 0, vPos = 0;
|
|
|
geoSigma.SetScrollBar(ref hMax, ref vMax, ref hPage, ref vPage, ref hPos, ref vPos);
|
|
|
if (hMax < 100)
|
|
|
{
|
|
|
hMax = 100;
|
|
|
}
|
|
|
if (vMax < 100)
|
|
|
{
|
|
|
vMax = 100;
|
|
|
}
|
|
|
if (hPos == 0)
|
|
|
{
|
|
|
//scrollH.Visible = false;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
scrollH.Visible = true;
|
|
|
}
|
|
|
if (vPos == 0)
|
|
|
{
|
|
|
//scrollV.Visible = false;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
scrollV.Visible = true;
|
|
|
}
|
|
|
Console.WriteLine($"set scroll bar vmax= {vMax}, vmin = {hMax}, vpos = {vPos}");
|
|
|
if (hMax < args.ScreenRect.Width)
|
|
|
{
|
|
|
hMax = hMax + 20;// args.ScreenRect.Width;
|
|
|
hPage = hMax;
|
|
|
hPos = 0;
|
|
|
}
|
|
|
if (vMax < args.ScreenRect.Height)
|
|
|
{
|
|
|
vMax = args.ScreenRect.Height;
|
|
|
vPage = vMax;
|
|
|
vPos = 0;
|
|
|
}
|
|
|
// nMin、nPage、nPos与控件Min,LargeChange、value类似
|
|
|
// 但nMax相当于Max+LargeChange-1
|
|
|
int nMaxValueH = hMax; // hMax-hPage+1;
|
|
|
int nMaxValueV = vMax;
|
|
|
this.scrollH.Minimum = 0;
|
|
|
this.scrollH.Maximum = nMaxValueH;
|
|
|
this.scrollH.LargeChange = (int)((hPage * largeScrollFactor) + 0.5);
|
|
|
this.scrollH.SmallChange = (int)((hPage * 0.2) + 0.5);
|
|
|
if (hPos >= this.scrollH.Minimum && hPos <= this.scrollH.Maximum)
|
|
|
{
|
|
|
this.scrollH.Value = hPos;
|
|
|
}
|
|
|
|
|
|
GeoSigmaWellPoleXY GeoSigmaWellPoleXY = (GeoSigmaWellPoleXY)geoSigma;
|
|
|
if (GeoSigmaWellPoleXY.IsLockWellHead())
|
|
|
{
|
|
|
int maxV, pageV, posV;
|
|
|
maxV = pageV = posV = 0;
|
|
|
GeoSigmaWellPoleXY.SetScrollBarVRangeForLockWellHead(ref maxV, ref pageV, ref posV);
|
|
|
this.scrollV.Minimum = 0;
|
|
|
this.scrollV.Maximum = maxV;
|
|
|
this.scrollV.LargeChange = pageV;
|
|
|
this.scrollV.SmallChange = (int)((pageV * 0.2) + 0.5);
|
|
|
if (posV >= this.scrollV.Minimum && posV <= this.scrollV.Maximum)
|
|
|
{
|
|
|
this.scrollV.Value = posV;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
this.scrollV.Minimum = 0;
|
|
|
this.scrollV.Maximum = nMaxValueV;
|
|
|
this.scrollV.LargeChange = vPage;
|
|
|
this.scrollV.SmallChange = (int)((vPage * 0.2) + 0.5);
|
|
|
if (vPos >= this.scrollV.Minimum && vPos <= this.scrollV.Maximum)
|
|
|
{
|
|
|
this.scrollV.Value = vPos;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
this.drawer1.ScreenLocationChanged?.Invoke();
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
}
|
|
|
|
|
|
public override void SetLockWellHead()
|
|
|
{
|
|
|
drawer1.SetLockWellHead();
|
|
|
drawer1.ResetScrollbar();
|
|
|
}
|
|
|
|
|
|
//public void AddTrack()
|
|
|
//{//test code
|
|
|
// GeoSigmaWellPoleXY GeoSigmaWellPoleXY = (GeoSigmaWellPoleXY)geoSigma;
|
|
|
// int[] typeIdArr = new int[0];
|
|
|
// string[] typeStrArr = new string[0];
|
|
|
// GeoSigmaWellPoleXY.GetWellTrackTypeInfo(ref typeIdArr, ref typeStrArr);
|
|
|
|
|
|
// int[] addTypes = new int[3];
|
|
|
// addTypes[0] = (int)(GeoSigmaWellPoleXY.eWellExtType.Track_Text);
|
|
|
// addTypes[1] = (int)(GeoSigmaWellPoleXY.eWellExtType.Track_Curve);
|
|
|
// addTypes[2] = (int)(GeoSigmaWellPoleXY.eWellExtType.Track_Symbol);
|
|
|
// bool b = GeoSigmaWellPoleXY.AddTrackAfterSelectedWellObject(addTypes, 3);
|
|
|
//}
|
|
|
|
|
|
//public void DeleteSelectedWellObject()
|
|
|
//{
|
|
|
// GeoSigmaWellPoleXY GeoSigmaWellPoleXY = (GeoSigmaWellPoleXY)geoSigma;
|
|
|
// bool b = GeoSigmaWellPoleXY.DeleteSelectedWellObject();
|
|
|
//}
|
|
|
|
|
|
public void CombineLeftTrack()
|
|
|
{
|
|
|
GeoSigmaWellPoleXY GeoSigmaWellPoleXY = (GeoSigmaWellPoleXY)geoSigma;
|
|
|
bool b = GeoSigmaWellPoleXY.SelectedTrackCombineLeftTrack();
|
|
|
}
|
|
|
|
|
|
public void CombineRightTrack()
|
|
|
{
|
|
|
GeoSigmaWellPoleXY GeoSigmaWellPoleXY = (GeoSigmaWellPoleXY)geoSigma;
|
|
|
bool b = GeoSigmaWellPoleXY.SelectedTrackCombineRightTrack();
|
|
|
}
|
|
|
|
|
|
public override void AddPictureToWellTrack()
|
|
|
{
|
|
|
OpenFileDialog openFileDialog = new OpenFileDialog();
|
|
|
openFileDialog.Title = "选择图片文件";
|
|
|
openFileDialog.Filter = "图片文件|*.jpg;*.jpeg;*.png;*.bmp;*.gif|所有文件|*.*";
|
|
|
openFileDialog.FilterIndex = 1;
|
|
|
openFileDialog.RestoreDirectory = true;
|
|
|
openFileDialog.Multiselect = false; // 是否允许多选
|
|
|
|
|
|
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
|
|
{
|
|
|
string filePath = openFileDialog.FileName;
|
|
|
int type, ttype;
|
|
|
type = ttype = -1;
|
|
|
UInt64 thandle = 0;
|
|
|
|
|
|
GeoSigmaWellPoleXY GeoSigmaWellPoleXY = (GeoSigmaWellPoleXY)geoSigma;
|
|
|
if (GeoSigmaWellPoleXY.GetSelectWellObject(ref type, ref ttype, ref thandle))
|
|
|
{
|
|
|
if (type == (int)(GeoSigmaWellPoleXY.eWellExtType.KEP_TRACKINDATA)
|
|
|
&& ttype == (int)(GeoSigmaWellPoleXY.eWellExtType.KEP_IMAGE))
|
|
|
{
|
|
|
GeoSigmaWellPoleXY.SetPictureInWellTrack(thandle, filePath);
|
|
|
|
|
|
drawer1.EnableRedraw = true;
|
|
|
drawer1.Invalidate();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//public GeoSigmaWellPoleXY.NewWellInfo mNewWellInfo = new GeoSigmaWellPoleXY.NewWellInfo();
|
|
|
|
|
|
public void testGetWellObjectProperties()
|
|
|
{
|
|
|
GeoSigmaWellPoleXY GeoSigmaWellPoleXY = (GeoSigmaWellPoleXY)geoSigma;
|
|
|
|
|
|
UInt64 wellHandle = 0;
|
|
|
GeoSigmaWellPoleXY.GetSelectedWell(ref wellHandle);
|
|
|
string[] stratificationClass;
|
|
|
GeoSigmaWellPoleXY.GetWellStratificationClasses(wellHandle, out stratificationClass);
|
|
|
|
|
|
string[] resultSymbols;
|
|
|
GeoSigmaWellPoleXY.GetSymbolNamesForResult(out resultSymbols);
|
|
|
Bitmap bmp = new Bitmap(50, 50);
|
|
|
Graphics gBmp = Graphics.FromImage(bmp);
|
|
|
IntPtr pBmpDC = gBmp.GetHdc();
|
|
|
GeoSigmaWellPoleXY.GetDrawSymbolForResult(resultSymbols[0], pBmpDC, 50, 50);
|
|
|
|
|
|
string[] lithSymbols;
|
|
|
GeoSigmaWellPoleXY.GetSymbolNamesForLithology(out lithSymbols);
|
|
|
Bitmap lithbmp = new Bitmap(50, 50);
|
|
|
Graphics lithgBmp = Graphics.FromImage(lithbmp);
|
|
|
IntPtr plithBmpDC = lithgBmp.GetHdc();
|
|
|
GeoSigmaWellPoleXY.GetDrawSymbolForLithology(lithSymbols[0], plithBmpDC, 50, 50);
|
|
|
|
|
|
string[] lithConSymbols;
|
|
|
GeoSigmaWellPoleXY.GetSymbolNamesForLithConstitution(out lithConSymbols);
|
|
|
Bitmap lithconbmp = new Bitmap(50, 50);
|
|
|
Graphics lithcongBmp = Graphics.FromImage(lithconbmp);
|
|
|
IntPtr plithconBmpDC = lithcongBmp.GetHdc();
|
|
|
GeoSigmaWellPoleXY.GetDrawSymbolForLithConstitution(lithConSymbols[0], plithconBmpDC, 50, 50);
|
|
|
|
|
|
string[] framesLine;
|
|
|
GeoSigmaWellPoleXY.GetWellFrameLineNames(out framesLine);
|
|
|
Bitmap wellLinebmp = new Bitmap(100, 30);
|
|
|
Graphics wellLinegBmp = Graphics.FromImage(wellLinebmp);
|
|
|
IntPtr wellLineBmpDC = wellLinegBmp.GetHdc();
|
|
|
GeoSigmaWellPoleXY.GetDrawWellFrameLine(framesLine[2], wellLineBmpDC, 100, 30);
|
|
|
|
|
|
string[] normalSymbs;
|
|
|
GeoSigmaWellPoleXY.GetNormalSymbolNames(out normalSymbs);
|
|
|
Bitmap norsybbmp = new Bitmap(100, 30);
|
|
|
Graphics gnorsybbmp = Graphics.FromImage(norsybbmp);
|
|
|
IntPtr gnorsybbmpDC = gnorsybbmp.GetHdc();
|
|
|
GeoSigmaWellPoleXY.GetDrawNormalSymbol(normalSymbs[2], gnorsybbmpDC, 100, 30);
|
|
|
|
|
|
|
|
|
string[] CurvePointSymbolNames;
|
|
|
GeoSigmaWellPoleXY.GetCurvePointSymbolNames(out CurvePointSymbolNames);
|
|
|
Bitmap wellptbmp = new Bitmap(100, 30);
|
|
|
Graphics wellptgbmp = Graphics.FromImage(wellptbmp);
|
|
|
IntPtr pwellptbmp = wellptgbmp.GetHdc();
|
|
|
GeoSigmaWellPoleXY.GetDrawCurvePointSymbol(CurvePointSymbolNames[2], pwellptbmp, 100, 30);
|
|
|
|
|
|
string[] stratumLithSymbolNames;
|
|
|
GeoSigmaWellPoleXY.GetStratumLithNames(out stratumLithSymbolNames);
|
|
|
Bitmap slithbmp = new Bitmap(100, 30);
|
|
|
Graphics swellptgbmp = Graphics.FromImage(slithbmp);
|
|
|
IntPtr pswellptbmp = swellptgbmp.GetHdc();
|
|
|
GeoSigmaWellPoleXY.GetDrawStratumLith(stratumLithSymbolNames[2], pswellptbmp, 100, 30);
|
|
|
|
|
|
string[] curveLine;
|
|
|
GeoSigmaWellPoleXY.GetWellCurveLineNames(out curveLine);
|
|
|
|
|
|
List<cPerforation> listPerforations = workAreaDb.Instance.workData.getWellPerforations("DD7-3");
|
|
|
|
|
|
List<cWellInnerLayer> listInnerLayers = workAreaDb.Instance.workData.getInnerLayers("D6-1");
|
|
|
|
|
|
List<cWellCycle> lstLongCycles = workAreaDb.Instance.workData.getWellCycles("D6-1", 1);
|
|
|
List<cWellCycle> lstMediumCycles = workAreaDb.Instance.workData.getWellCycles("D6-1", 2);
|
|
|
List<cWellCycle> lstShorCycles = workAreaDb.Instance.workData.getWellCycles("D6-1", 3);
|
|
|
|
|
|
string strInnerLayer = "";
|
|
|
WellDataConvert.getInnerLayersJson(ref strInnerLayer, listInnerLayers);
|
|
|
|
|
|
List<cWellLithology> lstLiths = workAreaDb.Instance.workData.getWellLithologys("DD7-3");
|
|
|
string strLithJson = "";
|
|
|
WellDataConvert.getWellLithologysJson(ref strLithJson, lstLiths);
|
|
|
|
|
|
List<cWellOilTest> lstOilTest = workAreaDb.Instance.workData.getWellOilTests("DD7-3");
|
|
|
string strOilTestJson = "";
|
|
|
WellDataConvert.getWellOilTestJson(ref strLithJson, lstOilTest);
|
|
|
|
|
|
int type, ttype;
|
|
|
type = ttype = -1;
|
|
|
ulong objHandle = 0;
|
|
|
bool b = GeoSigmaWellPoleXY.GetSelectWellObject(ref type, ref ttype, ref objHandle);
|
|
|
if (b)
|
|
|
{
|
|
|
string[] curveNames;
|
|
|
GeoSigmaWellPoleXY.GetWellAllCurveNames(objHandle, out curveNames);
|
|
|
|
|
|
string[] discreteNames;
|
|
|
GeoSigmaWellPoleXY.GetWellAllDiscreteNames(objHandle, out discreteNames);
|
|
|
|
|
|
string strXml = "";
|
|
|
|
|
|
b = GeoSigmaWellPoleXY.GetWellObjectAttributesXml(objHandle, type, ttype, ref strXml);
|
|
|
if (b)
|
|
|
{
|
|
|
XmlDocument xmlDoc = new XmlDocument();
|
|
|
try
|
|
|
{
|
|
|
xmlDoc.LoadXml(strXml);
|
|
|
|
|
|
b = GeoSigmaWellPoleXY.SetWellObjectAttributesXml(objHandle, type, ttype, strXml);
|
|
|
}
|
|
|
catch (XmlException xmle)
|
|
|
{
|
|
|
Console.WriteLine(xmle.Message);
|
|
|
}
|
|
|
}
|
|
|
//b = GeoSigmaWellPoleXY.GetWellObjectAttributesJson(objHandle, type, ttype, ref strJson);
|
|
|
//if (b)
|
|
|
//{
|
|
|
// JObject json = JObject.Parse(strJson);
|
|
|
// //JObject propJson = (JObject)json["properties"];
|
|
|
// //JObject inDataJson = (JObject)propJson["道内对象设置"];
|
|
|
// //inDataJson["控制岩性宽度"] = false;
|
|
|
// //string strJsonData = JsonConvert.SerializeObject(json);
|
|
|
// byte[] databytes = Encoding.UTF8.GetBytes(strJson);
|
|
|
// string jsonUtf8 = Encoding.ASCII.GetString(databytes);//
|
|
|
// GeoSigmaWellPoleXY.SetWellObjectAttributesJson(objHandle, type, ttype, databytes, databytes.Length);
|
|
|
//}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
//public void ViewExtendCenter()
|
|
|
//{
|
|
|
// drawer1.ViewExtendCenter();
|
|
|
//}
|
|
|
|
|
|
//public void ViewExtendWidth()
|
|
|
//{
|
|
|
// drawer1.ViewExtendWidth();
|
|
|
//}
|
|
|
|
|
|
private bool ScrollVertForWellPole(int nOrientation, int nType, int nValue)
|
|
|
{
|
|
|
GeoSigmaWellPoleXY GeoSigmaWellPoleXY = (GeoSigmaWellPoleXY)drawer1.Geo;
|
|
|
if (GeoSigmaWellPoleXY.IsLockWellHead())
|
|
|
{
|
|
|
GeoSigmaWellPoleXY.ScrollVForLockWellHead(nType, scrollV.Value, scrollV.LargeChange, scrollV.SmallChange, scrollV.Minimum, scrollV.Maximum);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
|
|
|
int nHs = drawer1.Height;
|
|
|
// 屏幕实际距离 Wr
|
|
|
double dHs = geoSigma.GetRealHeight(nHs);
|
|
|
|
|
|
double dOffset = 0;
|
|
|
int sliderBlockLen = scrollV.Value + scrollV.LargeChange;
|
|
|
if (nType == (int)ScrollEventType.SmallIncrement)
|
|
|
{
|
|
|
nValue = this.scrollV.SmallChange;
|
|
|
int deltaV = nValue;
|
|
|
if ((sliderBlockLen + nValue) > scrollV.Maximum)
|
|
|
{
|
|
|
deltaV = scrollV.Maximum - sliderBlockLen;
|
|
|
}
|
|
|
if (deltaV < 0)
|
|
|
deltaV = 0;
|
|
|
scrollV.Value += deltaV;
|
|
|
double dF = (double)deltaV / nHs;
|
|
|
dOffset = dHs * dF;
|
|
|
needVScrollToBottom = true;
|
|
|
}
|
|
|
else if (nType == (int)ScrollEventType.SmallDecrement)
|
|
|
{
|
|
|
nValue = -this.scrollV.SmallChange;
|
|
|
int deltaV = nValue;
|
|
|
if ((scrollV.Value + nValue) < scrollV.Minimum)
|
|
|
{
|
|
|
deltaV = scrollV.Minimum - scrollV.Value;
|
|
|
}
|
|
|
if (deltaV > 0)
|
|
|
deltaV = 0;
|
|
|
scrollV.Value += deltaV;
|
|
|
double dF = (double)deltaV / nHs;
|
|
|
dOffset = dHs * dF;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
double dF = (double)nValue / nHs;
|
|
|
dOffset = dHs * dF;
|
|
|
}
|
|
|
|
|
|
geoSigma.Scroll(nOrientation, -dOffset);
|
|
|
drawer1.EnableRedraw = true;
|
|
|
drawer1.Invalidate();
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
private bool ScrollHoriForWellPole(int nOrientation, int nType, int nValue)
|
|
|
{
|
|
|
//geoSigma.HScroll(nType, e.NewValue, scrollH.Maximum-scrollH.LargeChange+1);
|
|
|
|
|
|
// 屏幕总宽度
|
|
|
//int nScreenAllHor = this.scrollH.Maximum - this.scrollH.Minimum;
|
|
|
// 屏幕宽度 Ws
|
|
|
int nWs = drawer1.Width;
|
|
|
// 屏幕实际距离 Wr
|
|
|
double dWtest = geoSigma.GetRealWidth(nValue);
|
|
|
double dWs = geoSigma.GetRealWidth(nWs);
|
|
|
// dOffset = Wr*nValue/Ws;
|
|
|
double dOffset = 0;
|
|
|
int sliderBlockLen = scrollH.Value + scrollH.LargeChange;
|
|
|
if (nType == (int)ScrollEventType.SmallIncrement)
|
|
|
{
|
|
|
nValue = this.scrollH.SmallChange;
|
|
|
// scrollH.Maximum = scrollH.Maximum + nValue;
|
|
|
int deltaV = nValue;
|
|
|
if ((sliderBlockLen + nValue) > scrollH.Maximum)
|
|
|
{
|
|
|
deltaV = scrollH.Maximum - sliderBlockLen;
|
|
|
}
|
|
|
if (deltaV < 0)
|
|
|
deltaV = 0;
|
|
|
scrollH.Value += deltaV;
|
|
|
double dF = (double)deltaV / nWs;
|
|
|
dOffset = dWs * dF;
|
|
|
//drawer1.enlargeRight(dOffset);
|
|
|
}
|
|
|
else if (nType == (int)ScrollEventType.SmallDecrement)
|
|
|
{
|
|
|
nValue = -this.scrollH.SmallChange;
|
|
|
|
|
|
int deltaV = nValue;
|
|
|
if ((scrollH.Value + nValue) < scrollH.Minimum)
|
|
|
{
|
|
|
deltaV = scrollH.Minimum - scrollH.Value;
|
|
|
}
|
|
|
if (deltaV > 0)
|
|
|
deltaV = 0;
|
|
|
scrollH.Value += deltaV;
|
|
|
|
|
|
double dF = (double)deltaV / nWs;
|
|
|
dOffset = dWs * dF;
|
|
|
//drawer1.enlargeLeft(Math.Abs(dOffset));
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
double dF = (double)nValue / nWs;
|
|
|
dOffset = dWs * dF;
|
|
|
}
|
|
|
|
|
|
geoSigma.Scroll(nOrientation, dOffset);
|
|
|
drawer1.EnableRedraw = true;
|
|
|
drawer1.Invalidate();
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
private void ScrollByWheelForWellPole(bool bUp)
|
|
|
{
|
|
|
if (geoSigma == null)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
GeoSigmaWellPoleXY geoWell = (GeoSigmaWellPoleXY)geoSigma;
|
|
|
if (geoWell.IsLockWellHead())
|
|
|
{
|
|
|
int zdelta = this.scrollV.SmallChange;
|
|
|
if (!bUp)
|
|
|
zdelta = -this.scrollV.SmallChange;
|
|
|
geoWell.MouseWheelForLockWellHead(0, zdelta, 0, 0);
|
|
|
|
|
|
int delta = this.scrollV.SmallChange;
|
|
|
if (bUp == false)
|
|
|
{
|
|
|
int v = scrollV.Value + scrollV.LargeChange + this.scrollV.SmallChange;
|
|
|
if (v > scrollV.Maximum)
|
|
|
{
|
|
|
delta = scrollV.Maximum - (scrollV.Value + scrollV.LargeChange);
|
|
|
}
|
|
|
if (delta < 0)
|
|
|
delta = 0;
|
|
|
scrollV.Value += delta;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
delta = -this.scrollV.SmallChange;
|
|
|
int v = scrollV.Value - this.scrollV.SmallChange;
|
|
|
if (v < scrollV.Minimum)
|
|
|
{
|
|
|
delta = scrollV.Minimum - scrollV.Value;
|
|
|
if (delta > 0)
|
|
|
delta = 0;
|
|
|
}
|
|
|
scrollV.Value += delta;
|
|
|
}
|
|
|
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
double dLeft = 0.0, dTop = 0.0, dRight = 0.0, dBottom = 0.0;
|
|
|
Geo.GetMapRange(ref dLeft, ref dTop, ref dRight, ref dBottom);
|
|
|
|
|
|
Rectangle rect = drawer1.ClientRectangle;
|
|
|
double scLeft = 0.0, scRight = 0.0, scTop = 0.0, scBottom = 0.0;
|
|
|
Geo.GetScreenReal(rect.Left, rect.Top, rect.Right, rect.Bottom, ref scLeft, ref scTop, ref scRight, ref scBottom);
|
|
|
bool bMapLessScreen = false;
|
|
|
if ((dTop - dBottom) < (scTop - scBottom))
|
|
|
bMapLessScreen = true;
|
|
|
|
|
|
int nValue = this.scrollV.SmallChange;
|
|
|
int deltaV = nValue;
|
|
|
if (bMapLessScreen == false)
|
|
|
{
|
|
|
if (bUp == false)
|
|
|
{
|
|
|
int v = scrollV.Value + scrollV.LargeChange + nValue;
|
|
|
if (v > scrollV.Maximum)
|
|
|
{
|
|
|
deltaV = scrollV.Maximum - (scrollV.Value + scrollV.LargeChange);
|
|
|
}
|
|
|
if (deltaV < 0)
|
|
|
deltaV = 0;
|
|
|
scrollV.Value += deltaV;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
deltaV = -nValue;
|
|
|
int v = scrollV.Value - nValue;
|
|
|
if (v < scrollV.Minimum)
|
|
|
{
|
|
|
deltaV = scrollV.Minimum - scrollV.Value;
|
|
|
if (deltaV > 0)
|
|
|
deltaV = 0;
|
|
|
}
|
|
|
scrollV.Value += deltaV;
|
|
|
}
|
|
|
|
|
|
int nHs = drawer1.Height; // 屏幕高度
|
|
|
|
|
|
double dHs = geoSigma.GetRealHeight(nHs); // 屏幕实际距离
|
|
|
double dF = (double)deltaV / nHs;
|
|
|
double dOffset = dHs * dF;
|
|
|
|
|
|
geoSigma.Scroll(1, -dOffset);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
if (bUp == true)
|
|
|
{//滚轮向下,图向下移动, 图的顶部不高于屏幕的顶部
|
|
|
double OneLine = Geo.GetRealHeight(scrollV.SmallChange);
|
|
|
if ((dBottom + OneLine) < scBottom)
|
|
|
OneLine = scBottom - dBottom;
|
|
|
if (OneLine > 0)
|
|
|
OneLine = 0;
|
|
|
geoSigma.Scroll(1, OneLine);
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{////滚轮向上, 图向上移动 ,图的底部不低于屏幕的底部
|
|
|
double OneLine = -Geo.GetRealHeight(scrollV.SmallChange);
|
|
|
if ((dTop + OneLine) > scTop)
|
|
|
OneLine = scTop - dTop;
|
|
|
if (OneLine < 0)
|
|
|
OneLine = 0;
|
|
|
geoSigma.Scroll(1, OneLine);
|
|
|
}
|
|
|
}
|
|
|
//int nHs = drawer1.Height; // 屏幕高度
|
|
|
|
|
|
//double dHs = geoSigma.GetRealHeight(nHs); // 屏幕实际距离
|
|
|
//double dF = (double)deltaV / nHs;
|
|
|
//double dOffset = dHs * dF;
|
|
|
|
|
|
//geoSigma.Scroll(1, -dOffset);
|
|
|
|
|
|
drawer1.EnableRedraw = true;
|
|
|
drawer1.Invalidate();
|
|
|
// 通知相关控件
|
|
|
drawer1.ScreenLocationChanged?.Invoke();
|
|
|
}
|
|
|
|
|
|
private void ToolStripMenuItemAddWellTrack_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
AddTrack();
|
|
|
}
|
|
|
|
|
|
private void ToolStripMenuItemWellTrackDel_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
GeoSigmaWellPoleXY GeoSigmaWellPoleXY = (GeoSigmaWellPoleXY)this.Geo;
|
|
|
GeoSigmaWellPoleXY.DeleteSelectedWellObject();
|
|
|
}
|
|
|
|
|
|
private void ToolStripMenuItemWellTrackAdd_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
AddTrack(); //ggff20251210
|
|
|
}
|
|
|
|
|
|
void getWellPoleDocContextMenu(ref ContextMenuStrip ctmenu, GeoSigmaWellPoleXY GeoSigmaWellPoleXY)
|
|
|
{
|
|
|
ctmenu = null;
|
|
|
int stype = -1;
|
|
|
int ttype = -1;
|
|
|
UInt64 thandle = 0;
|
|
|
// GeoSigmaWellPoleXY GeoSigmaWellPoleXY = (GeoSigmaWellPoleXY)this.Geo;
|
|
|
if (GeoSigmaWellPoleXY.GetSelectWellObject(ref stype, ref ttype, ref thandle))
|
|
|
{
|
|
|
if (stype == (int)(GeoSigmaWellPoleXY.eWellExtType.KEP_WELL))
|
|
|
{
|
|
|
ctmenu = ctmWellPole;
|
|
|
|
|
|
foreach (var item in ctmenu.Items)
|
|
|
{
|
|
|
if (item is ToolStripSeparator separator)
|
|
|
continue;
|
|
|
else if (item is ToolStripMenuItem menuItem)
|
|
|
{
|
|
|
if (menuItem.Name == "toolMenuItemRefreshWellPole")
|
|
|
{
|
|
|
if (workAreaDb.Instance.workData.isConn() == false)
|
|
|
{
|
|
|
menuItem.Enabled = false;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
menuItem.Enabled = true;
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else if (stype == (int)(GeoSigmaWellPoleXY.eWellExtType.KEP_TRACK))
|
|
|
{
|
|
|
if (ttype == (int)(GeoSigmaWellPoleXY.eWellExtType.Track_Group)
|
|
|
|| ttype == (int)(GeoSigmaWellPoleXY.eWellExtType.Track_Picture))
|
|
|
{
|
|
|
ctmenu = ctmWellGroupTrack;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (ttype != (int)(GeoSigmaWellPoleXY.eWellExtType.Track_Picture))
|
|
|
{
|
|
|
ctmenu = ctmWellTrack;
|
|
|
foreach (var item in ctmenu.Items)
|
|
|
{
|
|
|
if (item is ToolStripSeparator separator)
|
|
|
continue;
|
|
|
else if (item is ToolStripMenuItem menuItem)
|
|
|
{
|
|
|
if (menuItem.Name == "ToolStripMenuItemEditTrackData" || menuItem.Name == "toolStripMenuItemTrackRefreshData")
|
|
|
{
|
|
|
if (ttype == (int)(GeoSigmaWellPoleXY.eWellExtType.Track_Depth)
|
|
|
|| ttype == (int)(GeoSigmaWellPoleXY.eWellExtType.Track_Stratum))
|
|
|
{
|
|
|
menuItem.Enabled = false; menuItem.Visible = false;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
menuItem.Enabled = true; menuItem.Visible = true;
|
|
|
}
|
|
|
}
|
|
|
if (menuItem.Name == "toolStripMenuItemSaveData")
|
|
|
{
|
|
|
if (ttype == (int)(GeoSigmaWellPoleXY.eWellExtType.Track_Lith)
|
|
|
|| ttype == (int)(GeoSigmaWellPoleXY.eWellExtType.Track_InnerLayer)
|
|
|
|| ttype == (int)(GeoSigmaWellPoleXY.eWellExtType.Track_Shot)
|
|
|
|| ttype == (int)(GeoSigmaWellPoleXY.eWellExtType.Track_SandLayer)
|
|
|
|| ttype == (int)(GeoSigmaWellPoleXY.eWellExtType.Track_Sandstone)
|
|
|
|| ttype == (int)(GeoSigmaWellPoleXY.eWellExtType.Track_Result)
|
|
|
|| ttype == (int)(GeoSigmaWellPoleXY.eWellExtType.Track_Facies)
|
|
|
|| ttype == (int)(GeoSigmaWellPoleXY.eWellExtType.Track_Cycle))
|
|
|
{
|
|
|
if (workAreaDb.Instance.workData.isConn())
|
|
|
menuItem.Enabled = true;
|
|
|
else
|
|
|
menuItem.Enabled = false;
|
|
|
menuItem.Visible = true;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
menuItem.Enabled = false; menuItem.Visible = false;
|
|
|
}
|
|
|
}
|
|
|
if (menuItem.Name == "toolStripMenuItemFaultInDB")
|
|
|
{
|
|
|
if (ttype == (int)(GeoSigmaWellPoleXY.eWellExtType.Track_SandLayer))
|
|
|
{
|
|
|
if (workAreaDb.Instance.workData.isConn())
|
|
|
menuItem.Enabled = true;
|
|
|
else
|
|
|
menuItem.Enabled = false;
|
|
|
menuItem.Visible = true;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
menuItem.Enabled = false; menuItem.Visible = false;
|
|
|
}
|
|
|
}
|
|
|
if (menuItem.Name == "toolStripMenuItemEditFault")
|
|
|
{
|
|
|
if (ttype == (int)(GeoSigmaWellPoleXY.eWellExtType.Track_SandLayer))
|
|
|
{
|
|
|
menuItem.Visible = true;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
/*menuItem.Enabled = false; */
|
|
|
menuItem.Visible = false;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else if (stype == (int)(GeoSigmaWellPoleXY.eWellExtType.KEP_TRACKINDATA))
|
|
|
{
|
|
|
if (ttype == (int)(GeoSigmaWellPoleXY.eWellExtType.KEP_IMAGE))
|
|
|
{
|
|
|
ctmenu = contextMenuStripPictureInTrack;
|
|
|
}
|
|
|
else
|
|
|
ctmenu = ctmWellObjInTrack;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void ToolStripMenuItemMergerLeftTrack_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
GeoSigmaWellPoleXY GeoSigmaWellPoleXY = (GeoSigmaWellPoleXY)this.Geo;
|
|
|
bool b = GeoSigmaWellPoleXY.SelectedTrackCombineLeftTrack();
|
|
|
}
|
|
|
|
|
|
private void ToolStripMenuItemMergeRightTrack_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
GeoSigmaWellPoleXY GeoSigmaWellPoleXY = (GeoSigmaWellPoleXY)this.Geo;
|
|
|
bool b = GeoSigmaWellPoleXY.SelectedTrackCombineRightTrack();
|
|
|
}
|
|
|
|
|
|
private void ToolStripMenuItemEditTrackData_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
GeoSigmaWellPoleXY GeoSigmaWellPoleXY = (GeoSigmaWellPoleXY)this.Geo; // geoSigma;
|
|
|
|
|
|
int type, ttype;
|
|
|
type = ttype = -1;
|
|
|
UInt64 thandle = 0;
|
|
|
GeoSigmaWellPoleXY.GetSelectWellObject(ref type, ref ttype, ref thandle);
|
|
|
if (type != (int)(GeoSigmaWellPoleXY.eWellExtType.KEP_TRACK))
|
|
|
return;
|
|
|
if (ttype == (int)(GeoSigmaWellPoleXY.eWellExtType.Track_Group) || ttype == (int)(GeoSigmaWellPoleXY.eWellExtType.Track_Depth))
|
|
|
return;
|
|
|
|
|
|
if (ttype == (int)GeoSigmaWellPoleXY.eWellExtType.Track_Sample)
|
|
|
{
|
|
|
var dataDlg = new FrmRockSampleDataEdit() { StartPosition = FormStartPosition.CenterScreen };
|
|
|
try
|
|
|
{
|
|
|
string strJson = "";
|
|
|
if (GeoSigmaWellPoleXY.GetWellTrackDataJson(thandle, ref strJson) == true)
|
|
|
{
|
|
|
dataDlg.SetRockSampleData(strJson);
|
|
|
if (dataDlg.ShowDialog(this) == DialogResult.OK)
|
|
|
{
|
|
|
byte[] databytes = Encoding.UTF8.GetBytes(dataDlg.mStrDataJson);
|
|
|
// string jsonUtf8 = Encoding.ASCII.GetString(databytes);// Encoding.UTF8.GetString(databytes);
|
|
|
|
|
|
GeoSigmaWellPoleXY.SetWellTrackDataJson(thandle, databytes, databytes.Length);
|
|
|
drawer1.EnableRedraw = true;
|
|
|
drawer1.Invalidate();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
MessageBox.Show(ex.Message);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
var dataDlg = new FrmWellDataEdit() { StartPosition = FormStartPosition.CenterScreen };
|
|
|
try
|
|
|
{
|
|
|
string dataType = string.Empty;
|
|
|
string[] colsName = new string[0];
|
|
|
string[,] datas = new string[0, 0];
|
|
|
GeoSigmaWellPoleXY.GetWellTrackData(thandle, ref dataType, ref colsName, ref datas);
|
|
|
|
|
|
string[] colsNameCH = new string[0];
|
|
|
|
|
|
if(ttype == (int)GeoSigmaWellPoleXY.eWellExtType.Track_CommonData)
|
|
|
{ //获取数据道的字段名称
|
|
|
string strXml = "";
|
|
|
bool b = GeoSigmaWellPoleXY.GetWellObjectAttributesXml(thandle, (int)GeoSigmaWellPoleXY.eWellExtType.KEP_TRACK, ttype, ref strXml);
|
|
|
if (strXml != "")
|
|
|
{
|
|
|
Type trackType = typeof(WellCommonDataTrack);
|
|
|
WellCommonDataTrack tObjTrack = (WellCommonDataTrack)XmlHelper.Deserialize(trackType, strXml);
|
|
|
if (tObjTrack != null)
|
|
|
{
|
|
|
List<string> listCol = new List<string>();
|
|
|
listCol.Add("顶深");
|
|
|
listCol.Add("底深");
|
|
|
foreach (DataItem item in tObjTrack.dataItems.DataItem)
|
|
|
{
|
|
|
string col = tableInfoQuery.getColumnChsNameFromEngName(tObjTrack.dataItems.RefTableId, item.RefColId);
|
|
|
|
|
|
listCol.Add(col);
|
|
|
colsNameCH = listCol.ToArray();
|
|
|
}
|
|
|
|
|
|
if(tObjTrack.dataItems.DataItem.Count == 0)
|
|
|
{
|
|
|
GeoSigmaWellPoleXY.mWellTableInfos.GetTableColumnCHNames(dataType, colsName, ref colsNameCH);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
GeoSigmaWellPoleXY.mWellTableInfos.GetTableColumnCHNames(dataType, colsName, ref colsNameCH);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
GeoSigmaWellPoleXY.mWellTableInfos.GetTableColumnCHNames(dataType, colsName, ref colsNameCH);
|
|
|
|
|
|
|
|
|
dataDlg.SetData(colsName, colsNameCH, datas);
|
|
|
|
|
|
if (dataDlg.ShowDialog(this) == DialogResult.OK)
|
|
|
{
|
|
|
// byte[] databytes = Encoding.UTF8.GetBytes(dataDlg.strJsonData);
|
|
|
if (dataDlg.m_IsModified == true)
|
|
|
{
|
|
|
if (GeoSigmaWellPoleXY.TrackIsWellTableDataSource(thandle) == true)
|
|
|
{//井内管理数据就直接读去井内数据。
|
|
|
ulong wellHandle = 0;
|
|
|
|
|
|
if (GeoSigmaWellPoleXY.GetSelectedWell(ref wellHandle) == true)
|
|
|
{
|
|
|
if (dataType == "ReservesLayer")
|
|
|
{
|
|
|
GeoSigmaWellPoleXY.SetWellReservesLayersJson(wellHandle, dataDlg.strJsonData, true);
|
|
|
//GeoSigmaWellPoleXY.TrackReadWellTableData(thandle);
|
|
|
}
|
|
|
if (dataType == "SandSet")
|
|
|
{
|
|
|
GeoSigmaWellPoleXY.SetWellSandSetsJson(wellHandle, dataDlg.strJsonData, true);
|
|
|
//GeoSigmaWellPoleXY.TrackReadWellTableData(thandle);
|
|
|
}
|
|
|
if (dataType == "FaultPoint")
|
|
|
{
|
|
|
//GeoSigmaWellPoleXY.SetWellFaultDatasJson(wellHandle, dataDlg.strJsonData);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
GeoSigmaWellPoleXY.SetWellTrackDataJson(thandle, dataDlg.strJsonData);
|
|
|
}
|
|
|
this.drawer1.Invalidate();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
MessageBox.Show(ex.Message);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void ToolStripMenuItemDelWellObjInTrack_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
GeoSigmaWellPoleXY GeoSigmaWellPoleXY = (GeoSigmaWellPoleXY)this.Geo;
|
|
|
GeoSigmaWellPoleXY.DeleteSelectedWellObject();
|
|
|
}
|
|
|
|
|
|
private void ToolStripMenuItemDelPictureInTrack_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
GeoSigmaWellPoleXY GeoSigmaWellPoleXY = (GeoSigmaWellPoleXY)this.Geo;
|
|
|
GeoSigmaWellPoleXY.DeleteSelectedWellObject();
|
|
|
}
|
|
|
|
|
|
private void ToolStripMenuItemImportPicutreInTrack_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
OpenFileDialog openFileDialog = new OpenFileDialog();
|
|
|
openFileDialog.Title = "选择图片文件";
|
|
|
openFileDialog.Filter = "图片文件|*.jpg;*.jpeg;*.png;*.bmp;*.gif|所有文件|*.*";
|
|
|
openFileDialog.FilterIndex = 1;
|
|
|
openFileDialog.RestoreDirectory = true;
|
|
|
openFileDialog.Multiselect = false; // 是否允许多选
|
|
|
|
|
|
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
|
|
{
|
|
|
string filePath = openFileDialog.FileName;
|
|
|
int type, ttype;
|
|
|
type = ttype = -1;
|
|
|
UInt64 thandle = 0;
|
|
|
|
|
|
GeoSigmaWellPoleXY GeoSigmaWellPoleXY = (GeoSigmaWellPoleXY)Geo;
|
|
|
if (GeoSigmaWellPoleXY.GetSelectWellObject(ref type, ref ttype, ref thandle))
|
|
|
{
|
|
|
if (type == (int)(GeoSigmaWellPoleXY.eWellExtType.KEP_TRACKINDATA)
|
|
|
&& ttype == (int)(GeoSigmaWellPoleXY.eWellExtType.KEP_IMAGE))
|
|
|
{
|
|
|
GeoSigmaWellPoleXY.SetPictureInWellTrack(thandle, filePath);
|
|
|
|
|
|
Invalidate();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void toolStripMenuItemGroupTrackDel_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
GeoSigmaWellPoleXY GeoSigmaWellPoleXY = (GeoSigmaWellPoleXY)this.Geo;
|
|
|
GeoSigmaWellPoleXY.DeleteSelectedWellObject();
|
|
|
}
|
|
|
|
|
|
private void toolStripMenuItemGroupTrackAdd_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
AddTrack();
|
|
|
}
|
|
|
|
|
|
private void toolStripMenuItemGroupTrackMergeLeft_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
GeoSigmaWellPoleXY GeoSigmaWellPoleXY = (GeoSigmaWellPoleXY)this.Geo;
|
|
|
bool b = GeoSigmaWellPoleXY.SelectedTrackCombineLeftTrack();
|
|
|
}
|
|
|
|
|
|
private void toolStripMenuItemGroupTrackMergeRight_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
GeoSigmaWellPoleXY GeoSigmaWellPoleXY = (GeoSigmaWellPoleXY)this.Geo;
|
|
|
bool b = GeoSigmaWellPoleXY.SelectedTrackCombineRightTrack();
|
|
|
}
|
|
|
|
|
|
|
|
|
public void AddTrack()
|
|
|
{
|
|
|
var dlg = new FrmAddWellTrack() { StartPosition = FormStartPosition.CenterScreen };
|
|
|
GeoSigmaWellPoleXY GeoSigmaWellPoleXY = (GeoSigmaWellPoleXY)this.Geo;
|
|
|
string[] typeNames = new string[0];
|
|
|
int[] typeIds = new int[0];
|
|
|
GeoSigmaWellSectionXY.GetWellTrackTypeInfo(ref typeIds, ref typeNames);
|
|
|
dlg.setTypeInfo(typeNames, typeIds);
|
|
|
if (dlg.ShowDialog(this) == DialogResult.OK)
|
|
|
{
|
|
|
if (dlg.mSelectTypeIds.Count > 0)
|
|
|
{
|
|
|
UInt64 wellHandle = 0;
|
|
|
GeoSigmaWellPoleXY.GetSelectedWell(ref wellHandle);
|
|
|
GeoSigmaWellPoleXY.GetWellBaseInfo(wellHandle, out GeoSigmaWellPoleXY.WellBaseInfo wellinfo);
|
|
|
|
|
|
int[] newTypeIds = dlg.mSelectTypeIds.ToArray();
|
|
|
|
|
|
bool b = GeoSigmaWellPoleXY.AddTrackAfterSelectedWellObject(newTypeIds, newTypeIds.Length, out UInt64[] newTrackHandle, out int[] newTType);
|
|
|
if (newTrackHandle.Length > 0)
|
|
|
{
|
|
|
for (int i = 0; i < newTrackHandle.Length; i++)
|
|
|
{
|
|
|
readTrackWorkAreaData(newTrackHandle[i], newTType[i], wellinfo.wellName, false);
|
|
|
}
|
|
|
this.Invalidate();
|
|
|
}
|
|
|
//viewer.Redraw();
|
|
|
}
|
|
|
// viewer.AddTrack();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
bool getTempateFilePath(ref string templatePath)
|
|
|
{
|
|
|
bool b = false;
|
|
|
templatePath = AppDomain.CurrentDomain.BaseDirectory + "Templates\\WellPole\\";
|
|
|
|
|
|
if (Directory.Exists(templatePath) == false)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
Directory.CreateDirectory(templatePath);
|
|
|
}
|
|
|
catch (UnauthorizedAccessException)
|
|
|
{
|
|
|
MessageBox.Show("没有创建模板目录的权限");
|
|
|
return b;
|
|
|
}
|
|
|
catch (PathTooLongException)
|
|
|
{
|
|
|
MessageBox.Show("路径太长");
|
|
|
return b;
|
|
|
}
|
|
|
catch (IOException ex)
|
|
|
{
|
|
|
MessageBox.Show($"IO错误: {ex.Message}");
|
|
|
return b;
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
MessageBox.Show($"发生错误: {ex.Message}");
|
|
|
return b;
|
|
|
}
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
private void menuSaveWellTemplates_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
string templatePath = "";
|
|
|
|
|
|
if (getTempateFilePath(ref templatePath) == false)
|
|
|
return;
|
|
|
|
|
|
SaveFileDialog dlg = new SaveFileDialog();
|
|
|
dlg.Filter = "模板文件(*.pcg)|*.pcg";
|
|
|
dlg.Title = "保存模板文件";
|
|
|
|
|
|
string fileName = Path.GetFileName(this.drawer1.DrawFileName);
|
|
|
dlg.InitialDirectory = templatePath;
|
|
|
dlg.FileName = "template_" + fileName;
|
|
|
if (dlg.ShowDialog() == DialogResult.OK)
|
|
|
{
|
|
|
GeoSigmaWellPoleXY geoWell = (GeoSigmaWellPoleXY)this.geoSigma;
|
|
|
geoWell.SaveWellPoleTemplateFile(dlg.FileName);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
private void menuApplyingTemplates_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
string templatePath = "";
|
|
|
|
|
|
if (getTempateFilePath(ref templatePath) == false)
|
|
|
return;
|
|
|
|
|
|
OpenFileDialog dlg = new OpenFileDialog();
|
|
|
dlg.Title = "选择模板文件";
|
|
|
dlg.Filter = "模板文件(*.pcg)|*.pcg";
|
|
|
dlg.RestoreDirectory = true;
|
|
|
dlg.Multiselect = false; // 是否允许多选
|
|
|
dlg.InitialDirectory = templatePath;
|
|
|
if (dlg.ShowDialog() == DialogResult.OK)
|
|
|
{
|
|
|
string filePath = dlg.FileName;
|
|
|
|
|
|
GeoSigmaWellPoleXY geoWell = (GeoSigmaWellPoleXY)this.geoSigma;
|
|
|
|
|
|
if(geoWell.ApplyingWellPoleTemplateFile(filePath))
|
|
|
{
|
|
|
this.drawer1.EnableRedraw = true;
|
|
|
this.drawer1.Invalidate();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void menuItemWellTrajectory_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
GeoSigmaWellPoleXY GeoSigmaWellPoleXY = (GeoSigmaWellPoleXY)this.Geo;
|
|
|
UInt64 wellHandle = 0;
|
|
|
if (GeoSigmaWellPoleXY.GetSelectedWell(ref wellHandle) == true)
|
|
|
{
|
|
|
var dataDlg = new FrmWellDataEdit() { StartPosition = FormStartPosition.CenterScreen };
|
|
|
try
|
|
|
{
|
|
|
string dataType = "trajectory";
|
|
|
string[] colsName = new string[0];
|
|
|
string[,] datas = new string[0, 0];
|
|
|
GeoSigmaWellPoleXY.GetWellTrajectoryDatasJson(wellHandle, ref colsName, ref datas);
|
|
|
|
|
|
string[] colsNameCH = new string[0];
|
|
|
GeoSigmaWellPoleXY.mWellTableInfos.GetTableColumnCHNames(dataType, colsName, ref colsNameCH);
|
|
|
dataDlg.SetData(colsName, colsNameCH, datas);
|
|
|
|
|
|
if (dataDlg.ShowDialog(this) == DialogResult.OK)
|
|
|
{
|
|
|
byte[] databytes = Encoding.UTF8.GetBytes(dataDlg.strJsonData);
|
|
|
string jsonUtf8 = Encoding.ASCII.GetString(databytes);// Encoding.UTF8.GetString(databytes);
|
|
|
|
|
|
//GeoSigmaWellPoleXY.SetWellTrackDataJson(thandle, databytes, databytes.Length);
|
|
|
Invalidate();
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
MessageBox.Show(ex.Message);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
private void toolMenuItemRefreshWellPole_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
GeoSigmaWellPoleXY GeoSigmaWellPoleXY = (GeoSigmaWellPoleXY)geoSigma;
|
|
|
GeoSigmaWellPoleXY.SetWellUndoRedoAction();
|
|
|
|
|
|
UInt64 wellHandle = 0;
|
|
|
GeoSigmaWellPoleXY.GetSelectedWell(ref wellHandle);
|
|
|
if (wellHandle != 0)
|
|
|
{
|
|
|
GeoSigmaWellPoleXY.GetWellBaseInfo(wellHandle, out GeoSigmaWellPoleXY.WellBaseInfo wellinfo);
|
|
|
readWorkAreaDataForWell(wellinfo.wellName, wellHandle);
|
|
|
}
|
|
|
drawer1.EnableRedraw = true;
|
|
|
drawer1.Invalidate();
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
MessageBox.Show(ex.Message);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void toolStripMenuItemTrackRefreshData_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
GeoSigmaWellPoleXY GeoSigmaWellPoleXY = (GeoSigmaWellPoleXY)this.Geo; // geoSigma;
|
|
|
|
|
|
int type, ttype;
|
|
|
type = ttype = -1;
|
|
|
UInt64 thandle = 0;
|
|
|
GeoSigmaWellPoleXY.GetSelectWellObject(ref type, ref ttype, ref thandle);
|
|
|
if (type != (int)(GeoSigmaWellPoleXY.eWellExtType.KEP_TRACK))
|
|
|
return;
|
|
|
if (ttype == (int)(GeoSigmaWellPoleXY.eWellExtType.Track_Group) || ttype == (int)(GeoSigmaWellPoleXY.eWellExtType.Track_Depth))
|
|
|
return;
|
|
|
|
|
|
UInt64 wellHandle = 0;
|
|
|
if (GeoSigmaWellPoleXY.GetSelectedWell(ref wellHandle) == false)
|
|
|
return;
|
|
|
GeoSigmaWellPoleXY.GetWellBaseInfo(wellHandle, out GeoSigmaWellPoleXY.WellBaseInfo wellinfo);
|
|
|
|
|
|
if (workAreaDb.Instance.workData.isConn())
|
|
|
{
|
|
|
if (ttype == (int)(GeoSigmaWellPoleXY.eWellExtType.Track_Curve))
|
|
|
{
|
|
|
DataTable curvesTable = new DataTable();
|
|
|
InterfaceWorkAreaData.LoadCurveData.ResultDataInfo qCurveResult = new InterfaceWorkAreaData.LoadCurveData.ResultDataInfo();
|
|
|
|
|
|
string strXml = "";
|
|
|
if (GeoSigmaWellPoleXY.GetWellObjectAttributesXml(wellHandle, (int)GeoSigmaWellPoleXY.eWellExtType.KEP_WELL, 0, ref strXml) == true)
|
|
|
{
|
|
|
XmlDocument xmlDoc = new XmlDocument();
|
|
|
try
|
|
|
{
|
|
|
xmlDoc.LoadXml(strXml);
|
|
|
XmlNode node = xmlDoc.SelectSingleNode("/Pcg/Head");
|
|
|
if (node != null)
|
|
|
{
|
|
|
string wellName = node.Attributes["WellName"].Value;
|
|
|
qCurveResult = workAreaDb.Instance.workData.getCurvesData(wellName, ref curvesTable);
|
|
|
|
|
|
string strCurve = "";
|
|
|
if (GeoSigmaWellPoleXY.GetWellObjectAttributesXml(thandle, (int)GeoSigmaWellPoleXY.eWellExtType.KEP_TRACK, ttype, ref strCurve) == true)
|
|
|
{
|
|
|
xmlDoc.LoadXml(strCurve);
|
|
|
node = xmlDoc.SelectSingleNode("/Pcg/WellTrack");
|
|
|
if (node != null)
|
|
|
{
|
|
|
string curveName = node.Attributes["Name"].Value;
|
|
|
WellDataConvert.getWellCurveValueForNewWell(curvesTable, GeoSigmaWellPoleXY, wellHandle, thandle, curveName);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
catch (XmlException xmle)
|
|
|
{
|
|
|
Console.WriteLine(xmle.Message);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
readTrackWorkAreaData(thandle, ttype, wellinfo.wellName);
|
|
|
}
|
|
|
drawer1.EnableRedraw = true;
|
|
|
drawer1.Invalidate();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void toolStripMenuItemSaveData_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
GeoSigmaWellPoleXY GeoSigmaWellPoleXY = (GeoSigmaWellPoleXY)this.Geo; // geoSigma;
|
|
|
|
|
|
int type, ttype;
|
|
|
type = ttype = -1;
|
|
|
UInt64 thandle = 0;
|
|
|
GeoSigmaWellPoleXY.GetSelectWellObject(ref type, ref ttype, ref thandle);
|
|
|
if (type != (int)(GeoSigmaWellPoleXY.eWellExtType.KEP_TRACK))
|
|
|
return;
|
|
|
|
|
|
UInt64 wellHandle = 0;
|
|
|
GeoSigmaWellPoleXY.GetSelectedWell(ref wellHandle);
|
|
|
GeoSigmaWellPoleXY.GetWellBaseInfo(wellHandle, out GeoSigmaWellPoleXY.WellBaseInfo wellinfo);
|
|
|
|
|
|
string strJson = "";
|
|
|
|
|
|
if (MessageBox.Show("数据入库将删除原有数据,确定要保存数据吗?", "提示", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
|
|
|
return;
|
|
|
|
|
|
if (ttype == (int)GeoSigmaWellPoleXY.eWellExtType.Track_Lith)
|
|
|
{
|
|
|
GeoSigmaWellPoleXY.GetWellTrackDataJson(thandle, ref strJson);
|
|
|
|
|
|
if (WellDataConvert.getWellLithologyFromJson(wellinfo.wellName, strJson, out List<WellLithology> list))
|
|
|
{
|
|
|
DBHelp.NewDb.Deleteable<WellLithology>(r => r.Well == wellinfo.wellName).ExecuteCommand();
|
|
|
DBHelp.NewDb.BulkInsert(list);
|
|
|
MessageBox.Show("写入完毕");
|
|
|
}
|
|
|
}
|
|
|
else if (ttype == (int)GeoSigmaWellPoleXY.eWellExtType.Track_InnerLayer)
|
|
|
{
|
|
|
GeoSigmaWellPoleXY.GetWellTrackDataJson(thandle, ref strJson);
|
|
|
|
|
|
if (WellDataConvert.getWellInnerLayerFromJson(wellinfo.wellName, strJson, out List<WellInnerLayer> list))
|
|
|
{
|
|
|
DBHelp.NewDb.Deleteable<WellInnerLayer>(r => r.Well == wellinfo.wellName).ExecuteCommand();
|
|
|
DBHelp.NewDb.BulkInsert(list);
|
|
|
MessageBox.Show("写入完毕");
|
|
|
}
|
|
|
}
|
|
|
else if (ttype == (int)GeoSigmaWellPoleXY.eWellExtType.Track_Shot)
|
|
|
{
|
|
|
GeoSigmaWellPoleXY.GetWellTrackDataJson(thandle, ref strJson);
|
|
|
if (WellDataConvert.getWellPerforationFromJson(wellinfo.wellName, strJson, out List<WellPerforation> list))
|
|
|
{
|
|
|
DBHelp.NewDb.Deleteable<WellPerforation>(r => r.JH == wellinfo.wellName).ExecuteCommand();
|
|
|
DBHelp.NewDb.BulkInsert(list);
|
|
|
MessageBox.Show("写入完毕");
|
|
|
}
|
|
|
}
|
|
|
else if (ttype == (int)GeoSigmaWellPoleXY.eWellExtType.Track_SandLayer)
|
|
|
{
|
|
|
GeoSigmaWellPoleXY.GetWellTrackDataJson(thandle, ref strJson);
|
|
|
if (WellDataConvert.getWellInterpretDrillLayerFromJson(wellinfo.wellName, strJson, out List<InterpretDrillWellLayered> list))
|
|
|
{
|
|
|
DBHelp.NewDb.Deleteable<InterpretDrillWellLayered>(r => r.JH == wellinfo.wellName).ExecuteCommand();
|
|
|
DBHelp.NewDb.BulkInsert(list);
|
|
|
MessageBox.Show("写入完毕");
|
|
|
}
|
|
|
}
|
|
|
else if (ttype == (int)GeoSigmaWellPoleXY.eWellExtType.Track_Sandstone
|
|
|
|| ttype == (int)GeoSigmaWellPoleXY.eWellExtType.Track_Result
|
|
|
|| ttype == (int)GeoSigmaWellPoleXY.eWellExtType.Track_Facies)
|
|
|
{
|
|
|
GeoSigmaWellPoleXY.GetWellTableDatasJson(wellHandle, "ReservesLayer", ref strJson);
|
|
|
if (WellDataConvert.getWellReserversLayerFromJson(wellinfo.wellName, strJson, out List<WellReservesLayer> list))
|
|
|
{
|
|
|
DBHelp.NewDb.Deleteable<WellReservesLayer>(r => r.Well == wellinfo.wellName).ExecuteCommand();
|
|
|
DBHelp.NewDb.BulkInsert(list);
|
|
|
MessageBox.Show("写入完毕");
|
|
|
}
|
|
|
}
|
|
|
else if (ttype == (int)GeoSigmaWellPoleXY.eWellExtType.Track_Cycle)
|
|
|
{
|
|
|
string strSource, strCol;
|
|
|
strSource = strCol = "";
|
|
|
GeoSigmaWellPoleXY.TrackGetDataSourceID(thandle, ref strSource, ref strCol);
|
|
|
GeoSigmaWellPoleXY.GetWellTrackDataJson(thandle, ref strJson);
|
|
|
|
|
|
bool b = false;
|
|
|
|
|
|
if (strSource == WellObjectBaseInfo.CycleTableTypes[(int)(WellObjectBaseInfo.eCycleDataType.CycleLongterm)]) //"CycleLongterm")
|
|
|
{
|
|
|
if (WellDataConvert.getWellLongCyClesJsonFromJson(wellinfo.wellName, strJson, out List<CycleLongterm> list))
|
|
|
{
|
|
|
DBHelp.NewDb.Deleteable<CycleLongterm>(r => r.Well == wellinfo.wellName).ExecuteCommand();
|
|
|
DBHelp.NewDb.BulkInsert(list);
|
|
|
MessageBox.Show("写入完毕");
|
|
|
}
|
|
|
}
|
|
|
else if (strSource == WellObjectBaseInfo.CycleTableTypes[(int)(WellObjectBaseInfo.eCycleDataType.CycleShortterm)])
|
|
|
{
|
|
|
if (WellDataConvert.getWellShortCyClesJsonFromJson(wellinfo.wellName, strJson, out List<CycleShortterm> list))
|
|
|
{
|
|
|
DBHelp.NewDb.Deleteable<CycleShortterm>(r => r.Well == wellinfo.wellName).ExecuteCommand();
|
|
|
DBHelp.NewDb.BulkInsert(list);
|
|
|
MessageBox.Show("写入完毕");
|
|
|
}
|
|
|
}
|
|
|
else if (strSource == WellObjectBaseInfo.CycleTableTypes[(int)(WellObjectBaseInfo.eCycleDataType.CycleMediumterm)])
|
|
|
{
|
|
|
if (WellDataConvert.getWellMediumCyClesJsonFromJson(wellinfo.wellName, strJson, out List<CycleMediumterm> list))
|
|
|
{
|
|
|
DBHelp.NewDb.Deleteable<CycleMediumterm>(r => r.Well == wellinfo.wellName).ExecuteCommand();
|
|
|
DBHelp.NewDb.BulkInsert(list);
|
|
|
MessageBox.Show("写入完毕");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public override void SetAddFaultPoint()
|
|
|
{
|
|
|
//GeoSigmaWellPoleXY GeoSigmaWellPoleXY = (GeoSigmaWellPoleXY)this.Geo;
|
|
|
//int stype = -1;
|
|
|
//int ttype = -1;
|
|
|
//UInt64 thandle = 0;
|
|
|
//if (GeoSigmaWellPoleXY.GetSelectWellObject(ref stype, ref ttype, ref thandle))
|
|
|
//{
|
|
|
// if (stype == (int)(GeoSigmaWellPoleXY.eWellExtType.KEP_WELL))
|
|
|
// {
|
|
|
// FillCurveGradientFrm dlgNew = new FillCurveGradientFrm() { StartPosition = FormStartPosition.CenterScreen };
|
|
|
|
|
|
// dlgNew.bAutoMidClr = false;
|
|
|
// dlgNew.leftValue = 0;
|
|
|
// dlgNew.rightValue = 200;
|
|
|
|
|
|
// dlgNew.leftColor = Color.Red;
|
|
|
// dlgNew.midColor = Color.Aqua;
|
|
|
// dlgNew.rightColor = Color.White;
|
|
|
|
|
|
// GeoSigmaWellPoleXY.GetWellAllCurveNames(thandle, out string[] namesStr);
|
|
|
// for (int i = 0; i < namesStr.Length; i++)
|
|
|
// {
|
|
|
// dlgNew.curvesName.Add(namesStr[i]);
|
|
|
// }
|
|
|
|
|
|
// if (dlgNew.ShowDialog(this) == DialogResult.Cancel)
|
|
|
// {
|
|
|
// return;
|
|
|
// }
|
|
|
// int tt = 100;
|
|
|
// }
|
|
|
//}
|
|
|
|
|
|
GeoSigmaWellPoleXY GeoSigmaWellPoleXY = (GeoSigmaWellPoleXY)geoSigma; //ggff20251210
|
|
|
GeoSigmaWellPoleXY.SetAddFaultPoint();
|
|
|
}
|
|
|
public override bool IsAddFaultPoint()
|
|
|
{
|
|
|
GeoSigmaWellPoleXY GeoSigmaWellPoleXY = (GeoSigmaWellPoleXY)geoSigma;
|
|
|
return GeoSigmaWellPoleXY.IsAddFaultPoint();
|
|
|
}
|
|
|
|
|
|
private void toolStripMenuItemEditFault_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
GeoSigmaWellPoleXY GeoSigmaWellPoleXY = (GeoSigmaWellPoleXY)this.Geo; // geoSigma;
|
|
|
|
|
|
int type, ttype;
|
|
|
type = ttype = -1;
|
|
|
UInt64 thandle = 0;
|
|
|
GeoSigmaWellPoleXY.GetSelectWellObject(ref type, ref ttype, ref thandle);
|
|
|
if (type != (int)(GeoSigmaWellPoleXY.eWellExtType.KEP_TRACK))
|
|
|
return;
|
|
|
|
|
|
if (ttype == (int)GeoSigmaWellPoleXY.eWellExtType.Track_SandLayer)
|
|
|
{
|
|
|
var dataDlg = new FrmWellDataEdit() { StartPosition = FormStartPosition.CenterScreen };
|
|
|
try
|
|
|
{
|
|
|
UInt64 wellHandle = 0;
|
|
|
string strJson = "";
|
|
|
GeoSigmaWellPoleXY.GetSelectedWell(ref wellHandle);
|
|
|
GeoSigmaWellPoleXY.GetWellTableDatasJson(wellHandle, "FaultPoint", ref strJson);
|
|
|
string dataType = string.Empty;
|
|
|
string[] colsName = new string[0];
|
|
|
string[,] datas = new string[0, 0];
|
|
|
WellDataConvert.getColNameAndDatasFromJson(strJson, ref dataType, ref colsName, ref datas);
|
|
|
|
|
|
string[] colsNameCH = new string[0];
|
|
|
GeoSigmaWellPoleXY.mWellTableInfos.GetTableColumnCHNames(dataType, colsName, ref colsNameCH);
|
|
|
dataDlg.SetData(colsName, colsNameCH, datas);
|
|
|
|
|
|
if (dataDlg.ShowDialog(this) == DialogResult.OK)
|
|
|
{
|
|
|
// byte[] databytes = Encoding.UTF8.GetBytes(dataDlg.strJsonData);
|
|
|
if (dataDlg.m_IsModified == true)
|
|
|
{
|
|
|
|
|
|
GeoSigmaWellPoleXY.SetWellFaultDatasJson(wellHandle, dataDlg.strJsonData, true);
|
|
|
this.drawer1.Invalidate();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
MessageBox.Show(ex.Message);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void toolStripMenuItemFaultInDB_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
GeoSigmaWellPoleXY GeoSigmaWellPoleXY = (GeoSigmaWellPoleXY)this.Geo; // geoSigma;
|
|
|
|
|
|
int type, ttype;
|
|
|
type = ttype = -1;
|
|
|
UInt64 thandle = 0;
|
|
|
GeoSigmaWellPoleXY.GetSelectWellObject(ref type, ref ttype, ref thandle);
|
|
|
if (type != (int)(GeoSigmaWellPoleXY.eWellExtType.KEP_TRACK))
|
|
|
return;
|
|
|
|
|
|
UInt64 wellHandle = 0;
|
|
|
GeoSigmaWellPoleXY.GetSelectedWell(ref wellHandle);
|
|
|
GeoSigmaWellPoleXY.GetWellBaseInfo(wellHandle, out GeoSigmaWellPoleXY.WellBaseInfo wellinfo);
|
|
|
|
|
|
string strJson = "";
|
|
|
GeoSigmaWellPoleXY.GetWellTableDatasJson(wellHandle, "FaultPoint", ref strJson);
|
|
|
if (WellDataConvert.getWellFaultsFromJson(wellinfo.wellName, strJson, out List<WellBreakPoint> list))
|
|
|
{
|
|
|
DBHelp.NewDb.Deleteable<WellBreakPoint>(r => r.JH == wellinfo.wellName).ExecuteCommand();
|
|
|
DBHelp.NewDb.BulkInsert(list);
|
|
|
MessageBox.Show("写入完毕");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public void InitStratumDivisionData()
|
|
|
{
|
|
|
GeoSigmaWellPoleXY GeoSigmaWellPoleXY = (GeoSigmaWellPoleXY)geoSigma;
|
|
|
UInt64 wellHandle = 0;
|
|
|
if (GeoSigmaWellPoleXY.GetSelectedWell(ref wellHandle))
|
|
|
{
|
|
|
readStratumDivisionFromWorkArea(wellHandle);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|