mirror of
https://github.com/eliasstepanik/OSCADSharpDotnet7.git
synced 2026-01-11 21:48:34 +00:00
+ Added IBindable on OSCADObject and cascaded it down.
+ Removed redundant IBindable declaration on Solids
This commit is contained in:
parent
54b8e6a686
commit
255318fb07
@ -18,7 +18,7 @@ namespace OSCADSharp.ConsoleTests
|
||||
Variables.Global.Add("cubeWidth", 10);
|
||||
|
||||
OSCADObject obj = new Sphere();
|
||||
((Sphere)obj).Bind("Radius", Variables.Global["sphereRadius"]);
|
||||
obj.Bind("Radius", Variables.Global["sphereRadius"]);
|
||||
|
||||
var cube = new Cube();
|
||||
cube.Bind("Width", Variables.Global["cubeWidth"]);
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using OSCADSharp.Booleans;
|
||||
using OSCADSharp.Bindings;
|
||||
using OSCADSharp.Booleans;
|
||||
using OSCADSharp.Files;
|
||||
using OSCADSharp.Scripting;
|
||||
using OSCADSharp.Spatial;
|
||||
@ -16,7 +17,7 @@ namespace OSCADSharp
|
||||
/// Represents any Object or collection of objects that becomes am
|
||||
/// an OpenSCAD script when converted to a string.
|
||||
/// </summary>
|
||||
public abstract class OSCADObject
|
||||
public abstract class OSCADObject : IBindable
|
||||
{
|
||||
#region Attributes
|
||||
private uint id = Ids.Get();
|
||||
@ -340,6 +341,14 @@ namespace OSCADSharp
|
||||
|
||||
return Dependencies.FileInvokerFactory(filePath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Binds a a variable to a property on this object
|
||||
/// </summary>
|
||||
/// <param name="property">A string specifying the property such as "Diameter" or "Radius"</param>
|
||||
/// <param name="variable">The variable to bind the to. This variable will appear in script output in lieu of the
|
||||
/// literal value of the property</param>
|
||||
public abstract void Bind(string property, Variable variable);
|
||||
#endregion
|
||||
|
||||
#region Operators
|
||||
|
||||
@ -95,5 +95,10 @@ namespace OSCADSharp.Scripting
|
||||
|
||||
return new Bounds(newBottomLeft, newTopRight);
|
||||
}
|
||||
|
||||
public override void Bind(string property, Variable variable)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,7 +12,7 @@ namespace OSCADSharp.Solids
|
||||
/// <summary>
|
||||
/// A Cube geometry
|
||||
/// </summary>
|
||||
public class Cube : OSCADObject, IBindable
|
||||
public class Cube : OSCADObject
|
||||
{
|
||||
#region Attributes
|
||||
private Vector3 size = new BindableVector(1, 1, 1, sizeSynonyms);
|
||||
@ -161,7 +161,7 @@ namespace OSCADSharp.Solids
|
||||
/// <param name="property">A string specifying the property such as "Diameter" or "Radius"</param>
|
||||
/// <param name="variable">The variable to bind the to. This variable will appear in script output in lieu of the
|
||||
/// literal value of the property</param>
|
||||
public void Bind(string property, Variable variable)
|
||||
public override void Bind(string property, Variable variable)
|
||||
{
|
||||
if (sizeSynonyms.ContainsKey(property.ToLower()))
|
||||
{
|
||||
|
||||
@ -12,7 +12,7 @@ namespace OSCADSharp.Solids
|
||||
/// <summary>
|
||||
/// A Cylinder geometry
|
||||
/// </summary>
|
||||
public class Cylinder : OSCADObject, IBindable
|
||||
public class Cylinder : OSCADObject
|
||||
{
|
||||
#region Attributes
|
||||
private bool center = false;
|
||||
@ -255,7 +255,7 @@ namespace OSCADSharp.Solids
|
||||
/// <param name="property">A string specifying the property such as "Diameter" or "Radius"</param>
|
||||
/// <param name="variable">The variable to bind the to. This variable will appear in script output in lieu of the
|
||||
/// literal value of the property</param>
|
||||
public void Bind(string property, Variable variable)
|
||||
public override void Bind(string property, Variable variable)
|
||||
{
|
||||
if (property.ToLower() == "center")
|
||||
{
|
||||
|
||||
@ -14,7 +14,7 @@ namespace OSCADSharp.Solids
|
||||
/// <summary>
|
||||
/// A Sphere geometry
|
||||
/// </summary>
|
||||
public class Sphere : OSCADObject, IBindable
|
||||
public class Sphere : OSCADObject
|
||||
{
|
||||
#region Attributes
|
||||
/// <summary>
|
||||
@ -146,7 +146,7 @@ namespace OSCADSharp.Solids
|
||||
/// <param name="property">A string specifying the property such as "Diameter" or "Radius"</param>
|
||||
/// <param name="variable">The variable to bind the to. This variable will appear in script output in lieu of the
|
||||
/// literal value of the property</param>
|
||||
public void Bind(string property, Variable variable)
|
||||
public override void Bind(string property, Variable variable)
|
||||
{
|
||||
this.bindings.Add<Sphere>(this, property, variable);
|
||||
}
|
||||
|
||||
@ -12,7 +12,7 @@ namespace OSCADSharp.Solids
|
||||
/// <summary>
|
||||
/// Create text using fonts installed on the local system or provided as separate font file.
|
||||
/// </summary>
|
||||
public class Text3D : OSCADObject, IBindable
|
||||
public class Text3D : OSCADObject
|
||||
{
|
||||
#region Attributes
|
||||
/// <summary>
|
||||
@ -165,7 +165,7 @@ namespace OSCADSharp.Solids
|
||||
/// <param name="property">A string specifying the property such as "Diameter" or "Radius"</param>
|
||||
/// <param name="variable">The variable to bind the to. This variable will appear in script output in lieu of the
|
||||
/// literal value of the property</param>
|
||||
public void Bind(string property, Variable variable)
|
||||
public override void Bind(string property, Variable variable)
|
||||
{
|
||||
this.bindings.Add<Text3D>(this, property, variable);
|
||||
}
|
||||
|
||||
@ -54,5 +54,10 @@ namespace OSCADSharp.Transforms
|
||||
{
|
||||
return this.obj.Bounds();
|
||||
}
|
||||
|
||||
public override void Bind(string property, Variable variable)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -57,5 +57,10 @@ namespace OSCADSharp.Transforms
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override void Bind(string property, Variable variable)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -88,5 +88,10 @@ namespace OSCADSharp.Transforms
|
||||
|
||||
return new Bounds(newBottomLeft, newTopRight);
|
||||
}
|
||||
|
||||
public override void Bind(string property, Variable variable)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -61,5 +61,10 @@ namespace OSCADSharp.Transforms
|
||||
|
||||
return new Bounds(oldBounds.BottomLeft * scaleMultiplier, oldBounds.TopRight * scaleMultiplier);
|
||||
}
|
||||
|
||||
public override void Bind(string property, Variable variable)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -55,5 +55,10 @@ namespace OSCADSharp.Transforms
|
||||
return new Bounds(Matrix.GetRotatedPoint(oldBounds.BottomLeft, this.Angle.X, this.Angle.Y, this.Angle.Z),
|
||||
Matrix.GetRotatedPoint(oldBounds.TopRight, this.Angle.X, this.Angle.Y, this.Angle.Z));
|
||||
}
|
||||
|
||||
public override void Bind(string property, Variable variable)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -54,5 +54,10 @@ namespace OSCADSharp.Transforms
|
||||
var oldBounds = obj.Bounds();
|
||||
return new Bounds(oldBounds.BottomLeft * this.ScaleFactor, oldBounds.TopRight * this.ScaleFactor);
|
||||
}
|
||||
|
||||
public override void Bind(string property, Variable variable)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -51,5 +51,10 @@ namespace OSCADSharp.Transforms
|
||||
var oldBounds = obj.Bounds();
|
||||
return new Bounds(oldBounds.BottomLeft + this.Vector, oldBounds.TopRight + this.Vector);
|
||||
}
|
||||
|
||||
public override void Bind(string property, Variable variable)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user