/// <summary> /// 绘制车次 /// </summary> /// <param name="doc"></param> void IDecorateLabel.Draw(DXFLibrary.Document doc) { /*绘制T形标志*/ DXFLibrary.Line l = null; if (CurrentDirection == Direction.Down) { l = new DXFLibrary.Line("TrainID", OriginX, -OriginY, OriginX, -(OriginY - VerticalBarHeight)); } else { l = new DXFLibrary.Line("TrainID", OriginX, -OriginY, OriginX, -(OriginY + VerticalBarHeight)); } doc.add(l); l = new DXFLibrary.Line("TrainID", BaseLineLeft, -BaseLineY, BaseLineRight, -BaseLineY); doc.add(l); /*接入标记的修饰*/ if (!IsTerminal) { if (CurrentDirection == Direction.Down) { l = new DXFLibrary.Line("TrainID", BaseLineLeft, -BaseLineY, BaseLineLeft - Parameters.EnterDecorationDistance, -(BaseLineY - TextHeight)); } else { l = new DXFLibrary.Line("TrainID", BaseLineLeft, -BaseLineY, BaseLineLeft - Parameters.EnterDecorationDistance, -(BaseLineY + TextHeight)); } doc.add(l); } /*绘制文字*/ DXFLibrary.Text t = new DXFLibrary.Text(TrainName, Rect.X, -(Rect.Y + TextHeight), TextHeight, "TrainID"); doc.add(t); }
/// <summary> /// 绘制时间线 /// </summary> /// <param name="doc">DXF文件对象</param> internal void Draw(DXFLibrary.Document doc) { string layerName = "0"; switch (this.Type)//*根据时间线类型确定图层*/ { case TimeLineType.HalfHour: layerName = "HalfTimes"; break; case TimeLineType.Hour: layerName = "HourTimes"; break; case TimeLineType.Normal: layerName = "Times"; break; } /*绘制时间线分段*/ foreach (TimeLineTopAndBottom tl in TopAndBottomSet) { DXFLibrary.Line l = new DXFLibrary.Line(layerName, X, -tl.Top, X, -tl.Bottom); doc.add(l); } }
//**CONSTRUCTOR internal ExportLinesToDXF(List<PolyCurve[]> polycurves, string filename) { DXFLibrary.Document dxf = new DXFLibrary.Document(); DXFLibrary.Tables tables = new DXFLibrary.Tables(); dxf.SetTables(tables); DXFLibrary.Table layers = new DXFLibrary.Table("LAYER"); tables.addTable(layers); DXFLibrary.Layer layer = new DXFLibrary.Layer("PROFILES", 30, "CONTINUOUS"); layers.AddTableEntry(layer); List<Curve> Curves = new List<Curve>(); for (int i = 0; i < polycurves.Count; i++) for (int j = 0; j < polycurves[i].Length; j++) for (int k = 0; k < polycurves[i][j].Curves().Length; k++) Curves.AddRange(polycurves[i][j].Curves()[k].ApproximateWithArcAndLineSegments()); for (int i = 0; i < Curves.Count; i++) { DXFLibrary.Line line = new DXFLibrary.Line( "PROFILES", Curves[i].StartPoint.X, Curves[i].StartPoint.Y, Curves[i].StartPoint.Z, Curves[i].EndPoint.X, Curves[i].EndPoint.Y, Curves[i].EndPoint.Z); dxf.add(line); } Curves.ForEach(c => c.Dispose()); using (FileStream f1 = new FileStream(filename, FileMode.Create)) { DXFLibrary.Writer.Write(dxf, f1); f1.Close(); } }
/// <summary> /// 绘制列车运行线 /// </summary> /// <param name="doc">DXF文件对象</param> internal void Draw(DXFLibrary.Document doc) { double lastX = 0; double lastY = 0; TrainStationOp lastTso = null; foreach (TrainStationOp tso in TrainStationOpSet) { if (lastTso == null || lastTso.Station.ParentBlock != tso.Station.ParentBlock)/*列车径路的第一个车站,或某区块的第一个车站*/ { /*不绘制区间运行线*/ } else { /*绘制区间运行线*/ DXFLibrary.Line l1 = new DXFLibrary.Line("Trains", lastX, -lastY, tso.ArriveX, -tso.Station.Y); doc.add(l1); } lastX = tso.ArriveX; lastY = tso.Station.Y; /*绘制车站运行线*/ DXFLibrary.Line l2 = new DXFLibrary.Line("Trains", lastX, -lastY, tso.DepartX, -tso.Station.Y); doc.add(l2); lastX = tso.DepartX; lastY = tso.Station.Y; lastTso = tso; } /*画接入交出标记*/ foreach (IDecorateLabel dec in TrainDecorateSet) { dec.Draw(doc); } /*画时间标志*/ foreach (TimeLabel tlb in TimeLabelSet) { tlb.Draw(doc); } }
static void Main(string[] args) { DXFLibrary.Document doc = new DXFLibrary.Document(); DXFLibrary.Tables tables = new DXFLibrary.Tables(); doc.SetTables(tables); DXFLibrary.Table layers = new DXFLibrary.Table("LAYER"); tables.addTable(layers); DXFLibrary.Layer layerDoors; layerDoors = new DXFLibrary.Layer("Doors", 30, "CONTINUOUS"); layers.AddTableEntry(layerDoors); DXFLibrary.Circle cc = new DXFLibrary.Circle(5, 5, 0.1d, "PartialHeightDoors"); doc.add(cc); DXFLibrary.Line line1 = new DXFLibrary.Line("Doors", 0, 0, 0, 10); doc.add(line1); DXFLibrary.Line line2 = new DXFLibrary.Line("Doors", 0, 0, 10, 0); doc.add(line2); DXFLibrary.Line line3 = new DXFLibrary.Line("Doors", 10, 10, 0, 10); doc.add(line3); DXFLibrary.Line line4 = new DXFLibrary.Line("Doors", 10, 10, 10, 0); doc.add(line4); DXFLibrary.Line3D line5 = new DXFLibrary.Line3D("Doors", 2, 2, 0, 5, 5, 10); doc.add(line5); FileStream f1 = new FileStream("test2.dxf", System.IO.FileMode.Create); DXFLibrary.Writer.Write(doc, f1); f1.Close(); }
/// <summary> /// 绘制运行图区块 /// </summary> /// <param name="doc">DXF文件对象</param> internal void Draw(DXFLibrary.Document doc) { /*绘制每个车站线*/ foreach (DStation station in DStationSet) { station.Draw(doc); } /*绘制运行图区块的外框*/ DXFLibrary.PolyLine l = new DXFLibrary.PolyLine("Blocks"); l.AddVertex(new DXFLibrary.Vertex(Left, -Top, "Blocks")); l.AddVertex(new DXFLibrary.Vertex(Left + Width, -Top, "Blocks")); l.AddVertex(new DXFLibrary.Vertex(Left + Width, -(Top + Height), "Blocks")); l.AddVertex(new DXFLibrary.Vertex(Left, -(Top + Height), "Blocks")); l.AddVertex(new DXFLibrary.Vertex(Left, -Top, "Blocks")); doc.add(l); }
/// <summary> /// 绘制车站线 /// </summary> /// <param name="doc"></param> internal void Draw(DXFLibrary.Document doc) { DXFLibrary.Line l = new DXFLibrary.Line("Stations", Left, -Y, Right, -Y); doc.add(l); }