Skip to content

Commit

Permalink
Merge pull request #293 from nanoLogika/20240225_mme_MultiLeader_rework
Browse files Browse the repository at this point in the history
20240225 mme multi leader rework
  • Loading branch information
DomCR authored Mar 20, 2024
2 parents 82bcaf0 + 77b9ab9 commit e398566
Show file tree
Hide file tree
Showing 8 changed files with 410 additions and 85 deletions.
8 changes: 0 additions & 8 deletions ACadSharp/AttachmentType.cs

This file was deleted.

4 changes: 2 additions & 2 deletions ACadSharp/Entities/MultiLeader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -238,14 +238,14 @@ public class BlockAttribute
/// <summary>
/// Block Content Rotation
/// </summary>
[DxfCodeValue(43)]
[DxfCodeValue(DxfReferenceType.IsAngle, 43)]
public double BlockContentRotation { get; set; }

/// <summary>
/// Block Content Connection Type
/// </summary>
[DxfCodeValue(176)]
public AttachmentType BlockContentConnection { get; set; }
public BlockContentConnectionType BlockContentConnection { get; set; }

#endregion

Expand Down
2 changes: 1 addition & 1 deletion ACadSharp/Entities/MultiLeaderPropertyOverrideFlags.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public enum MultiLeaderPropertyOverrideFlags : int
/// <summary>
/// Override <see cref="MultiLeaderStyle.BlockContentConnection"/> property.
/// </summary>
BlockConnectionConnection = 0x800000,
BlockContentConnection = 0x800000,


/// <summary>
Expand Down
30 changes: 15 additions & 15 deletions ACadSharp/IO/DWG/DwgStreamReaders/DwgObjectReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2826,7 +2826,7 @@ private CadTemplate readMultiLeader()
//BL 90 Property Override Flags (int32)
mLeader.PropertyOverrideFlags = (MultiLeaderPropertyOverrideFlags)this._objectReader.ReadBitLong();
//BS 170 LeaderLineType (short)
mLeader.PathType = (MultiLeaderPathType)_objectReader.ReadBitShort();
mLeader.PathType = (MultiLeaderPathType)this._objectReader.ReadBitShort();
//CMC 91 Leade LineColor (Color)
mLeader.LineColor = _mergedReaders.ReadCmColor();
//H 341 LeaderLineTypeID (handle/LineType)
Expand Down Expand Up @@ -2872,7 +2872,7 @@ private CadTemplate readMultiLeader()
// 43 Block Content Rotation
mLeader.BlockContentRotation = this._objectReader.ReadBitDouble();
// 176 Block Content Connection Type
mLeader.BlockContentConnection = (AttachmentType)this._objectReader.ReadBitShort();
mLeader.BlockContentConnection = (BlockContentConnectionType)_objectReader.ReadBitShort();
// 293 Enable Annotation Scale/Is annotative
mLeader.EnableAnnotationScale = this._objectReader.ReadBit();

Expand Down Expand Up @@ -2953,7 +2953,7 @@ private MultiLeaderAnnotContext readMultiLeaderAnnotContext(CadMLeaderTemplate t

// Common
// BD 40 Overall scale
annotContext.OverallScale = this._objectReader.ReadBitDouble();
annotContext.ScaleFactor = _objectReader.ReadBitDouble();
// 3BD 10 Content base point
annotContext.ContentBasePoint = this._objectReader.Read3BitDouble();
// BD 41 Text height
Expand All @@ -2969,23 +2969,23 @@ private MultiLeaderAnnotContext readMultiLeaderAnnotContext(CadMLeaderTemplate t
// BS 176 Text align type (0 = left, 1 = center, 2 = right)
annotContext.TextAlignment = (TextAlignmentType)this._objectReader.ReadBitShort();
// BS 177 Attachment type (0 = content extents, 1 = insertion point).
annotContext.AttachmentType = (AttachmentType)this._objectReader.ReadBitShort();
annotContext.BlockContentConnection = (BlockContentConnectionType)this._objectReader.ReadBitShort();
// B 290 Has text contents
annotContext.HasTextContents = this._objectReader.ReadBit();
if (annotContext.HasTextContents)
{
// TV 304 Text label
annotContext.TextLabel = this._textReader.ReadVariableText();
// 3BD 11 Normal vector
annotContext.Normal = this._objectReader.Read3BitDouble();
annotContext.TextNormal = this._objectReader.Read3BitDouble();
// H 340 Text style handle (hard pointer)
template.AnnotContextTextStyleHandle = this.handleReference();
// 3BD 12 Location
annotContext.Location = this._objectReader.Read3BitDouble();
annotContext.TextLocation = this._objectReader.Read3BitDouble();
// 3BD 13 Direction
annotContext.Direction = this._objectReader.Read3BitDouble();
// BD 42 Rotation (radians)
annotContext.Rotation = this._objectReader.ReadBitDouble();
annotContext.TextRotation = this._objectReader.ReadBitDouble();
// BD 43 Boundary width
annotContext.BoundaryWidth = this._objectReader.ReadBitDouble();
// BD 44 Boundary height
Expand All @@ -2997,7 +2997,7 @@ private MultiLeaderAnnotContext readMultiLeaderAnnotContext(CadMLeaderTemplate t
// CMC 90 Text color
annotContext.TextColor = this._objectReader.ReadCmColor();
// BS 171 Alignment (1 = left, 2 = center, 3 = right)
annotContext.TextAlignment = (TextAlignmentType)this._objectReader.ReadBitShort();
annotContext.TextAttachmentPoint = (TextAttachmentPointType)this._objectReader.ReadBitShort();
// BS 172 Flow direction (1 = horizontal, 3 = vertical, 6 = by style)
annotContext.FlowDirection = (FlowDirectionType)this._objectReader.ReadBitShort();
// CMC 91 Background fill color
Expand Down Expand Up @@ -3042,13 +3042,13 @@ private MultiLeaderAnnotContext readMultiLeaderAnnotContext(CadMLeaderTemplate t
// H 341 AcDbBlockTableRecord handle (soft pointer)
template.AnnotContextBlockRecordHandle = this.handleReference();
// 3BD 14 Normal vector
annotContext.Normal = this._objectReader.Read3BitDouble();
annotContext.BlockContentNormal = this._objectReader.Read3BitDouble();
// 3BD 15 Location
annotContext.Location = this._objectReader.Read3BitDouble();
annotContext.BlockContentLocation = this._objectReader.Read3BitDouble();
// 3BD 16 Scale vector
annotContext.BlockContentScale = this._objectReader.Read3BitDouble();
// BD 46 Rotation (radians)
annotContext.Rotation = this._objectReader.ReadBitDouble();
annotContext.BlockContentRotation = this._objectReader.ReadBitDouble();
// CMC 93 Block color
annotContext.BlockContentColor = this._objectReader.ReadCmColor();
// BD (16) 47 16 doubles containing the complete transformation
Expand Down Expand Up @@ -3147,7 +3147,7 @@ private LeaderRoot readLeaderRoot(CadMLeaderTemplate template)
if (this.R2010Plus)
{
// BS 271 Attachment direction(0 = horizontal, 1 = vertical, default is 0)
leaderRoot.AttachmentDirection = (TextAttachmentDirectionType)this._objectReader.ReadBitShort();
leaderRoot.TextAttachmentDirection = (TextAttachmentDirectionType)this._objectReader.ReadBitShort();
}

return leaderRoot;
Expand Down Expand Up @@ -3275,7 +3275,7 @@ private CadTemplate readMultiLeaderStyle()
mLeaderStyle.TextAngle = (TextAngleType)this._objectReader.ReadBitShort();

} // END IF IsNewFormat OR DXF file
// BS 176 Text alignment type
// BS 176 Text alignment type
mLeaderStyle.TextAlignment = (TextAlignmentType)this._objectReader.ReadBitShort();
// CMC 93 Text color
mLeaderStyle.TextColor = this._mergedReaders.ReadCmColor();
Expand All @@ -3288,8 +3288,8 @@ private CadTemplate readMultiLeaderStyle()
// B 297 Always align text left
mLeaderStyle.TextAlignAlwaysLeft = this._objectReader.ReadBit();
}// END IF IsNewFormat OR DXF file
// BD 46 Align space
mLeaderStyle.AlignSpace = this._objectReader.ReadBitDouble();
// BD 46 Align space
mLeaderStyle.AlignSpace = _objectReader.ReadBitDouble();
// H 343 Block handle (hard pointer)
template.BlockContentHandle = this.handleReference();
// CMC 94 Block color
Expand Down
2 changes: 1 addition & 1 deletion ACadSharp/Objects/LeaderLinePropertOverrideFlags.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public enum LeaderLinePropertOverrideFlags : int
ArrowheadSize = 16,

/// <summary>
/// <see cref="MultiLeaderAnnotContext.Lines" /> property
/// <see cref="MultiLeaderAnnotContext.LeaderLine.Arrowhead" /> property
/// overrides settings from <see cref="MultiLeader"/> and <see cref="MultiLeaderStyle"/>.
/// </summary>
Arrowhead = 32,
Expand Down
36 changes: 23 additions & 13 deletions ACadSharp/Objects/MultiLeaderAnnotContext.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using ACadSharp.Attributes;
using ACadSharp.Entities;
using ACadSharp.Tables;

using CSMath;
Expand Down Expand Up @@ -33,7 +34,7 @@ public partial class MultiLeaderAnnotContext : CadObject
/// Overall scale
/// </summary>
[DxfCodeValue(40)]
public double OverallScale { get; set; }
public double ScaleFactor { get; set; }

/// <summary>
/// Content base point
Expand Down Expand Up @@ -90,7 +91,7 @@ public partial class MultiLeaderAnnotContext : CadObject
/// --> MLeader.BlockContentConnectionType
/// </summary>
[DxfCodeValue(177)]
public AttachmentType AttachmentType { get; set; }
public BlockContentConnectionType BlockContentConnection { get; set; }

/// <summary>
/// Has text contents
Expand All @@ -107,8 +108,8 @@ public partial class MultiLeaderAnnotContext : CadObject
/// <summary>
/// Normal vector
/// </summary>
[DxfCodeValue(11)]
public XYZ Normal { get; set; }
[DxfCodeValue(11, 21, 31)]
public XYZ TextNormal { get; set; }

/// <summary>
/// Text style handle (hard pointer)
Expand All @@ -120,7 +121,7 @@ public partial class MultiLeaderAnnotContext : CadObject
/// Location
/// </summary>
[DxfCodeValue(12, 22, 32)]
public XYZ Location { get; set; }
public XYZ TextLocation { get; set; }

/// <summary>
/// Direction
Expand All @@ -131,8 +132,8 @@ public partial class MultiLeaderAnnotContext : CadObject
/// <summary>
/// Rotation (radians)
/// </summary>
[DxfCodeValue(42)]
public double Rotation { get; set; }
[DxfCodeValue(DxfReferenceType.IsAngle, 42)]
public double TextRotation { get; set; }

/// <summary>
/// Boundary width
Expand Down Expand Up @@ -166,6 +167,8 @@ public partial class MultiLeaderAnnotContext : CadObject

// BS 171 Alignment (1 = left, 2 = center, 3 = right)
// see above: TextAlignment
[DxfCodeValue(171)]
public TextAttachmentPointType TextAttachmentPoint { get; set; }

/// <summary>
/// Flow direction
Expand Down Expand Up @@ -260,18 +263,25 @@ public partial class MultiLeaderAnnotContext : CadObject

// These fields read from DWG are stored into the
// Normal and Location property (see above).
//3BD 14 Normal vector
//3BD 15 Location
[DxfCodeValue(14, 24, 34)]
public XYZ BlockContentNormal { get; set; }

/// <summary>
/// Location
/// </summary>
[DxfCodeValue(15, 25, 35)]
public XYZ BlockContentLocation { get; set; }
/// <summary>
/// Scale vector
/// </summary>
[DxfCodeValue(16)]
[DxfCodeValue(16, 26, 36)]
public XYZ BlockContentScale { get; set; }

// This field read from DWG are stored into the
// Rotation property (see above).
//BD 46 Rotation (radians)
/// <summary>
/// Rottaion (radians)
/// </summary>
[DxfCodeValue(DxfReferenceType.IsAngle, 46)]
public double BlockContentRotation { get; set; }

/// <summary>
/// Block color
Expand Down
6 changes: 3 additions & 3 deletions ACadSharp/Objects/MultiLeaderAnnotContextClasses.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public LeaderRoot() { }
/// <summary>
/// Attachment direction
/// </summary>
public TextAttachmentDirectionType AttachmentDirection { get; internal set; }
public TextAttachmentDirectionType TextAttachmentDirection { get; set; }

public object Clone()
{
Expand Down Expand Up @@ -135,7 +135,7 @@ public LeaderLine() { }
/// <summary>
/// Points of leader line
/// </summary>
public IList<XYZ> Points { get; set; } = new List<XYZ>();
public IList<XYZ> Points { get; } = new List<XYZ>();

/// <summary>
/// Break info count
Expand All @@ -150,7 +150,7 @@ public LeaderLine() { }
/// <summary>
/// Start/end point pairs
/// </summary>
public IList<StartEndPointPair> StartEndPoints { get; set; }
public IList<StartEndPointPair> StartEndPoints { get; } = new List<StartEndPointPair>();

/// <summary>
/// Leader line index.
Expand Down
Loading

0 comments on commit e398566

Please sign in to comment.