Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pdf project branch #550

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/ACadSharp/Entities/IText.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using ACadSharp.Tables;
using CSMath;

namespace ACadSharp.Entities
{
Expand All @@ -23,6 +24,19 @@ public interface IText
/// <summary>
/// Style of this text entity.
/// </summary>
TextStyle Style { get; set; }
TextStyle Style { get; set; }

/// <summary>
/// First alignment point(in OCS).
/// </summary>
XYZ InsertPoint { get; set; }

/// <summary>
/// X-axis direction vector(in WCS).
/// </summary>
/// <remarks>
/// A group code 50 (rotation angle in radians) passed as DXF input is converted to the equivalent direction vector (if both a code 50 and codes 11, 21, 31 are passed, the last one wins). This is provided as a convenience for conversions from text objects
/// </remarks>
XYZ AlignmentPoint { get; set; }
}
}
46 changes: 17 additions & 29 deletions src/ACadSharp/Entities/MText.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using ACadSharp.Tables;
using CSMath;
using System;
using System.Collections;

namespace ACadSharp.Entities
{
Expand Down Expand Up @@ -102,22 +103,9 @@ public TextStyle Style
}
}

/// <summary>
/// X-axis direction vector(in WCS)
/// </summary>
/// <remarks>
/// A group code 50 (rotation angle in radians) passed as DXF input is converted to the equivalent direction vector (if both a code 50 and codes 11, 21, 31 are passed, the last one wins). This is provided as a convenience for conversions from text objects
/// </remarks>
/// <inheritdoc/>
[DxfCodeValue(11, 21, 31)]
public XYZ AlignmentPoint
{
get => this._alignmentPoint;
set
{
this._alignmentPoint = value;
this._rotation = new XY(this._alignmentPoint.X, this._alignmentPoint.Y).GetAngle();
}
}
public XYZ AlignmentPoint { get; set; }

/// <summary>
/// Horizontal width of the characters that make up the mtext entity.
Expand Down Expand Up @@ -145,18 +133,10 @@ public XYZ AlignmentPoint
/// The rotation angle in radians.
/// </value>
[DxfCodeValue(DxfReferenceType.IsAngle, 50)]
public double Rotation
{
get => this._rotation;
set
{
this._rotation = value;
this.AlignmentPoint = new XYZ(Math.Cos(this._rotation), Math.Sin(this._rotation), 0.0);
}
}
public double Rotation { get; set; } = 0.0;

/// <summary>
/// Mtext line spacing style
/// Mtext line spacing style.
/// </summary>
[DxfCodeValue(73)]
public LineSpacingStyleType LineSpacingStyle { get; set; }
Expand Down Expand Up @@ -203,10 +183,6 @@ public double Rotation

private double _height = 1.0;

private XYZ _alignmentPoint = XYZ.AxisX;

private double _rotation = 0.0;

private TextStyle _style = TextStyle.Default;

/// <inheritdoc/>
Expand All @@ -218,6 +194,18 @@ public override BoundingBox GetBoundingBox()
return new BoundingBox(this.InsertPoint);
}

/// <summary>
/// Get the text value separated in lines.
/// </summary>
/// <returns></returns>
public string[] GetTextLines()
{
return this.Value.Split(
new string[] { "\r\n", "\r", "\n" },
StringSplitOptions.None
);
}

/// <inheritdoc/>
public override CadObject Clone()
{
Expand Down
8 changes: 3 additions & 5 deletions src/ACadSharp/Entities/TextEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ public class TextEntity : Entity, IText
[DxfCodeValue(39)]
public double Thickness { get; set; } = 0.0;

/// <summary>
/// First alignment point(in OCS)
/// </summary>
/// <inheritdoc/>
[DxfCodeValue(10, 20, 30)]
public XYZ InsertPoint { get; set; } = XYZ.Zero;

Expand Down Expand Up @@ -134,7 +132,7 @@ public TextStyle Style
public TextHorizontalAlignment HorizontalAlignment { get; set; } = TextHorizontalAlignment.Left;

/// <summary>
/// Second alignment point (in OCS)
/// Second alignment point (in OCS).
/// </summary>
/// <remarks>
/// This value is meaningful only if the value of a 72 or 73 group is nonzero (if the justification is anything other than baseline/left)
Expand All @@ -156,7 +154,7 @@ public TextStyle Style

private string _value = string.Empty;

private double _height = 0.0;
private double _height = 1.0;

private TextStyle _style = TextStyle.Default;

Expand Down