mirror of
https://github.com/eliasstepanik/OSCADSharpDotnet7.git
synced 2026-01-11 21:48:34 +00:00
Fix for Cube/TranslatedObject cloning of bindings
This commit is contained in:
parent
d8eb02ecc4
commit
6e4c018df7
@ -189,7 +189,8 @@ namespace OSCADSharp.UnitTests
|
||||
|
||||
string script = clone.ToString();
|
||||
|
||||
|
||||
Assert.IsTrue(script.Contains("translate(v = [xOffset"));
|
||||
Assert.IsTrue(script.Contains("size = [15, 5, myHeight]"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -42,6 +42,14 @@ namespace OSCADSharp.Bindings
|
||||
this.bindings.Add<BindableBoolean>(this, property, stringifiedVar);
|
||||
}
|
||||
|
||||
public BindableBoolean Clone()
|
||||
{
|
||||
var clone = new BindableBoolean(this.boundProperty);
|
||||
clone.bindings = this.bindings;
|
||||
|
||||
return clone;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return this.bindings.Get(this.boundProperty).BoundVariable.Name;
|
||||
|
||||
@ -56,10 +56,10 @@ namespace OSCADSharp.Bindings
|
||||
|
||||
public new BindableVector Clone()
|
||||
{
|
||||
return new BindableVector(base.Clone())
|
||||
{
|
||||
bindings = this.bindings
|
||||
};
|
||||
var clone = new BindableVector(base.Clone());
|
||||
clone.bindings = this.bindings.Clone();
|
||||
|
||||
return clone;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -114,13 +114,19 @@ namespace OSCADSharp.Solids
|
||||
/// <returns></returns>
|
||||
public override OSCADObject Clone()
|
||||
{
|
||||
return new Cube()
|
||||
var size = this.size as BindableVector;
|
||||
var center = this.centerBinding.Clone();
|
||||
|
||||
var clone = new Cube()
|
||||
{
|
||||
Name = this.Name,
|
||||
Size = ((BindableVector)this.Size).Clone(),
|
||||
Center = this.Center,
|
||||
size = size.Clone(),
|
||||
center = this.Center,
|
||||
centerBinding = center,
|
||||
bindings = this.bindings.Clone()
|
||||
};
|
||||
|
||||
return clone;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -15,7 +15,7 @@ namespace OSCADSharp.Transforms
|
||||
internal class TranslatedObject : SingleStatementObject
|
||||
{
|
||||
internal Vector3 Vector { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Creates a translated object
|
||||
/// </summary>
|
||||
@ -40,6 +40,10 @@ namespace OSCADSharp.Transforms
|
||||
this.BindIfVariableNotNull("z", z);
|
||||
}
|
||||
|
||||
internal TranslatedObject(OSCADObject obj) : base(obj)
|
||||
{
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
string translation = this.bindings.Contains("vector") ? this.bindings.Get("vector").BoundVariable.Name : this.Vector.ToString();
|
||||
@ -51,11 +55,16 @@ namespace OSCADSharp.Transforms
|
||||
|
||||
public override OSCADObject Clone()
|
||||
{
|
||||
return new TranslatedObject(this.obj.Clone(), this.Vector)
|
||||
var bindableVec = this.Vector as BindableVector;
|
||||
|
||||
var clone = new TranslatedObject(this.obj.Clone())
|
||||
{
|
||||
Name = this.Name,
|
||||
bindings = this.bindings.Clone()
|
||||
bindings = this.bindings.Clone(),
|
||||
Vector = bindableVec != null ? bindableVec.Clone() : this.Vector.Clone()
|
||||
};
|
||||
|
||||
return clone;
|
||||
}
|
||||
|
||||
public override Vector3 Position()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user