Beispiel #1
0
        internal void AddValuePairs(List <DxfCodePair> pairs)
        {
            pairs.Add(new DxfCodePair(49, DashDotSpaceLength));
            pairs.Add(new DxfCodePair(74, (short)ComplexFlags));
            if (ComplexFlags != 0)
            {
                var value = IsEmbeddedElementAString ? 0 : ShapeNumber;
                pairs.Add(new DxfCodePair(75, (short)value));
                if (StylePointer.Handle != 0u)
                {
                    pairs.Add(new DxfCodePair(340, DxfCommonConverters.UIntHandle(StylePointer.Handle)));
                }
            }

            pairs.AddRange(ScaleValues.Select(s => new DxfCodePair(46, s)));
            if (IsEmbeddedElementAShape || IsEmbeddedElementAString)
            {
                pairs.Add(new DxfCodePair(50, RotationAngle));
            }

            foreach (var offset in Offsets)
            {
                pairs.Add(new DxfCodePair(44, offset.X));
                pairs.Add(new DxfCodePair(45, offset.Y));
            }

            if (IsEmbeddedElementAString)
            {
                pairs.Add(new DxfCodePair(9, TextString));
            }
        }
Beispiel #2
0
        internal static DxfXDataItem FromBuffer(DxfCodePairBufferReader buffer)
        {
            var pair = buffer.Peek();

            buffer.Advance();
            switch ((DxfXDataType)pair.Code)
            {
            case DxfXDataType.String:
                return(new DxfXDataString(pair.StringValue));

            case DxfXDataType.ControlString:
                return(DxfXDataItemList.ListFromBuffer(buffer));

            case DxfXDataType.Layer:
                return(new DxfXDataLayerName(pair.StringValue));

            case DxfXDataType.BinaryData:
                return(new DxfXDataBinaryData(DxfCommonConverters.HexBytes(pair.StringValue)));

            case DxfXDataType.Handle:
                return(new DxfXDataHandle(DxfCommonConverters.UIntHandle(pair.StringValue)));

            case DxfXDataType.RealTriple:
                return(new DxfXData3Reals(ReadPoint(pair, buffer, pair.Code)));

            case DxfXDataType.WorldSpacePosition:
                return(new DxfXDataWorldSpacePosition(ReadPoint(pair, buffer, pair.Code)));

            case DxfXDataType.WorldSpaceDisplacement:
                return(new DxfXDataWorldSpaceDisplacement(ReadPoint(pair, buffer, pair.Code)));

            case DxfXDataType.WorldDirection:
                return(new DxfXDataWorldDirection(ReadPoint(pair, buffer, pair.Code)));

            case DxfXDataType.Real:
                return(new DxfXDataReal(pair.DoubleValue));

            case DxfXDataType.Distance:
                return(new DxfXDataDistance(pair.DoubleValue));

            case DxfXDataType.ScaleFactor:
                return(new DxfXDataScaleFactor(pair.DoubleValue));

            case DxfXDataType.Integer:
                return(new DxfXDataInteger(pair.ShortValue));

            case DxfXDataType.Long:
                return(new DxfXDataLong(pair.IntegerValue));

            default:
                return(null);    // unexpected XDATA code pair
            }
        }
        internal void TrySetPair(DxfCodePair pair)
        {
            switch (pair.Code)
            {
            case 2:
                Name = pair.StringValue;
                break;

            case 5:
                Handle = DxfCommonConverters.UIntHandle(pair.StringValue);
                break;

            case 330:
                OwnerHandle = DxfCommonConverters.UIntHandle(pair.StringValue);
                break;
            }
        }
Beispiel #4
0
 private static void SetOwnerPair(IDxfCodePairOrGroup codePairOrGroup, IDxfItemInternal owner)
 {
     if (codePairOrGroup.IsCodePair)
     {
         var pair = (DxfCodePair)codePairOrGroup;
         if (pair.Code == 330)
         {
             pair.Value = DxfCommonConverters.UIntHandle(owner.Handle);
         }
     }
     else
     {
         foreach (var item in ((DxfCodePairGroup)codePairOrGroup).Items)
         {
             SetOwnerPair(item, owner);
         }
     }
 }
        internal void AddCommonValuePairs(List <DxfCodePair> pairs, DxfAcadVersion version, bool outputHandles)
        {
            pairs.Add(new DxfCodePair(0, DxfTable.TableTypeToName(TableType)));
            if (outputHandles)
            {
                int code = TableType == DxfTableType.DimStyle ? 105 : 5;
                pairs.Add(new DxfCodePair(code, DxfCommonConverters.UIntHandle(Handle)));
            }

            foreach (var group in ExtensionDataGroups)
            {
                group.AddValuePairs(pairs, version, outputHandles);
            }

            if (version >= DxfAcadVersion.R2000)
            {
                pairs.Add(new DxfCodePair(330, DxfCommonConverters.UIntHandle(OwnerHandle)));
            }

            pairs.Add(new DxfCodePair(100, "AcDbSymbolTableRecord"));
        }
Beispiel #6
0
        internal void AddValuePairs(List <DxfCodePair> pairs, DxfAcadVersion version, bool outputHandles)
        {
            var code = (int)Type;

            switch (this)
            {
            case DxfXDataString s:
                pairs.Add(new DxfCodePair(code, s.Value));
                break;

            case DxfXDataItemList l:
                AddListValuePairs(l.Items, pairs, version, outputHandles);
                break;

            case DxfXDataNamedList n:
                pairs.Add(new DxfCodePair(code, n.Name));
                AddListValuePairs(n.Items, pairs, version, outputHandles);
                break;

            case DxfXDataLayerName l:
                pairs.Add(new DxfCodePair(code, l.Value));
                break;

            case DxfXDataBinaryData b:
                pairs.Add(new DxfCodePair(code, DxfCommonConverters.HexBytes(b.Value)));
                break;

            case DxfXDataHandle h:
                pairs.Add(new DxfCodePair(code, DxfCommonConverters.UIntHandle(h.Value)));
                break;

            case DxfXData3Reals r:
                pairs.Add(new DxfCodePair(code, r.Value.X));
                pairs.Add(new DxfCodePair(code + 10, r.Value.Y));
                pairs.Add(new DxfCodePair(code + 20, r.Value.Z));
                break;

            case DxfXDataWorldSpacePosition w:
                pairs.Add(new DxfCodePair(code, w.Value.X));
                pairs.Add(new DxfCodePair(code + 10, w.Value.Y));
                pairs.Add(new DxfCodePair(code + 20, w.Value.Z));
                break;

            case DxfXDataWorldSpaceDisplacement w:
                pairs.Add(new DxfCodePair(code, w.Value.X));
                pairs.Add(new DxfCodePair(code + 10, w.Value.Y));
                pairs.Add(new DxfCodePair(code + 20, w.Value.Z));
                break;

            case DxfXDataWorldDirection w:
                pairs.Add(new DxfCodePair(code, w.Value.X));
                pairs.Add(new DxfCodePair(code + 10, w.Value.Y));
                pairs.Add(new DxfCodePair(code + 20, w.Value.Z));
                break;

            case DxfXDataReal r:
                pairs.Add(new DxfCodePair(code, r.Value));
                break;

            case DxfXDataDistance d:
                pairs.Add(new DxfCodePair(code, d.Value));
                break;

            case DxfXDataScaleFactor s:
                pairs.Add(new DxfCodePair(code, s.Value));
                break;

            case DxfXDataInteger i:
                pairs.Add(new DxfCodePair(code, i.Value));
                break;

            case DxfXDataLong l:
                pairs.Add(new DxfCodePair(code, l.Value));
                break;

            default:
                throw new InvalidOperationException("Unexpected XDATA item " + Type);
            }
        }
 protected static string UIntHandle(uint u)
 {
     return(DxfCommonConverters.UIntHandle(u));
 }
 protected static uint UIntHandle(string s)
 {
     return(DxfCommonConverters.UIntHandle(s));
 }
Beispiel #9
0
 private static string UIntHandle(uint u)
 {
     return(DxfCommonConverters.UIntHandle(u));
 }
Beispiel #10
0
 private static uint UIntHandle(string s)
 {
     return(DxfCommonConverters.UIntHandle(s));
 }
Beispiel #11
0
        internal void AddValuePairs(List <DxfCodePair> pairs, DxfAcadVersion version, bool outputHandles)
        {
            var code = (int)Type;

            switch (Type)
            {
            case DxfXDataType.String:
                pairs.Add(new DxfCodePair(code, ((DxfXDataString)this).Value));
                break;

            case DxfXDataType.ControlString:
                pairs.Add(new DxfCodePair(code, "{"));
                foreach (var subItem in ((DxfXDataControlGroup)this).Items)
                {
                    subItem.AddValuePairs(pairs, version, outputHandles);
                }

                pairs.Add(new DxfCodePair(code, "}"));
                break;

            case DxfXDataType.Layer:
                pairs.Add(new DxfCodePair(code, ((DxfXDataLayerName)this).Value));
                break;

            case DxfXDataType.BinaryData:
                pairs.Add(new DxfCodePair(code, DxfCommonConverters.HexBytes(((DxfXDataBinaryData)this).Value)));
                break;

            case DxfXDataType.Handle:
                pairs.Add(new DxfCodePair(code, DxfCommonConverters.UIntHandle(((DxfXDataHandle)this).Value)));
                break;

            case DxfXDataType.RealTriple:
            {
                var point = ((DxfXData3Reals)this).Value;
                pairs.Add(new DxfCodePair(code, point.X));
                pairs.Add(new DxfCodePair(code + 10, point.Y));
                pairs.Add(new DxfCodePair(code + 20, point.Z));
                break;
            }

            case DxfXDataType.WorldSpacePosition:
            {
                var point = ((DxfXDataWorldSpacePosition)this).Value;
                pairs.Add(new DxfCodePair(code, point.X));
                pairs.Add(new DxfCodePair(code + 10, point.Y));
                pairs.Add(new DxfCodePair(code + 20, point.Z));
                break;
            }

            case DxfXDataType.WorldSpaceDisplacement:
            {
                var point = ((DxfXDataWorldSpaceDisplacement)this).Value;
                pairs.Add(new DxfCodePair(code, point.X));
                pairs.Add(new DxfCodePair(code + 10, point.Y));
                pairs.Add(new DxfCodePair(code + 20, point.Z));
                break;
            }

            case DxfXDataType.WorldDirection:
            {
                var point = ((DxfXDataWorldDirection)this).Value;
                pairs.Add(new DxfCodePair(code, point.X));
                pairs.Add(new DxfCodePair(code + 10, point.Y));
                pairs.Add(new DxfCodePair(code + 20, point.Z));
                break;
            }

            case DxfXDataType.Real:
                pairs.Add(new DxfCodePair(code, ((DxfXDataReal)this).Value));
                break;

            case DxfXDataType.Distance:
                pairs.Add(new DxfCodePair(code, ((DxfXDataDistance)this).Value));
                break;

            case DxfXDataType.ScaleFactor:
                pairs.Add(new DxfCodePair(code, ((DxfXDataScaleFactor)this).Value));
                break;

            case DxfXDataType.Integer:
                pairs.Add(new DxfCodePair(code, ((DxfXDataInteger)this).Value));
                break;

            case DxfXDataType.Long:
                pairs.Add(new DxfCodePair(code, ((DxfXDataLong)this).Value));
                break;

            default:
                throw new InvalidOperationException("Unexpected XDATA item " + Type);
            }
        }