diff --git a/PartPreviewWindow/View3DTransfromPart.cs b/PartPreviewWindow/View3DTransfromPart.cs index fad2d4158..e0b1fc40e 100644 --- a/PartPreviewWindow/View3DTransfromPart.cs +++ b/PartPreviewWindow/View3DTransfromPart.cs @@ -114,6 +114,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow List asynchPlatingDataList = new List(); List MeshExtraData; + bool autoRotateEnabled = true; public Matrix4X4 SelectedMeshTransform { @@ -191,6 +192,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow MeshSelectInfo meshSelectInfo; public override void OnMouseDown(MouseEventArgs mouseEvent) { + autoRotateEnabled = false; base.OnMouseDown(mouseEvent); if (meshViewerWidget.TrackballTumbleWidget.UnderMouseState == Agg.UI.UnderMouseState.FirstUnderMouse) { @@ -433,6 +435,31 @@ namespace MatterHackers.MatterControl.PartPreviewWindow meshViewerWidget.LoadMesh(printItemWrapper.FileLocation); meshViewerWidget.LoadDone += new EventHandler(meshViewerWidget_LoadDone); } + + UiThread.RunOnIdle(AutoSpin); + } + + Stopwatch timeSinceLastSpin = new Stopwatch(); + void AutoSpin(object state) + { + if (!WidgetHasBeenClosed && autoRotateEnabled) + { + // add it back in to keep it running. + UiThread.RunOnIdle(AutoSpin); + + if (!timeSinceLastSpin.IsRunning || timeSinceLastSpin.ElapsedMilliseconds > 50) + { + timeSinceLastSpin.Restart(); + + Quaternion currentRotation = meshViewerWidget.TrackballTumbleWidget.TrackBallController.CurrentRotation.GetRotation(); + Quaternion invertedRotation = Quaternion.Invert(currentRotation); + + Quaternion rotateAboutZ = Quaternion.FromEulerAngles(new Vector3(0, 0, .01)); + rotateAboutZ = invertedRotation * rotateAboutZ * currentRotation; + meshViewerWidget.TrackballTumbleWidget.TrackBallController.Rotate(rotateAboutZ); + Invalidate(); + } + } } private void MakeCopyOfMesh()