⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 columns.cs

📁 剖面生成器
💻 CS
字号:
using System;
using SuperMapLib;
using System.Drawing;

namespace ProfileCtrl
{
	/// <summary>
	/// 钻孔柱状图类
	/// </summary>
	public class Columns
	{
		private Bore[] bores;//钻孔数据的集合
		private float scaleX, scaleY, scaleT=0.005f;//scaleT 文本缩放比例因子
		private float width1=0.02f,width;//柱状图的宽度
		private int zkCount;
		private bool isSum=true;//是否是大层
		/// <summary>
		/// 是否是大层
		/// </summary>
		public bool IsSum
		{
			get{return isSum;}
			set{isSum=value;}
		}
		/// <summary>
		/// 文本缩放比例因子
		/// </summary>
		public float ScaleT
		{
			get{return scaleT;}
			set{scaleT=value;}
		}
		/// <summary>
		/// 柱状图的宽度
		/// </summary>
		public float Width
		{
			get{return width;}
			set{width=value;}
		}
		
		public Columns(Bore[] bore1)
		{
			//
			// TODO: 在此处添加构造函数逻辑
			//
			bores=bore1;
			this.scaleX=PublicValue.scaleX;
			this.scaleY=PublicValue.scaleY;
			zkCount=bore1.Length;
		}
		public void Draw(soRecordset objColumnRs,soRecordset objColumnLineRs,soFillStyleLib objFill)
		{
			for(int i=0;i<zkCount;i++)
			{
				this.DrawColumn(objColumnRs,objFill,bores[i]);
				this.DrawColumnLine(objColumnLineRs,bores[i]);
				this.DrawText(objColumnRs,isSum,bores[i]);

			}
		}
		/// <summary>
		/// 画出每个钻孔
		/// </summary>
		/// <param name="objRs"></param>
		/// <param name="xCoor"></param>
		/// <param name="scaleY"></param>
		public void DrawLine(soRecordset objRs,float xCoor,float scaleY,Bore bore)
		{
			soPoint objPoint = new soPoint();			
			soPoints objPoints = new soPoints();
			soGeoLine objGeoLine = new soGeoLine();			
			//			objPoint.x = bore..x/scaleX;
			objPoint.x = xCoor;
			objPoint.y = bore.GetCDBG()[0]/scaleY;
			objPoints.Add(objPoint);
			objPoint.y = bore.GetCDBG()[bore.GetCDBG().Length-1]/scaleY;
			objPoints.Add(objPoint);
			objGeoLine.AddPart(objPoints);
			objRs.AddNew((soGeometry)objGeoLine);
			objRs.Update();			
			objPoint = null;
			objPoints = null;
			objGeoLine = null;
		}
		/// <summary>
		/// 画出探孔的每段地层线(岩性线)
		/// </summary>
		/// <param name="objRs">岩性线层</param>
		/// <param name="scaleX">剖面图横比例尺</param>
		/// <param name="scaleY">剖面图纵比例尺</param>
		private void DrawColumnLine(soRecordset objRs,Bore bore)
		{
			soPoints objPoints;
			soGeoLine objGeoLine;
			soPoint objPoint = new soPoint();			
			for(int i=1;i<bore.GetCDBG().Length;i++)
			{
				objPoints = new soPoints();
				objGeoLine = new soGeoLine();
				objPoint.x = bore.X/scaleX;
				objPoint.y = bore.GetCDBG()[i-1]/scaleY;
				objPoints.Add(objPoint);
				objPoint.y = bore.GetCDBG()[i]/scaleY;
				objPoints.Add(objPoint);
				objGeoLine.AddPart(objPoints);
				objRs.AddNew((soGeometry)objGeoLine);
				objRs.SetFieldValue("岩性",bore.GetYXBH()[i]);
				objRs.SetFieldValue("Color",bore.GetDCYS()[i]);
				objRs.Update();
				objPoints = null;
				objGeoLine = null;
			}
			objPoint = null;					
		}
		/// <summary>
		/// 画出探孔柱状图
		/// </summary>
		/// <param name="objRs">存放柱状图的cad数据集</param>
		/// <param name="objFill">每种岩性地层的图例样式</param>
		/// <param name="scaleX">横比例尺</param>
		/// <param name="scaleY">纵比例尺</param>
		/// <param name="width">柱状图的宽度</param>
		private void DrawColumn(soRecordset objRs, soFillStyleLib objFill,Bore bore)		//画柱状图
		{
			width = width1/2;	//岩性柱宽的一半
			soPoints objPoints;
			soGeoRegion objGeoRegion;			
			soStyle objStyle = new soStyle();		
			soPoint objPoint1 = new soPoint();
			soPoint objPoint2 = new soPoint();
			for(int i=1;i<bore.GetCDBG().Length;i++)
			{
				objPoints = new soPoints();
				objGeoRegion = new soGeoRegion();
				objPoint1.x = objPoint2.x = bore.X/scaleX - width;
				objPoint1.y = bore.GetCDBG()[i-1]/scaleY;
				objPoint2.y = bore.GetCDBG()[i]/scaleY;
				objPoints.Add(objPoint2);
				objPoints.Add(objPoint1);
				objPoint1.x = objPoint2.x = bore.X/scaleX + width;
				objPoints.Add(objPoint1);
				objPoints.Add(objPoint2);
				objGeoRegion.AddPart(objPoints);
//				System.Windows.Forms.MessageBox.Show(bore.GetYXBH()[i].ToString()+"\r\n"+objFill.Find(bore.GetYXBH()[i],0).ToString());
				objStyle.BrushStyle = objFill.FindIndex(objFill.Find(bore.GetYXBH()[i],0));
				objStyle.BrushColor = System.Convert.ToUInt32(System.Drawing.ColorTranslator.ToOle(Color.FromName(bore.GetDCYS()[i])));
				objGeoRegion.Style = objStyle;
				objRs.AddNew((soGeometry)objGeoRegion);
				objRs.SetFieldValue("岩性",bore.GetYXBH()[i]);
				objRs.Update();				
				objPoints = null;
			}
			objPoint1 = null;
			objPoint2 = null;
			objGeoRegion = null;
			objStyle = null;
		}		
		/// <summary>
		/// 在对应的位置标注每个地层的底界深度
		/// </summary>
		/// <param name="objRs">存放柱状图的cad数据集</param>
		/// <param name="scaleX">地图横比例尺</param>
		/// <param name="scaleY">地图纵比例尺</param>
		/// <param name="scaleT">字体的大小</param>
		/// <param name="isSum">是否概化</param>
		private void DrawText(soRecordset objRs, bool isSum,Bore bore)
		{	
			soGeoText objGeoText = new soGeoText();		
			objGeoText.TextStyle.Color = System.Convert.ToUInt32(System.Drawing.ColorTranslator.ToOle(Color.Black));
			objGeoText.TextStyle.FontName = "宋体";
			objGeoText.TextStyle.FontHeight = scaleT;
			objGeoText.TextStyle.FontWidth = scaleT;
			soTextPart objText = new soTextPart();
			objText.x = bore.X/scaleX + objGeoText.TextStyle.FontWidth;
			soPoints objPoints;
			soGeoLine objGeoLine;
			soPoint objPoint1,objPoint2;
			objPoint1 = new soPoint();
			objPoint1.x = bore.X/scaleX;
			objPoint2 = new soPoint();
			objPoint2.x = bore.X/scaleX + objGeoText.TextStyle.FontWidth;
			if(isSum)
			{
				for(int i=1;i<bore.GetCDBG().Length-1;i++)
				{
					objPoints = new soPoints();
					objGeoLine = new soGeoLine();
					objPoint1.y = objPoint2.y = bore.GetCDBG()[i]/scaleY;
					objPoints.Add(objPoint1);
					objPoints.Add(objPoint2);
					objGeoLine.AddPart(objPoints);
					objRs.AddNew((soGeometry)objGeoLine);
					objRs.Update();
					objText.y = objPoint1.y + objGeoText.TextStyle.FontWidth * 0.5;
					objText.Text = bore.GetCDBG()[i].ToString();
					objGeoText.AddPart(objText);
				}
			}
			//孔口标注
			objText.x = bore.X/scaleX - bore.ZKYSBH.ToString().Length * objGeoText.TextStyle.FontWidth * 0.5; 
			objText.y = bore.DMBG/scaleY + objGeoText.TextStyle.FontHeight * 2;;
			objText.Text = bore.ZKYSBH.ToString();
			objGeoText.AddPart(objText);
			objText.x = bore.X/scaleX - bore.DMBG.ToString().Length * objGeoText.TextStyle.FontWidth * 0.5; 
			objText.y -= objGeoText.TextStyle.FontHeight;
			objText.Text = bore.DMBG.ToString();
			objGeoText.AddPart(objText);
			objPoints = new soPoints();
			objGeoLine = new soGeoLine();
			objPoint1.y = objText.y;
			int leng = bore.ZKYSBH.Length>bore.DMBG.ToString().Length ? bore.ZKYSBH.Length : bore.DMBG.ToString().Length;
			objPoint1.x = bore.X/scaleX - leng * objGeoText.TextStyle.FontWidth * 0.5;
			objPoints.Add(objPoint1);
			objPoint1.x += leng * objGeoText.TextStyle.FontWidth;
			objPoints.Add(objPoint1);
			objGeoLine.AddPart(objPoints);
			objRs.AddNew((soGeometry)objGeoLine);
			objRs.Update();
			//孔底标注
			objText.x = bore.X/scaleX - bore.GetCDBG()[bore.GetCDBG().Length-1].ToString().Length * objGeoText.TextStyle.FontWidth * 0.5; 
			objText.y = bore.GetCDBG()[bore.GetCDBG().Length-1]/scaleY;
			objText.Text = bore.GetCDBG()[bore.GetCDBG().Length-1].ToString();
			objGeoText.AddPart(objText);

			objRs.AddNew((soGeometry)objGeoText);
			objRs.Update();
			objPoint1 = null;
			objPoint2 = null;
			objPoints = null;
			objGeoLine = null;
			objText = null;	
			objGeoText = null;				
		}
	

	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -