mirror of
https://github.com/eliasstepanik/OSCADSharpDotnet7.git
synced 2026-01-24 03:38:26 +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);
|
Variables.Global.Add("cubeWidth", 10);
|
||||||
|
|
||||||
OSCADObject obj = new Sphere();
|
OSCADObject obj = new Sphere();
|
||||||
((Sphere)obj).Bind("Radius", Variables.Global["sphereRadius"]);
|
obj.Bind("Radius", Variables.Global["sphereRadius"]);
|
||||||
|
|
||||||
var cube = new Cube();
|
var cube = new Cube();
|
||||||
cube.Bind("Width", Variables.Global["cubeWidth"]);
|
cube.Bind("Width", Variables.Global["cubeWidth"]);
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using OSCADSharp.Booleans;
|
using OSCADSharp.Bindings;
|
||||||
|
using OSCADSharp.Booleans;
|
||||||
using OSCADSharp.Files;
|
using OSCADSharp.Files;
|
||||||
using OSCADSharp.Scripting;
|
using OSCADSharp.Scripting;
|
||||||
using OSCADSharp.Spatial;
|
using OSCADSharp.Spatial;
|
||||||
@ -16,7 +17,7 @@ namespace OSCADSharp
|
|||||||
/// Represents any Object or collection of objects that becomes am
|
/// Represents any Object or collection of objects that becomes am
|
||||||
/// an OpenSCAD script when converted to a string.
|
/// an OpenSCAD script when converted to a string.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class OSCADObject
|
public abstract class OSCADObject : IBindable
|
||||||
{
|
{
|
||||||
#region Attributes
|
#region Attributes
|
||||||
private uint id = Ids.Get();
|
private uint id = Ids.Get();
|
||||||
@ -340,6 +341,14 @@ namespace OSCADSharp
|
|||||||
|
|
||||||
return Dependencies.FileInvokerFactory(filePath);
|
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
|
#endregion
|
||||||
|
|
||||||
#region Operators
|
#region Operators
|
||||||
|
|||||||
@ -95,5 +95,10 @@ namespace OSCADSharp.Scripting
|
|||||||
|
|
||||||
return new Bounds(newBottomLeft, newTopRight);
|
return new Bounds(newBottomLeft, newTopRight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void Bind(string property, Variable variable)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,7 +12,7 @@ namespace OSCADSharp.Solids
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// A Cube geometry
|
/// A Cube geometry
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class Cube : OSCADObject, IBindable
|
public class Cube : OSCADObject
|
||||||
{
|
{
|
||||||
#region Attributes
|
#region Attributes
|
||||||
private Vector3 size = new BindableVector(1, 1, 1, sizeSynonyms);
|
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="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
|
/// <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>
|
/// 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()))
|
if (sizeSynonyms.ContainsKey(property.ToLower()))
|
||||||
{
|
{
|
||||||
|
|||||||
@ -12,7 +12,7 @@ namespace OSCADSharp.Solids
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// A Cylinder geometry
|
/// A Cylinder geometry
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class Cylinder : OSCADObject, IBindable
|
public class Cylinder : OSCADObject
|
||||||
{
|
{
|
||||||
#region Attributes
|
#region Attributes
|
||||||
private bool center = false;
|
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="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
|
/// <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>
|
/// 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")
|
if (property.ToLower() == "center")
|
||||||
{
|
{
|
||||||
|
|||||||
@ -14,7 +14,7 @@ namespace OSCADSharp.Solids
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// A Sphere geometry
|
/// A Sphere geometry
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class Sphere : OSCADObject, IBindable
|
public class Sphere : OSCADObject
|
||||||
{
|
{
|
||||||
#region Attributes
|
#region Attributes
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -146,7 +146,7 @@ namespace OSCADSharp.Solids
|
|||||||
/// <param name="property">A string specifying the property such as "Diameter" or "Radius"</param>
|
/// <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
|
/// <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>
|
/// 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);
|
this.bindings.Add<Sphere>(this, property, variable);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,7 +12,7 @@ namespace OSCADSharp.Solids
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create text using fonts installed on the local system or provided as separate font file.
|
/// Create text using fonts installed on the local system or provided as separate font file.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class Text3D : OSCADObject, IBindable
|
public class Text3D : OSCADObject
|
||||||
{
|
{
|
||||||
#region Attributes
|
#region Attributes
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -165,7 +165,7 @@ namespace OSCADSharp.Solids
|
|||||||
/// <param name="property">A string specifying the property such as "Diameter" or "Radius"</param>
|
/// <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
|
/// <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>
|
/// 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);
|
this.bindings.Add<Text3D>(this, property, variable);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -54,5 +54,10 @@ namespace OSCADSharp.Transforms
|
|||||||
{
|
{
|
||||||
return this.obj.Bounds();
|
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();
|
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);
|
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);
|
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),
|
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));
|
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();
|
var oldBounds = obj.Bounds();
|
||||||
return new Bounds(oldBounds.BottomLeft * this.ScaleFactor, oldBounds.TopRight * this.ScaleFactor);
|
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();
|
var oldBounds = obj.Bounds();
|
||||||
return new Bounds(oldBounds.BottomLeft + this.Vector, oldBounds.TopRight + this.Vector);
|
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