Exemplo n.º 1
0
        /// <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);
        }
Exemplo n.º 2
0
        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();
        }
Exemplo n.º 3
0
        /// <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);
            }
        }
Exemplo n.º 4
0
        //**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();
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// 绘制车站线
        /// </summary>
        /// <param name="doc">DXF文件对象</param>
        /// <param name="layers">图层集合对象</param>
        private void DrawStations(DXFLibrary.Document doc, DXFLibrary.Table layers)
        {
            DXFLibrary.Layer layerStations;
            layerStations = new DXFLibrary.Layer("Stations", 84, "CONTINUOUS");/*创建车站线图层*/
            layers.AddTableEntry(layerStations);

            DXFLibrary.Layer layerBlocks;
            layerBlocks = new DXFLibrary.Layer("Blocks", 84, "CONTINUOUS");/*创建运行图区块边框图层*/
            layers.AddTableEntry(layerBlocks);

            /*绘制各图块的车站线*/
            foreach (DiagramBlock db in BlockSet)
            {
                db.Draw(doc);
            }
        }
Exemplo n.º 6
0
        /// <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);
        }
Exemplo n.º 7
0
        /// <summary>
        /// 绘制运行图
        /// </summary>
        public void DrawDiagram()
        {
            /*调用DXFLiabrary类库进行DXF文件生成*/
            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);

            DrawStations(doc, layers); /*绘制车站线*/
            DrawTimeLine(doc, layers); /*绘制时间线*/
            DrawTrains(doc, layers);   /*绘制列车运行线*/

            System.IO.FileStream fs = new System.IO.FileStream(this.Title + ".dxf", System.IO.FileMode.Create);
            DXFLibrary.Writer.Write(doc, fs);/*文件流输出*/
            fs.Close();
        }
Exemplo n.º 8
0
        /// <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);
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// 绘制列车
        /// </summary>
        /// <param name="doc">DXF文件对象</param>
        /// <param name="layers">图层集合对象</param>
        private void DrawTrains(DXFLibrary.Document doc, DXFLibrary.Table layers)
        {
            DXFLibrary.Layer layerTrains;
            layerTrains = new DXFLibrary.Layer("Trains", 10, "CONTINUOUS");/*创建列车图层*/
            layers.AddTableEntry(layerTrains);

            DXFLibrary.Layer layerTrainID;
            layerTrainID = new DXFLibrary.Layer("TrainID", 10, "CONTINUOUS");/*创建列车车次标志图层*/
            layers.AddTableEntry(layerTrainID);

            DXFLibrary.Layer layerTrainTime;
            layerTrainTime = new DXFLibrary.Layer("TrainTime", 10, "CONTINUOUS");/*创建列车时刻图层*/
            layers.AddTableEntry(layerTrainTime);

            /*绘制列车运行线*/
            foreach (DTrain tr in TrainSet)
            {
                tr.Draw(doc);
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// 绘制时间线
        /// </summary>
        /// <param name="doc">DXF文件对象</param>
        /// <param name="layers">图层集合对象</param>
        private void DrawTimeLine(DXFLibrary.Document doc, DXFLibrary.Table layers)
        {
            DXFLibrary.Layer layerTimes;
            layerTimes = new DXFLibrary.Layer("Times", 84, "CONTINUOUS");/*创建一般时间线图层*/
            layers.AddTableEntry(layerTimes);

            DXFLibrary.Layer layerHalfTimes;
            layerHalfTimes = new DXFLibrary.Layer("HalfTimes", 84, "CONTINUOUS");/*创建半小时线图层*/
            layers.AddTableEntry(layerHalfTimes);

            DXFLibrary.Layer layerHourTimes;
            layerHourTimes = new DXFLibrary.Layer("HourTimes", 84, "CONTINUOUS");/*创建小时线图层*/
            layers.AddTableEntry(layerHourTimes);

            /*绘制时间线*/
            foreach (DTime t in TimeSet)
            {
                t.Draw(doc);
            }
        }
Exemplo n.º 11
0
 /// <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);
 }
Exemplo n.º 12
0
 //**CONSTRUCTOR
 internal ExportToDXF()
 {
     // dxflibrary document implementation
     dxf = new DXFLibrary.Document();
     tables = new DXFLibrary.Tables();
     dxf.SetTables(tables);
     layers = new DXFLibrary.Table("LAYER");
     tables.addTable(layers);
     layerNames = new List<string>();
     DXFLibrary.Layer layer = new DXFLibrary.Layer("0", 7, "CONTINUOUS");
     layers.AddTableEntry(layer);
     layerNames.Add("0");
 }