Esempio n. 1
0
        public void CreateEntities(PicFactory factory)
        {
            if (!(listBoxSolutions.SelectedItem is ImpositionSolution solution))
            {
                return;
            }
            solution.CreateEntities(factory);

            // insert dimensions
            short grp = 0;

            if (PicCotation.GetBBCotations(solution.Bbox, CotTypeBB, 0.1, out Vector2D pt0, out Vector2D pt1, out Vector2D pt2, out Vector2D pt3, out double delta0, out double delta1))
            {
                PicCotationDistance cotH = factory.AddCotation(PicCotation.CotType.COT_HORIZONTAL, grp, 0, pt0, pt1, delta0, "", 1) as PicCotationDistance;
                cotH.UseShortLines = true;
                cotH.Auto          = true;

                PicCotationDistance cotV = factory.AddCotation(PicCotation.CotType.COT_VERTICAL, grp, 0, pt2, pt3, delta1, "", 1) as PicCotationDistance;
                cotV.UseShortLines = true;
                cotV.Auto          = true;
            }


            if (null != Format && PicCotation.GetBBCotations(new Box2D(solution.CardboardPosition, solution.CardboardDimensions), CotTypeFormat, 0.1, out Vector2D ptf0, out Vector2D ptf1, out Vector2D ptf2, out Vector2D ptf3, out double deltaf0, out double deltaf1))
            {
                PicCotationDistance cotH = factory.AddCotation(PicCotation.CotType.COT_HORIZONTAL, grp, 0, ptf0, ptf1, deltaf0, "", 1) as PicCotationDistance;
                cotH.UseShortLines = true;
                cotH.Auto          = false;

                PicCotationDistance cotV = factory.AddCotation(PicCotation.CotType.COT_VERTICAL, grp, 0, ptf2, ptf3, deltaf1, "", 1) as PicCotationDistance;
                cotV.UseShortLines = true;
                cotV.Auto          = false;
            }
            factory.InsertCardboardFormat(solution.CardboardPosition, solution.CardboardDimensions);
        }
Esempio n. 2
0
            /// <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);
            }
Esempio n. 3
0
        // global quotation
        private void BuildGlobalQuotation(PicFactory factory, short grp, Box2D box)
        {
            if (!box.IsValid)
            {
                return;
            }
            double delta             = 0.1 * Math.Max(box.Width, box.Height);
            PicCotationDistance cotH = factory.AddCotation(PicCotation.CotType.COT_HORIZONTAL, grp, 0, box.PtMin, new Vector2D(box.XMax, box.YMin), -delta, "", 1) as PicCotationDistance;

            cotH.UseShortLines = true;
            PicCotationDistance cotV = factory.AddCotation(PicCotation.CotType.COT_VERTICAL, grp, 0, box.PtMin, new Vector2D(box.XMin, box.YMax), delta, "", 1) as PicCotationDistance;

            cotV.UseShortLines = true;
        }
        public void ExportEntity(ExpBlock block, PicEntity entity)
        {
            PicTypedDrawable drawable = entity as PicTypedDrawable;
            ExpLayer         layer    = null;
            ExpPen           pen      = null;

            if (null != drawable)
            {
                pen   = _exporter.GetPenByAttribute(LineTypeToExpPen(drawable.LineType));
                layer = _exporter.GetLayerByName(string.Format("Layer {0}", drawable.Layer));
            }
            PicSegment seg = entity as PicSegment;

            if (null != seg)
            {
                _exporter.AddSegment(block, layer, pen, seg.Pt0.X, seg.Pt0.Y, seg.Pt1.X, seg.Pt1.Y);
            }
            PicArc arc = entity as PicArc;

            if (null != arc)
            {
                // using dxf conversions
                double ang = arc.AngleEnd - arc.AngleBeg, angd = arc.AngleBeg, ango = arc.AngleEnd - arc.AngleBeg;
                if (ang < 0.0)
                {
                    angd += ang; ango = -ang;
                }
                else
                {
                    ango = ang;
                }
                _exporter.AddArc(block, layer, pen, arc.Center.X, arc.Center.Y, arc.Radius, angd, angd + ango);
            }
            PicCotationDistance cotation = drawable as PicCotationDistance;

            if (null != cotation)
            {
                List <Segment> segments = new List <Segment>();
                Vector2D       textPt   = Vector2D.Zero;
                double         textSize = 0.0;
                cotation.DrawSeg(ref segments, ref textPt, ref textSize);
                foreach (Segment cotSeg in segments)
                {
                    _exporter.AddSegment(block, layer, pen, cotSeg.P0.X, cotSeg.P0.Y, cotSeg.P1.X, cotSeg.P1.Y);
                }
                _exporter.AddText(block, layer, pen, textPt.X, textPt.Y, cotation.Text);
            }
        }
Esempio n. 5
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!");
            }
        }
Esempio n. 6
0
        /// <summary>
        /// ProcessEntity : write entity corresponding dxf description in line buffer
        /// </summary>
        /// <param name="entity">Entity</param>
        public override void ProcessEntity(PicEntity entity)
        {
            PicTypedDrawable drawable = (PicTypedDrawable)entity;

            if (null != drawable)
            {
                switch (drawable.Code)
                {
                case PicEntity.ECode.PE_POINT:
                    break;

                case PicEntity.ECode.PE_SEGMENT:
                {
                    PicSegment seg = (PicSegment)entity;
                    dxf.WriteLine(
                        dw
                        , new DL_LineData(
                            seg.Pt0.X                   // start point
                            , seg.Pt0.Y
                            , 0.0
                            , seg.Pt1.X         // end point
                            , seg.Pt1.Y
                            , 0.0
                            , InternalLineTypeToDxfColor(seg.LineType)
                            , "0"
                            )
                        , new DL_Attributes("0", InternalLineTypeToDxfColor(seg.LineType), -1, InternalLineTypeToDxfLineType(seg.LineType))
                        );
                }
                break;

                case PicEntity.ECode.PE_ARC:
                {
                    PicArc arc = (PicArc)entity;
                    double ang = arc.AngleEnd - arc.AngleBeg, angd = arc.AngleBeg, ango = arc.AngleEnd - arc.AngleBeg;
                    if (ang < 0.0)
                    {
                        angd += ang;
                        ango  = -ang;
                    }
                    else
                    {
                        ango = ang;
                    }

                    dxf.WriteArc(dw,
                                 new DL_ArcData(
                                     arc.Center.X, arc.Center.Y, 0.0,
                                     arc.Radius,
                                     angd, angd + ango,
                                     InternalLineTypeToDxfColor(arc.LineType),
                                     "0"
                                     ),
                                 new DL_Attributes("0", InternalLineTypeToDxfColor(arc.LineType), -1, InternalLineTypeToDxfLineType(arc.LineType))
                                 );
                }
                break;

                case PicEntity.ECode.PE_COTATIONDISTANCE:
                case PicEntity.ECode.PE_COTATIONHORIZONTAL:
                case PicEntity.ECode.PE_COTATIONVERTICAL:
                {
                    PicCotationDistance cotation = entity as PicCotationDistance;
                    List <Segment>      segments = new List <Segment>();
                    Vector2D            textPt   = Vector2D.Zero;
                    double textSize = 0.0;
                    cotation.DrawSeg(ref segments, ref textPt, ref textSize);
                    // draw segments
                    foreach (Segment seg in segments)
                    {
                        dxf.WriteLine(dw,
                                      new DL_LineData(
                                          seg.P0.X, seg.P0.Y, 0.0,
                                          seg.P1.X, seg.P1.Y, 0.0,
                                          InternalLineTypeToDxfColor(cotation.LineType),
                                          "0"
                                          ),
                                      new DL_Attributes("0", InternalLineTypeToDxfColor(cotation.LineType), -1, InternalLineTypeToDxfLineType(cotation.LineType))
                                      );
                    }
                    // draw text
                    dxf.WriteText(dw,
                                  new DL_TextData(
                                      textPt.X, textPt.Y, 0.0,
                                      textPt.X, textPt.Y, 0.0,
                                      textSize, 1.0, 0,
                                      1, 2, cotation.Text, "STANDARD", 0.0),
                                  new DL_Attributes("0", InternalLineTypeToDxfColor(cotation.LineType), -1, InternalLineTypeToDxfLineType(cotation.LineType)));
                }
                break;

                case PicEntity.ECode.PE_ELLIPSE:
                    break;

                case PicEntity.ECode.PE_NURBS:
                    break;

                default:
                    throw new Exception("Can not export this kind of entity!");
                }
            }
        }
Esempio n. 7
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!");
            }
        }