mirror of
https://github.com/eliasstepanik/OSCADSharpDotnet7.git
synced 2026-01-17 00:18:35 +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();
|
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);
|
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()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return this.bindings.Get(this.boundProperty).BoundVariable.Name;
|
return this.bindings.Get(this.boundProperty).BoundVariable.Name;
|
||||||
|
|||||||
@ -56,10 +56,10 @@ namespace OSCADSharp.Bindings
|
|||||||
|
|
||||||
public new BindableVector Clone()
|
public new BindableVector Clone()
|
||||||
{
|
{
|
||||||
return new BindableVector(base.Clone())
|
var clone = new BindableVector(base.Clone());
|
||||||
{
|
clone.bindings = this.bindings.Clone();
|
||||||
bindings = this.bindings
|
|
||||||
};
|
return clone;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -114,13 +114,19 @@ namespace OSCADSharp.Solids
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public override OSCADObject Clone()
|
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,
|
Name = this.Name,
|
||||||
Size = ((BindableVector)this.Size).Clone(),
|
size = size.Clone(),
|
||||||
Center = this.Center,
|
center = this.Center,
|
||||||
|
centerBinding = center,
|
||||||
bindings = this.bindings.Clone()
|
bindings = this.bindings.Clone()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
return clone;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@ -15,7 +15,7 @@ namespace OSCADSharp.Transforms
|
|||||||
internal class TranslatedObject : SingleStatementObject
|
internal class TranslatedObject : SingleStatementObject
|
||||||
{
|
{
|
||||||
internal Vector3 Vector { get; set; }
|
internal Vector3 Vector { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a translated object
|
/// Creates a translated object
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -40,6 +40,10 @@ namespace OSCADSharp.Transforms
|
|||||||
this.BindIfVariableNotNull("z", z);
|
this.BindIfVariableNotNull("z", z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal TranslatedObject(OSCADObject obj) : base(obj)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
string translation = this.bindings.Contains("vector") ? this.bindings.Get("vector").BoundVariable.Name : this.Vector.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()
|
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,
|
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()
|
public override Vector3 Position()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user