Exemplo n.º 1
0
        public DxfAttributeObjectContextData(DxfAttribute attribute, DxfScale scale)
            : base((DxfText)attribute, scale)
        {
            DxfMText mtext = attribute.method_21();

            this.dxfMTextObjectContextData_0 = mtext != null ? new DxfMTextObjectContextData(mtext, scale) : (DxfMTextObjectContextData)null;
        }
        /// <summary>
        /// Visits the specified entity.
        /// See the <see cref="IEntityVisitor"/> for more details.
        /// </summary>
        public override void Visit(DxfInsert insert)
        {
            InsertInfo info           = insertStack.Peek();
            BlockData  blockData      = blockDataByName[insert.Block.Name];
            DxfLayer   effectiveLayer = info.GetEffectiveLayer(insert);
            DxfBlock   block          = blockData.GetBlock(effectiveLayer);

            if (block.Entities.Count == 0)
            {
                // no need to keep insert if block is empty
                info.currentCollection.RemoveAt(info.currentIndex);
            }
            else
            {
                // overwrite block with reduced one
                insert.Block = block;
                // take care of attributes
                for (int a = insert.Attributes.Count - 1; a >= 0; --a)
                {
                    DxfAttribute attrib      = insert.Attributes[a];
                    DxfLayer     attribLayer = attrib.Layer.IsZeroLayer
                                               ? effectiveLayer
                                               : attrib.Layer;
                    if (IsRemovedLayer(attribLayer))
                    {
                        insert.Attributes.RemoveAt(a);
                    }
                }
            }
        }
Exemplo n.º 3
0
        public void WriteAttributeTest()
        {
            var att = new DxfAttribute();

            att.MText = new DxfMText()
            {
                Text = "mtext-value"
            };
            EnsureFileContainsEntity(att, @"
  0
ATTRIB
", DxfAcadVersion.R13);
            EnsureFileContainsEntity(att, @"
  0
MTEXT
", DxfAcadVersion.R13);
        }
Exemplo n.º 4
0
 public void Visit(DxfAttribute attribute)
 {
     this.method_0((DxfEntity)attribute);
 }
Exemplo n.º 5
0
        public override void ResolveReferences(Class374 modelBuilder)
        {
            base.ResolveReferences(modelBuilder);
            DxfInsertBase handledObject = (DxfInsertBase)this.HandledObject;

            if (this.ulong_6 != 0UL)
            {
                DxfBlock dxfBlock = modelBuilder.method_3(this.ulong_6) as DxfBlock;
                if (dxfBlock != null)
                {
                    handledObject.Block = dxfBlock;
                }
                else
                {
                    modelBuilder.Messages.Add(new DxfMessage(DxfStatus.UnresolvedReference, Severity.Warning)
                    {
                        Parameters =
                        {
                            {
                                "Type",
                                (object)"BLOCK_RECORD"
                            },
                            {
                                "Handle",
                                (object)this.ulong_6
                            },
                            {
                                "Insert",
                                (object)handledObject
                            },
                            {
                                "InsertHandle",
                                (object)handledObject.Handle
                            }
                        }
                    });
                }
            }
            else if (!string.IsNullOrEmpty(this.string_2))
            {
                handledObject.Block = modelBuilder.Model.GetBlockWithName(this.string_2);
                if (handledObject.Block == null)
                {
                    modelBuilder.Messages.Add(new DxfMessage(DxfStatus.UnresolvedReference, Severity.Warning)
                    {
                        Parameters =
                        {
                            {
                                "Type",
                                (object)"BLOCK_RECORD"
                            },
                            {
                                "Name",
                                (object)this.string_2
                            },
                            {
                                "Insert",
                                (object)handledObject
                            },
                            {
                                "InsertHandle",
                                (object)handledObject.Handle
                            }
                        }
                    });
                }
            }
            if (this.ulong_7 != 0UL)
            {
                for (Class285 entityBuilder = modelBuilder.method_6(this.ulong_7); entityBuilder != null; entityBuilder = modelBuilder.method_7(entityBuilder))
                {
                    handledObject.Attributes.Add((DxfAttribute)entityBuilder.Entity);
                    if ((long)entityBuilder.HandledObject.Handle == (long)this.ulong_8)
                    {
                        break;
                    }
                }
            }
            else if (this.list_1 != null)
            {
                foreach (ulong handle in this.list_1)
                {
                    DxfAttribute dxfAttribute = modelBuilder.method_4 <DxfAttribute>(handle);
                    if (dxfAttribute != null)
                    {
                        handledObject.Attributes.Add(dxfAttribute);
                    }
                }
            }
            if (this.ulong_9 == 0UL)
            {
                return;
            }
            DxfSequenceEnd dxfSequenceEnd = modelBuilder.method_4 <DxfSequenceEnd>(this.ulong_9);

            if (dxfSequenceEnd == null)
            {
                return;
            }
            handledObject.AttributesSeqEnd = dxfSequenceEnd;
        }
Exemplo n.º 6
0
 public void Visit(DxfAttribute attribute)
 {
     this.bool_0 = true;
 }
 /// <summary>
 /// Visits the specified entity.
 /// See the <see cref="IEntityVisitor"/> for more details.
 /// </summary>
 public override void Visit(DxfAttribute attribute)
 {
     HandleEntity(attribute);
 }
Exemplo n.º 8
0
        private static List <DxfEntity> OffsetToNest(IList <DxfEntity> dxfEntities, DxfPoint pivot, DxfPoint offset, double rotationAngle)
        {
            List <DxfEntity> dxfreturn = new List <DxfEntity>();
            List <DxfPoint>  tmpPts;

            foreach (DxfEntity entity in dxfEntities)
            {
                switch (entity.EntityType)
                {
                case DxfEntityType.Arc:
                    DxfArc dxfArc = (DxfArc)entity;
                    dxfArc.Center      = RotateLocation(rotationAngle, dxfArc.Center);
                    dxfArc.Center     += offset;
                    dxfArc.StartAngle += rotationAngle;
                    dxfArc.EndAngle   += rotationAngle;
                    dxfreturn.Add(dxfArc);
                    break;

                case DxfEntityType.ArcAlignedText:
                    DxfArcAlignedText dxfArcAligned = (DxfArcAlignedText)entity;
                    dxfArcAligned.CenterPoint  = RotateLocation(rotationAngle, dxfArcAligned.CenterPoint);
                    dxfArcAligned.CenterPoint += offset;
                    dxfArcAligned.StartAngle  += rotationAngle;
                    dxfArcAligned.EndAngle    += rotationAngle;
                    dxfreturn.Add(dxfArcAligned);
                    break;

                case DxfEntityType.Attribute:
                    DxfAttribute dxfAttribute = (DxfAttribute)entity;
                    dxfAttribute.Location  = RotateLocation(rotationAngle, dxfAttribute.Location);
                    dxfAttribute.Location += offset;
                    dxfreturn.Add(dxfAttribute);
                    break;

                case DxfEntityType.AttributeDefinition:
                    DxfAttributeDefinition dxfAttributecommon = (DxfAttributeDefinition)entity;
                    dxfAttributecommon.Location  = RotateLocation(rotationAngle, dxfAttributecommon.Location);
                    dxfAttributecommon.Location += offset;
                    dxfreturn.Add(dxfAttributecommon);
                    break;

                case DxfEntityType.Circle:
                    DxfCircle dxfCircle = (DxfCircle)entity;
                    dxfCircle.Center  = RotateLocation(rotationAngle, dxfCircle.Center);
                    dxfCircle.Center += offset;
                    dxfreturn.Add(dxfCircle);
                    break;

                case DxfEntityType.Ellipse:
                    DxfEllipse dxfEllipse = (DxfEllipse)entity;
                    dxfEllipse.Center  = RotateLocation(rotationAngle, dxfEllipse.Center);
                    dxfEllipse.Center += offset;
                    dxfreturn.Add(dxfEllipse);
                    break;

                case DxfEntityType.Image:
                    DxfImage dxfImage = (DxfImage)entity;
                    dxfImage.Location  = RotateLocation(rotationAngle, dxfImage.Location);
                    dxfImage.Location += offset;

                    dxfreturn.Add(dxfImage);
                    break;

                case DxfEntityType.Leader:
                    DxfLeader dxfLeader = (DxfLeader)entity;
                    tmpPts = new List <DxfPoint>();

                    foreach (DxfPoint vrt in dxfLeader.Vertices)
                    {
                        var tmppnt = RotateLocation(rotationAngle, vrt);
                        tmppnt += offset;
                        tmpPts.Add(tmppnt);
                    }

                    dxfLeader.Vertices.Clear();
                    dxfLeader.Vertices.Concat(tmpPts);
                    dxfreturn.Add(dxfLeader);
                    break;

                case DxfEntityType.Line:
                    DxfLine dxfLine = (DxfLine)entity;
                    dxfLine.P1  = RotateLocation(rotationAngle, dxfLine.P1);
                    dxfLine.P2  = RotateLocation(rotationAngle, dxfLine.P2);
                    dxfLine.P1 += offset;
                    dxfLine.P2 += offset;
                    dxfreturn.Add(dxfLine);
                    break;

                case DxfEntityType.LwPolyline:
                    DxfPolyline dxfPoly = (DxfPolyline)entity;
                    foreach (DxfVertex vrt in dxfPoly.Vertices)
                    {
                        vrt.Location  = RotateLocation(rotationAngle, vrt.Location);
                        vrt.Location += offset;
                    }

                    dxfreturn.Add(dxfPoly);
                    break;

                case DxfEntityType.MLine:
                    DxfMLine mLine = (DxfMLine)entity;
                    tmpPts            = new List <DxfPoint>();
                    mLine.StartPoint += offset;

                    mLine.StartPoint = RotateLocation(rotationAngle, mLine.StartPoint);

                    foreach (DxfPoint vrt in mLine.Vertices)
                    {
                        var tmppnt = RotateLocation(rotationAngle, vrt);
                        tmppnt += offset;
                        tmpPts.Add(tmppnt);
                    }

                    mLine.Vertices.Clear();
                    mLine.Vertices.Concat(tmpPts);
                    dxfreturn.Add(mLine);
                    break;

                case DxfEntityType.Polyline:
                    DxfPolyline polyline = (DxfPolyline)entity;

                    List <DxfVertex> verts = new List <DxfVertex>();
                    foreach (DxfVertex vrt in polyline.Vertices)
                    {
                        var tmppnt = vrt;
                        tmppnt.Location  = RotateLocation(rotationAngle, tmppnt.Location);
                        tmppnt.Location += offset;
                        verts.Add(tmppnt);
                    }

                    DxfPolyline polyout = new DxfPolyline(verts);
                    polyout.Location = polyline.Location + offset;
                    polyout.IsClosed = polyline.IsClosed;
                    polyout.Layer    = polyline.Layer;
                    dxfreturn.Add(polyout);

                    break;

                case DxfEntityType.Body:
                case DxfEntityType.DgnUnderlay:
                case DxfEntityType.Dimension:
                case DxfEntityType.DwfUnderlay:
                case DxfEntityType.Face:
                case DxfEntityType.Helix:
                case DxfEntityType.Insert:
                case DxfEntityType.Light:
                case DxfEntityType.ModelerGeometry:
                case DxfEntityType.MText:
                case DxfEntityType.OleFrame:
                case DxfEntityType.Ole2Frame:
                case DxfEntityType.PdfUnderlay:
                case DxfEntityType.Point:
                case DxfEntityType.ProxyEntity:
                case DxfEntityType.Ray:
                case DxfEntityType.Region:
                case DxfEntityType.RText:
                case DxfEntityType.Section:
                case DxfEntityType.Seqend:
                case DxfEntityType.Shape:
                case DxfEntityType.Solid:
                case DxfEntityType.Spline:
                case DxfEntityType.Text:
                case DxfEntityType.Tolerance:
                case DxfEntityType.Trace:
                case DxfEntityType.Underlay:
                case DxfEntityType.Vertex:
                case DxfEntityType.WipeOut:
                case DxfEntityType.XLine:
                    throw new ArgumentException("unsupported entity type: " + entity.EntityType);
                }
            }

            return(dxfreturn);
        }
Exemplo n.º 9
0
 public override void Visit(DxfAttribute attribute)
 {
     attribute.method_19();
 }