2014-10-15 16:57:26 -07:00
|
|
|
|
/*
|
|
|
|
|
|
Copyright (c) 2014, Kevin Pope
|
|
|
|
|
|
All rights reserved.
|
|
|
|
|
|
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without
|
2015-04-08 15:20:10 -07:00
|
|
|
|
modification, are permitted provided that the following conditions are met:
|
2014-10-15 16:57:26 -07:00
|
|
|
|
|
|
|
|
|
|
1. Redistributions of source code must retain the above copyright notice, this
|
2015-04-08 15:20:10 -07:00
|
|
|
|
list of conditions and the following disclaimer.
|
2014-10-15 16:57:26 -07:00
|
|
|
|
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
|
|
this list of conditions and the following disclaimer in the documentation
|
2015-04-08 15:20:10 -07:00
|
|
|
|
and/or other materials provided with the distribution.
|
2014-10-15 16:57:26 -07:00
|
|
|
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
|
|
|
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
|
|
|
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
|
|
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
|
|
|
|
|
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
|
|
|
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
|
|
|
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
|
|
|
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
|
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
|
|
|
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
|
|
|
|
|
|
The views and conclusions contained in the software and documentation are those
|
2015-04-08 15:20:10 -07:00
|
|
|
|
of the authors and should not be interpreted as representing official policies,
|
2014-10-15 16:57:26 -07:00
|
|
|
|
either expressed or implied, of the FreeBSD Project.
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
using MatterHackers.Agg;
|
|
|
|
|
|
using MatterHackers.Agg.Image;
|
2016-05-15 22:12:35 -07:00
|
|
|
|
using MatterHackers.Agg.ImageProcessing;
|
2014-10-15 16:57:26 -07:00
|
|
|
|
using MatterHackers.Agg.PlatformAbstract;
|
|
|
|
|
|
using MatterHackers.Agg.UI;
|
|
|
|
|
|
using MatterHackers.Localizations;
|
2016-01-13 07:39:22 -08:00
|
|
|
|
using MatterHackers.MatterControl.CustomWidgets;
|
2014-10-15 16:57:26 -07:00
|
|
|
|
using MatterHackers.MatterControl.PrinterCommunication;
|
2016-04-18 11:31:31 -07:00
|
|
|
|
using MatterHackers.MatterControl.SlicerConfiguration;
|
2015-11-23 13:08:21 -08:00
|
|
|
|
using MatterHackers.MatterControl.Utilities;
|
2015-04-08 15:20:10 -07:00
|
|
|
|
using MatterHackers.VectorMath;
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
2015-11-23 13:08:21 -08:00
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
|
using System.Threading;
|
|
|
|
|
|
using System.Threading.Tasks;
|
2014-10-15 16:57:26 -07:00
|
|
|
|
|
|
|
|
|
|
namespace MatterHackers.MatterControl.PrinterControls
|
|
|
|
|
|
{
|
2015-04-08 15:20:10 -07:00
|
|
|
|
public class MovementControls : ControlWidgetBase
|
|
|
|
|
|
{
|
2015-11-23 10:49:08 -08:00
|
|
|
|
public FlowLayoutWidget manualControlsLayout;
|
2015-04-08 15:20:10 -07:00
|
|
|
|
private Button disableMotors;
|
2015-11-23 10:49:08 -08:00
|
|
|
|
private EditManualMovementSpeedsWindow editManualMovementSettingsWindow;
|
2015-04-08 15:20:10 -07:00
|
|
|
|
private Button homeAllButton;
|
|
|
|
|
|
private Button homeXButton;
|
|
|
|
|
|
private Button homeYButton;
|
|
|
|
|
|
private Button homeZButton;
|
2016-01-13 07:39:22 -08:00
|
|
|
|
internal JogControls jogControls;
|
2015-11-23 10:49:08 -08:00
|
|
|
|
private AltGroupBox movementControlsGroupBox;
|
2015-11-23 13:08:21 -08:00
|
|
|
|
|
2016-01-13 07:39:22 -08:00
|
|
|
|
// Provides a list of DisableableWidgets controls that can be toggled on/off at runtime
|
|
|
|
|
|
internal List<DisableableWidget> DisableableWidgets = new List<DisableableWidget>();
|
|
|
|
|
|
|
|
|
|
|
|
// Displays the current baby step offset stream values
|
|
|
|
|
|
private TextWidget offsetStreamLabel;
|
|
|
|
|
|
|
2015-11-23 13:08:21 -08:00
|
|
|
|
private LimitCallingFrequency reportDestinationChanged = null;
|
|
|
|
|
|
|
2016-12-29 06:55:12 -08:00
|
|
|
|
private EventHandler unregisterEvents;
|
2015-11-23 13:08:21 -08:00
|
|
|
|
|
2016-07-18 14:15:37 -07:00
|
|
|
|
public static double XSpeed => ActiveSliceSettings.Instance.Helpers.GetMovementSpeeds()["x"];
|
2015-08-25 14:10:33 -07:00
|
|
|
|
|
2016-07-18 14:15:37 -07:00
|
|
|
|
public static double YSpeed => ActiveSliceSettings.Instance.Helpers.GetMovementSpeeds()["y"];
|
2015-11-23 10:49:08 -08:00
|
|
|
|
|
2016-07-18 14:15:37 -07:00
|
|
|
|
public static double ZSpeed => ActiveSliceSettings.Instance.Helpers.GetMovementSpeeds()["z"];
|
2015-11-23 10:49:08 -08:00
|
|
|
|
|
|
|
|
|
|
public static double EFeedRate(int extruderIndex)
|
|
|
|
|
|
{
|
2016-07-18 14:15:37 -07:00
|
|
|
|
var movementSpeeds = ActiveSliceSettings.Instance.Helpers.GetMovementSpeeds();
|
2016-06-17 09:29:11 -07:00
|
|
|
|
|
|
|
|
|
|
string extruderIndexKey = "e" + extruderIndex.ToString();
|
|
|
|
|
|
if (movementSpeeds.ContainsKey(extruderIndexKey))
|
2015-11-23 10:49:08 -08:00
|
|
|
|
{
|
2016-06-17 09:29:11 -07:00
|
|
|
|
return movementSpeeds[extruderIndexKey];
|
2015-11-23 10:49:08 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
2016-06-17 09:29:11 -07:00
|
|
|
|
return movementSpeeds["e0"];
|
2015-11-23 10:49:08 -08:00
|
|
|
|
}
|
2015-04-08 15:20:10 -07:00
|
|
|
|
|
2017-02-03 13:06:08 -08:00
|
|
|
|
public override void OnClosed(ClosedEventArgs e)
|
2015-11-23 13:08:21 -08:00
|
|
|
|
{
|
2016-04-18 11:31:31 -07:00
|
|
|
|
unregisterEvents?.Invoke(this, null);
|
2015-11-23 13:08:21 -08:00
|
|
|
|
base.OnClosed(e);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2016-01-13 07:39:22 -08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Helper method to create DisableableWidget containers and populate the DisableableWidgets local property.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="widget">The widget to wrap.</param>
|
|
|
|
|
|
private DisableableWidget CreateDisableableContainer(GuiWidget widget)
|
|
|
|
|
|
{
|
|
|
|
|
|
var container = new DisableableWidget();
|
|
|
|
|
|
container.AddChild(widget);
|
|
|
|
|
|
DisableableWidgets.Add(container);
|
|
|
|
|
|
|
|
|
|
|
|
return container;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2016-11-30 13:31:19 -08:00
|
|
|
|
public MovementControls()
|
2015-04-08 15:20:10 -07:00
|
|
|
|
{
|
|
|
|
|
|
Button editButton;
|
2016-01-13 15:37:03 -08:00
|
|
|
|
movementControlsGroupBox = new AltGroupBox(textImageButtonFactory.GenerateGroupBoxLabelWithEdit(new TextWidget("Movement".Localize(), pointSize: 18, textColor: ActiveTheme.Instance.SecondaryAccentColor), out editButton));
|
2015-04-08 15:20:10 -07:00
|
|
|
|
editButton.Click += (sender, e) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
if (editManualMovementSettingsWindow == null)
|
|
|
|
|
|
{
|
2016-07-18 14:15:37 -07:00
|
|
|
|
editManualMovementSettingsWindow = new EditManualMovementSpeedsWindow("Movement Speeds".Localize(), ActiveSliceSettings.Instance.Helpers.GetMovementSpeedsString(), SetMovementSpeeds);
|
2017-02-16 10:38:03 -08:00
|
|
|
|
editManualMovementSettingsWindow.Closed += (s, e2) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
editManualMovementSettingsWindow = null;
|
|
|
|
|
|
};
|
2015-04-08 15:20:10 -07:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
editManualMovementSettingsWindow.BringToFront();
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
movementControlsGroupBox.Margin = new BorderDouble(0);
|
|
|
|
|
|
movementControlsGroupBox.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
|
|
|
|
|
movementControlsGroupBox.HAnchor |= Agg.UI.HAnchor.ParentLeftRight;
|
|
|
|
|
|
movementControlsGroupBox.VAnchor = Agg.UI.VAnchor.FitToChildren;
|
|
|
|
|
|
|
2015-08-25 14:10:33 -07:00
|
|
|
|
jogControls = new JogControls(new XYZColors());
|
|
|
|
|
|
jogControls.Margin = new BorderDouble(0);
|
2015-04-08 15:20:10 -07:00
|
|
|
|
{
|
2015-08-25 14:10:33 -07:00
|
|
|
|
manualControlsLayout = new FlowLayoutWidget(FlowDirection.TopToBottom);
|
2015-04-08 15:20:10 -07:00
|
|
|
|
manualControlsLayout.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
|
|
|
|
|
|
manualControlsLayout.VAnchor = Agg.UI.VAnchor.FitToChildren;
|
2016-05-06 17:56:27 -07:00
|
|
|
|
manualControlsLayout.Padding = new BorderDouble(3, 5, 3, 0);
|
2015-04-08 15:20:10 -07:00
|
|
|
|
{
|
2015-08-25 14:10:33 -07:00
|
|
|
|
FlowLayoutWidget leftToRightContainer = new FlowLayoutWidget(FlowDirection.LeftToRight);
|
|
|
|
|
|
|
2016-01-13 07:39:22 -08:00
|
|
|
|
manualControlsLayout.AddChild(CreateDisableableContainer(GetHomeButtonBar()));
|
|
|
|
|
|
manualControlsLayout.AddChild(CreateDisableableContainer(CreateSeparatorLine()));
|
2015-08-25 14:10:33 -07:00
|
|
|
|
manualControlsLayout.AddChild(jogControls);
|
2016-01-13 07:39:22 -08:00
|
|
|
|
////manualControlsLayout.AddChild(leftToRightContainer);
|
|
|
|
|
|
manualControlsLayout.AddChild(CreateDisableableContainer(CreateSeparatorLine()));
|
|
|
|
|
|
manualControlsLayout.AddChild(CreateDisableableContainer(GetHWDestinationBar()));
|
|
|
|
|
|
manualControlsLayout.AddChild(CreateDisableableContainer(CreateSeparatorLine()));
|
2015-04-08 15:20:10 -07:00
|
|
|
|
}
|
2015-11-23 10:49:08 -08:00
|
|
|
|
|
2015-04-08 15:20:10 -07:00
|
|
|
|
movementControlsGroupBox.AddChild(manualControlsLayout);
|
|
|
|
|
|
}
|
2015-11-23 10:49:08 -08:00
|
|
|
|
|
2015-04-08 15:20:10 -07:00
|
|
|
|
this.AddChild(movementControlsGroupBox);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-02-16 10:38:03 -08:00
|
|
|
|
private static void SetMovementSpeeds(string speedString)
|
2015-11-23 10:49:08 -08:00
|
|
|
|
{
|
2017-02-16 10:38:03 -08:00
|
|
|
|
if (!string.IsNullOrEmpty(speedString))
|
2015-11-23 10:49:08 -08:00
|
|
|
|
{
|
2017-02-16 10:38:03 -08:00
|
|
|
|
ActiveSliceSettings.Instance.SetValue(SettingsKey.manual_movement_speeds, speedString);
|
2015-11-23 10:49:08 -08:00
|
|
|
|
ApplicationController.Instance.ReloadAdvancedControlsPanel();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2015-04-08 15:20:10 -07:00
|
|
|
|
private FlowLayoutWidget GetHomeButtonBar()
|
|
|
|
|
|
{
|
|
|
|
|
|
FlowLayoutWidget homeButtonBar = new FlowLayoutWidget();
|
|
|
|
|
|
homeButtonBar.HAnchor = HAnchor.ParentLeftRight;
|
2016-05-06 17:56:27 -07:00
|
|
|
|
homeButtonBar.Margin = new BorderDouble(3, 0, 3, 6);
|
2015-04-08 15:20:10 -07:00
|
|
|
|
homeButtonBar.Padding = new BorderDouble(0);
|
|
|
|
|
|
|
|
|
|
|
|
textImageButtonFactory.borderWidth = 1;
|
|
|
|
|
|
textImageButtonFactory.normalBorderColor = new RGBA_Bytes(ActiveTheme.Instance.PrimaryTextColor, 200);
|
|
|
|
|
|
textImageButtonFactory.hoverBorderColor = new RGBA_Bytes(ActiveTheme.Instance.PrimaryTextColor, 200);
|
|
|
|
|
|
|
2016-05-15 22:12:35 -07:00
|
|
|
|
ImageBuffer helpIconImage = StaticData.Instance.LoadIcon("icon_home_white_24x24.png", 24, 24);
|
2016-05-16 17:56:52 -07:00
|
|
|
|
if (ActiveTheme.Instance.IsDarkTheme)
|
2016-05-15 22:12:35 -07:00
|
|
|
|
{
|
|
|
|
|
|
helpIconImage.InvertLightness();
|
|
|
|
|
|
}
|
2015-04-08 15:20:10 -07:00
|
|
|
|
ImageWidget homeIconImageWidget = new ImageWidget(helpIconImage);
|
2016-05-15 22:12:35 -07:00
|
|
|
|
|
2016-05-06 17:56:27 -07:00
|
|
|
|
homeIconImageWidget.Margin = new BorderDouble(0, 0, 6, 0);
|
|
|
|
|
|
homeIconImageWidget.OriginRelativeParent += new Vector2(0, 2) * GuiWidget.DeviceScale;
|
2015-04-08 15:20:10 -07:00
|
|
|
|
RGBA_Bytes oldColor = this.textImageButtonFactory.normalFillColor;
|
|
|
|
|
|
textImageButtonFactory.normalFillColor = new RGBA_Bytes(180, 180, 180);
|
2017-01-04 07:23:30 -08:00
|
|
|
|
homeAllButton = textImageButtonFactory.Generate("ALL".Localize());
|
2015-04-08 15:20:10 -07:00
|
|
|
|
this.textImageButtonFactory.normalFillColor = oldColor;
|
2017-01-04 10:25:19 -08:00
|
|
|
|
homeAllButton.ToolTipText = "Home X, Y and Z".Localize();
|
2016-05-06 17:56:27 -07:00
|
|
|
|
homeAllButton.Margin = new BorderDouble(0, 0, 6, 0);
|
2017-01-17 14:47:04 -08:00
|
|
|
|
homeAllButton.Click += homeAll_Click;
|
2014-10-15 16:57:26 -07:00
|
|
|
|
|
2016-05-06 17:56:27 -07:00
|
|
|
|
textImageButtonFactory.FixedWidth = (int)homeAllButton.Width * GuiWidget.DeviceScale;
|
2015-04-08 15:20:10 -07:00
|
|
|
|
homeXButton = textImageButtonFactory.Generate("X", centerText: true);
|
2017-01-04 10:25:19 -08:00
|
|
|
|
homeXButton.ToolTipText = "Home X".Localize();
|
2016-05-06 17:56:27 -07:00
|
|
|
|
homeXButton.Margin = new BorderDouble(0, 0, 6, 0);
|
2017-01-17 14:47:04 -08:00
|
|
|
|
homeXButton.Click += homeXButton_Click;
|
2015-04-08 15:20:10 -07:00
|
|
|
|
|
|
|
|
|
|
homeYButton = textImageButtonFactory.Generate("Y", centerText: true);
|
2017-01-04 10:25:19 -08:00
|
|
|
|
homeYButton.ToolTipText = "Home Y".Localize();
|
2016-05-06 17:56:27 -07:00
|
|
|
|
homeYButton.Margin = new BorderDouble(0, 0, 6, 0);
|
2017-01-17 14:47:04 -08:00
|
|
|
|
homeYButton.Click += homeYButton_Click;
|
2015-04-08 15:20:10 -07:00
|
|
|
|
|
|
|
|
|
|
homeZButton = textImageButtonFactory.Generate("Z", centerText: true);
|
2017-01-04 10:25:19 -08:00
|
|
|
|
homeZButton.ToolTipText = "Home Z".Localize();
|
2016-05-06 17:56:27 -07:00
|
|
|
|
homeZButton.Margin = new BorderDouble(0, 0, 6, 0);
|
2017-01-17 14:47:04 -08:00
|
|
|
|
homeZButton.Click += homeZButton_Click;
|
2015-04-08 15:20:10 -07:00
|
|
|
|
|
|
|
|
|
|
textImageButtonFactory.normalFillColor = RGBA_Bytes.White;
|
|
|
|
|
|
textImageButtonFactory.FixedWidth = 0;
|
|
|
|
|
|
|
|
|
|
|
|
disableMotors = textImageButtonFactory.Generate("Release".Localize().ToUpper());
|
|
|
|
|
|
disableMotors.Margin = new BorderDouble(0);
|
2017-02-16 10:38:03 -08:00
|
|
|
|
disableMotors.Click += (s, e) =>
|
|
|
|
|
|
{
|
2017-06-13 17:22:49 -07:00
|
|
|
|
PrinterConnection.Instance.ReleaseMotors();
|
2017-02-16 10:38:03 -08:00
|
|
|
|
};
|
2015-08-25 14:10:33 -07:00
|
|
|
|
|
2016-05-06 17:56:27 -07:00
|
|
|
|
GuiWidget spacerReleaseShow = new GuiWidget(10 * GuiWidget.DeviceScale, 0);
|
2015-04-08 15:20:10 -07:00
|
|
|
|
|
|
|
|
|
|
homeButtonBar.AddChild(homeIconImageWidget);
|
|
|
|
|
|
homeButtonBar.AddChild(homeAllButton);
|
|
|
|
|
|
homeButtonBar.AddChild(homeXButton);
|
|
|
|
|
|
homeButtonBar.AddChild(homeYButton);
|
|
|
|
|
|
homeButtonBar.AddChild(homeZButton);
|
2016-01-13 07:39:22 -08:00
|
|
|
|
|
2017-01-11 06:19:19 -08:00
|
|
|
|
offsetStreamLabel = new TextWidget("Z Offset".Localize() + ":", pointSize: 8)
|
|
|
|
|
|
{
|
|
|
|
|
|
TextColor = ActiveTheme.Instance.PrimaryTextColor,
|
|
|
|
|
|
Margin = new BorderDouble(left: 10),
|
|
|
|
|
|
AutoExpandBoundsToText = true,
|
|
|
|
|
|
VAnchor = VAnchor.ParentCenter
|
|
|
|
|
|
};
|
2016-01-13 07:39:22 -08:00
|
|
|
|
homeButtonBar.AddChild(offsetStreamLabel);
|
|
|
|
|
|
|
2017-01-19 10:56:28 -08:00
|
|
|
|
var ztuningWidget = new ZTuningWidget();
|
|
|
|
|
|
homeButtonBar.AddChild(ztuningWidget);
|
|
|
|
|
|
|
2016-04-25 13:35:36 -07:00
|
|
|
|
homeButtonBar.AddChild(new HorizontalSpacer());
|
2015-04-08 15:20:10 -07:00
|
|
|
|
homeButtonBar.AddChild(disableMotors);
|
|
|
|
|
|
homeButtonBar.AddChild(spacerReleaseShow);
|
|
|
|
|
|
|
|
|
|
|
|
return homeButtonBar;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2015-11-23 13:08:21 -08:00
|
|
|
|
private FlowLayoutWidget GetHWDestinationBar()
|
|
|
|
|
|
{
|
|
|
|
|
|
FlowLayoutWidget hwDestinationBar = new FlowLayoutWidget();
|
|
|
|
|
|
hwDestinationBar.HAnchor = HAnchor.ParentLeftRight;
|
2016-05-06 17:56:27 -07:00
|
|
|
|
hwDestinationBar.Margin = new BorderDouble(3, 0, 3, 6);
|
2015-11-23 13:08:21 -08:00
|
|
|
|
hwDestinationBar.Padding = new BorderDouble(0);
|
|
|
|
|
|
|
|
|
|
|
|
TextWidget xPosition = new TextWidget("X: 0.0 ", pointSize: 12, textColor: ActiveTheme.Instance.PrimaryTextColor);
|
|
|
|
|
|
TextWidget yPosition = new TextWidget("Y: 0.0 ", pointSize: 12, textColor: ActiveTheme.Instance.PrimaryTextColor);
|
|
|
|
|
|
TextWidget zPosition = new TextWidget("Z: 0.0 ", pointSize: 12, textColor: ActiveTheme.Instance.PrimaryTextColor);
|
|
|
|
|
|
|
|
|
|
|
|
hwDestinationBar.AddChild(xPosition);
|
|
|
|
|
|
hwDestinationBar.AddChild(yPosition);
|
|
|
|
|
|
hwDestinationBar.AddChild(zPosition);
|
|
|
|
|
|
|
2015-11-23 15:45:35 -08:00
|
|
|
|
SetDestinationPositionText(xPosition, yPosition, zPosition);
|
|
|
|
|
|
|
2015-11-23 13:08:21 -08:00
|
|
|
|
reportDestinationChanged = new LimitCallingFrequency(1, () =>
|
|
|
|
|
|
{
|
|
|
|
|
|
UiThread.RunOnIdle(() =>
|
|
|
|
|
|
{
|
2015-11-23 15:45:35 -08:00
|
|
|
|
SetDestinationPositionText(xPosition, yPosition, zPosition);
|
2015-11-23 13:08:21 -08:00
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2017-06-13 17:22:49 -07:00
|
|
|
|
PrinterConnection.Instance.DestinationChanged.RegisterEvent((object sender, EventArgs e) =>
|
2015-11-23 13:08:21 -08:00
|
|
|
|
{
|
|
|
|
|
|
reportDestinationChanged.CallEvent();
|
|
|
|
|
|
}, ref unregisterEvents);
|
|
|
|
|
|
|
|
|
|
|
|
return hwDestinationBar;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2015-11-23 15:45:35 -08:00
|
|
|
|
private static void SetDestinationPositionText(TextWidget xPosition, TextWidget yPosition, TextWidget zPosition)
|
|
|
|
|
|
{
|
2017-06-13 17:22:49 -07:00
|
|
|
|
Vector3 destinationPosition = PrinterConnection.Instance.CurrentDestination;
|
2015-11-23 15:45:35 -08:00
|
|
|
|
xPosition.Text = "X: {0:0.00}".FormatWith(destinationPosition.x);
|
|
|
|
|
|
yPosition.Text = "Y: {0:0.00}".FormatWith(destinationPosition.y);
|
|
|
|
|
|
zPosition.Text = "Z: {0:0.00}".FormatWith(destinationPosition.z);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2015-11-23 10:49:08 -08:00
|
|
|
|
private void homeAll_Click(object sender, EventArgs mouseEvent)
|
2015-04-08 15:20:10 -07:00
|
|
|
|
{
|
2017-06-13 17:22:49 -07:00
|
|
|
|
PrinterConnection.Instance.HomeAxis(PrinterConnection.Axis.XYZ);
|
2015-04-08 15:20:10 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void homeXButton_Click(object sender, EventArgs mouseEvent)
|
|
|
|
|
|
{
|
2017-06-13 17:22:49 -07:00
|
|
|
|
PrinterConnection.Instance.HomeAxis(PrinterConnection.Axis.X);
|
2015-04-08 15:20:10 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void homeYButton_Click(object sender, EventArgs mouseEvent)
|
|
|
|
|
|
{
|
2017-06-13 17:22:49 -07:00
|
|
|
|
PrinterConnection.Instance.HomeAxis(PrinterConnection.Axis.Y);
|
2015-04-08 15:20:10 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void homeZButton_Click(object sender, EventArgs mouseEvent)
|
|
|
|
|
|
{
|
2017-06-13 17:22:49 -07:00
|
|
|
|
PrinterConnection.Instance.HomeAxis(PrinterConnection.Axis.Z);
|
2015-04-08 15:20:10 -07:00
|
|
|
|
}
|
2015-11-23 10:49:08 -08:00
|
|
|
|
}
|
2015-04-08 15:20:10 -07:00
|
|
|
|
|
2015-11-23 10:49:08 -08:00
|
|
|
|
public class XYZColors
|
|
|
|
|
|
{
|
|
|
|
|
|
public static RGBA_Bytes eColor = new RGBA_Bytes(180, 180, 180);
|
|
|
|
|
|
public static RGBA_Bytes xColor = new RGBA_Bytes(180, 180, 180);
|
|
|
|
|
|
public static RGBA_Bytes yColor = new RGBA_Bytes(255, 255, 255);
|
|
|
|
|
|
public static RGBA_Bytes zColor = new RGBA_Bytes(255, 255, 255);
|
|
|
|
|
|
|
|
|
|
|
|
public XYZColors()
|
2015-04-08 15:20:10 -07:00
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-01-19 10:56:28 -08:00
|
|
|
|
|
|
|
|
|
|
public class ZTuningWidget : GuiWidget
|
|
|
|
|
|
{
|
|
|
|
|
|
private TextWidget zOffsetStreamDisplay;
|
|
|
|
|
|
private Button clearZOffsetButton;
|
|
|
|
|
|
private FlowLayoutWidget zOffsetStreamContainer;
|
|
|
|
|
|
|
|
|
|
|
|
private EventHandler unregisterEvents;
|
2017-02-17 16:46:38 -08:00
|
|
|
|
private bool allowRemoveButton;
|
2017-01-19 10:56:28 -08:00
|
|
|
|
|
2017-02-17 16:46:38 -08:00
|
|
|
|
public ZTuningWidget(bool allowRemoveButton = true)
|
2017-01-19 10:56:28 -08:00
|
|
|
|
{
|
2017-02-17 16:46:38 -08:00
|
|
|
|
this.allowRemoveButton = allowRemoveButton;
|
2017-01-19 10:56:28 -08:00
|
|
|
|
this.HAnchor = HAnchor.FitToChildren;
|
|
|
|
|
|
this.VAnchor = VAnchor.FitToChildren | VAnchor.ParentCenter;
|
|
|
|
|
|
|
2017-02-01 13:38:14 -08:00
|
|
|
|
ActiveSliceSettings.SettingChanged.RegisterEvent((s, e) =>
|
2017-01-19 10:56:28 -08:00
|
|
|
|
{
|
2017-02-01 15:46:11 -08:00
|
|
|
|
if ((e as StringEventArgs)?.Data == SettingsKey.baby_step_z_offset)
|
2017-02-01 13:38:14 -08:00
|
|
|
|
{
|
2017-02-01 15:46:11 -08:00
|
|
|
|
OffsetStreamChanged(null, null);
|
2017-02-01 13:38:14 -08:00
|
|
|
|
}
|
2017-01-19 10:56:28 -08:00
|
|
|
|
}, ref unregisterEvents);
|
|
|
|
|
|
|
|
|
|
|
|
zOffsetStreamContainer = new FlowLayoutWidget(FlowDirection.LeftToRight)
|
|
|
|
|
|
{
|
|
|
|
|
|
Margin = new BorderDouble(3, 0),
|
|
|
|
|
|
Padding = new BorderDouble(3),
|
|
|
|
|
|
HAnchor = HAnchor.FitToChildren,
|
|
|
|
|
|
VAnchor = VAnchor.ParentCenter,
|
|
|
|
|
|
BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor,
|
|
|
|
|
|
Height = 20
|
|
|
|
|
|
};
|
|
|
|
|
|
this.AddChild(zOffsetStreamContainer);
|
|
|
|
|
|
|
2017-02-13 15:10:46 -08:00
|
|
|
|
double zoffset = ActiveSliceSettings.Instance.GetValue<double>(SettingsKey.baby_step_z_offset);
|
|
|
|
|
|
zOffsetStreamDisplay = new TextWidget(zoffset.ToString("0.##"))
|
2017-01-19 10:56:28 -08:00
|
|
|
|
{
|
|
|
|
|
|
AutoExpandBoundsToText = true,
|
|
|
|
|
|
TextColor = ActiveTheme.Instance.PrimaryTextColor,
|
|
|
|
|
|
Margin = new BorderDouble(5, 0, 8, 0),
|
|
|
|
|
|
VAnchor = VAnchor.ParentCenter
|
|
|
|
|
|
};
|
|
|
|
|
|
zOffsetStreamContainer.AddChild(zOffsetStreamDisplay);
|
|
|
|
|
|
|
2017-06-11 14:29:42 -07:00
|
|
|
|
clearZOffsetButton = ApplicationController.Instance.Theme.CreateSmallResetButton();
|
|
|
|
|
|
clearZOffsetButton.Name = "Clear ZOffset button";
|
|
|
|
|
|
clearZOffsetButton.ToolTipText = "Clear ZOffset".Localize();
|
|
|
|
|
|
clearZOffsetButton.Visible = allowRemoveButton && zoffset != 0;
|
2017-02-01 13:38:14 -08:00
|
|
|
|
clearZOffsetButton.Click += (sender, e) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
ActiveSliceSettings.Instance.SetValue(SettingsKey.baby_step_z_offset, "0");
|
|
|
|
|
|
};
|
2017-01-19 10:56:28 -08:00
|
|
|
|
zOffsetStreamContainer.AddChild(clearZOffsetButton);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
internal void OffsetStreamChanged(object sender, EventArgs e)
|
|
|
|
|
|
{
|
2017-02-01 13:38:14 -08:00
|
|
|
|
double zoffset = ActiveSliceSettings.Instance.GetValue<double>(SettingsKey.baby_step_z_offset);
|
2017-01-19 10:56:28 -08:00
|
|
|
|
bool hasOverriddenZOffset = (zoffset != 0);
|
|
|
|
|
|
|
2017-02-17 16:46:38 -08:00
|
|
|
|
zOffsetStreamContainer.BackgroundColor = (allowRemoveButton && hasOverriddenZOffset) ? SliceSettingsWidget.userSettingBackgroundColor : ActiveTheme.Instance.SecondaryBackgroundColor;
|
|
|
|
|
|
clearZOffsetButton.Visible = allowRemoveButton && hasOverriddenZOffset;
|
2017-01-19 10:56:28 -08:00
|
|
|
|
|
|
|
|
|
|
zOffsetStreamDisplay.Text = zoffset.ToString("0.##");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-02-03 13:06:08 -08:00
|
|
|
|
public override void OnClosed(ClosedEventArgs e)
|
2017-01-19 10:56:28 -08:00
|
|
|
|
{
|
|
|
|
|
|
unregisterEvents?.Invoke(null, null);
|
|
|
|
|
|
base.OnClosed(e);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2016-09-07 13:19:04 -07:00
|
|
|
|
}
|