Skip to content

Commit 075b773

Browse files
committed
Add XML documentation to all public API members
Document all public types, methods, properties, and operators across the core library and all three rendering packages. Covers Coord types, model interfaces, readers/writers, renderers, and render contexts.
1 parent c4d92c9 commit 075b773

66 files changed

Lines changed: 529 additions & 7 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/OriginalCircuit.Altium.Rendering.Core/ColorHelper.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,29 @@ public static uint BgrToArgb(int bgrColor)
1616
return 0xFF000000 | (r << 16) | (g << 8) | b;
1717
}
1818

19+
/// <summary>
20+
/// Creates a fully opaque ARGB color from individual red, green, and blue components.
21+
/// </summary>
1922
public static uint FromRgb(byte r, byte g, byte b) => 0xFF000000 | ((uint)r << 16) | ((uint)g << 8) | b;
2023

21-
// Common colors
24+
/// <summary>Black (0xFF000000).</summary>
2225
public const uint Black = 0xFF000000;
26+
/// <summary>White (0xFFFFFFFF).</summary>
2327
public const uint White = 0xFFFFFFFF;
28+
/// <summary>Red (0xFFFF0000).</summary>
2429
public const uint Red = 0xFFFF0000;
30+
/// <summary>Green (0xFF00FF00).</summary>
2531
public const uint Green = 0xFF00FF00;
32+
/// <summary>Blue (0xFF0000FF).</summary>
2633
public const uint Blue = 0xFF0000FF;
34+
/// <summary>Yellow (0xFFFFFF00).</summary>
2735
public const uint Yellow = 0xFFFFFF00;
36+
/// <summary>Dark green (0xFF006400).</summary>
2837
public const uint DarkGreen = 0xFF006400;
38+
/// <summary>Dark blue (0xFF00008B).</summary>
2939
public const uint DarkBlue = 0xFF00008B;
40+
/// <summary>Navy (0xFF000080).</summary>
3041
public const uint Navy = 0xFF000080;
42+
/// <summary>Gray (0xFF808080).</summary>
3143
public const uint Gray = 0xFF808080;
3244
}

src/OriginalCircuit.Altium.Rendering.Core/CoordTransform.cs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,29 @@ namespace OriginalCircuit.Altium.Rendering;
77
/// </summary>
88
public sealed class CoordTransform
99
{
10+
/// <summary>
11+
/// Zoom scale factor applied when converting world units to screen pixels.
12+
/// </summary>
1013
public double Scale { get; set; } = 1.0;
14+
15+
/// <summary>
16+
/// X coordinate of the world-space center point, in raw Altium internal units.
17+
/// </summary>
1118
public double CenterX { get; set; }
19+
20+
/// <summary>
21+
/// Y coordinate of the world-space center point, in raw Altium internal units.
22+
/// </summary>
1223
public double CenterY { get; set; }
24+
25+
/// <summary>
26+
/// Width of the target screen or image in pixels.
27+
/// </summary>
1328
public double ScreenWidth { get; set; }
29+
30+
/// <summary>
31+
/// Height of the target screen or image in pixels.
32+
/// </summary>
1433
public double ScreenHeight { get; set; }
1534

1635
/// <summary>
@@ -22,13 +41,19 @@ public sealed class CoordTransform
2241
// Altium internal units per mil = 10000 (Coord.FromMils(1).ToRaw() = 10000)
2342
private const double UnitsPerMil = 10000.0;
2443

44+
/// <summary>
45+
/// Converts world coordinates to screen pixel coordinates, applying scale, centering, and Y-axis inversion.
46+
/// </summary>
2547
public (double x, double y) WorldToScreen(Coord worldX, Coord worldY)
2648
{
2749
var sx = (worldX.ToRaw() - CenterX) * Scale + ScreenWidth / 2.0;
2850
var sy = (CenterY - worldY.ToRaw()) * Scale + ScreenHeight / 2.0; // Y inverted
2951
return (sx, sy);
3052
}
3153

54+
/// <summary>
55+
/// Scales a <see cref="Coord"/> value from world units to screen pixel length.
56+
/// </summary>
3257
public double ScaleValue(Coord value) => value.ToRaw() * Scale;
3358

3459
/// <summary>
@@ -54,6 +79,12 @@ public double MapLineWidthEnum(int lineWidthEnum)
5479
return ScalePixelLength(px);
5580
}
5681

82+
/// <summary>
83+
/// Computes <see cref="Scale"/>, <see cref="CenterX"/>, and <see cref="CenterY"/> so that
84+
/// the given bounding rectangle fits within the screen dimensions.
85+
/// </summary>
86+
/// <param name="bounds">The world-space bounding rectangle to fit.</param>
87+
/// <param name="margin">Fraction of the screen area to use (default 0.95 leaves a 5% margin).</param>
5788
public void AutoZoom(CoordRect bounds, double margin = 0.95)
5889
{
5990
if (bounds.Width.ToRaw() == 0 && bounds.Height.ToRaw() == 0) return;

src/OriginalCircuit.Altium.Rendering.Core/IRenderContext.cs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,15 @@ public enum TextVAlign
3737
/// </summary>
3838
public sealed record TextRenderOptions
3939
{
40+
/// <summary>Font family name (e.g. "Arial").</summary>
4041
public string FontFamily { get; init; } = "Arial";
42+
/// <summary>Whether the font is bold.</summary>
4143
public bool Bold { get; init; }
44+
/// <summary>Whether the font is italic.</summary>
4245
public bool Italic { get; init; }
46+
/// <summary>Horizontal text alignment relative to the anchor point.</summary>
4347
public TextHAlign HorizontalAlignment { get; init; } = TextHAlign.Left;
48+
/// <summary>Vertical text alignment relative to the anchor point.</summary>
4449
public TextVAlign VerticalAlignment { get; init; } = TextVAlign.Baseline;
4550
}
4651

@@ -55,57 +60,83 @@ public sealed record TextRenderOptions
5560
/// </summary>
5661
public interface IRenderContext
5762
{
63+
/// <summary>Clears the entire canvas with the specified background color.</summary>
5864
void Clear(uint argbColor);
5965

66+
/// <summary>Draws a line between two points.</summary>
6067
void DrawLine(double x1, double y1, double x2, double y2, uint color, double width,
6168
LineStyle style = LineStyle.Solid);
6269

70+
/// <summary>Draws an elliptical arc.</summary>
6371
void DrawArc(double cx, double cy, double rx, double ry, double startAngle, double sweepAngle,
6472
uint color, double width);
6573

74+
/// <summary>Draws a rectangle outline.</summary>
6675
void DrawRectangle(double x, double y, double width, double height, uint color, double lineWidth);
76+
/// <summary>Fills a rectangle.</summary>
6777
void FillRectangle(double x, double y, double width, double height, uint color);
6878

79+
/// <summary>Draws a rounded rectangle outline with independent corner radii.</summary>
6980
void DrawRoundedRectangle(double x, double y, double width, double height,
7081
double cornerRadiusX, double cornerRadiusY, uint color, double lineWidth);
7182

83+
/// <summary>Fills a rounded rectangle.</summary>
7284
void FillRoundedRectangle(double x, double y, double width, double height,
7385
double cornerRadius, uint color);
7486

87+
/// <summary>Draws an ellipse outline.</summary>
7588
void DrawEllipse(double cx, double cy, double rx, double ry, uint color, double width);
89+
/// <summary>Fills an ellipse.</summary>
7690
void FillEllipse(double cx, double cy, double rx, double ry, uint color);
7791

92+
/// <summary>Draws a closed polygon outline.</summary>
7893
void DrawPolygon(ReadOnlySpan<double> xPoints, ReadOnlySpan<double> yPoints, uint color, double width);
94+
/// <summary>Fills a closed polygon.</summary>
7995
void FillPolygon(ReadOnlySpan<double> xPoints, ReadOnlySpan<double> yPoints, uint color);
8096

97+
/// <summary>Draws an open polyline through the given points.</summary>
8198
void DrawPolyline(ReadOnlySpan<double> xPoints, ReadOnlySpan<double> yPoints, uint color, double width,
8299
LineStyle style = LineStyle.Solid);
83100

101+
/// <summary>Draws a cubic bezier curve.</summary>
84102
void DrawBezier(double x0, double y0, double x1, double y1, double x2, double y2,
85103
double x3, double y3, uint color, double width);
86104

105+
/// <summary>Fills a pie (arc sector) shape.</summary>
87106
void FillPie(double cx, double cy, double rx, double ry, double startAngle, double sweepAngle,
88107
uint color);
89108

109+
/// <summary>Draws a pie (arc sector) outline.</summary>
90110
void DrawPie(double cx, double cy, double rx, double ry, double startAngle, double sweepAngle,
91111
uint color, double lineWidth);
92112

113+
/// <summary>Draws text at the specified position using the given font family.</summary>
93114
void DrawText(string text, double x, double y, double fontSize, uint color,
94115
string fontFamily = "Arial");
95116

117+
/// <summary>Draws text at the specified position using detailed text rendering options.</summary>
96118
void DrawText(string text, double x, double y, double fontSize, uint color,
97119
TextRenderOptions options);
98120

121+
/// <summary>Measures the dimensions of the specified text without rendering it.</summary>
99122
TextMetrics MeasureText(string text, double fontSize, TextRenderOptions? options = null);
100123

124+
/// <summary>Draws a raster image from raw byte data into the specified rectangle.</summary>
101125
void DrawImage(ReadOnlySpan<byte> imageData, double x, double y, double width, double height);
102126

127+
/// <summary>Sets a rectangular clipping region.</summary>
103128
void SetClipRect(double x, double y, double w, double h);
129+
/// <summary>Resets the clipping region to the full canvas.</summary>
104130
void ResetClip();
105131

132+
/// <summary>Saves the current graphics state (transform, clip) onto a stack.</summary>
106133
void SaveState();
134+
/// <summary>Restores the most recently saved graphics state from the stack.</summary>
107135
void RestoreState();
136+
/// <summary>Applies a translation to the current transform.</summary>
108137
void Translate(double dx, double dy);
138+
/// <summary>Applies a rotation (in degrees) to the current transform.</summary>
109139
void Rotate(double angleDegrees);
140+
/// <summary>Applies a scale to the current transform.</summary>
110141
void Scale(double sx, double sy);
111142
}

src/OriginalCircuit.Altium.Rendering.Core/PcbComponentRenderer.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,20 @@ public sealed class PcbComponentRenderer
1111
{
1212
private readonly CoordTransform _transform;
1313

14+
/// <summary>
15+
/// Initializes a new instance of <see cref="PcbComponentRenderer"/> with the specified coordinate transform.
16+
/// </summary>
17+
/// <param name="transform">The coordinate transform used to map world coordinates to screen coordinates.</param>
1418
public PcbComponentRenderer(CoordTransform transform)
1519
{
1620
_transform = transform ?? throw new ArgumentNullException(nameof(transform));
1721
}
1822

23+
/// <summary>
24+
/// Renders all primitives of a PCB component to the specified context, sorted by layer draw priority.
25+
/// </summary>
26+
/// <param name="component">The PCB component to render.</param>
27+
/// <param name="context">The render context to draw into.</param>
1928
public void Render(IPcbComponent component, IRenderContext context)
2029
{
2130
ArgumentNullException.ThrowIfNull(component);

0 commit comments

Comments
 (0)