Skip to content

Commit

Permalink
Merge pull request #164 from AnalyticalGraphicsInc/checkerboardMaterial
Browse files Browse the repository at this point in the history
Add checkerboard material.
  • Loading branch information
shunter authored May 16, 2019
2 parents 3bab8f6 + f47bc2a commit 68ee35c
Show file tree
Hide file tree
Showing 16 changed files with 16,972 additions and 1,799 deletions.
1 change: 1 addition & 0 deletions DotNet/CesiumLanguageWriter.sln
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Schema", "Schema", "{04E49F
..\Schema\CartographicListValue.json = ..\Schema\CartographicListValue.json
..\Schema\CartographicRectangleValue.json = ..\Schema\CartographicRectangleValue.json
..\Schema\CartographicValue.json = ..\Schema\CartographicValue.json
..\Schema\CheckerboardMaterial.json = ..\Schema\CheckerboardMaterial.json
..\Schema\Clock.json = ..\Schema\Clock.json
..\Schema\ClockRangeValue.json = ..\Schema\ClockRangeValue.json
..\Schema\ClockStepValue.json = ..\Schema\ClockStepValue.json
Expand Down
1 change: 1 addition & 0 deletions DotNet/CesiumLanguageWriter/CesiumLanguageWriter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@
<Compile Include="Generated\BoxDimensionsCesiumWriter.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Generated\CheckerboardMaterialCesiumWriter.cs" />
<Compile Include="Generated\ClockCesiumWriter.cs">
<SubType>Code</SubType>
</Compile>
Expand Down

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions DotNet/CesiumLanguageWriter/Generated/MaterialCesiumWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,16 @@ public class MaterialCesiumWriter : CesiumPropertyWriter<MaterialCesiumWriter>
/// </summary>
public const string StripePropertyName = "stripe";

/// <summary>
/// The name of the <c>checkerboard</c> property.
/// </summary>
public const string CheckerboardPropertyName = "checkerboard";

private readonly Lazy<SolidColorMaterialCesiumWriter> m_solidColor = new Lazy<SolidColorMaterialCesiumWriter>(() => new SolidColorMaterialCesiumWriter(SolidColorPropertyName), false);
private readonly Lazy<ImageMaterialCesiumWriter> m_image = new Lazy<ImageMaterialCesiumWriter>(() => new ImageMaterialCesiumWriter(ImagePropertyName), false);
private readonly Lazy<GridMaterialCesiumWriter> m_grid = new Lazy<GridMaterialCesiumWriter>(() => new GridMaterialCesiumWriter(GridPropertyName), false);
private readonly Lazy<StripeMaterialCesiumWriter> m_stripe = new Lazy<StripeMaterialCesiumWriter>(() => new StripeMaterialCesiumWriter(StripePropertyName), false);
private readonly Lazy<CheckerboardMaterialCesiumWriter> m_checkerboard = new Lazy<CheckerboardMaterialCesiumWriter>(() => new CheckerboardMaterialCesiumWriter(CheckerboardPropertyName), false);

/// <summary>
/// Initializes a new instance.
Expand Down Expand Up @@ -141,5 +147,24 @@ public StripeMaterialCesiumWriter OpenStripeProperty()
return OpenAndReturn(StripeWriter);
}

/// <summary>
/// Gets the writer for the <c>checkerboard</c> property. The returned instance must be opened by calling the <see cref="CesiumElementWriter.Open"/> method before it can be used for writing. The <c>checkerboard</c> property defines a material that fills the surface with a checkerboard pattern.
/// </summary>
[NotNull]
public CheckerboardMaterialCesiumWriter CheckerboardWriter
{
get { return m_checkerboard.Value; }
}

/// <summary>
/// Opens and returns the writer for the <c>checkerboard</c> property. The <c>checkerboard</c> property defines a material that fills the surface with a checkerboard pattern.
/// </summary>
[NotNull]
public CheckerboardMaterialCesiumWriter OpenCheckerboardProperty()
{
OpenIntervalIfNecessary();
return OpenAndReturn(CheckerboardWriter);
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ public class PolylineMaterialCesiumWriter : CesiumPropertyWriter<PolylineMateria
/// </summary>
public const string StripePropertyName = "stripe";

/// <summary>
/// The name of the <c>checkerboard</c> property.
/// </summary>
public const string CheckerboardPropertyName = "checkerboard";

private readonly Lazy<SolidColorMaterialCesiumWriter> m_solidColor = new Lazy<SolidColorMaterialCesiumWriter>(() => new SolidColorMaterialCesiumWriter(SolidColorPropertyName), false);
private readonly Lazy<PolylineOutlineMaterialCesiumWriter> m_polylineOutline = new Lazy<PolylineOutlineMaterialCesiumWriter>(() => new PolylineOutlineMaterialCesiumWriter(PolylineOutlinePropertyName), false);
private readonly Lazy<PolylineArrowMaterialCesiumWriter> m_polylineArrow = new Lazy<PolylineArrowMaterialCesiumWriter>(() => new PolylineArrowMaterialCesiumWriter(PolylineArrowPropertyName), false);
Expand All @@ -64,6 +69,7 @@ public class PolylineMaterialCesiumWriter : CesiumPropertyWriter<PolylineMateria
private readonly Lazy<ImageMaterialCesiumWriter> m_image = new Lazy<ImageMaterialCesiumWriter>(() => new ImageMaterialCesiumWriter(ImagePropertyName), false);
private readonly Lazy<GridMaterialCesiumWriter> m_grid = new Lazy<GridMaterialCesiumWriter>(() => new GridMaterialCesiumWriter(GridPropertyName), false);
private readonly Lazy<StripeMaterialCesiumWriter> m_stripe = new Lazy<StripeMaterialCesiumWriter>(() => new StripeMaterialCesiumWriter(StripePropertyName), false);
private readonly Lazy<CheckerboardMaterialCesiumWriter> m_checkerboard = new Lazy<CheckerboardMaterialCesiumWriter>(() => new CheckerboardMaterialCesiumWriter(CheckerboardPropertyName), false);

/// <summary>
/// Initializes a new instance.
Expand Down Expand Up @@ -241,5 +247,24 @@ public StripeMaterialCesiumWriter OpenStripeProperty()
return OpenAndReturn(StripeWriter);
}

/// <summary>
/// Gets the writer for the <c>checkerboard</c> property. The returned instance must be opened by calling the <see cref="CesiumElementWriter.Open"/> method before it can be used for writing. The <c>checkerboard</c> property defines a material that fills the line with a checkerboard pattern.
/// </summary>
[NotNull]
public CheckerboardMaterialCesiumWriter CheckerboardWriter
{
get { return m_checkerboard.Value; }
}

/// <summary>
/// Opens and returns the writer for the <c>checkerboard</c> property. The <c>checkerboard</c> property defines a material that fills the line with a checkerboard pattern.
/// </summary>
[NotNull]
public CheckerboardMaterialCesiumWriter OpenCheckerboardProperty()
{
OpenIntervalIfNecessary();
return OpenAndReturn(CheckerboardWriter);
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
<Compile Include="TestCesiumFormattingHelper.cs" />
<Compile Include="TestCesiumInterpolatablePropertyWriter.cs" />
<Compile Include="TestCesiumResource.cs" />
<Compile Include="TestCheckerboardMaterialCesiumWriter.cs" />
<Compile Include="TestCustomPropertiesCesiumWriter.cs" />
<Compile Include="TestDoubleCesiumWriter.cs" />
<Compile Include="TestGenerateValidationDocument.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System.Drawing;
using CesiumLanguageWriter;
using CesiumLanguageWriter.Advanced;
using NUnit.Framework;

namespace CesiumLanguageWriterTests
{
[TestFixture]
public class TestCheckerboardMaterialCesiumWriter : TestCesiumPropertyWriter<CheckerboardMaterialCesiumWriter>
{
[Test]
public void TestWriteCheckerboardMaterial()
{
using (Packet)
using (var polyline = Packet.OpenPolylineProperty())
using (var material = polyline.OpenMaterialProperty())
using (var checkerboardMaterial = material.OpenCheckerboardProperty())
{
checkerboardMaterial.WriteEvenColorProperty(Color.Red);
checkerboardMaterial.WriteOddColorProperty(Color.Blue);
checkerboardMaterial.WriteRepeatProperty(3.5, 4.5);
}

Assert.AreEqual("{\"polyline\":{\"material\":{\"checkerboard\":{\"evenColor\":{\"rgba\":[255,0,0,255]},\"oddColor\":{\"rgba\":[0,0,255,255]},\"repeat\":{\"cartesian2\":[3.5,4.5]}}}}}", StringWriter.ToString());
}

protected override CesiumPropertyWriter<CheckerboardMaterialCesiumWriter> CreatePropertyWriter(string propertyName)
{
return new CheckerboardMaterialCesiumWriter(propertyName);
}
}
}
Loading

0 comments on commit 68ee35c

Please sign in to comment.