예제 #1
0
        /// <summary>
        /// ProcessEntity : write entity corresponding des description
        /// </summary>
        /// <param name="entity"></param>
        public override void ProcessEntity(PicEntity entity)
        {
            switch (entity.Code)
            {
            case PicEntity.eCode.PE_POINT:
                break;

            case PicEntity.eCode.PE_SEGMENT:
            {
                PicSegment seg = (PicSegment)entity;
                _desWriter.WriteSegment(
                    new DES_Segment(
                        (float)seg.Pt0.X
                        , (float)seg.Pt0.Y
                        , (float)seg.Pt1.X
                        , (float)seg.Pt1.Y
                        , LineTypeToDesPen(seg.LineType)
                        , (byte)seg.Group
                        , (byte)seg.Layer
                        )
                    );
            }
            break;

            case PicEntity.eCode.PE_ARC:
            {
                PicArc arc = (PicArc)entity;
                _desWriter.WriteArc(
                    new DES_Arc(
                        (float)arc.Center.X
                        , (float)arc.Center.Y
                        , (float)arc.Radius
                        , (float)arc.AngleBeg
                        , (float)arc.AngleEnd
                        , LineTypeToDesPen(arc.LineType)
                        , (byte)arc.Group
                        , (byte)arc.Layer
                        )
                    );
            }
            break;

            case PicEntity.eCode.PE_COTATIONDISTANCE:
            {
                PicCotationDistance cotation = entity as PicCotationDistance;

                /*
                 * _desWriter.WriteCotationDistance(
                 *  new DES_CotationDistance(
                 *      (float)cotation.Pt0.X
                 *      , (float)cotation.Pt0.Y
                 *      , (float)cotation.Pt1.X
                 *      , (float)cotation.Pt1.Y
                 *      , (float)cotation.Offset
                 *      , (byte)cotation.Group
                 *      , (byte)cotation.Layer
                 *      )
                 *  );
                 */
            }
            break;

            case PicEntity.eCode.PE_COTATIONHORIZONTAL:
            {
            }
            break;

            case PicEntity.eCode.PE_COTATIONVERTICAL:
            {
            }
            break;

            case PicEntity.eCode.PE_COTATIONRADIUSEXT:
            {
            }
            break;

            case PicEntity.eCode.PE_COTATIONRADIUSINT:
            {
            }
            break;

            case PicEntity.eCode.PE_BLOCK:
            {
                PicBlock block = entity as PicBlock;
                foreach (PicEntity blockEntity in block)
                {
                    ProcessEntity(blockEntity);
                }
            }
            break;

            case PicEntity.eCode.PE_BLOCKREF:
            {
                PicBlockRef blockRef = entity as PicBlockRef;
                _desWriter.WriteBlockRef(
                    new DES_Pose(
                        (float)blockRef.Position.X
                        , (float)blockRef.Position.Y
                        , (float)blockRef.Angle
                        , (byte)blockRef.Block.ExportedGroup)
                    );
            }
            break;

            case PicEntity.eCode.PE_CARDBOARDFORMAT:
            {
            }
            break;

            default:
                throw new Exception("Can not export this kind of entity!");
            }
        }
예제 #2
0
        /// <summary>
        /// ProcessEntity : write entity corresponding des description
        /// </summary>
        /// <param name="entity"></param>
        public override void ProcessEntity(PicEntity entity)
        {
            switch (entity.Code)
            {
            case PicEntity.ECode.PE_POINT:
                break;

            case PicEntity.ECode.PE_SEGMENT:
            {
                PicSegment seg = (PicSegment)entity;
                _desWriter.WriteSegment(
                    new DES_Segment(
                        (float)seg.Pt0.X
                        , (float)seg.Pt0.Y
                        , (float)seg.Pt1.X
                        , (float)seg.Pt1.Y
                        , LineTypeToDesPen(seg.LineType)
                        , (byte)seg.Group
                        , (byte)seg.Layer
                        )
                    );
            }
            break;

            case PicEntity.ECode.PE_ARC:
            {
                PicArc arc = (PicArc)entity;
                _desWriter.WriteArc(
                    new DES_Arc(
                        (float)arc.Center.X
                        , (float)arc.Center.Y
                        , (float)arc.Radius
                        , (float)arc.AngleBeg
                        , (float)arc.AngleEnd
                        , LineTypeToDesPen(arc.LineType)
                        , (byte)arc.Group
                        , (byte)arc.Layer
                        )
                    );
            }
            break;

            case PicEntity.ECode.PE_COTATIONDISTANCE:
            {
                PicCotationDistance cotation = entity as PicCotationDistance;
                _desWriter.WriteCotationDistance(
                    new DES_CotationDistance(
                        (float)cotation.Pt0.X, (float)cotation.Pt0.Y, (float)cotation.Pt1.X, (float)cotation.Pt1.Y
                        , LineTypeToDesPen(cotation.LineType)
                        , (byte)cotation.Group
                        , (byte)cotation.Layer
                        , (float)cotation.Offset
                        , 0.0f
                        , 0.0f
                        , 0.0f
                        , false, false, false, false, 1, cotation.Text, ' ')
                    );
            }
            break;

            case PicEntity.ECode.PE_COTATIONHORIZONTAL:
            {
                PicCotationHorizontal cotation = entity as PicCotationHorizontal;
                // get offset points
                Vector2D offsetPt0, offsetPt1;
                cotation.GetOffsetPoints(out offsetPt0, out offsetPt1);

                _desWriter.WriteCotationDistance(
                    new DES_CotationDistance(
                        (float)offsetPt0.X, (float)offsetPt0.Y, (float)offsetPt1.X, (float)offsetPt1.Y
                        , LineTypeToDesPen(cotation.LineType)
                        , (byte)cotation.Group
                        , (byte)cotation.Layer
                        , (float)(cotation.Pt0.Y - offsetPt0.Y + cotation.Offset)
                        , 0.0f
                        , 0.0f
                        , 0.0f
                        , false, false, false, false, 1, cotation.Text, ' ')
                    );
            }
            break;

            case PicEntity.ECode.PE_COTATIONVERTICAL:
            {
                PicCotationVertical cotation = entity as PicCotationVertical;
                // get offset points
                Vector2D offsetPt0, offsetPt1;
                cotation.GetOffsetPoints(out offsetPt0, out offsetPt1);

                _desWriter.WriteCotationDistance(
                    new DES_CotationDistance(
                        (float)offsetPt0.X, (float)offsetPt0.Y, (float)offsetPt1.X, (float)offsetPt1.Y
                        , LineTypeToDesPen(cotation.LineType)
                        , (byte)cotation.Group
                        , (byte)cotation.Layer
                        , (float)(offsetPt0.X - cotation.Pt0.X + cotation.Offset)
                        , 0.0f
                        , 0.0f
                        , 0.0f
                        , false, false, false, false, 1, cotation.Text, ' ')
                    );
            }
            break;

            case PicEntity.ECode.PE_COTATIONRADIUSEXT:
            {
            }
            break;

            case PicEntity.ECode.PE_COTATIONRADIUSINT:
            {
            }
            break;

            case PicEntity.ECode.PE_BLOCK:
            {
                PicBlock block = entity as PicBlock;
                foreach (PicEntity blockEntity in block)
                {
                    ProcessEntity(blockEntity);
                }
            }
            break;

            case PicEntity.ECode.PE_BLOCKREF:
            {
                PicBlockRef blockRef = entity as PicBlockRef;
                _desWriter.WriteBlockRef(
                    new DES_Pose(
                        (float)blockRef.Position.X
                        , (float)blockRef.Position.Y
                        , (float)blockRef.Angle
                        , (byte)blockRef.Block.ExportedGroup)
                    );
            }
            break;

            case PicEntity.ECode.PE_CARDBOARDFORMAT:
            {
            }
            break;

            default:
                throw new Exception("Can not export this kind of entity!");
            }
        }