diff --git a/ApplicationView/ApplicationController.cs b/ApplicationView/ApplicationController.cs index 0ffe4e0af..921ffba35 100644 --- a/ApplicationView/ApplicationController.cs +++ b/ApplicationView/ApplicationController.cs @@ -210,6 +210,42 @@ namespace MatterHackers.MatterControl await this.SetActivePrinter(emptyPrinter); } + public Color BlendHsl(string a, string b, int index, int count) + { + return PrimitiveColors[a].BlendHsl(PrimitiveColors[b], 1.0 / (count + 1.0) * index); + } + + Dictionary _primitiveColors; + public Dictionary PrimitiveColors + { + get + { + if (_primitiveColors == null) + { + _primitiveColors = new Dictionary(); + // put in all the constant things before blening them + _primitiveColors.Add("Cube", Color.FromHSL(.01, .98, .76)); // red + _primitiveColors.Add("Text", Color.FromHSL(.175, .98, .76)); // yellow + _primitiveColors.Add("HalfSphere", Color.FromHSL(.87, .98, .76)); // violet + + // first color + _primitiveColors.Add("Pyramid", BlendHsl("Cube", "Text", 1, 3)); + _primitiveColors.Add("Wedge", BlendHsl("Cube", "Text", 2, 3)); + _primitiveColors.Add("HalfWedge", BlendHsl("Cube", "Text", 3, 3)); + // mid color + _primitiveColors.Add("Cylinder", BlendHsl("Text", "HalfSphere", 1, 6)); + _primitiveColors.Add("Cone", BlendHsl("Text", "HalfSphere", 2, 6)); + _primitiveColors.Add("HalfCylinder", BlendHsl("Text", "HalfSphere", 3, 6)); + _primitiveColors.Add("Torus", BlendHsl("Text", "HalfSphere", 4, 6)); + _primitiveColors.Add("Ring", BlendHsl("Text", "HalfSphere", 5, 6)); + _primitiveColors.Add("Sphere", BlendHsl("Text", "HalfSphere", 6, 6)); + // end color + } + + return _primitiveColors; + } + } + public void LaunchBrowser(string targetUri) { UiThread.RunOnIdle(() => diff --git a/DesignTools/Primitives/ConeObject3D.cs b/DesignTools/Primitives/ConeObject3D.cs index caf423609..c90d374fb 100644 --- a/DesignTools/Primitives/ConeObject3D.cs +++ b/DesignTools/Primitives/ConeObject3D.cs @@ -38,11 +38,12 @@ using MatterHackers.VectorMath; namespace MatterHackers.MatterControl.DesignTools { + [HideUpdateButtonAttribute] public class ConeObject3D : Object3D, IRebuildable { public ConeObject3D() { - Color = PrimitiveColors["Cone"]; + Color = ApplicationController.Instance.PrimitiveColors["Cone"]; } public static ConeObject3D Create() diff --git a/DesignTools/Primitives/CubeObject3D.cs b/DesignTools/Primitives/CubeObject3D.cs index d91b5f236..3c1b3bdea 100644 --- a/DesignTools/Primitives/CubeObject3D.cs +++ b/DesignTools/Primitives/CubeObject3D.cs @@ -34,6 +34,7 @@ using MatterHackers.PolygonMesh; namespace MatterHackers.MatterControl.DesignTools { + [HideUpdateButtonAttribute] public class CubeObject3D : Object3D, IRebuildable { public CubeObject3D() @@ -56,7 +57,7 @@ namespace MatterHackers.MatterControl.DesignTools { var item = new CubeObject3D() { - Color = PrimitiveColors["Cube"] + Color = ApplicationController.Instance.PrimitiveColors["Cube"] }; item.Rebuild(null); return item; diff --git a/DesignTools/Primitives/CylinderObject3D.cs b/DesignTools/Primitives/CylinderObject3D.cs index dbd4c2b44..99177970d 100644 --- a/DesignTools/Primitives/CylinderObject3D.cs +++ b/DesignTools/Primitives/CylinderObject3D.cs @@ -38,11 +38,12 @@ using MatterHackers.VectorMath; namespace MatterHackers.MatterControl.DesignTools { + [HideUpdateButtonAttribute] public class CylinderObject3D : Object3D, IRebuildable, IPropertyGridModifier { public CylinderObject3D() { - Color = PrimitiveColors["Cylinder"]; + Color = ApplicationController.Instance.PrimitiveColors["Cylinder"]; } public CylinderObject3D(double diameter, double height, int sides) @@ -112,10 +113,11 @@ namespace MatterHackers.MatterControl.DesignTools public double Diameter { get; set; } = 20; public double Height { get; set; } = 20; public int Sides { get; set; } = 30; + public bool Advanced { get; set; } = false; - public double DiameterTop { get; set; } = 20; public double StartingAngle { get; set; } = 0; public double EndingAngle { get; set; } = 360; + public double DiameterTop { get; set; } = 20; public void Rebuild(UndoBuffer undoBuffer) { diff --git a/DesignTools/Primitives/RoundRoofObject3D.cs b/DesignTools/Primitives/HalfCylinderObject3D.cs similarity index 90% rename from DesignTools/Primitives/RoundRoofObject3D.cs rename to DesignTools/Primitives/HalfCylinderObject3D.cs index 9d46abe11..1cad4e0d3 100644 --- a/DesignTools/Primitives/RoundRoofObject3D.cs +++ b/DesignTools/Primitives/HalfCylinderObject3D.cs @@ -37,16 +37,17 @@ using MatterHackers.VectorMath; namespace MatterHackers.MatterControl.DesignTools { - public class RoundRoofObject3D : Object3D, IRebuildable + [HideUpdateButtonAttribute] + public class HalfCylinderObject3D : Object3D, IRebuildable { - public RoundRoofObject3D() + public HalfCylinderObject3D() { - Color = PrimitiveColors["RoundRoof"]; + Color = ApplicationController.Instance.PrimitiveColors["HalfCylinder"]; } - public static RoundRoofObject3D Create() + public static HalfCylinderObject3D Create() { - var item = new RoundRoofObject3D(); + var item = new HalfCylinderObject3D(); item.Rebuild(null); return item; diff --git a/DesignTools/Primitives/HalfSphereObject3D.cs b/DesignTools/Primitives/HalfSphereObject3D.cs index 9fb1ba776..daf61cc0e 100644 --- a/DesignTools/Primitives/HalfSphereObject3D.cs +++ b/DesignTools/Primitives/HalfSphereObject3D.cs @@ -37,11 +37,12 @@ using MatterHackers.VectorMath; namespace MatterHackers.MatterControl.DesignTools { + [HideUpdateButtonAttribute] public class HalfSphereObject3D : Object3D, IRebuildable { public HalfSphereObject3D() { - Color = PrimitiveColors["HalfSphere"]; + Color = ApplicationController.Instance.PrimitiveColors["HalfSphere"]; } public HalfSphereObject3D(double diametar, int sides) diff --git a/DesignTools/Primitives/RoofObject3D.cs b/DesignTools/Primitives/HalfWedgeObject3D.cs similarity index 90% rename from DesignTools/Primitives/RoofObject3D.cs rename to DesignTools/Primitives/HalfWedgeObject3D.cs index 2d97f77fe..04c62cf2c 100644 --- a/DesignTools/Primitives/RoofObject3D.cs +++ b/DesignTools/Primitives/HalfWedgeObject3D.cs @@ -37,16 +37,17 @@ using MatterHackers.VectorMath; namespace MatterHackers.MatterControl.DesignTools { - public class RoofObject3D : Object3D, IRebuildable + [HideUpdateButtonAttribute] + public class HalfWedgeObject3D : Object3D, IRebuildable { - public RoofObject3D() + public HalfWedgeObject3D() { - Color = PrimitiveColors["Roof"]; + Color = ApplicationController.Instance.PrimitiveColors["HalfWedge"]; } - public static RoofObject3D Create() + public static HalfWedgeObject3D Create() { - var item = new RoofObject3D(); + var item = new HalfWedgeObject3D(); item.Rebuild(null); return item; diff --git a/DesignTools/Primitives/PyramidObject3D.cs b/DesignTools/Primitives/PyramidObject3D.cs index 26f1e9041..8f1e38281 100644 --- a/DesignTools/Primitives/PyramidObject3D.cs +++ b/DesignTools/Primitives/PyramidObject3D.cs @@ -36,11 +36,12 @@ using MatterHackers.VectorMath; namespace MatterHackers.MatterControl.DesignTools { + [HideUpdateButtonAttribute] public class PyramidObject3D : Object3D, IRebuildable { public PyramidObject3D() { - Color = PrimitiveColors["Pyramid"]; + Color = ApplicationController.Instance.PrimitiveColors["Pyramid"]; } public static PyramidObject3D Create() diff --git a/DesignTools/Primitives/RingObject3D.cs b/DesignTools/Primitives/RingObject3D.cs index 1cb7ebc13..beddc4291 100644 --- a/DesignTools/Primitives/RingObject3D.cs +++ b/DesignTools/Primitives/RingObject3D.cs @@ -39,11 +39,12 @@ using MatterHackers.VectorMath; namespace MatterHackers.MatterControl.DesignTools { + [HideUpdateButtonAttribute] public class RingObject3D : Object3D, IRebuildable, IPropertyGridModifier { public RingObject3D() { - Color = PrimitiveColors["Ring"]; + Color = ApplicationController.Instance.PrimitiveColors["Ring"]; } public RingObject3D(double outerDiameter, double innerDiameter, double height, int sides) @@ -68,6 +69,7 @@ namespace MatterHackers.MatterControl.DesignTools public double InnerDiameter { get; set; } = 15; public double Height { get; set; } = 5; public int Sides { get; set; } = 30; + public bool Advanced { get; set; } = false; public double StartingAngle { get; set; } = 0; public double EndingAngle { get; set; } = 360; diff --git a/DesignTools/Primitives/SphereObject3D.cs b/DesignTools/Primitives/SphereObject3D.cs index fec484ed5..bed024f6a 100644 --- a/DesignTools/Primitives/SphereObject3D.cs +++ b/DesignTools/Primitives/SphereObject3D.cs @@ -37,11 +37,12 @@ using MatterHackers.VectorMath; namespace MatterHackers.MatterControl.DesignTools { + [HideUpdateButtonAttribute] public class SphereObject3D : Object3D, IRebuildable, IPropertyGridModifier { public SphereObject3D() { - Color = PrimitiveColors["Sphere"]; + Color = ApplicationController.Instance.PrimitiveColors["Sphere"]; } public SphereObject3D(double diameter, int sides) @@ -62,10 +63,11 @@ namespace MatterHackers.MatterControl.DesignTools public double Diameter { get; set; } = 20; public int Sides { get; set; } = 30; + public bool Advanced { get; set; } = false; - public int LatitudeSides { get; set; } = 30; public double StartingAngle { get; set; } = 0; public double EndingAngle { get; set; } = 360; + public int LatitudeSides { get; set; } = 30; public void Rebuild(UndoBuffer undoBuffer) { diff --git a/DesignTools/Primitives/TextObject3D.cs b/DesignTools/Primitives/TextObject3D.cs index 0a8f5e35a..73967865d 100644 --- a/DesignTools/Primitives/TextObject3D.cs +++ b/DesignTools/Primitives/TextObject3D.cs @@ -42,6 +42,7 @@ namespace MatterHackers.MatterControl.DesignTools { public enum NamedTypeFace { Liberation_Sans, Liberation_Sans_Bold, Liberation_Mono, Titillium, Damion }; + [HideUpdateButtonAttribute] public static class NamedTypeFaceCache { public static TypeFace GetTypeFace(NamedTypeFace Name) @@ -73,7 +74,7 @@ namespace MatterHackers.MatterControl.DesignTools { public TextObject3D() { - Color = PrimitiveColors["Text"]; + Color = ApplicationController.Instance.PrimitiveColors["Text"]; } public static TextObject3D Create() diff --git a/DesignTools/Primitives/TorusObject3D.cs b/DesignTools/Primitives/TorusObject3D.cs index f8e37f08b..b57b35ee5 100644 --- a/DesignTools/Primitives/TorusObject3D.cs +++ b/DesignTools/Primitives/TorusObject3D.cs @@ -39,11 +39,12 @@ using MatterHackers.VectorMath; namespace MatterHackers.MatterControl.DesignTools { + [HideUpdateButtonAttribute] public class TorusObject3D : Object3D, IRebuildable, IPropertyGridModifier { public TorusObject3D() { - Color = PrimitiveColors["Torus"]; + Color = ApplicationController.Instance.PrimitiveColors["Torus"]; } public static TorusObject3D Create() @@ -53,26 +54,28 @@ namespace MatterHackers.MatterControl.DesignTools return item; } - public double InnerDiameter { get; set; } = 10; public double OuterDiameter { get; set; } = 20; + public double InnerDiameter { get; set; } = 10; public int Sides { get; set; } = 30; public bool Advanced { get; set; } = false; - [DisplayName("Ring Sides")] - public int RingSides { get; set; } = 15; public double StartingAngle { get; set; } = 0; public double EndingAngle { get; set; } = 360; + public int RingSides { get; set; } = 15; + public int RingPhaseAngle { get; set; } = 0; public void Rebuild(UndoBuffer undoBuffer) { var ringSides = RingSides; var startingAngle = StartingAngle; var endingAngle = EndingAngle; - if(!Advanced) + var ringPhaseAngle = RingPhaseAngle; + if (!Advanced) { ringSides = Math.Max(3, (int)(Sides / 2)); startingAngle = 0; endingAngle = 360; + ringPhaseAngle = 0; } var innerDiameter = Math.Min(OuterDiameter - .1, InnerDiameter); @@ -83,16 +86,17 @@ namespace MatterHackers.MatterControl.DesignTools var toroidRadius = innerDiameter / 2 + poleRadius; var path = new VertexStorage(); var angleDelta = MathHelper.Tau / ringSides; - var angle = 0.0; + var ringStartAngle = MathHelper.DegreesToRadians(ringPhaseAngle); + var ringAngle = ringStartAngle; var circleCenter = new Vector2(toroidRadius, 0); - path.MoveTo(circleCenter + new Vector2(poleRadius * Math.Cos(angle), poleRadius * Math.Sin(angle))); + path.MoveTo(circleCenter + new Vector2(poleRadius * Math.Cos(ringStartAngle), poleRadius * Math.Sin(ringStartAngle))); for (int i = 0; i < ringSides - 1; i++) { - angle += angleDelta; - path.LineTo(circleCenter + new Vector2(poleRadius * Math.Cos(angle), poleRadius * Math.Sin(angle))); + ringAngle += angleDelta; + path.LineTo(circleCenter + new Vector2(poleRadius * Math.Cos(ringAngle), poleRadius * Math.Sin(ringAngle))); } - path.LineTo(circleCenter + new Vector2(poleRadius * Math.Cos(0), poleRadius * Math.Sin(0))); + path.LineTo(circleCenter + new Vector2(poleRadius * Math.Cos(ringStartAngle), poleRadius * Math.Sin(ringStartAngle))); var startAngle = MathHelper.Range0ToTau(MathHelper.DegreesToRadians(startingAngle)); var endAngle = MathHelper.Range0ToTau(MathHelper.DegreesToRadians(endingAngle)); @@ -107,9 +111,10 @@ namespace MatterHackers.MatterControl.DesignTools public void UpdateControls(PublicPropertyEditor editor) { - editor.GetEditRow((this.ID, nameof(RingSides))).Visible = Advanced; editor.GetEditRow((this.ID, nameof(StartingAngle))).Visible = Advanced; editor.GetEditRow((this.ID, nameof(EndingAngle))).Visible = Advanced; + editor.GetEditRow((this.ID, nameof(RingSides))).Visible = Advanced; + editor.GetEditRow((this.ID, nameof(RingPhaseAngle))).Visible = Advanced; InnerDiameter = Math.Min(OuterDiameter - .1, InnerDiameter); } } diff --git a/DesignTools/Primitives/WedgeObject3D.cs b/DesignTools/Primitives/WedgeObject3D.cs index ad8e37ca2..b587f8ca6 100644 --- a/DesignTools/Primitives/WedgeObject3D.cs +++ b/DesignTools/Primitives/WedgeObject3D.cs @@ -37,11 +37,12 @@ using MatterHackers.VectorMath; namespace MatterHackers.MatterControl.DesignTools { + [HideUpdateButtonAttribute] public class WedgeObject3D : Object3D, IRebuildable { public WedgeObject3D() { - Color = PrimitiveColors["Wedge"]; + Color = ApplicationController.Instance.PrimitiveColors["Wedge"]; } public static WedgeObject3D Create() diff --git a/MatterControl.csproj b/MatterControl.csproj index 6f6d74333..3795bb1c9 100644 --- a/MatterControl.csproj +++ b/MatterControl.csproj @@ -74,6 +74,8 @@ + + @@ -125,8 +127,6 @@ - - diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index 44b1f77ab..5ff72caf6 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit 44b1f77abed3748b62ac082d190a6e2df4df2fe6 +Subproject commit 5ff72caf66fa6b90d2619a84adbbd6899094dee0