mirror of
https://github.com/eliasstepanik/OSCADSharpDotnet7.git
synced 2026-01-11 21:48:34 +00:00
+ Renamed Sizes class to Inches
+ In progress Bindings clone functionality
This commit is contained in:
parent
047a6472b1
commit
d8eb02ecc4
@ -14,8 +14,8 @@ namespace OSCADSharp.ConsoleTests
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
var diam = new Variable("mainColumn", Sizes.HalfInch);
|
||||
var height = new Variable("overallHeight", Sizes.QuarterInch);
|
||||
var diam = new Variable("mainColumn", Inches.Half);
|
||||
var height = new Variable("overallHeight", Inches.Quarter);
|
||||
Variables.Global.Add(diam);
|
||||
Variables.Global.Add(height);
|
||||
|
||||
|
||||
@ -162,9 +162,9 @@ namespace OSCADSharp.UnitTests
|
||||
[TestMethod]
|
||||
public void Cube_ConstructorBindingsAppearInOutput()
|
||||
{
|
||||
var length = new Variable("deckBoxLength", Sizes.SixteenthInch * 32);
|
||||
var width = new Variable("deckBoxWidth", Sizes.SixteenthInch * 32);
|
||||
var height = new Variable("deckboxHeight", Sizes.InchesToMillimeters(2.5));
|
||||
var length = new Variable("deckBoxLength", Inches.Sixteenth * 32);
|
||||
var width = new Variable("deckBoxWidth", Inches.Sixteenth * 32);
|
||||
var height = new Variable("deckboxHeight", Inches.ToMillimeters(2.5));
|
||||
var centered = new Variable("isCentered", true);
|
||||
|
||||
var cube = new Cube(length, width, height, centered);
|
||||
@ -174,5 +174,22 @@ namespace OSCADSharp.UnitTests
|
||||
Assert.IsTrue(script.Contains("size = [deckBoxLength, deckBoxWidth, deckboxHeight]"));
|
||||
Assert.IsTrue(script.Contains("center = isCentered"));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Cube_CloneHasSameBindings()
|
||||
{
|
||||
var cubeHeight = new Variable("myHeight", 35);
|
||||
var cubeXTranslation = new Variable("xOffset", 50);
|
||||
|
||||
OSCADObject cube = new Cube(15, 5, 15);
|
||||
cube.Bind("Height", cubeHeight);
|
||||
cube = cube.Translate(cubeXTranslation, 0, 0);
|
||||
|
||||
var clone = cube.Clone();
|
||||
|
||||
string script = clone.ToString();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -183,8 +183,8 @@ namespace OSCADSharp.UnitTests
|
||||
[TestMethod]
|
||||
public void Cylinder_CanCreatePreBoundCylinderWithConstructor()
|
||||
{
|
||||
var diam = new Variable("mainColumn", Sizes.HalfInch);
|
||||
var height = new Variable("overallHeight", Sizes.QuarterInch);
|
||||
var diam = new Variable("mainColumn", Inches.Half);
|
||||
var height = new Variable("overallHeight", Inches.Quarter);
|
||||
|
||||
var cyl = new Cylinder(diam, diam, height);
|
||||
|
||||
|
||||
@ -170,7 +170,7 @@ namespace OSCADSharp.UnitTests
|
||||
[TestMethod]
|
||||
public void Sphere_CanCreateSphereWithBindingsFromConstructor()
|
||||
{
|
||||
var diam = new Variable("width", Sizes.OneInch);
|
||||
var diam = new Variable("width", Inches.One);
|
||||
var resolution = new Variable("rez", 100);
|
||||
|
||||
var sphere = new Sphere(diam, resolution);
|
||||
|
||||
@ -53,5 +53,13 @@ namespace OSCADSharp.Bindings
|
||||
|
||||
return String.Format("[{0}, {1}, {2}]", x, y, z);
|
||||
}
|
||||
|
||||
public new BindableVector Clone()
|
||||
{
|
||||
return new BindableVector(base.Clone())
|
||||
{
|
||||
bindings = this.bindings
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -129,7 +129,16 @@ namespace OSCADSharp.Bindings
|
||||
internal void Synonym(string propertyName, string alternateName)
|
||||
{
|
||||
this.synonyms[alternateName] = propertyName;
|
||||
}
|
||||
}
|
||||
|
||||
internal Bindings Clone()
|
||||
{
|
||||
var clone = new Bindings(this.propertyNametoOpenSCADFieldMappings);
|
||||
clone.synonyms = this.synonyms;
|
||||
clone.bindings = this.bindings;
|
||||
|
||||
return clone;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@ -34,7 +34,7 @@ namespace OSCADSharp.Scripting
|
||||
/// Must be compatible with the data type being assigned to.
|
||||
/// </summary>
|
||||
public object Value { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets this variable as a name = value string
|
||||
/// </summary>
|
||||
@ -42,6 +42,6 @@ namespace OSCADSharp.Scripting
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("{0} = {1}", this.Name, this.Value.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,41 +9,41 @@ namespace OSCADSharp
|
||||
/// <summary>
|
||||
/// Constants and conversions for units for us imperial-minded folks.
|
||||
/// </summary>
|
||||
public class Sizes
|
||||
public class Inches
|
||||
{
|
||||
/// <summary>
|
||||
/// One imperial inch
|
||||
/// </summary>
|
||||
public const double OneInch = 25.4;
|
||||
public const double One = 25.4;
|
||||
|
||||
/// <summary>
|
||||
/// Half of an imperial inch
|
||||
/// </summary>
|
||||
public const double HalfInch = OneInch / 2;
|
||||
public const double Half = One / 2;
|
||||
|
||||
/// <summary>
|
||||
/// Quarter of an imperial inch
|
||||
/// </summary>
|
||||
public const double QuarterInch = HalfInch / 2;
|
||||
public const double Quarter = Half / 2;
|
||||
|
||||
/// <summary>
|
||||
/// Eigth of an imperial inch
|
||||
/// </summary>
|
||||
public const double EigthInch = QuarterInch / 2;
|
||||
public const double Eigth = Quarter / 2;
|
||||
|
||||
/// <summary>
|
||||
/// Sixteenth of an imperial inch
|
||||
/// </summary>
|
||||
public const double SixteenthInch = EigthInch / 2;
|
||||
public const double Sixteenth = Eigth / 2;
|
||||
|
||||
/// <summary>
|
||||
/// Converts inches to millimeters
|
||||
/// </summary>
|
||||
/// <param name="inches">Number of inches</param>
|
||||
/// <returns>Equivalent value in milimeters</returns>
|
||||
public static double InchesToMillimeters(double inches)
|
||||
public static double ToMillimeters(double inches)
|
||||
{
|
||||
return inches * OneInch;
|
||||
return inches * One;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -117,8 +117,9 @@ namespace OSCADSharp.Solids
|
||||
return new Cube()
|
||||
{
|
||||
Name = this.Name,
|
||||
Size = this.Size,
|
||||
Center = this.Center
|
||||
Size = ((BindableVector)this.Size).Clone(),
|
||||
Center = this.Center,
|
||||
bindings = this.bindings.Clone()
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -217,7 +217,8 @@ namespace OSCADSharp.Solids
|
||||
Resolution = this.Resolution,
|
||||
MinimumAngle = this.MinimumAngle,
|
||||
MinimumCircumferentialLength = this.MinimumCircumferentialLength,
|
||||
Center = this.Center
|
||||
Center = this.Center,
|
||||
bindings = this.bindings.Clone()
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -122,7 +122,8 @@ namespace OSCADSharp.Solids
|
||||
Resolution = this.Resolution,
|
||||
MinimumAngle = this.MinimumAngle,
|
||||
MinimumFragmentSize = this.MinimumFragmentSize,
|
||||
Radius = this.Radius
|
||||
Radius = this.Radius,
|
||||
bindings = this.bindings.Clone()
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -106,7 +106,8 @@ namespace OSCADSharp.Solids
|
||||
Font = this.Font,
|
||||
Spacing = this.Spacing,
|
||||
TextDirection = this.TextDirection,
|
||||
Language = this.Language
|
||||
Language = this.Language,
|
||||
bindings = this.bindings.Clone()
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -58,7 +58,8 @@ namespace OSCADSharp.Transforms
|
||||
{
|
||||
return new ColoredObject(this.obj.Clone(), this.ColorName, this.Opacity)
|
||||
{
|
||||
Name = this.Name
|
||||
Name = this.Name,
|
||||
bindings = this.bindings.Clone()
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -56,7 +56,8 @@ namespace OSCADSharp.Transforms
|
||||
{
|
||||
return new MirroredObject(this.obj.Clone(), this.Normal)
|
||||
{
|
||||
Name = this.Name
|
||||
Name = this.Name,
|
||||
bindings = this.bindings.Clone()
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -56,7 +56,8 @@ namespace OSCADSharp.Transforms
|
||||
{
|
||||
return new ResizedObject(this.obj.Clone(), this.Size)
|
||||
{
|
||||
Name = this.Name
|
||||
Name = this.Name,
|
||||
bindings = this.bindings.Clone()
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -56,7 +56,8 @@ namespace OSCADSharp.Transforms
|
||||
{
|
||||
return new RotatedObject(this.obj.Clone(), this.Angle)
|
||||
{
|
||||
Name = this.Name
|
||||
Name = this.Name,
|
||||
bindings = this.bindings.Clone()
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -56,7 +56,8 @@ namespace OSCADSharp.Transforms
|
||||
{
|
||||
return new ScaledObject(this.obj.Clone(), this.ScaleFactor)
|
||||
{
|
||||
Name = this.Name
|
||||
Name = this.Name,
|
||||
bindings = this.bindings.Clone()
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -53,7 +53,8 @@ namespace OSCADSharp.Transforms
|
||||
{
|
||||
return new TranslatedObject(this.obj.Clone(), this.Vector)
|
||||
{
|
||||
Name = this.Name
|
||||
Name = this.Name,
|
||||
bindings = this.bindings.Clone()
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user