public ExpPen CreatePen(ExpPen.ToolAttribute attribute, string name, uint id) { ExpPen pen = new ExpPen(id, name, attribute); _pens.Add(pen); return(pen); }
public ExpText(ExpBlock block, ExpLayer layer, ExpPen pen, double xt, double yt, string text) : base(block, layer, pen) { _xt = xt; _yt = yt; _text = text; }
public ExpPen CreatePen(ExpPen.ToolAttribute attribute, string name) { ExpPen pen = new ExpPen(_penInc++, name, attribute); _pens.Add(pen); return(pen); }
public ExpPen GetPenByAttribute(ExpPen.ToolAttribute attribute) { ExpPen pen = _pens.Find(p => p.Attribute == attribute); if (null == pen) { pen = CreatePen(attribute); } return(pen); }
private int PenToTool(ExpPen pen) { if (penToolMap.ContainsKey(pen.Attribute)) { return(penToolMap[pen.Attribute]); } else { return(penToolMap[ExpPen.ToolAttribute.LT_CONSTRUCTION]); } }
void ExportEntity(ref StringBuilder sb, ExpPen pen, ExpBlockRef blockRef, ExpEntity entity) { const double INCH2MM = 72.0 / 25.4; if (entity.Pen != pen) { return; } ExpLine line = entity as ExpLine; if (null != line) { double X0 = line.X0, Y0 = line.Y0, X1 = line.X1, Y1 = line.Y1; if (null != blockRef) { blockRef.TransformPoint(line.X0, line.Y0, out X0, out Y0); } sb.AppendLine(string.Format( CultureInfo.InvariantCulture, "{0:0.###} {1:0.###} m", X0 * INCH2MM, Y0 * INCH2MM)); if (null != blockRef) { blockRef.TransformPoint(line.X1, line.Y1, out X1, out Y1); } sb.AppendLine(string.Format( CultureInfo.InvariantCulture, "{0:0.###} {1:0.###} L", X1 * INCH2MM, Y1 * INCH2MM)); sb.AppendLine("S"); } ExpArc arc = entity as ExpArc; if (null != arc) { // divide arc if necessary int iStep = (int)Math.Ceiling(arc.OpeningAngle / 91.0); iStep = iStep >= 1 ? iStep : 1; const double rad = Math.PI / 180.0; const double paga = 1.0; double angleStep = arc.OpeningAngle / iStep; double ang1 = arc.Angle0; double xc = arc.Xcenter; double yc = arc.Ycenter; double dim = arc.Radius; double dir = arc.Angle0; for (int i = 0; i < iStep; ++i) { double ang2 = ang1 + angleStep; // control points of elipse arc in ellipse local coord double x1 = arc.Radius * Math.Cos((ang1 - dir) * rad); double y1f = arc.Radius * paga * Math.Sin((ang1 - dir) * rad); double x4 = dim * Math.Cos((ang2 - dir) * rad); double y4 = dim * paga * Math.Sin((ang2 - dir) * rad); double dx1 = -dim *Math.Sin((ang1 - dir) *rad); double dy1 = dim * paga * Math.Cos((ang1 - dir) * rad); double dx4 = -dim *Math.Sin((ang2 - dir) *rad); double dy4 = dim * paga * Math.Cos((ang2 - dir) * rad); double alpha = Math.Sin((ang2 - ang1) * rad) * ((Math.Sqrt(4.0 + 3.0 * Math.Atan(0.5 * (ang2 - ang1) * rad) * Math.Atan(0.5 * (ang2 - ang1) * rad))) - 1.0f) / 3.0f; double x2 = x1 + alpha * dx1; double y2 = y1f + alpha * dy1; double x3 = x4 - alpha * dx4; double y3 = y4 - alpha * dy4; // rotation Rotation(ref x1, ref y1f, x1, y1f, Math.Cos(dir * rad), Math.Sin(dir * rad)); Rotation(ref x2, ref y2, x2, y2, Math.Cos(dir * rad), Math.Sin(dir * rad)); Rotation(ref x3, ref y3, x3, y3, Math.Cos(dir * rad), Math.Sin(dir * rad)); Rotation(ref x4, ref y4, x4, y4, Math.Cos(dir * rad), Math.Sin(dir * rad)); // translation x1 += xc; y1f += yc; x2 += xc; y2 += yc; x3 += xc; y3 += yc; x4 += xc; y4 += yc; double X1 = x1, Y1 = y1f; if (null != blockRef) { blockRef.TransformPoint(x1, y1f, out X1, out Y1); } double X2 = x2, Y2 = y2; if (null != blockRef) { blockRef.TransformPoint(x2, y2, out X2, out Y2); } double X3 = x3, Y3 = y3; if (null != blockRef) { blockRef.TransformPoint(x3, y3, out X3, out Y3); } double X4 = x4, Y4 = y4; if (null != blockRef) { blockRef.TransformPoint(x4, y4, out X4, out Y4); } sb.AppendLine(string.Format( CultureInfo.InvariantCulture, "{0:0.##} {1:0.##} m", X1 * INCH2MM, Y1 * INCH2MM)); sb.AppendLine(string.Format(CultureInfo.InvariantCulture, "{0:0.##} {1:0.##} {2:0.##} {3:0.##} {4:0.##} {5:0.##} c", X2 * INCH2MM, Y2 * INCH2MM, X3 * INCH2MM, Y3 * INCH2MM, X4 * INCH2MM, Y4 * INCH2MM)); sb.AppendLine("S"); ang1 = ang2; } } }
public void AddText(ExpBlock block, ExpLayer layer, ExpPen pen, double xt, double yt, string text) { _entities.Add(new ExpText(block, layer, pen, xt, yt, text)); }
public void AddArc(ExpBlock block, ExpLayer layer, ExpPen pen, double xc, double yc, double radius, double angle0, double angle1) { _entities.Add(new ExpArc(block, layer, pen, xc, yc, radius, angle0, angle1)); }
public void AddSegment(ExpBlock block, ExpLayer layer, ExpPen pen, double x0, double y0, double x1, double y1) { _entities.Add(new ExpLine(block, layer, pen, x0, y0, x1, y1)); }
public ExpArc(ExpBlock block, ExpLayer layer, ExpPen pen, double xc, double yc, double radius, double angle0, double angle1) : base(block, layer, pen) { _xc = xc; _yc = yc; _radius = radius; _angle0 = angle0; _angle1 = angle1; }
public ExpLine(ExpBlock block, ExpLayer layer, ExpPen pen, double x0, double y0, double x1, double y1) : base(block, layer, pen) { _x0 = x0; _y0 = y0; _x1 = x1; _y1 = y1; }
public ExpEntity(ExpBlock block, ExpLayer layer, ExpPen pen) { _block = block; _layer = layer; _pen = pen; }
private int PenToPt(ExpPen pen) { return(1); }