using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WW.Cad.Base;
using WW.Cad.Drawing;
using WW.Cad.Drawing.GDI;
using WW.Cad.IO;
using WW.Cad.Model;
using WW.Math;
using WW.Cad.Model.Entities;
using WW.Actions;
using WW.Cad.Model.Tables;
using WW.Cad.Model.Objects;
namespace TProduct.PumpGraph.Dxf
{
//来源 : 毅飞机械 (面板分开, 只要流量扬程和效率在一个面板, 流量功率汽蚀在另一个面板里 , 且只显示工作曲线 )
public partial class MultiSpeed8 : MultiSpeed_Split
{
public MultiSpeed8()
{
}
public override bool CreateDxf(string strFilePath, string strTemplateFile)
{
this._strTemplateFile = strTemplateFile;
return CreateDxf(strFilePath);
}
public override bool CreateDxf(string strFilePath)
{
try
{
if (string.IsNullOrEmpty(_strTemplateFile) || !System.IO.File.Exists(_strTemplateFile))
{
return false;
}
_dxfFileModel = DwgReader.Read(_strTemplateFile);
//颜色
InitialChartColorAndFont();
//检查坐标
CheckNpshCoord();
CheckPowerCoord();
//初始化整个面板尺寸信息
InitialDiagramSize(600, 320 + 44 + 580);
//绘制图框
DrawDiagramPanelQH_QE();
DrawDiagramPanelQP_QNPSH();
DrawQHCurve();
DrawQECurve();
DrawQPCurve();
DrawQNPSHCurve();
//标题栏
DrawFrameTtileText();
//工作点
DrawWorkPoint();
////额定点 和 额定参数文字
////DrawRatedParas();
//区域参数 和 区域参数文字
// DrawRegion();
#region 等效线
if (_equalParaCurveE != null && IsDispEqualParaCurveE)
{
DrawEqualParaCurveE(_equalParaCurveE);
}
if (IsDispEqualParaTextE && _equalParaCurveE != null)
{
DrawEqualParaCurvePara(_equalParaCurveE);
}
#endregion
//if (_equipmentCurveParas != null)
//{
// WW.Cad.Model.Entities.EntityColor colorDxf = GetEntityColor(System.Drawing.Color.Beige);
// DrawSingleCurveQH(colorDxf, _equipmentCurveParas.CurveInfo);
//}
//////绘制型谱
////DrawSpetrumShape();
////绘制介质粘度信息
//DrawViscoInfo();
//保存文件
SaveFile(strFilePath);
}
catch // (Exception ex)
{
return false;
}
return true;
}
private int _grid_number_up = 0;//上部网格数
private int _grid_number_down = 0;
private int _blankGridNumberUpBottom = 2;//扬程下面预留2个格子
private int _blankGridNumberUpTop = 1;//扬程上面预留1个格子
private int _blankGridNumberDownBottom = 1;//功率下面预留2个格子
private int _blankGridNumberDownTop = 1;//功率上面预留1个格子
private double _diagram_up_top_posi = 0;
private double _diagram_down_top_posi = 0;
private double _diagram_up_bottom_posi = 0;
private double _diagram_down_bottom_posi = 0;
///
/// 初始化面板尺寸
///
/// 面板总宽
/// 面板总高
protected override void InitialDiagramSize(double diagramTotalLength, double diagramTotalHeight)
{
_diagramLeftBottomPt = new Point2D(0, 0);
_diagramRightBottomPt.X = _diagramLeftBottomPt.X + diagramTotalLength;
_diagramRightBottomPt.Y = _diagramLeftBottomPt.Y;
_diagramLeftTopPt.X = _diagramLeftBottomPt.X;
_diagramLeftTopPt.Y = _diagramLeftBottomPt.Y + diagramTotalHeight;
_diagramRightTopPt.X = _diagramRightBottomPt.X;
_diagramRightTopPt.Y = _diagramLeftTopPt.Y;
_blankGridNumberDownTop = 0;//毅飞不要功率上面有间隙
_grid_number_up = Math.Max(_coordinateParas.EndLineNoH - _coordinateParas.StartLineNoH + _blankGridNumberUpBottom, _coordinateParas.EndLineNoH - _coordinateParas.StartLineNoH) + _blankGridNumberUpTop;
_grid_number_down = Math.Max(_coordinateParas.EndLineNoP - _coordinateParas.StartLineNoP + _blankGridNumberDownBottom, _coordinateParas.EndLineNoNPSH - _coordinateParas.StartLineNoNPSH) + _blankGridNumberDownTop;
_diagram_Space = 44;//两个面板之间的间隙
_diagram_Cell_Height_Up = 580.0 / (_grid_number_up);
_diagram_Cell_Height_Down = 320.0 / (_grid_number_down);
_diagram_Cell_Width = diagramTotalLength / _coordinateParas.GridNumberX;
_diagram_up_top_posi = _diagramLeftBottomPt.Y + diagramTotalHeight;
_diagram_up_bottom_posi = _diagramLeftBottomPt.Y + _grid_number_down * _diagram_Cell_Height_Down + _diagram_Space;
_diagram_down_top_posi = _diagramLeftBottomPt.Y + _grid_number_down * _diagram_Cell_Height_Down;
_diagram_down_bottom_posi = _diagramLeftBottomPt.Y;
// 功率
_diagramRightBottomPt_QP.X = _diagramRightBottomPt.X;
_diagramRightBottomPt_QP.Y = _diagramRightBottomPt.Y + _blankGridNumberDownBottom * _diagram_Cell_Height_Down;
_diagramLeftTopPt_QP.X = _diagramLeftBottomPt.X;
_diagramLeftTopPt_QP.Y = _diagramLeftBottomPt.Y + (_coordinateParas.EndLineNoP - _coordinateParas.StartLineNoP + _blankGridNumberDownBottom) * _diagram_Cell_Height_Down;
_diagramRightTopPt_QP.X = _diagramRightBottomPt.X;
_diagramRightTopPt_QP.Y = _diagramLeftTopPt_QP.Y;
_diagramLeftBottomPt_QP.X = _diagramLeftBottomPt.X;
_diagramLeftBottomPt_QP.Y = _diagramLeftBottomPt.Y + _blankGridNumberDownBottom * _diagram_Cell_Height_Down;
//汽蚀
_diagramLeftBottomPt_QNPSH = new Point2D(0, 0);
_diagramRightBottomPt_QNPSH.X = _diagramLeftBottomPt_QNPSH.X + diagramTotalLength;
_diagramRightBottomPt_QNPSH.Y = _diagramLeftBottomPt_QNPSH.Y;
_diagramLeftTopPt_QNPSH.X = _diagramLeftBottomPt_QNPSH.X;
_diagramLeftTopPt_QNPSH.Y = _diagramLeftBottomPt_QNPSH.Y + (_coordinateParas.EndLineNoNPSH - _coordinateParas.StartLineNoNPSH) * _diagram_Cell_Height_Down;
_diagramRightTopPt_QNPSH.X = _diagramRightBottomPt_QNPSH.X;
_diagramRightTopPt_QNPSH.Y = _diagramLeftTopPt_QNPSH.Y;
//扬程
_diagramLeftBottomPt_QH.X = _diagramLeftBottomPt.X;
_diagramLeftBottomPt_QH.Y = _diagram_up_bottom_posi + (_blankGridNumberUpBottom) * _diagram_Cell_Height_Up;
_diagramRightBottomPt_QH.X = _diagramLeftBottomPt_QH.X + diagramTotalLength;
_diagramRightBottomPt_QH.Y = _diagramLeftBottomPt_QH.Y;
_diagramLeftTopPt_QH.X = _diagramLeftBottomPt_QH.X;
_diagramLeftTopPt_QH.Y = _diagram_up_bottom_posi + (_coordinateParas.EndLineNoH - _coordinateParas.StartLineNoH + _blankGridNumberUpBottom) * _diagram_Cell_Height_Up;
_diagramRightTopPt_QH.X = _diagramRightBottomPt_QH.X;
_diagramRightTopPt_QH.Y = _diagramLeftTopPt_QH.Y;
//效率
_diagramLeftBottomPt_QE.X = _diagramLeftBottomPt.X;
_diagramLeftBottomPt_QE.Y = _diagram_up_bottom_posi;
_diagramRightBottomPt_QE.X = _diagramLeftBottomPt_QE.X + diagramTotalLength;
_diagramRightBottomPt_QE.Y = _diagramLeftBottomPt_QE.Y;
_diagramLeftTopPt_QE.X = _diagramLeftBottomPt_QE.X;
_diagramLeftTopPt_QE.Y = _diagram_up_bottom_posi + (_coordinateParas.EndLineNoE - _coordinateParas.StartLineNoE) * _diagram_Cell_Height_Up;
_diagramRightTopPt_QE.X = _diagramRightBottomPt_QE.X;
_diagramRightTopPt_QE.Y = _diagramLeftTopPt_QE.Y;
var layer_gridLine = GetLayerByName("细实线");
//竖线(下部)
for (int i = 0; i <= _coordinateParas.GridNumberX; i++)
{
var pt1 = new Point2D(_diagramLeftBottomPt.X + i * _diagram_Cell_Width, _diagram_down_bottom_posi);
var pt2 = new Point2D(_diagramLeftBottomPt.X + i * _diagram_Cell_Width, _diagram_down_top_posi);
var gridLine = new DxfLine(pt1, pt2);
gridLine.LineWeight = _gridLineWidth;
gridLine.Color = _gridLineColor;
gridLine.Layer = layer_gridLine;
_dxfFileModel.Entities.Add(gridLine);
}
//横线(下部)
for (int i = 0; i <= _grid_number_down; i++)
{
var pt1 = new Point2D(_diagramLeftBottomPt.X, _diagram_down_bottom_posi + i * _diagram_Cell_Height_Down);
var pt2 = new Point2D(_diagramLeftBottomPt.X + diagramTotalLength, _diagram_down_bottom_posi + i * _diagram_Cell_Height_Down);
var gridLine = new DxfLine(pt1, pt2);
gridLine.LineWeight = _gridLineWidth;
gridLine.Color = _gridLineColor;
gridLine.Layer = layer_gridLine;
_dxfFileModel.Entities.Add(gridLine);
}
int info_width = 158 + 30;
int info_height = 123;
//竖线(上部)
for (int i = 0; i <= _coordinateParas.GridNumberX; i++)
{
var pt1 = new Point2D(_diagramLeftBottomPt_QH.X + i * _diagram_Cell_Width, _diagram_up_bottom_posi);
var pt2 = new Point2D(_diagramLeftBottomPt_QH.X + i * _diagram_Cell_Width, _diagram_up_top_posi);
if (pt2.X >= (600 - info_width))
pt2.Y = 944 - info_height;
var gridLine = new DxfLine(pt1, pt2);
gridLine.LineWeight = _gridLineWidth;
gridLine.Color = _gridLineColor;
gridLine.Layer = layer_gridLine;
_dxfFileModel.Entities.Add(gridLine);
}
//横线(上部)
for (int i = 0; i <= _grid_number_up; i++)
{
var pt1 = new Point2D(_diagramLeftBottomPt_QH.X, _diagram_up_bottom_posi + i * _diagram_Cell_Height_Up);
var pt2 = new Point2D(_diagramLeftBottomPt_QH.X + diagramTotalLength, _diagram_up_bottom_posi + i * _diagram_Cell_Height_Up);
if (pt2.Y >= 944 - info_height)
pt2.X = (600 - info_width);
var gridLine = new DxfLine(pt1, pt2);
gridLine.LineWeight = _gridLineWidth;
gridLine.Color = _gridLineColor;
gridLine.Layer = layer_gridLine;
_dxfFileModel.Entities.Add(gridLine);
}
//边框
{
//白色
var dxf_white_color = TProduct.PumpGraph.Dxf.AutoCadHelper.WhiteColor;
var pt1 = new Point2D((600 - info_width), 944);
var pt2 = new Point2D((600 - info_width), 944 - info_height);
var line1 = new DxfLine(pt1, pt2);
line1.LineWeight = 30;
line1.Color = dxf_white_color;
line1.Layer = layer_gridLine;
_dxfFileModel.Entities.Add(line1);
pt1 = new Point2D((600 - info_width), 944 - info_height);
pt2 = new Point2D(600, 944 - info_height);
var line2 = new DxfLine(pt1, pt2);
line2.LineWeight = 30;
line2.Color = dxf_white_color;
line2.Layer = layer_gridLine;
_dxfFileModel.Entities.Add(line2);
//WW.Cad.Model.Color white_color = WW.Cad.Model.Color.CreateFromColorIndex(7); //白色
//var dxf_white_color = TProduct.PumpGraph.Dxf.AutoCadHelper.GetColor(white_color);
//var pt1 = new Point2D(_diagramLeftBottomPt.X, _diagram_down_bottom_posi);
//var pt2 = new Point2D(_diagramLeftBottomPt.X, _diagram_down_top_posi);
//var line1 = new DxfLine(pt1, pt2);
//line1.LineWeight = 30;
//line1.Color = dxf_white_color;
//_dxfFileModel.Entities.Add(line1);
//pt1 = new Point2D(_diagramLeftBottomPt.X, _diagram_down_bottom_posi);
//pt2 = new Point2D(_diagramRightBottomPt.X, _diagram_down_bottom_posi);
//var line2 = new DxfLine(pt1, pt2);
//line2.LineWeight = 30;
//line2.Color = dxf_white_color;
//_dxfFileModel.Entities.Add(line2);
//pt1 = new Point2D(_diagramRightBottomPt.X, _diagram_down_bottom_posi);
//pt2 = new Point2D(_diagramRightBottomPt.X, _diagram_down_top_posi);
//var line3 = new DxfLine(pt1, pt2);
//line3.LineWeight = 30;
//line3.Color = dxf_white_color;
//_dxfFileModel.Entities.Add(line3);
//pt1 = new Point2D(_diagramLeftBottomPt.X, _diagram_down_top_posi);
//pt2 = new Point2D(_diagramRightBottomPt.X, _diagram_down_top_posi);
//var line4 = new DxfLine(pt1, pt2);
//line4.LineWeight = 30;
//line4.Color = dxf_white_color;
//_dxfFileModel.Entities.Add(line4);
//pt1 = new Point2D(_diagramLeftBottomPt_QH.X, _diagram_up_bottom_posi);
//pt2 = new Point2D(_diagramLeftBottomPt_QH.X, _diagram_up_top_posi);
//var line5 = new DxfLine(pt1, pt2);
//line5.LineWeight = 30;
//line5.Color = dxf_white_color;
//_dxfFileModel.Entities.Add(line5);
//pt1 = new Point2D(_diagramLeftBottomPt_QH.X, _diagram_up_bottom_posi);
//pt2 = new Point2D(_diagramRightBottomPt_QH.X, _diagram_up_bottom_posi);
//var line6 = new DxfLine(pt1, pt2);
//line6.LineWeight = 30;
//line6.Color = dxf_white_color;
//_dxfFileModel.Entities.Add(line6);
//pt1 = new Point2D(_diagramRightBottomPt_QH.X, _diagram_up_bottom_posi);
//pt2 = new Point2D(_diagramRightBottomPt_QH.X, _diagram_up_top_posi);
//var line7 = new DxfLine(pt1, pt2);
//line7.LineWeight = 30;
//line7.Color = dxf_white_color;
//_dxfFileModel.Entities.Add(line7);
//pt1 = new Point2D(_diagramLeftBottomPt_QH.X, _diagram_up_top_posi);
//pt2 = new Point2D(_diagramRightBottomPt_QH.X, _diagram_up_top_posi);
//var line8 = new DxfLine(pt1, pt2);
//line8.LineWeight = 30;
//line8.Color = dxf_white_color;
//_dxfFileModel.Entities.Add(line8);
}
}
protected override string BuildCadText(string content)
{
return @"{\fArial|b0|i0|c0|p34;\W1;" + content + "}";
}
///
/// 绘制面板(扬程和效率)
///
protected void DrawDiagramPanelQH_QE()
{
var layer_gridLine = GetLayerByName("细实线");
var layer_text = GetLayerByName("扬程功率线");
#region 流量
for (int i = 0; i <= _coordinateParas.GridNumberX; i++)
{
//位置
var posi_focus = _diagramLeftBottomPt_QH.X + i * _diagram_Cell_Width;
//刻度线
var pt1 = new Point2D(posi_focus, _diagram_up_bottom_posi);
var pt2 = new Point2D(posi_focus, _diagram_up_bottom_posi - (i % 2 == 0 ? _axisMajorTickLength : _axisMinorTickLength));
var grid_line = new DxfLine(pt1, pt2);
grid_line.LineWeight = _gridLineWidth;
grid_line.Color = _gridLineColor;
grid_line.Layer = layer_gridLine;
_dxfFileModel.Entities.Add(grid_line);
//流量刻度
double keduValue = _coordinateParas.CoordMinQ + i * _coordinateParas.CoordSpaceQ;
string kedu_str = "";
if (_unitQ == Eventech.Model.UnitQ.M3H)
{
kedu_str = keduValue.ToString();
}
else
{
kedu_str = GetNumberString(Eventech.Common.UnitQHelper.fromM3H(_unitQ, keduValue));
}
if (i == _coordinateParas.GridNumberX)
{
kedu_str = string.Format("Q({0})", Eventech.Common.UnitQHelper.GetEnUnitName(_unitQ));
}
var labelPtQ = new Point3D(posi_focus, _diagram_up_bottom_posi - _axisLabelSpaceToDiagramQ, 0d);
DxfMText axisLabel_q = new DxfMText(BuildCadText(kedu_str), labelPtQ, _axisLabelSizeX);//\P表示回车
axisLabel_q.AttachmentPoint = AttachmentPoint.TopCenter;
if (_axisTextFont != null)
axisLabel_q.Style = this._axisTextFont;
axisLabel_q.Layer = layer_text;
axisLabel_q.Color = this._axisLabelColorQ;
_dxfFileModel.Entities.Add(axisLabel_q);
}
#endregion
#region 扬程刻度
for (int i = _coordinateParas.StartLineNoH; i <= _coordinateParas.EndLineNoH; i++)
{//_diagramLeftBottomPt_QH.X,
//网格线
var horizLeftH = _diagram_up_bottom_posi + (i - _coordinateParas.StartLineNoH + _blankGridNumberUpBottom) * _diagram_Cell_Height_Up;
//var horizRightH = new Point2D(_diagramRightBottomPt_QH.X, horizLeftH.Y);
//var horizLine = new DxfLine(horizLeftH, horizRightH);
//horizLine.LineWeight = _gridLineWidth;
//horizLine.Color = _gridLineColor;
//_dxfFileModel.Entities.Add(horizLine);
#region 子网格线
//if (_isDispGridSubLineY && gridNumberH != i)
//{
// if (_gridSubLineColor == null)
// {
// WW.Cad.Model.Color sub_grid_color = WW.Cad.Model.Color.CreateFromRgb(255, 20, 147);
// _gridSubLineColor = TProduct.PumpGraph.Dxf.AutoCadHelper.GetColor(sub_grid_color);
// }
// for (int m = 1; m < 5; m++)
// {
// var space = m * _diagram_Cell_Height / 5;
// var horizLeftH_sub = new Point2D(_diagramLeftBottomPt_QH.X, horizLeftH.Y + space);
// var horizRightH_sub = new Point2D(_diagramRightBottomPt_QH.X, horizLeftH.Y + space);
// var horizLine_sub = new DxfLine(horizLeftH_sub, horizRightH_sub);
// horizLine_sub.LineWeight = 1;
// horizLine_sub.Color = _gridSubLineColor;
// _dxfFileModel.Entities.Add(horizLine_sub);
// }
//}
#endregion
//刻度线
var axis_label_psoi1 = new Point2D(_diagramLeftBottomPt_QH.X, horizLeftH);
var axis_label_psoi2 = new Point2D(_diagramLeftBottomPt_QH.X - (i % 2 == 0 ? _axisMajorTickLength : _axisMinorTickLength), horizLeftH);
var grid_line = new DxfLine(axis_label_psoi1, axis_label_psoi2);
grid_line.LineWeight = _gridLineWidth;
grid_line.Color = _gridLineColor;
grid_line.Layer = layer_gridLine;
_dxfFileModel.Entities.Add(grid_line);
//刻度
double keduValue = _coordinateParas.CoordMinH + (i) * _coordinateParas.CoordSpaceH;
if (keduValue < 0)
continue;
string kedu_str_left = "";
var aligmn = AttachmentPoint.MiddleRight;
if (_unitH == Eventech.Model.UnitH.M)
{
kedu_str_left = keduValue.ToString();
}
else if (_unitH == Eventech.Model.UnitH.MPa)
{
kedu_str_left = (keduValue / 100).ToString();
}
else
{
kedu_str_left = Eventech.Common.UnitHHelper.fromM2(_unitH, keduValue).ToString("N2");
}
if (i == _coordinateParas.EndLineNoH)
{//这个时间间隔过小,碰到了
if (this._diagram_Cell_Height_Up < 49)
break;
}
var label_posi_left = new Point3D(_diagramLeftBottomPt_QH.X - _axisLabelSpaceToDiagramY_left, horizLeftH, 0d);
DxfMText axisLabel_h_left = new DxfMText(BuildCadText(kedu_str_left), label_posi_left, _axisLabelSizeY);//\P表示回车 @"{\fArial|b0|i0|c0|p34;\W1;"+ kedu_str_left+"}"
axisLabel_h_left.AttachmentPoint = aligmn;
if (_axisTextFont != null)
{
//_axisTextFont.FontFilename = "Arial";
axisLabel_h_left.Style = this._axisTextFont;
}
axisLabel_h_left.Layer = layer_text;
axisLabel_h_left.Color = this._axisLabelColorH;
_dxfFileModel.Entities.Add(axisLabel_h_left);
}
//Title
Point3D pt_title_head = new Point3D();
pt_title_head.X = _diagramLeftTopPt_QH.X - _axisTitleSpaceToDiagramY_right;
pt_title_head.Y = _diagram_up_top_posi - 15;
pt_title_head.Z = 0d;
DxfMText text_axisTitle_head = new DxfMText(BuildCadText(string.Format(@"H\P[{0}]", Eventech.Common.UnitHHelper.GetEnUnitName(_unitH))),
pt_title_head, _axisTitleSizeY);//\P表示回车
if (this._axisTextFont != null)
text_axisTitle_head.Style = this._axisTextFont;
text_axisTitle_head.AttachmentPoint = AttachmentPoint.MiddleCenter;
text_axisTitle_head.Color = this._axisTitleColorH;
text_axisTitle_head.Layer = layer_text;
_dxfFileModel.Entities.Add(text_axisTitle_head);
#endregion
#region 效率刻度
for (int i = _coordinateParas.StartLineNoE; i <= _coordinateParas.EndLineNoE; i++)
{
//网格线 _diagramRightBottomPt_QE.X
var horizLeftE = _diagram_up_bottom_posi + (i - _coordinateParas.StartLineNoE) * _diagram_Cell_Height_Up;
//var horizRightH = new Point2D(_diagramRightBottomPt_QH.X, horizLeftH.Y);
//var horizLine = new DxfLine(horizLeftH, horizRightH);
//horizLine.LineWeight = _gridLineWidth;
//horizLine.Color = _gridLineColor;
//_dxfFileModel.Entities.Add(horizLine);
//刻度线
var axis_label_text_posi1 = new Point2D(_diagramRightBottomPt_QE.X + (i % 2 == 0 ? _axisMajorTickLength : _axisMinorTickLength), horizLeftE);
var axis_label_text_posi2 = new Point2D(_diagramRightBottomPt_QE.X, horizLeftE);
var grid_line = new DxfLine(axis_label_text_posi1, axis_label_text_posi2);
grid_line.LineWeight = _gridLineWidth;
grid_line.Color = _gridLineColor;
grid_line.Layer = layer_gridLine;
_dxfFileModel.Entities.Add(grid_line);
//刻度
double keduValue = _coordinateParas.CoordMinE + (i) * _coordinateParas.CoordSpaceE;
if (keduValue < 0)
continue;
string kedu_str_left = keduValue.ToString();
var label_posi_left = new Point3D(_diagramRightBottomPt_QE.X + _axisLabelSpaceToDiagramY_left, horizLeftE, 0d);
DxfMText axisLabel_h_left = new DxfMText(BuildCadText(kedu_str_left), label_posi_left, _axisLabelSizeY);//\P表示回车
axisLabel_h_left.AttachmentPoint = AttachmentPoint.MiddleLeft;
if (_axisTextFont != null)
axisLabel_h_left.Style = this._axisTextFont;
axisLabel_h_left.Color = this._axisLabelColorH;
axisLabel_h_left.Layer = layer_text;
_dxfFileModel.Entities.Add(axisLabel_h_left);
}
//Title
Point3D pt_title_eta = new Point3D();
pt_title_eta.X = _diagramRightTopPt_QE.X + _axisTitleSpaceToDiagramY_left;
pt_title_eta.Y = _diagram_up_top_posi - 15;
pt_title_eta.Z = 0d;
DxfMText text_axisTitle_eta = new DxfMText(BuildCadText(@"Eff\P[%]"), pt_title_eta, _axisTitleSizeY);//\P表示回车
if (this._axisTextFont != null)
text_axisTitle_eta.Style = this._axisTextFont;
text_axisTitle_eta.AttachmentPoint = AttachmentPoint.MiddleCenter;
text_axisTitle_eta.Color = this._axisTitleColorH;
text_axisTitle_eta.Layer = layer_text;
_dxfFileModel.Entities.Add(text_axisTitle_eta);
#endregion
}
///
/// 绘制面板(功率和汽蚀)
///
protected void DrawDiagramPanelQP_QNPSH()
{
var layer_gridLine = GetLayerByName("细实线");
var layer_text = GetLayerByName("扬程功率线");
#region 流量
//for (int i = 0; i <= _coordinateParas.GridNumberX; i++)
//{
// //位置
// var posi_focus = _diagramRightBottomPt.X + i * _diagram_Cell_Width;
// //刻度线
// var pt1 = new Point2D(posi_focus, _diagramRightBottomPt.Y);
// var pt2 = new Point2D(posi_focus, _diagramRightBottomPt.Y - (i % 2 == 0 ? _axisMajorTickLength : _axisMinorTickLength));
// var keDuLine = new DxfLine(pt1, pt2);
// keDuLine.LineWeight = _gridLineWidth;
// keDuLine.Color = _gridLineColor;
// _dxfFileModel.Entities.Add(keDuLine);
// //流量刻度
// double keduValue = _coordinateParas.CoordMinQ + i * _coordinateParas.CoordSpaceQ;
// string kedu_str = "";
// if (_unitQ == Eventech.Model.UnitQ.M3H)
// {
// kedu_str = keduValue.ToString();
// }
// else
// {
// kedu_str = Eventech.Common.UnitQHelper.fromM3H(_unitQ, keduValue).ToString("N2");
// }
// if (i == _coordinateParas.GridNumberX)
// {
// kedu_str = string.Format("Q({0})", Eventech.Common.UnitQHelper.GetEnUnitName(_unitQ));
// }
// var labelPtQ = new Point3D(posi_focus, _diagramRightBottomPt.Y - _axisLabelSpaceToDiagramQ, 0d);
// DxfMText axisLabel_q = new DxfMText(kedu_str, labelPtQ, _axisLabelSizeX);//\P表示回车
// axisLabel_q.AttachmentPoint = AttachmentPoint.TopCenter;
// //axisLabel_q.ReferenceRectangleHeight = _axisLabelSizeX;
// if (_axisTextFont != null)
// axisLabel_q.Style = this._axisTextFont;
// //axisLabel_q.Height = _axisLabelSizeX;
// axisLabel_q.Color = this._axisLabelColorQ;
// _dxfFileModel.Entities.Add(axisLabel_q);
//}
#endregion
#region 功率刻度
string unit_name = "kW";
for (int i = _coordinateParas.StartLineNoP; i <= _coordinateParas.EndLineNoP; i++)
{
//格子线
var horizLeftP = _diagram_down_bottom_posi + (i - _coordinateParas.StartLineNoP + _blankGridNumberDownBottom) * _diagram_Cell_Height_Down;
//var horizRightP = new Point2D(_diagramRightBottomPt_QP.X, horizLeftP.Y);
//var horizLine = new DxfLine(horizLeftP, horizRightP);
//horizLine.LineWeight = _gridLineWidth;
//horizLine.Color = _gridLineColor;
//_dxfFileModel.Entities.Add(horizLine);
#region 子格子线
//if (_isDispGridSubLineY && gridNumber_y != i)
//{
// if (_gridSubLineColor == null)
// {
// WW.Cad.Model.Color sub_grid_color = WW.Cad.Model.Color.CreateFromRgb(255, 20, 147);
// _gridSubLineColor = TProduct.PumpGraph.Dxf.AutoCadHelper.GetColor(sub_grid_color);
// }
// for (int m = 1; m < 5; m++)
// {
// var space = m * _diagram_Cell_Height / 5;
// var horizLeftH_sub = new Point2D(_diagramRightBottomPt.X, horizLeftP.Y + space);
// var horizRightH_sub = new Point2D(_diagramRightBottomPt_QP.X, horizLeftP.Y + space);
// var horizLine_sub = new DxfLine(horizLeftH_sub, horizRightH_sub);
// horizLine_sub.LineWeight = 1;
// horizLine_sub.Color = _gridSubLineColor;
// _dxfFileModel.Entities.Add(horizLine_sub);
// }
//}
#endregion
//刻度线
var pt1 = new Point2D(_diagramLeftBottomPt.X, horizLeftP);
var pt2 = new Point2D(_diagramLeftBottomPt.X - (i % 2 == 0 ? _axisMajorTickLength : _axisMinorTickLength), horizLeftP);
var grid_line = new DxfLine(pt1, pt2);
grid_line.LineWeight = _gridLineWidth;
grid_line.Color = _gridLineColor;
grid_line.Layer = layer_gridLine;
_dxfFileModel.Entities.Add(grid_line);
//刻度
double keduValueP = _coordinateParas.CoordMinP + (i) * _coordinateParas.CoordSpaceP;
if (keduValueP < 0)
continue;
if (keduValueP < 0.001)
keduValueP = 0;
if (_unitP == Eventech.Model.UnitP.KW)
{
keduValueP = Math.Round(keduValueP, 3);
}
else
{
if (_unitP == Eventech.Model.UnitP.HP)
unit_name = "hp";
else
unit_name = "";
keduValueP = Math.Round(Eventech.Common.UnitPHelper.fromKW(_unitP, keduValueP), 1);
}
if (i == _coordinateParas.EndLineNoP)
{
if (_blankGridNumberDownTop == 0)
break;//没有间隙
if (this._diagram_Cell_Height_Down < 49)
break;//这个时间间隔过小,碰到了
}
var labelPtP = new Point3D(_diagramLeftBottomPt.X - _axisLabelSpaceToDiagramY_left, horizLeftP, 0d);
DxfMText axisLabel_p_left = new DxfMText(BuildCadText(keduValueP.ToString()), labelPtP, _axisLabelSizeY);//\P表示回车
axisLabel_p_left.AttachmentPoint = AttachmentPoint.MiddleRight;
if (_axisTextFont != null)
axisLabel_p_left.Style = this._axisTextFont;
axisLabel_p_left.Layer = layer_text;
axisLabel_p_left.Color = this._axisLabelColorP;
_dxfFileModel.Entities.Add(axisLabel_p_left);
}
Point3D pt_title_power = new Point3D();
pt_title_power.X = _diagramLeftBottomPt.X - _axisTitleSpaceToDiagramY_right - 5;
pt_title_power.Y = _diagram_down_top_posi - 15;
pt_title_power.Z = 0d;
DxfMText textTitle_P = new DxfMText(BuildCadText(string.Format(@"P\P[{0}]", unit_name)), pt_title_power, _axisTitleSizeY);//\P表示回车
textTitle_P.AttachmentPoint = AttachmentPoint.MiddleCenter;
if (_axisTextFont != null)
textTitle_P.Style = _axisTextFont;
textTitle_P.Color = _axisTitleColorP;
textTitle_P.Layer = layer_text;
_dxfFileModel.Entities.Add(textTitle_P);
#endregion
#region 汽蚀刻度
var gridNumberNPSH = _coordinateParas.EndLineNoNPSH - _coordinateParas.StartLineNoNPSH;
if (gridNumberNPSH > 1)
{
for (int i = _coordinateParas.StartLineNoNPSH; i <= _coordinateParas.EndLineNoNPSH; i++)
{
//格子线
var horizLeftNPSH = _diagram_down_bottom_posi + (i - _coordinateParas.StartLineNoNPSH) * _diagram_Cell_Height_Down;
//var horizRightH = new Point2D(_diagramLeftBottomPt.X, horizLeftH.Y);
//var horizLine = new DxfLine(horizLeftH, horizRightH);
//horizLine.LineWeight = _gridLineWidth;
//horizLine.Color = _gridLineColor;
//_dxfFileModel.Entities.Add(horizLine);
//刻度线
var pt1 = new Point2D(_diagramRightBottomPt_QNPSH.X, horizLeftNPSH);
var pt2 = new Point2D(_diagramRightBottomPt_QNPSH.X + (i % 2 == 0 ? _axisMajorTickLength : _axisMinorTickLength), horizLeftNPSH);
var grid_line = new DxfLine(pt1, pt2);
grid_line.LineWeight = _gridLineWidth;
grid_line.Color = _gridLineColor;
grid_line.Layer = layer_gridLine;
_dxfFileModel.Entities.Add(grid_line);
//刻度
double keduValue = _coordinateParas.CoordMinNPSH + (i) * _coordinateParas.CoordSpaceNPSH;
if (keduValue < 0)
continue;
string kedu_str_left = keduValue.ToString();
var label_posi_left = new Point3D(_diagramRightBottomPt_QNPSH.X + _axisLabelSpaceToDiagramY_left, horizLeftNPSH, 0d);
DxfMText axisLabel_npsh_left = new DxfMText(BuildCadText(kedu_str_left), label_posi_left, _axisLabelSizeY);//\P表示回车
axisLabel_npsh_left.AttachmentPoint = AttachmentPoint.MiddleLeft;
if (_axisTextFont != null)
axisLabel_npsh_left.Style = this._axisTextFont;
axisLabel_npsh_left.Color = this._axisLabelColorH;
axisLabel_npsh_left.Layer = layer_text;
_dxfFileModel.Entities.Add(axisLabel_npsh_left);
}
//Title
Point3D pt_title_npsh = new Point3D();
pt_title_npsh.X = _diagramRightTopPt_QNPSH.X + _axisTitleSpaceToDiagramY_left + 8;
pt_title_npsh.Y = _diagram_down_top_posi - 15;
pt_title_npsh.Z = 0d;
DxfMText text_axisTitle_npsh = new DxfMText(BuildCadText(@"NPSH\P[m]"), pt_title_npsh, _axisTitleSizeY);//\P表示回车
if (this._axisTextFont != null)
text_axisTitle_npsh.Style = this._axisTextFont;
text_axisTitle_npsh.AttachmentPoint = AttachmentPoint.MiddleCenter;
text_axisTitle_npsh.Color = this._axisTitleColorH;
text_axisTitle_npsh.Layer = layer_text;
_dxfFileModel.Entities.Add(text_axisTitle_npsh);
}
#endregion
}
///
///
///
protected override void InitialChartColorAndFont()
{
base.InitialChartColorAndFont();
_axisTitleSpaceToDiagramY_right = 20;
_axisTitleSpaceToDiagramY_left = 20;
_axisTitleSpaceToLabel_Vertial_Y = 10;
_axisLabelSpaceToDiagramY_left = 13.5f;
_axisLabelSpaceToDiagramY_right = 13.5f;
_axisLabelSpaceToDiagramQ = 13;
// _axisTitleSpaceToDiagramQ_Y = 50;
// _axisTitleSpaceToDiagramQ_X = 15;
_isDispGridSubLineX = true;
_isDispGridSubLineY = true;
this._equalParaCurveWidth = 30;
this._gridLineWidth = 5;
this._defaultFeatCurveWidth = 40;
this._axisLabelSizeX = 10;
this._axisLabelSizeY = 10;
this._axisTitleSizeX = 12;
this._axisTitleSizeY = 12;
this._equalCurveParaLabelHeight = 8;
this._defatulCurveLabelHeight = 9;
_axisTitleDockV_Left = AttachmentPoint.MiddleCenter;
_frameTextFont = _dxfFileModel.GetTextStyleWithName("Standard");//文件自带字体 (义维定义)
_curveTextFont = _dxfFileModel.GetTextStyleWithName("Standard");//文件自带字体
_axisTextFont = _dxfFileModel.GetTextStyleWithName("Standard");
var dxf_white_color = TProduct.PumpGraph.Dxf.AutoCadHelper.WhiteColor;
_gridLineColor = TProduct.PumpGraph.Dxf.AutoCadHelper.GreenColor;
_axisTitleColorH = dxf_white_color;
_axisTitleColorQ = dxf_white_color;
_axisTitleColorE = dxf_white_color;
_axisTitleColorP = dxf_white_color;
_axisTitleColorNPSH = dxf_white_color;
_axisLabelColorQ = dxf_white_color;
_axisLabelColorP = dxf_white_color;
_axisLabelColorE = dxf_white_color;
_axisLabelColorNPSH = dxf_white_color;
_gridSubLineColor = TProduct.PumpGraph.Dxf.AutoCadHelper.GetColor(130);
_equalParaCurveColor = dxf_white_color;
_axisLabelColorH = dxf_white_color;
_equalParaCurveColor = dxf_white_color;
if (this._isMonoColor)
{
_gridSubLineColor = dxf_white_color;
_gridLineColor = dxf_white_color;
}
}
///
///
///
///
///
///
///
public override bool InitialTemplate(string CorpDataFolder, Eventech.Model.eLocalizationType location, string attachInfo)
{
_currentLangugage = location;
var file = GetTemplateFilePath(CorpDataFolder, location);
if (string.IsNullOrEmpty(file))
return false;
this._strTemplateFile = file;
return true;
}
public static string GetTemplateFilePath(string CorpDataFolder, Eventech.Model.eLocalizationType location)
{
string strTemplateFolder = null;
if (location != Eventech.Model.eLocalizationType.zhCN)
{
strTemplateFolder = System.IO.Path.Combine(CorpDataFolder, "template", "LXP_Style8_EN.dwg");
if (System.IO.File.Exists(strTemplateFolder))
{
return strTemplateFolder;
}
strTemplateFolder = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "template", "LXP_Style8_EN.dwg");
if (System.IO.File.Exists(strTemplateFolder))
{
return strTemplateFolder;
}
}
strTemplateFolder = System.IO.Path.Combine(CorpDataFolder, "template", "LXP_Style8_CN.dwg");
if (System.IO.File.Exists(strTemplateFolder))
{
return strTemplateFolder;
}
strTemplateFolder = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "template", "LXP_Style8_CN.dwg");
if (System.IO.File.Exists(strTemplateFolder))
{
return strTemplateFolder;
}
return strTemplateFolder;
}
}
}