Getting interaction volumes to be able to be scripted in automation runner
This commit is contained in:
parent
55e335093d
commit
b9cc00c2e9
6 changed files with 86 additions and 43 deletions
|
|
@ -63,6 +63,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
public MoveInZControl(IInteractionVolumeContext context)
|
||||
: base(context)
|
||||
{
|
||||
Name = "MoveInZControl";
|
||||
zHeightDisplayInfo = new ValueDisplayInfo()
|
||||
{
|
||||
ForceHide = () =>
|
||||
|
|
|
|||
|
|
@ -48,6 +48,8 @@ namespace MatterHackers.MeshVisualizer
|
|||
public bool MouseDownOnControl;
|
||||
public Matrix4X4 TotalTransform = Matrix4X4.Identity;
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
private bool mouseOver = false;
|
||||
|
||||
public InteractionVolume(IInteractionVolumeContext meshViewerToDrawWith)
|
||||
|
|
|
|||
|
|
@ -162,6 +162,51 @@ namespace MatterHackers.MeshVisualizer
|
|||
|
||||
public override void FindNamedChildrenRecursive(string nameToSearchFor, List<WidgetAndPosition> foundChildren, RectangleDouble touchingBounds, SearchType seachType, bool allowInvalidItems = true)
|
||||
{
|
||||
foreach (InteractionVolume child in interactionLayer.InteractionVolumes)
|
||||
{
|
||||
string object3DName = child.Name;
|
||||
|
||||
bool nameFound = false;
|
||||
|
||||
if (seachType == SearchType.Exact)
|
||||
{
|
||||
if (object3DName == nameToSearchFor)
|
||||
{
|
||||
nameFound = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (nameToSearchFor == ""
|
||||
|| object3DName.Contains(nameToSearchFor))
|
||||
{
|
||||
nameFound = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (nameFound)
|
||||
{
|
||||
AxisAlignedBoundingBox bounds = child.CollisionVolume.GetAxisAlignedBoundingBox();
|
||||
bounds = bounds.NewTransformed(child.TotalTransform);
|
||||
|
||||
RectangleDouble screenBoundsOfObject3D = RectangleDouble.ZeroIntersection;
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
screenBoundsOfObject3D.ExpandToInclude(this.World.GetScreenPosition(bounds.GetTopCorner(i)));
|
||||
screenBoundsOfObject3D.ExpandToInclude(this.World.GetScreenPosition(bounds.GetBottomCorner(i)));
|
||||
}
|
||||
|
||||
if (touchingBounds.IsTouching(screenBoundsOfObject3D))
|
||||
{
|
||||
Vector3 renderPosition = bounds.Center;
|
||||
Vector2 objectCenterScreenSpace = this.World.GetScreenPosition(renderPosition);
|
||||
Point2D screenPositionOfObject3D = new Point2D((int)objectCenterScreenSpace.x, (int)objectCenterScreenSpace.y);
|
||||
|
||||
foundChildren.Add(new WidgetAndPosition(this, screenPositionOfObject3D, object3DName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var child in scene.Children)
|
||||
{
|
||||
string object3DName = child.Name;
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 97b5ea15d8c467718a4eedaa79142101ce1ab30b
|
||||
Subproject commit c0e756961265b558607b0dab418dab1e372e8c09
|
||||
|
|
@ -1 +1 @@
|
|||
Subproject commit 9040a33c4af85d8ff9bde011d9043b381b1ca183
|
||||
Subproject commit db24fd8c66bbf2034b0f6162e5c35c00282c4a46
|
||||
|
|
@ -233,7 +233,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
}
|
||||
|
||||
[Test]
|
||||
public async Task MirrorUndoDo()
|
||||
public async Task ValidateDoUndoOnSceneOperations()
|
||||
{
|
||||
await MatterControlUtilities.RunTest((testRunner) =>
|
||||
{
|
||||
|
|
@ -243,55 +243,27 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
var view3D = testRunner.GetWidgetByName("View3DWidget", out _) as View3DWidget;
|
||||
var scene1 = view3D.InteractionLayer.Scene;
|
||||
|
||||
testRunner.AddDefaultFileToBedplate(partName: "Row Item MatterControl - Coin.stl");
|
||||
|
||||
// test z translation
|
||||
RunDoUndoTest(testRunner, scene1, (scene) =>
|
||||
{
|
||||
testRunner.AddDefaultFileToBedplate(partName: "Row Item MatterControl - Coin.stl");
|
||||
// TODO: assert the part is centered on the bed
|
||||
|
||||
testRunner.ClickByName("MatterControl - Coin.stl");
|
||||
Assert.IsNotNull(scene.SelectedItem);
|
||||
AddCoinToBed(testRunner, scene);
|
||||
},
|
||||
(scene) =>
|
||||
{
|
||||
testRunner.ClickByName("Mirror Button");
|
||||
testRunner.ClickByName("Mirror Button X");
|
||||
testRunner.DragDropByName("MoveInZControl", "MoveInZControl", offsetDrop: new Point2D(0, 40));
|
||||
});
|
||||
|
||||
// test mirror operations
|
||||
TestMirrorDoUndo(testRunner, scene1, "Mirror Button X");
|
||||
TestMirrorDoUndo(testRunner, scene1, "Mirror Button Y");
|
||||
TestMirrorDoUndo(testRunner, scene1, "Mirror Button Z");
|
||||
|
||||
// test drag x y translation
|
||||
RunDoUndoTest(testRunner, scene1, (scene) =>
|
||||
{
|
||||
testRunner.AddSelectedItemToBedplate();
|
||||
testRunner.Delay(.1);
|
||||
|
||||
testRunner.ClickByName("MatterControl - Coin.stl");
|
||||
Assert.IsNotNull(scene.SelectedItem);
|
||||
},
|
||||
(scene) =>
|
||||
{
|
||||
testRunner.ClickByName("Mirror Button");
|
||||
testRunner.ClickByName("Mirror Button Y");
|
||||
});
|
||||
|
||||
RunDoUndoTest(testRunner, scene1, (scene) =>
|
||||
{
|
||||
testRunner.AddSelectedItemToBedplate();
|
||||
testRunner.Delay(.1);
|
||||
|
||||
testRunner.ClickByName("MatterControl - Coin.stl");
|
||||
Assert.IsNotNull(scene.SelectedItem);
|
||||
},
|
||||
(scene) =>
|
||||
{
|
||||
testRunner.ClickByName("Mirror Button");
|
||||
testRunner.ClickByName("Mirror Button Z");
|
||||
});
|
||||
|
||||
RunDoUndoTest(testRunner, scene1, (scene) =>
|
||||
{
|
||||
testRunner.AddSelectedItemToBedplate();
|
||||
testRunner.Delay(.1);
|
||||
|
||||
testRunner.ClickByName("MatterControl - Coin.stl");
|
||||
Assert.IsNotNull(scene.SelectedItem);
|
||||
AddCoinToBed(testRunner, scene);
|
||||
},
|
||||
(scene) =>
|
||||
{
|
||||
|
|
@ -305,6 +277,29 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
}, overrideWidth: 1300, maxTimeToRun: 200);
|
||||
}
|
||||
|
||||
private static void AddCoinToBed(AutomationRunner testRunner, InteractiveScene scene)
|
||||
{
|
||||
testRunner.AddSelectedItemToBedplate();
|
||||
testRunner.Delay(.1);
|
||||
// TODO: assert the part is centered on the bed
|
||||
|
||||
testRunner.ClickByName("MatterControl - Coin.stl");
|
||||
Assert.IsNotNull(scene.SelectedItem);
|
||||
}
|
||||
|
||||
private void TestMirrorDoUndo(AutomationRunner testRunner, InteractiveScene scene1, string mirrorButtonName)
|
||||
{
|
||||
RunDoUndoTest(testRunner, scene1, (scene) =>
|
||||
{
|
||||
AddCoinToBed(testRunner, scene);
|
||||
},
|
||||
(scene) =>
|
||||
{
|
||||
testRunner.ClickByName("Mirror Button");
|
||||
testRunner.ClickByName(mirrorButtonName);
|
||||
});
|
||||
}
|
||||
|
||||
private void RunDoUndoTest(AutomationRunner testRunner,
|
||||
InteractiveScene scene,
|
||||
Action<InteractiveScene> InitializeTest,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue