Skip to content

Add text class #271

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

Merged
merged 14 commits into from
Apr 30, 2025
66 changes: 66 additions & 0 deletions src/Speckle.Objects/Other/Text.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
using Speckle.Objects.Geometry;
using Speckle.Sdk.Common;

Check failure on line 2 in src/Speckle.Objects/Other/Text.cs

View workflow job for this annotation

GitHub Actions / build

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 2 in src/Speckle.Objects/Other/Text.cs

View workflow job for this annotation

GitHub Actions / build

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 2 in src/Speckle.Objects/Other/Text.cs

View workflow job for this annotation

GitHub Actions / build

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 2 in src/Speckle.Objects/Other/Text.cs

View workflow job for this annotation

GitHub Actions / build

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)
using Speckle.Sdk.Models;
using Point = Speckle.Objects.Geometry.Point;

namespace Speckle.Objects.Other;

/// <summary>
/// Text class for representation in the viewer
/// </summary>
[SpeckleType("Objects.Other.Text")]
public class Text : Base
{
/// <summary>
/// Plain text, without formatting
/// </summary>
public required string value { get; set; }
public required Point origin { get; set; }

/// <summary>
/// Height in linear units or pixels (if Units.None)
/// </summary>
public required double height { get; set; }

/// <summary>
/// Units will be 'Units.None' if the text size is defined in pixels (stays the same size
/// independently of zooming the model). Default pixel size it 17px (used for Viewer measurements)
/// </summary>
public required string units { get; set; }

/// <summary>
/// Horizontal alignment: Left, Center or Right
/// </summary>
public alignmentHorizontal alignmentH { get; set; }

/// <summary>
/// Vertical alignment: Top, Center or Bottom
/// </summary>
public alignmentVertical alignmentV { get; set; }

/// <summary>
/// Plane will be null if the text object orientation follows camera view
/// </summary>
public Plane? plane { get; set; }

/// <summary>
/// Maximum width of the text field (in 'units').
/// Text will be split into lines (wrapped) to fit into the width.
/// null, if text should not be wrapped.
/// </summary>
public double? maxWidth { get; set; }
}

public enum alignmentHorizontal
{
Left,
Center,
Right,
}

public enum alignmentVertical
{
Top,
Center,
Bottom,
}
Loading