Merge pull request #3250 from larsbrubaker/design_tools

Put colors back on primitives
This commit is contained in:
Lars Brubaker 2018-04-26 15:45:35 -07:00 committed by GitHub
commit f1f080c4c2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 243 additions and 311 deletions

View file

@ -103,6 +103,14 @@ namespace MatterHackers.MatterControl.ConfigurationPage
}
};
AddMenuItem("Help".Localize(), () =>
{
UiThread.RunOnIdle(() =>
{
DialogWindow.Show(new DesignSpaceGuid("Guides Tab", ""));
});
});
this.AddSettingsRow(
new SettingsItem(
"Notifications".Localize(),

View file

@ -29,6 +29,7 @@ either expressed or implied, of the FreeBSD Project.
using System.ComponentModel;
using System.Threading;
using MatterHackers.Agg;
using MatterHackers.Agg.UI;
using MatterHackers.Agg.VertexSource;
using MatterHackers.DataConverters3D;
@ -39,10 +40,9 @@ namespace MatterHackers.MatterControl.DesignTools
{
public class ConeObject3D : Object3D, IRebuildable
{
public ConeObject3D()
{
Color = PrimitiveColors["Cone"];
}
public static ConeObject3D Create()

View file

@ -27,6 +27,7 @@ of the authors and should not be interpreted as representing official policies,
either expressed or implied, of the FreeBSD Project.
*/
using MatterHackers.Agg;
using MatterHackers.Agg.UI;
using MatterHackers.DataConverters3D;
using MatterHackers.PolygonMesh;
@ -47,15 +48,16 @@ namespace MatterHackers.MatterControl.DesignTools
Rebuild(null);
}
public double Width { get; set; } = 20;
public double Depth { get; set; } = 20;
public double Height { get; set; } = 20;
public static CubeObject3D Create()
{
var item = new CubeObject3D();
var item = new CubeObject3D()
{
Color = PrimitiveColors["Cube"]
};
item.Rebuild(null);
return item;
}

View file

@ -1,114 +0,0 @@
/*
Copyright (c) 2018, Lars Brubaker, John Lewin
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of the FreeBSD Project.
*/
using System.Threading;
using MatterHackers.Agg.UI;
using MatterHackers.Agg.VertexSource;
using MatterHackers.DataConverters3D;
using MatterHackers.MatterControl.DesignTools.Operations;
using MatterHackers.PolygonMesh;
using MatterHackers.VectorMath;
namespace MatterHackers.MatterControl.DesignTools
{
public class CylinderAdvancedObject3D : Object3D, IRebuildable
{
public CylinderAdvancedObject3D()
{
}
public static CylinderAdvancedObject3D Create(double radius, double height, int sides, Alignment alignment = Alignment.Z)
{
return Create(radius, radius, height, sides, alignment);
}
public static CylinderAdvancedObject3D Create(double radiusBottom, double radiusTop, double height, int sides, Alignment alignment = Alignment.Z)
{
var item = new CylinderAdvancedObject3D()
{
RadiusBottom = radiusBottom,
RadiusTop = radiusTop,
Height = height,
Sides = sides,
Alignment = alignment,
};
item.Rebuild(null);
return item;
}
public Alignment Alignment { get; set; } = Alignment.Z;
public double RadiusBottom { get; set; } = 20;
public double RadiusTop { get; set; } = 20;
public double Height { get; set; } = 20;
public int Sides { get; set; } = 30;
public void Rebuild(UndoBuffer undoBuffer)
{
var aabb = this.GetAxisAlignedBoundingBox();
var path = new VertexStorage();
path.MoveTo(0, -Height / 2);
path.LineTo(RadiusBottom, -Height / 2);
path.LineTo(RadiusTop, Height / 2);
path.LineTo(0, Height / 2);
Mesh = VertexSourceToMesh.Revolve(path, Sides);
switch (Alignment)
{
case Alignment.X:
Matrix = Matrix4X4.CreateRotationY(MathHelper.Tau / 4);
break;
case Alignment.Y:
Matrix = Matrix4X4.CreateRotationX(MathHelper.Tau / 4);
break;
case Alignment.Z:
// This is the natural case (how it was modled)
break;
case Alignment.negX:
Matrix = Matrix4X4.CreateRotationY(-MathHelper.Tau / 4);
break;
case Alignment.negY:
Matrix = Matrix4X4.CreateRotationX(-MathHelper.Tau / 4);
break;
case Alignment.negZ:
Matrix = Matrix4X4.CreateRotationX(MathHelper.Tau / 2);
break;
}
if (aabb.ZSize > 0)
{
// If the part was already created and at a height, maintain the height.
PlatingHelper.PlaceMeshAtHeight(this, aabb.minXYZ.Z);
}
}
}
}

View file

@ -28,23 +28,25 @@ either expressed or implied, of the FreeBSD Project.
*/
using System.Threading;
using MatterHackers.Agg;
using MatterHackers.Agg.UI;
using MatterHackers.Agg.VertexSource;
using MatterHackers.DataConverters3D;
using MatterHackers.MatterControl.DesignTools.Operations;
using MatterHackers.PolygonMesh;
using MatterHackers.VectorMath;
namespace MatterHackers.MatterControl.DesignTools
{
public class CylinderObject3D : Object3D, IRebuildable
public class CylinderObject3D : Object3D, IRebuildable, IPropertyGridModifier
{
public CylinderObject3D()
{
Color = PrimitiveColors["Cylinder"];
}
public CylinderObject3D(double diameter, double height, int sides)
: base()
{
Diameter = diameter;
Height = height;
@ -53,6 +55,52 @@ namespace MatterHackers.MatterControl.DesignTools
Rebuild(null);
}
public static CylinderObject3D Create2(double diameter, double height, int sides, Alignment alignment = Alignment.Z)
{
if (alignment == Alignment.Z)
{
return new CylinderObject3D(diameter, height, sides);
}
return Create2(diameter, diameter, height, sides, alignment);
}
public static CylinderObject3D Create2(double diameterBottom, double diameterTop, double height, int sides, Alignment alignment = Alignment.Z)
{
var item = new CylinderObject3D()
{
Advanced = true,
Diameter = diameterBottom,
DiameterTop = diameterTop,
Height = height,
Sides = sides,
};
item.Rebuild(null);
switch (alignment)
{
case Alignment.X:
item.Matrix = Matrix4X4.CreateRotationY(MathHelper.Tau / 4);
break;
case Alignment.Y:
item.Matrix = Matrix4X4.CreateRotationX(MathHelper.Tau / 4);
break;
case Alignment.Z:
// This is the natural case (how it was modled)
break;
case Alignment.negX:
item.Matrix = Matrix4X4.CreateRotationY(-MathHelper.Tau / 4);
break;
case Alignment.negY:
item.Matrix = Matrix4X4.CreateRotationX(-MathHelper.Tau / 4);
break;
case Alignment.negZ:
item.Matrix = Matrix4X4.CreateRotationX(MathHelper.Tau / 2);
break;
}
return item;
}
public static CylinderObject3D Create()
{
var item = new CylinderObject3D();
@ -64,18 +112,35 @@ 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 void Rebuild(UndoBuffer undoBuffer)
{
var aabb = this.GetAxisAlignedBoundingBox();
var path = new VertexStorage();
path.MoveTo(0, -Height / 2);
path.LineTo(Diameter / 2, -Height / 2);
path.LineTo(Diameter / 2, Height / 2);
path.LineTo(0, Height / 2);
if (!Advanced)
{
var path = new VertexStorage();
path.MoveTo(0, -Height / 2);
path.LineTo(Diameter / 2, -Height / 2);
path.LineTo(Diameter / 2, Height / 2);
path.LineTo(0, Height / 2);
Mesh = VertexSourceToMesh.Revolve(path, Sides);
Mesh = VertexSourceToMesh.Revolve(path, Sides);
}
else
{
var path = new VertexStorage();
path.MoveTo(0, -Height / 2);
path.LineTo(Diameter / 2, -Height / 2);
path.LineTo(DiameterTop / 2, Height / 2);
path.LineTo(0, Height / 2);
Mesh = VertexSourceToMesh.Revolve(path, Sides, MathHelper.DegreesToRadians(StartingAngle), MathHelper.DegreesToRadians(EndingAngle));
}
if (aabb.ZSize > 0)
{
@ -83,5 +148,12 @@ namespace MatterHackers.MatterControl.DesignTools
PlatingHelper.PlaceMeshAtHeight(this, aabb.minXYZ.Z);
}
}
public void UpdateControls(PublicPropertyEditor editor)
{
editor.GetEditRow((this.ID, nameof(DiameterTop))).Visible = Advanced;
editor.GetEditRow((this.ID, nameof(StartingAngle))).Visible = Advanced;
editor.GetEditRow((this.ID, nameof(EndingAngle))).Visible = Advanced;
}
}
}

View file

@ -29,6 +29,7 @@ either expressed or implied, of the FreeBSD Project.
using System;
using System.ComponentModel;
using MatterHackers.Agg;
using MatterHackers.Agg.UI;
using MatterHackers.Agg.VertexSource;
using MatterHackers.DataConverters3D;
@ -38,13 +39,11 @@ namespace MatterHackers.MatterControl.DesignTools
{
public class HalfSphereObject3D : Object3D, IRebuildable
{
public HalfSphereObject3D()
{
Color = PrimitiveColors["HalfSphere"];
}
public HalfSphereObject3D(double diametar, int sides)
{
this.Diameter = diametar;

View file

@ -30,6 +30,7 @@ either expressed or implied, of the FreeBSD Project.
using System;
using System.IO;
using System.Threading;
using MatterHackers.Agg;
using MatterHackers.Agg.Image;
using MatterHackers.Agg.ImageProcessing;
using MatterHackers.Agg.Platform;
@ -52,7 +53,6 @@ namespace MatterHackers.MatterControl.DesignTools
public ImageObject3D()
{
base.Mesh = null;
}
public override string AssetPath

View file

@ -28,11 +28,10 @@ either expressed or implied, of the FreeBSD Project.
*/
using System;
using System.Threading;
using MatterHackers.Agg;
using MatterHackers.Agg.UI;
using MatterHackers.Agg.VertexSource;
using MatterHackers.DataConverters3D;
using MatterHackers.PolygonMesh;
using MatterHackers.VectorMath;
namespace MatterHackers.MatterControl.DesignTools
@ -41,6 +40,7 @@ namespace MatterHackers.MatterControl.DesignTools
{
public PyramidObject3D()
{
Color = PrimitiveColors["Pyramid"];
}
public static PyramidObject3D Create()

View file

@ -30,6 +30,7 @@ either expressed or implied, of the FreeBSD Project.
using System;
using System.ComponentModel;
using System.Threading;
using MatterHackers.Agg;
using MatterHackers.Agg.UI;
using MatterHackers.Agg.VertexSource;
using MatterHackers.DataConverters3D;
@ -38,12 +39,11 @@ using MatterHackers.VectorMath;
namespace MatterHackers.MatterControl.DesignTools
{
public class RingObject3D : Object3D, IRebuildable
public class RingObject3D : Object3D, IRebuildable, IPropertyGridModifier
{
public RingObject3D()
{
Color = PrimitiveColors["Ring"];
}
public RingObject3D(double outerDiameter, double innerDiameter, double height, int sides)
@ -68,29 +68,33 @@ 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;
public void Rebuild(UndoBuffer undoBuffer)
{
var aabb = this.GetAxisAlignedBoundingBox();
var startingAngle = StartingAngle;
var endingAngle = EndingAngle;
if (!Advanced)
{
startingAngle = 0;
endingAngle = 360;
}
var innerDiameter = Math.Min(OuterDiameter - .1, InnerDiameter);
var path = new VertexStorage();
path.MoveTo(OuterDiameter / 2, 0);
path.LineTo(OuterDiameter / 2, Height);
path.LineTo(innerDiameter / 2, Height);
path.LineTo(innerDiameter / 2, 0);
for (int i = 1; i < Sides; i++)
{
var angle = MathHelper.Tau * i / (Sides - 1);
path.LineTo(Math.Cos(angle) * OuterDiameter / 2, Math.Sin(angle) * OuterDiameter / 2);
}
path.MoveTo(InnerDiameter / 2, 0);
for (int i = 1; i < Sides; i++)
{
var angle = -MathHelper.Tau * i / (Sides - 1);
path.LineTo(Math.Cos(angle) * InnerDiameter / 2, Math.Sin(angle) * InnerDiameter / 2);
}
Mesh = VertexSourceToMesh.Extrude(path, Height);
var startAngle = MathHelper.Range0ToTau(MathHelper.DegreesToRadians(startingAngle));
var endAngle = MathHelper.Range0ToTau(MathHelper.DegreesToRadians(endingAngle));
Mesh = VertexSourceToMesh.Revolve(path, Sides, startAngle, endAngle);
if (aabb.ZSize > 0)
{
@ -98,5 +102,12 @@ namespace MatterHackers.MatterControl.DesignTools
PlatingHelper.PlaceMeshAtHeight(this, aabb.minXYZ.Z);
}
}
public void UpdateControls(PublicPropertyEditor editor)
{
editor.GetEditRow((this.ID, nameof(StartingAngle))).Visible = Advanced;
editor.GetEditRow((this.ID, nameof(EndingAngle))).Visible = Advanced;
InnerDiameter = Math.Min(OuterDiameter - .1, InnerDiameter);
}
}
}

View file

@ -29,6 +29,7 @@ either expressed or implied, of the FreeBSD Project.
using System;
using System.ComponentModel;
using MatterHackers.Agg;
using MatterHackers.Agg.UI;
using MatterHackers.Agg.VertexSource;
using MatterHackers.DataConverters3D;
@ -38,10 +39,9 @@ namespace MatterHackers.MatterControl.DesignTools
{
public class RoofObject3D : Object3D, IRebuildable
{
public RoofObject3D()
{
Color = PrimitiveColors["Roof"];
}
public static RoofObject3D Create()

View file

@ -29,6 +29,7 @@ either expressed or implied, of the FreeBSD Project.
using System;
using System.ComponentModel;
using MatterHackers.Agg;
using MatterHackers.Agg.UI;
using MatterHackers.Agg.VertexSource;
using MatterHackers.DataConverters3D;
@ -38,10 +39,9 @@ namespace MatterHackers.MatterControl.DesignTools
{
public class RoundRoofObject3D : Object3D, IRebuildable
{
public RoundRoofObject3D()
{
Color = PrimitiveColors["RoundRoof"];
}
public static RoundRoofObject3D Create()

View file

@ -1,96 +0,0 @@
/*
Copyright (c) 2018, Lars Brubaker, John Lewin
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of the FreeBSD Project.
*/
using System;
using System.ComponentModel;
using MatterHackers.Agg.UI;
using MatterHackers.Agg.VertexSource;
using MatterHackers.DataConverters3D;
using MatterHackers.VectorMath;
namespace MatterHackers.MatterControl.DesignTools
{
public class SphereAdvancedObject3D : Object3D, IRebuildable
{
public SphereAdvancedObject3D()
{
}
public static SphereAdvancedObject3D Create()
{
var item = new SphereAdvancedObject3D();
item.Rebuild(null);
return item;
}
public double Diameter { get; set; } = 20;
public int LongitudeSides { get; set; } = 30;
public int LatitudeSides { get; set; } = 20;
[DisplayName("Start Angle")]
//[Range(0, 360, ErrorMessage = "Angle {0} must be between {1} and {2}.")]
public double StartAngleDegrees { get; set; } = 20;
[DisplayName("End Angle")]
//[Range(0, 360, ErrorMessage = "Angle {0} must be between {1} and {2}.")]
public double EndAngleDegrees { get; set; } = 240;
public void Rebuild(UndoBuffer undoBuffer)
{
var aabb = this.GetAxisAlignedBoundingBox();
var path = new VertexStorage();
var angleDelta = MathHelper.Tau / 2 / LatitudeSides;
var angle = -MathHelper.Tau / 4;
var radius = Diameter / 2;
path.MoveTo(new Vector2(radius * Math.Cos(angle), radius * Math.Sin(angle)));
for (int i = 0; i < LatitudeSides; i++)
{
angle += angleDelta;
path.LineTo(new Vector2(radius * Math.Cos(angle), radius * Math.Sin(angle)));
}
var startAngle = MathHelper.Range0ToTau(MathHelper.DegreesToRadians(StartAngleDegrees));
var endAngle = MathHelper.Range0ToTau(MathHelper.DegreesToRadians(EndAngleDegrees));
var steps = Math.Max(1, (int)(LongitudeSides * MathHelper.Tau / Math.Abs(MathHelper.GetDeltaAngle(startAngle, endAngle)) + .5));
Mesh = VertexSourceToMesh.Revolve(path,
steps,
startAngle,
endAngle);
if (aabb.ZSize > 0)
{
// If the part was already created and at a height, maintain the height.
PlatingHelper.PlaceMeshAtHeight(this, aabb.minXYZ.Z);
}
}
}
}

View file

@ -29,6 +29,7 @@ either expressed or implied, of the FreeBSD Project.
using System;
using System.ComponentModel;
using MatterHackers.Agg;
using MatterHackers.Agg.UI;
using MatterHackers.Agg.VertexSource;
using MatterHackers.DataConverters3D;
@ -36,12 +37,11 @@ using MatterHackers.VectorMath;
namespace MatterHackers.MatterControl.DesignTools
{
public class SphereObject3D : Object3D, IRebuildable
public class SphereObject3D : Object3D, IRebuildable, IPropertyGridModifier
{
public SphereObject3D()
{
Color = PrimitiveColors["Sphere"];
}
public SphereObject3D(double diameter, int sides)
@ -62,28 +62,55 @@ 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 void Rebuild(UndoBuffer undoBuffer)
{
var aabb = this.GetAxisAlignedBoundingBox();
var startingAngle = StartingAngle;
var endingAngle = EndingAngle;
var latitudeSides = LatitudeSides;
if (!Advanced)
{
startingAngle = 0;
endingAngle = 360;
latitudeSides = Sides;
}
var path = new VertexStorage();
var angleDelta = MathHelper.Tau / 2 / Sides;
var angleDelta = MathHelper.Tau / 2 / latitudeSides;
var angle = -MathHelper.Tau / 4;
var radius = Diameter / 2;
path.MoveTo(new Vector2(radius * Math.Cos(angle), radius * Math.Sin(angle)));
for (int i = 0; i < Sides; i++)
for (int i = 0; i < latitudeSides; i++)
{
angle += angleDelta;
path.LineTo(new Vector2(radius * Math.Cos(angle), radius * Math.Sin(angle)));
}
Mesh = VertexSourceToMesh.Revolve(path, Sides);
var startAngle = MathHelper.Range0ToTau(MathHelper.DegreesToRadians(startingAngle));
var endAngle = MathHelper.Range0ToTau(MathHelper.DegreesToRadians(endingAngle));
var steps = Math.Max(1, (int)(Sides * MathHelper.Tau / Math.Abs(MathHelper.GetDeltaAngle(startAngle, endAngle)) + .5));
Mesh = VertexSourceToMesh.Revolve(path,
steps,
startAngle,
endAngle);
if (aabb.ZSize > 0)
{
// If the part was already created and at a height, maintain the height.
PlatingHelper.PlaceMeshAtHeight(this, aabb.minXYZ.Z);
}
}
public void UpdateControls(PublicPropertyEditor editor)
{
editor.GetEditRow((this.ID, nameof(StartingAngle))).Visible = Advanced;
editor.GetEditRow((this.ID, nameof(EndingAngle))).Visible = Advanced;
editor.GetEditRow((this.ID, nameof(LatitudeSides))).Visible = Advanced;
}
}
}

View file

@ -28,6 +28,7 @@ either expressed or implied, of the FreeBSD Project.
*/
using System.ComponentModel;
using MatterHackers.Agg;
using MatterHackers.Agg.Font;
using MatterHackers.Agg.Transform;
using MatterHackers.Agg.UI;
@ -72,6 +73,7 @@ namespace MatterHackers.MatterControl.DesignTools
{
public TextObject3D()
{
Color = PrimitiveColors["Text"];
}
public static TextObject3D Create()

View file

@ -30,6 +30,7 @@ either expressed or implied, of the FreeBSD Project.
using System;
using System.ComponentModel;
using System.Threading;
using MatterHackers.Agg;
using MatterHackers.Agg.UI;
using MatterHackers.Agg.VertexSource;
using MatterHackers.DataConverters3D;
@ -38,12 +39,11 @@ using MatterHackers.VectorMath;
namespace MatterHackers.MatterControl.DesignTools
{
public class TorusObject3D : Object3D, IRebuildable
public class TorusObject3D : Object3D, IRebuildable, IPropertyGridModifier
{
public TorusObject3D()
{
Color = PrimitiveColors["Torus"];
}
public static TorusObject3D Create()
@ -55,24 +55,38 @@ namespace MatterHackers.MatterControl.DesignTools
public double InnerDiameter { get; set; } = 10;
public double OuterDiameter { get; set; } = 20;
public int ToroidSides { get; set; } = 20;
public int Sides { get; set; } = 30;
public bool Advanced { get; set; } = false;
[DisplayName("Ring Sides")]
public int PoleSides { get; set; } = 16;
public int RingSides { get; set; } = 15;
public double StartingAngle { get; set; } = 0;
public double EndingAngle { get; set; } = 360;
public void Rebuild(UndoBuffer undoBuffer)
{
var ringSides = RingSides;
var startingAngle = StartingAngle;
var endingAngle = EndingAngle;
if(!Advanced)
{
ringSides = Math.Max(3, (int)(Sides / 2));
startingAngle = 0;
endingAngle = 360;
}
var innerDiameter = Math.Min(OuterDiameter - .1, InnerDiameter);
var aabb = this.GetAxisAlignedBoundingBox();
var poleRadius = (OuterDiameter / 2 - InnerDiameter / 2) / 2;
var toroidRadius = InnerDiameter / 2 + poleRadius;
var poleRadius = (OuterDiameter / 2 - innerDiameter / 2) / 2;
var toroidRadius = innerDiameter / 2 + poleRadius;
var path = new VertexStorage();
var angleDelta = MathHelper.Tau / PoleSides;
var angleDelta = MathHelper.Tau / ringSides;
var angle = 0.0;
var circleCenter = new Vector2(toroidRadius, 0);
path.MoveTo(circleCenter + new Vector2(poleRadius * Math.Cos(angle), poleRadius * Math.Sin(angle)));
for (int i = 0; i < PoleSides - 1; i++)
for (int i = 0; i < ringSides - 1; i++)
{
angle += angleDelta;
path.LineTo(circleCenter + new Vector2(poleRadius * Math.Cos(angle), poleRadius * Math.Sin(angle)));
@ -80,14 +94,23 @@ namespace MatterHackers.MatterControl.DesignTools
path.LineTo(circleCenter + new Vector2(poleRadius * Math.Cos(0), poleRadius * Math.Sin(0)));
var startAngle = MathHelper.Range0ToTau(MathHelper.DegreesToRadians(StartingAngle));
var endAngle = MathHelper.Range0ToTau(MathHelper.DegreesToRadians(EndingAngle));
Mesh = VertexSourceToMesh.Revolve(path, ToroidSides, startAngle, endAngle);
var startAngle = MathHelper.Range0ToTau(MathHelper.DegreesToRadians(startingAngle));
var endAngle = MathHelper.Range0ToTau(MathHelper.DegreesToRadians(endingAngle));
Mesh = VertexSourceToMesh.Revolve(path, Sides, startAngle, endAngle);
if (aabb.ZSize > 0)
{
// If the part was already created and at a height, maintain the height.
PlatingHelper.PlaceMeshAtHeight(this, aabb.minXYZ.Z);
}
}
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;
InnerDiameter = Math.Min(OuterDiameter - .1, InnerDiameter);
}
}
}

View file

@ -29,6 +29,7 @@ either expressed or implied, of the FreeBSD Project.
using System;
using System.ComponentModel;
using MatterHackers.Agg;
using MatterHackers.Agg.UI;
using MatterHackers.Agg.VertexSource;
using MatterHackers.DataConverters3D;
@ -38,10 +39,9 @@ namespace MatterHackers.MatterControl.DesignTools
{
public class WedgeObject3D : Object3D, IRebuildable
{
public WedgeObject3D()
{
Color = PrimitiveColors["Wedge"];
}
public static WedgeObject3D Create()

View file

@ -127,10 +127,8 @@
<Compile Include="DesignTools\Primitives\RingObject3D.cs" />
<Compile Include="DesignTools\Primitives\RoofObject3D.cs" />
<Compile Include="DesignTools\Primitives\RoundRoofObject3D.cs" />
<Compile Include="DesignTools\Primitives\SphereAdvancedObject3D.cs" />
<Compile Include="DesignTools\Primitives\WedgeObject3D.cs" />
<Compile Include="DesignTools\Primitives\PyramidObject3D.cs" />
<Compile Include="DesignTools\Primitives\CylinderAdvancedObject3D.cs" />
<Compile Include="DesignTools\Primitives\CylinderObject3D.cs" />
<Compile Include="DesignTools\Primitives\HalfSphereObject3D.cs" />
<Compile Include="DesignTools\Primitives\SphereObject3D.cs" />

View file

@ -100,7 +100,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
seeWhatsNewButton.Margin = new Agg.BorderDouble(10, 0);
seeWhatsNewButton.Click += (s, e) => UiThread.RunOnIdle(() =>
{
DialogWindow.Show(new DesignSpaceHelp("What's New Tab", ""));
DialogWindow.Show(new DesignSpaceGuid("What's New Tab", ""));
});
tabControl.TabBar.ActionArea.AddChild(seeWhatsNewButton);

View file

@ -630,7 +630,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
{
UiThread.RunOnIdle(() =>
{
DialogWindow.Show<DesignSpaceHelp>();
DialogWindow.Show<DesignSpaceGuid>();
});
}
}

View file

@ -42,14 +42,14 @@ using Newtonsoft.Json;
namespace MatterHackers.MatterControl
{
public class TipAssets
public class GuideAssets
{
/// <summary>
/// Where to find the gif or evertually movie file
/// </summary>
public string AnimationUri;
/// <summary>
/// The first level category this tip is part of
/// The first level category this guide is part of
/// </summary>
public string Category;
/// <summary>
@ -69,31 +69,31 @@ namespace MatterHackers.MatterControl
/// </summary>
public string Description;
/// <summary>
/// This is the imutable key assigned to this tip. It can
/// be used to navigate to this tip while opening the control
/// This is the imutable key assigned to this guide. It can
/// be used to navigate to this guide while opening the control
/// </summary>
public string Key;
}
public class DesignSpaceHelp : DialogPage
public class DesignSpaceGuid : DialogPage
{
List<TipAssets> whatsNewTips = new List<TipAssets>();
List<TipAssets> allAvailableTips = new List<TipAssets>();
List<GuideAssets> whatsNewGuides = new List<GuideAssets>();
List<GuideAssets> allAvailableGuides = new List<GuideAssets>();
public DesignSpaceHelp()
public DesignSpaceGuid()
: this("", "")
{
}
public DesignSpaceHelp(string preSelectTabName, string tipKey)
public DesignSpaceGuid(string preSelectTabName, string guideKey)
: base("Close".Localize())
{
WindowSize = new Vector2(800, 600);
MakeTestTips();
MakeTestGuides();
this.WindowTitle = "Design Space Help".Localize();
this.HeaderText = "Navigation Controls and Shortcut Keys".Localize();
this.WindowTitle = "MatterControl " + "Help".Localize();
this.HeaderText = "How to succed with MatterControl".Localize();
this.ChildBorderColor = theme.GetBorderColor(75);
var container = new FlowLayoutWidget(FlowDirection.TopToBottom)
@ -215,19 +215,19 @@ namespace MatterHackers.MatterControl
right = Math.Max(0, keys.Width - actions.Width);
shortcutKeys.Margin = new BorderDouble(left, 0, right, 0);
var tipsContainer = new FlowLayoutWidget(FlowDirection.TopToBottom)
var guideSectionContainer = new FlowLayoutWidget(FlowDirection.TopToBottom)
{
HAnchor = HAnchor.Stretch,
VAnchor = VAnchor.Stretch
};
var tipsTab = new ToolTab("Tips".Localize(), tabControl, tipsContainer, theme, hasClose: false)
var guideTab = new ToolTab("Guides".Localize(), tabControl, guideSectionContainer, theme, hasClose: false)
{
// this can be used to navigate to this tab on construction
Name = "Tips Tab"
Name = "Guides Tab"
};
tabControl.AddTab(tipsTab);
tabControl.AddTab(guideTab);
AddTips(tipsContainer, allAvailableTips);
AddGuides(guideSectionContainer, allAvailableGuides);
var whatsNewContainer = new FlowLayoutWidget(FlowDirection.TopToBottom)
{
@ -241,7 +241,7 @@ namespace MatterHackers.MatterControl
Name = "What's New Tab"
};
tabControl.AddTab(whatsNewTab);
AddTips(whatsNewContainer, whatsNewTips);
AddGuides(whatsNewContainer, whatsNewGuides);
// if the what's new tab becomes visible mark the time
whatsNewContainer.VisibleChanged += (s, e) =>
@ -272,9 +272,9 @@ namespace MatterHackers.MatterControl
}
}
private void MakeTestTips()
private void MakeTestGuides()
{
allAvailableTips.Add(new TipAssets()
allAvailableGuides.Add(new GuideAssets()
{
AnimationUri = "https://www.matterhackers.com/r/sjMyWZ",
Category = "Design Tools",
@ -284,7 +284,7 @@ namespace MatterHackers.MatterControl
Description = "Any object can be turned into support. Simply select it in the 3D view and click the 'Make Support' button. Support will automatically make interface layers and avoid interescting the printing object."
});
allAvailableTips.Add(new TipAssets()
allAvailableGuides.Add(new GuideAssets()
{
AnimationUri = "https://www.matterhackers.com/r/1oH3i1",
Category = "Design Tools",
@ -294,7 +294,7 @@ namespace MatterHackers.MatterControl
Description = "Click on any of the rotate corner contrors to rotate on the plane of that control. Moving the mouse over one of the arrow indicators locks the rotation to a 45° angle."
});
allAvailableTips.Add(new TipAssets()
allAvailableGuides.Add(new GuideAssets()
{
AnimationUri = "https://www.matterhackers.com/r/yNqiNT",
Category = "Design Tools",
@ -304,10 +304,10 @@ namespace MatterHackers.MatterControl
Description = "Click on any of the scale corner contrors to scale your part on the bed."
});
whatsNewTips = allAvailableTips;
whatsNewGuides = allAvailableGuides;
}
private void AddTips(FlowLayoutWidget tipsContainer, List<TipAssets> tipsList)
private void AddGuides(FlowLayoutWidget guideContainer, List<GuideAssets> guideList)
{
var sequence = new ImageSequence()
{
@ -352,17 +352,17 @@ namespace MatterHackers.MatterControl
double maxMenuItemWidth = 0;
PopupMenu.MenuItem firstItem = null;
foreach(var tip in tipsList)
foreach(var guide in guideList)
{
var menuItem = popupMenu.CreateMenuItem(tip.Name);
var menuItem = popupMenu.CreateMenuItem(guide.Name);
firstItem = (firstItem == null) ? menuItem : firstItem;
maxMenuItemWidth = Math.Max(maxMenuItemWidth, menuItem.Width);
menuItem.Click += (s, e) =>
{
title.Text = tip.Title;
description.Text = tip.Description;
title.Text = guide.Title;
description.Text = guide.Description;
imageSequenceWidget.ImageSequence = AggContext.StaticData.LoadSequence(Path.Combine("Icons", "provider_loading.gif"));
ApplicationController.Instance.DownloadToImageSequenceAsync(imageSequenceWidget.ImageSequence, tip.AnimationUri);
ApplicationController.Instance.DownloadToImageSequenceAsync(imageSequenceWidget.ImageSequence, guide.AnimationUri);
};
}
@ -381,7 +381,7 @@ namespace MatterHackers.MatterControl
splitter.Panel1.AddChild(popupMenu);
splitter.Panel1.BackgroundColor = theme.SlightShade;
splitter.Panel2.AddChild(rightPanel);
tipsContainer.AddChild(splitter);
guideContainer.AddChild(splitter);
}
public Color ChildBorderColor { get; private set; }

@ -1 +1 @@
Subproject commit aca385d04928c2c0e2ff90f3087e8f2d849e9f81
Subproject commit 8eae9ecc845c22222380d6e149c0c4dd97521a04

View file

@ -64,8 +64,8 @@ namespace MatterHackers.PolygonMesh.UnitTests
{
double topHeight = 10;
int sides = 3;
IObject3D keep = CylinderAdvancedObject3D.Create(20, topHeight * 2, sides);
IObject3D subtract = CylinderAdvancedObject3D.Create(10, topHeight * 2, sides);
IObject3D keep = CylinderObject3D.Create2(20, topHeight * 2, sides);
IObject3D subtract = CylinderObject3D.Create2(10, topHeight * 2, sides);
var keepMesh = keep.Mesh;
var subtractMesh = subtract.Mesh;
@ -109,8 +109,8 @@ namespace MatterHackers.PolygonMesh.UnitTests
// check that we subtarct two 3 sideh cylinders
{
int sides = 3;
IObject3D keep = CylinderAdvancedObject3D.Create(20, 20, sides);
IObject3D subtract = CylinderAdvancedObject3D.Create(10, 22, sides);
IObject3D keep = CylinderObject3D.Create2(20, 20, sides);
IObject3D subtract = CylinderObject3D.Create2(10, 22, sides);
var keepMesh = keep.Mesh;
var subtractMesh = subtract.Mesh;