/// <summary> /// Create new horizontal cotation /// </summary> /// <param name="grp">Group</param> /// <param name="layer">Layer</param> /// <param name="pt0">First extremity</param> /// <param name="pt1">Second extremity</param> /// <param name="offset">Offset</param> /// <returns></returns> public PicCotation AddCotation(PicCotation.CotType cotationType, short grp, short layer, Vector2D pt0, Vector2D pt1, double offset, string text, short noDecimals) { PicCotation cotation; switch (cotationType) { case PicCotation.CotType.COT_DISTANCE: cotation = PicCotationDistance.CreateNewCotation(GetNewEntityId(), pt0, pt1, offset, noDecimals); break; case PicCotation.CotType.COT_HORIZONTAL: cotation = PicCotationHorizontal.CreateNewCotation(GetNewEntityId(), pt0, pt1, offset, noDecimals); break; case PicCotation.CotType.COT_VERTICAL: cotation = PicCotationVertical.CreateNewCotation(GetNewEntityId(), pt0, pt1, offset, noDecimals); break; default: throw new Exception("Invalid cotation type"); } cotation.Group = grp; cotation.Layer = layer; cotation.Text = text; AddEntity(cotation); return(cotation); }
/// <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!"); } }