From e8e351dbecd07a8c20a57986288b9f35efba5ac6 Mon Sep 17 00:00:00 2001 From: "Dr. Matthias Menningen" Date: Thu, 29 Feb 2024 17:36:25 +0100 Subject: [PATCH] - MultiLeaderStyle: Comments + TODOs - MultiLeaderPropertyOverrideFlags: Misspelled enum identifier - MultiLeaderAnnotContext: OverallScale --> ScaleFactor (consistency!) property TextAttachmentPoint (group code: 171) - MultiLeaderAnnotContext.LeaderRoot: AttachmentDirection (internal set --> set) - MultiLeaderAnnotContext.LeaderLine: no setters for IList properties --- .../MultiLeaderPropertyOverrideFlags.cs | 2 +- .../DWG/DwgStreamReaders/DwgObjectReader.cs | 14 +- ACadSharp/Objects/MultiLeaderAnnotContext.cs | 5 +- .../Objects/MultiLeaderAnnotContextClasses.cs | 6 +- ACadSharp/Objects/MultiLeaderStyle.cs | 400 ++++++++++++++++-- 5 files changed, 376 insertions(+), 51 deletions(-) diff --git a/ACadSharp/Entities/MultiLeaderPropertyOverrideFlags.cs b/ACadSharp/Entities/MultiLeaderPropertyOverrideFlags.cs index 985f83f3..49c7ec62 100644 --- a/ACadSharp/Entities/MultiLeaderPropertyOverrideFlags.cs +++ b/ACadSharp/Entities/MultiLeaderPropertyOverrideFlags.cs @@ -129,7 +129,7 @@ public enum MultiLeaderPropertyOverrideFlags : int /// /// Override property. /// - BlockConnectionConnection = 0x800000, + BlockContentConnection = 0x800000, /// diff --git a/ACadSharp/IO/DWG/DwgStreamReaders/DwgObjectReader.cs b/ACadSharp/IO/DWG/DwgStreamReaders/DwgObjectReader.cs index d8091d0b..205c1414 100644 --- a/ACadSharp/IO/DWG/DwgStreamReaders/DwgObjectReader.cs +++ b/ACadSharp/IO/DWG/DwgStreamReaders/DwgObjectReader.cs @@ -2835,14 +2835,14 @@ private CadTemplate readMultiLeader() template.LeaderLineTypeHandle = this.handleReference(); // 171 LeaderLine Weight mLeader.LeaderLineWeight = (LineweightType)_objectReader.ReadBitShort(); + // TODO Why do we need this + _objectReader.Advance(2); + // 290 Enable Landing mLeader.EnableLanding = _objectReader.ReadBit(); // 291 Enable Dogleg mLeader.EnableDogleg = _objectReader.ReadBit(); - // TODO Why do we need this - _objectReader.Advance(2); - // 41 Dogleg Length / Landing distance mLeader.LandingDistance = _objectReader.ReadBitDouble(); // 342 Arrowhead ID @@ -2949,7 +2949,7 @@ private MultiLeaderAnnotContext readMultiLeaderAnnotContext(CadMLeaderTemplate t // Common // BD 40 Overall scale - annotContext.OverallScale = _objectReader.ReadBitDouble(); + annotContext.ScaleFactor = _objectReader.ReadBitDouble(); // 3BD 10 Content base point annotContext.ContentBasePoint = _objectReader.Read3BitDouble(); // BD 41 Text height @@ -2993,7 +2993,7 @@ private MultiLeaderAnnotContext readMultiLeaderAnnotContext(CadMLeaderTemplate t // CMC 90 Text color annotContext.TextColor = _objectReader.ReadCmColor(); // BS 171 Alignment (1 = left, 2 = center, 3 = right) - annotContext.TextAlignment = (TextAlignmentType)_objectReader.ReadBitShort(); + annotContext.TextAttachmentPoint = (TextAttachmentPointType)_objectReader.ReadBitShort(); // BS 172 Flow direction (1 = horizontal, 3 = vertical, 6 = by style) annotContext.FlowDirection = (FlowDirectionType)_objectReader.ReadBitShort(); // CMC 91 Background fill color @@ -3263,7 +3263,7 @@ private CadTemplate readMultiLeaderStyle() mLeaderStyle.TextAngle = (TextAngleType)_objectReader.ReadBitShort(); } // END IF IsNewFormat OR DXF file - // BS 176 Text alignment type + // BS 176 Text alignment type mLeaderStyle.TextAlignment = (TextAlignmentType)_objectReader.ReadBitShort(); // CMC 93 Text color mLeaderStyle.TextColor = _mergedReaders.ReadCmColor(); @@ -3276,7 +3276,7 @@ private CadTemplate readMultiLeaderStyle() // B 297 Always align text left mLeaderStyle.TextAlignAlwaysLeft = _objectReader.ReadBit(); }// END IF IsNewFormat OR DXF file - // BD 46 Align space + // BD 46 Align space mLeaderStyle.AlignSpace = _objectReader.ReadBitDouble(); // H 343 Block handle (hard pointer) template.BlockContentHandle = this.handleReference(); diff --git a/ACadSharp/Objects/MultiLeaderAnnotContext.cs b/ACadSharp/Objects/MultiLeaderAnnotContext.cs index 37715799..3508ff74 100644 --- a/ACadSharp/Objects/MultiLeaderAnnotContext.cs +++ b/ACadSharp/Objects/MultiLeaderAnnotContext.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using ACadSharp.Attributes; +using ACadSharp.Entities; using ACadSharp.Tables; using CSMath; @@ -33,7 +34,7 @@ public partial class MultiLeaderAnnotContext : CadObject /// Overall scale /// [DxfCodeValue(40)] - public double OverallScale { get; set; } + public double ScaleFactor { get; set; } /// /// Content base point @@ -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; } /// /// Flow direction diff --git a/ACadSharp/Objects/MultiLeaderAnnotContextClasses.cs b/ACadSharp/Objects/MultiLeaderAnnotContextClasses.cs index c554dfbf..b263c1e2 100644 --- a/ACadSharp/Objects/MultiLeaderAnnotContextClasses.cs +++ b/ACadSharp/Objects/MultiLeaderAnnotContextClasses.cs @@ -71,7 +71,7 @@ public LeaderRoot() { } /// /// Attachment direction /// - public TextAttachmentDirectionType AttachmentDirection { get; internal set; } + public TextAttachmentDirectionType AttachmentDirection { get; set; } public object Clone() { @@ -135,7 +135,7 @@ public LeaderLine() { } /// /// Points of leader line /// - public IList Points { get; set; } = new List(); + public IList Points { get; } = new List(); /// /// Break info count @@ -150,7 +150,7 @@ public LeaderLine() { } /// /// Start/end point pairs /// - public IList StartEndPoints { get; set; } + public IList StartEndPoints { get; } = new List(); /// /// Leader line index. diff --git a/ACadSharp/Objects/MultiLeaderStyle.cs b/ACadSharp/Objects/MultiLeaderStyle.cs index bf653f39..e63303dd 100644 --- a/ACadSharp/Objects/MultiLeaderStyle.cs +++ b/ACadSharp/Objects/MultiLeaderStyle.cs @@ -6,7 +6,7 @@ namespace ACadSharp.Objects { /// - /// Represents a table entry. + /// Represents a object. /// /// /// Object name
@@ -26,22 +26,31 @@ public class MultiLeaderStyle : CadObject public override string SubclassMarker => DxfSubclassMarker.MLeaderStyle; /// - /// Style name + /// Gets or sets the name of this . /// public string Name { get; set; } /// - /// Content Type + /// Gets or sets a value indicating the content type for the multileader. /// + /// + /// + /// This value can be overridden by the property when the + /// flag is set in the + /// property. + /// + /// [DxfCodeValue(170)] public LeaderContentType ContentType { get; set; } + // TODO What is the meaning of this property? Is it relevant for drawing a multileader? /// /// DrawMLeaderOrder Type /// [DxfCodeValue(171)] public MultiLeaderDrawOrderType MultiLeaderDrawOrder { get; set; } + // TODO What is the meaning of this property? Is it relevant for drawing a multileader? /// /// DrawLeaderOrder Type /// @@ -49,149 +58,363 @@ public class MultiLeaderStyle : CadObject public LeaderDrawOrderType LeaderDrawOrder { get; set; } /// - /// MaxLeader Segments Points + /// Gets or sets the max number of segments when a new leader is being created for a multileader. /// + /// + /// This property supports creating and editing a multileader but has no meaning for + /// the display of multileaders. + /// [DxfCodeValue(90)] public int MaxLeaderSegmentsPoints { get; set; } /// - /// First Segment Angle Constraint + /// Gets or sets a snap angle value for the first leader segment when a leader line + /// is being created for the mutileader. /// + /// + /// This property supports creating and editing a multileader but has no meaning for + /// the display of multileaders. + /// + /// + /// An angle value in radians or zero if no angle contstraint is set. + /// [DxfCodeValue(40)] public double FirstSegmentAngleConstraint { get; set; } /// - /// Second Segment Angle Constraint + /// Gets or sets a snap angle value for the second leader segment when a leader line + /// is being created for the mutileader. /// + /// + /// This property supports creating and editing a multileader but has no meaning for + /// the display of multileaders. + /// + /// + /// An angle value in radians or zero if no angle contstraint is set. + /// [DxfCodeValue(41)] public double SecondSegmentAngleConstraint { get; set; } /// - /// LeaderType + /// Gets or sets a value indicating whether leaders are to be displayed as polyline, + /// a spline curve or invisible. This setting applies for all leader lines of the + /// multileader. /// + /// + /// + /// This value can be overridden by the property when the + /// flag is set in the + /// property. + /// + /// The value for all leader lines can be overridden for each individual leader line by the + /// property when the + /// flag is set in the + /// property. + /// + /// [DxfCodeValue(173)] public MultiLeaderPathType PathType { get; set; } /// - /// LeaderLineColor + /// Gets or sets color to be applied all leader lines of the multileader. /// + /// + /// + /// This value can be overridden by the property when the + /// flag is set in the + /// property. + /// + /// The value for all leader lines can be overridden for each individual leader line by the + /// property when the + /// flag is set in the + /// property. + /// + /// [DxfCodeValue(91)] public Color LineColor { get; set; } /// - /// LeaderLineType ID + /// Gets or sets a object specifying line-type properties for the + /// musltileader. This setting applies for all leader lines of the multileader. /// + /// + /// + /// This setting can be overridden by the property + /// when the flag is set in the + /// property. + /// + /// The setting for all leader lines can be overridden for each individual leader line by the + /// property when the + /// flag is set in the + /// property. + /// + /// [DxfCodeValue(DxfReferenceType.Handle, 340)] public LineType LeaderLineType { get; set; } /// - /// LeaderLineWeight + /// Gets or sets a value specifying the lineweight to be applied to all leader lines of the multileader. /// + /// + /// + /// This value can be overridden by the property when the + /// flag is set in the + /// property. + /// + /// The value for all leader lines can be overridden for each individual leader line by the + /// property when the + /// flag is set in the + /// property. + /// + /// [DxfCodeValue(92)] public LineweightType LeaderLineWeight { get; set; } + // TODO It seems that this value indicates that for a new leader that is being created + // with this landing i.e. a dogleg is enabled. + // But why can this value be overridden? + // /// - /// Enable Landing + /// Gets or sets a value indicating whether landing is enabled. /// + /// + /// + /// This value can be overridden by the property + /// when the flag is set in the + /// property. + /// + /// [DxfCodeValue(290)] public bool EnableLanding { get; set; } /// - /// Landing Gap + /// Gets or sets the landing gap. This is the distance between the leader end point or, if present, + /// the end of the dogleg and the text label or the content block. /// + /// + /// + /// This value can be overridden by the property + /// when the flag is set in the + /// property. + /// + /// [DxfCodeValue(42)] public double LandingGap { get; set; } /// - /// Enable Dogleg + /// Gets or sets a value indicating that leader lines are to be drawn with a dogleg. /// + /// + /// + /// This value can be overridden by the property + /// when the flag is set in the + /// property. + /// + /// Note that this setting has no effect when the + /// is . + /// + /// [DxfCodeValue(291)] public bool EnableDogleg { get; set; } /// - /// Landing Distance + /// Gets or sets the landing distance, i.e. the length of the dogleg. /// + /// + /// + /// This value can be overridden by the property + /// when the flag is set in the + /// property. + /// + /// [DxfCodeValue(43)] public double LandingDistance { get; set; } /// - /// Mleader Style Description + /// Gets or sets a text containing the description of this . /// [DxfCodeValue(3)] public string Description { get; set; } /// - /// Arrowhead ID is Block? + /// Gets or sets a representing the arrowhead + /// to be displayed with every leader line. /// + /// + /// + /// This value can be overridden by the property + /// when the flag is set in the + /// property. + /// + /// The value for all leader lines can be overridden for each individual leader line by the + /// property when the + /// flag is set in the + /// property. + /// + /// [DxfCodeValue(DxfReferenceType.Handle, 341)] public BlockRecord Arrowhead { get; set; } /// - /// Arrowhead Size + /// Gests or sets the arrowhead size. /// + /// + /// + /// This value can be overridden by the property + /// when the flag is set in the + /// property. + /// + /// The value for all leader lines can be overridden for each individual leader line by the + /// property when the + /// flag is set in the + /// property. + /// + /// [DxfCodeValue(44)] public double ArrowheadSize { get; set; } /// - /// Default MText Contents + /// Gests or sets a default text that is to be set when a mutileader is being created + /// with this . /// [DxfCodeValue(300)] public string DefaultTextContents { get; set; } /// - /// mTextStyleId + /// Gets or sets the to be used to display the text label of the + /// multileader. /// + /// + /// + /// This value can be overridden by the property + /// when the flag is set in the + /// property. + /// + /// [DxfCodeValue(DxfReferenceType.Handle, 342)] public TextStyle TextStyle { get; set; } /// - /// Text Left Attachment Type + /// Gets or sets the Text Left Attachment Type. + /// This value controls the position of the connection point of the leader + /// attached to the left side of the text label. /// + /// + /// + /// This value can be overridden by the property + /// when the flag is set in the + /// property. + /// + /// This property is only relevant if is + /// and a leader attached + /// to the left side of the text label exists. + /// + /// + /// + /// A having the values 0-8 + /// can be used ("horizontal" attachment types). + /// [DxfCodeValue(174)] public TextAttachmentType TextLeftAttachment { get; set; } + // TODO How to set this value? /// - /// Text Angle Type + /// Gets or sets a value indicating the text angle. /// + /// + /// + /// This value can be overridden by the property + /// when the flag is set in the + /// property. + /// + /// [DxfCodeValue(175)] public TextAngleType TextAngle { get; set; } /// - /// Text Alignment Type + /// Gets or sets the text alignment, i.e. the alignment of text lines if the a multiline + /// text label, relative to the . /// + /// + /// + /// This value can be overridden by the property + /// when the flag is set in the + /// property. + /// + /// [DxfCodeValue(176)] public TextAlignmentType TextAlignment { get; set; } /// - /// Text Right Attachment Type + /// Gets or sets the Text Right Attachment Type. + /// This value controls the position of the connection point of the leader + /// attached to the right side of the text label. /// + /// + /// + /// This value can be overridden by the property + /// when the flag is set in the + /// property. + /// + /// This property is only relevant if is + /// and a leader attached + /// to the right side of the text label exists. + /// + /// + /// + /// A having the values 0-8 + /// can be used ("horizontal" attachment types). + /// [DxfCodeValue(178)] public TextAttachmentType TextRightAttachment { get; set; } /// - /// Text Color + /// Gest or sets the color for the text label of the multileader. /// + /// + /// + /// This value can be overridden by the property + /// when the flag is set in the + /// property. + /// + /// [DxfCodeValue(93)] public Color TextColor { get; set; } /// - /// Text Height + /// Gest or sets the text height for the text label of the multileader. /// + /// + /// + /// This value can be overridden by the property + /// when the flag is set in the + /// property. + /// + /// [DxfCodeValue(45)] public double TextHeight { get; set; } /// - /// Enable Frame Text + /// Gets or sets a value indicating the the text label is to be drawn with a frame. /// + /// + /// + /// This value can be overridden by the property + /// when the flag is set in the + /// property. + /// + /// [DxfCodeValue(292)] public bool TextFrame { get; set; } + // TODO Is this property only relevant for new leaders? /// /// Text Align Always Left /// [DxfCodeValue(297)] public bool TextAlignAlwaysLeft { get; set; } + // TODO What is the meaning of this property? /// /// Align Space /// @@ -199,37 +422,68 @@ public class MultiLeaderStyle : CadObject public double AlignSpace { get; set; } /// - /// Block Content ID + /// Gets or sets the reference to a standard containing content + /// to be displayed with the multileader. /// + /// + /// + /// Thw standard content block can be overridden by the + /// property when the flag is set in the + /// property. + /// + /// [DxfCodeValue(DxfReferenceType.Handle, 343)] public BlockRecord BlockContent { get; set; } /// - /// Block Content Color + /// Gets or sets the block-content color. /// + /// + /// + /// This value can be overridden by the property + /// when the flag is set in the + /// property. + /// + /// [DxfCodeValue(94)] public Color BlockContentColor { get; set; } /// - /// Block Content Scale + /// Gets or sets the scale factor for block content. /// + /// + /// + /// This value can be overridden by the property + /// when the flag is set in the + /// property. + /// + /// [DxfCodeValue(47, 49, 140)] public XYZ BlockContentScale { get; set; } //TODO: Change to 3 doubles values to better support the Dxf reading + // TODO: Cannot be overridden? Is this property only relevant in AutoCAD? /// - /// Enable Block Content Scale + /// Gets or sets a value indicating whether scaling of the block content is enabled. /// [DxfCodeValue(293)] public bool EnableBlockContentScale { get; set; } /// - /// Block Content Rotation + /// Gets or sets the block content rotation. /// + /// + /// + /// This value can be overridden by the property + /// when the flag is set in the + /// property. + /// + /// [DxfCodeValue(141)] public double BlockContentRotation { get; set; } + // TODO: Cannot be overridden? Is this property only relevant in AutoCAD? /// - /// Enable Block Content Rotation + /// Gets or sets a value indicating whether rotation of the block content is enabled. /// [DxfCodeValue(294)] public bool EnableBlockContentRotation { get; set; } @@ -237,12 +491,27 @@ public class MultiLeaderStyle : CadObject /// /// Block Content Connection Type /// + /// + /// + /// This value can be overridden by the property + /// when the flag is set in the + /// property. + /// + /// [DxfCodeValue(177)] public BlockContentConnectionType BlockContentConnection { get; set; } /// - /// Scale + /// Gets or sets the scale factor for the , , + /// , , and the elements of . /// + /// + /// + /// This value can be overridden by the property + /// when the flag is set in the + /// property. + /// + /// [DxfCodeValue(142)] public double ScaleFactor { get; set; } @@ -264,45 +533,98 @@ public class MultiLeaderStyle : CadObject [DxfCodeValue(296)] public bool IsAnnotative { get; set; } + // TODO What is the meaning of this property? /// /// Break Gap Size /// [DxfCodeValue(143)] public double BreakGapSize { get; set; } + // TODO Check + // whether this property is relevant for both text an block content + // How it can be overridden by LeaderRoot.AttachmentDirection /// - /// Text attachment direction for MText contents + /// Gets or sets the Text attachment direction for text or block contents, rename? + /// This property defines whether the leaders attach to the left/right of the content block/text, + /// or attach to the top/bottom. /// + /// + /// + /// This value can be overridden by the property + /// when the flag is set in the + /// property. + /// + /// The value for all leader lines can be overridden for each individual leader line by the + /// property when the + /// flag is set in the + /// property. + /// + /// + /// + /// A . + /// [DxfCodeValue(271)] public TextAttachmentDirectionType TextAttachmentDirection { get; set; } /// - /// Bottom text attachment direction + /// Gets or sets the text bottom attachment type. + /// This value controls the position of the connection point of the leader + /// attached to the bottom of the text label. /// + /// + /// + /// This value can be overridden by the property + /// when the flag is set in the + /// property. + /// + /// This property is only relevant if is + /// and a leader attached + /// to the bottom of the text label exists. + /// + /// /// /// A having the values - /// 9 = Center + /// 9 = Center, /// 10 = Underline and Center + /// can be used ("vertical" attachment types). /// [DxfCodeValue(272)] public TextAttachmentType TextBottomAttachment { get; set; } /// - /// Top text attachment direction + /// Gets or sets the text top attachment type. + /// This value controls the position of the connection point of the leader + /// attached to the top of the text label. /// + /// + /// + /// This value can be overridden by the property + /// when the flag is set in the + /// property. + /// + /// This property is only relevant if is + /// and a leader attached + /// to the top of the text label exists. + /// + /// /// /// A having the values - /// 9 = Center + /// 9 = Center, /// 10 = Underline and Center + /// can be used ("vertical" attachment types). /// [DxfCodeValue(273)] public TextAttachmentType TextTopAttachment { get; set; } /// - /// Default constructor + /// Initializes a new instance of the class. /// public MultiLeaderStyle() : this(string.Empty) { } + /// + /// Initializes a new instance of the class + /// and sets the name of this style. + /// public MultiLeaderStyle(string name) : base() { this.Name = name;