Rename on bed items can be undone

Made bed heat able to set to 0

Don't save scene while still loading it
This commit is contained in:
Lars Brubaker 2022-01-25 16:27:22 -08:00
parent a0e05e0717
commit 261376bef2
16 changed files with 152 additions and 68 deletions

View file

@ -208,16 +208,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
{
get
{
var temp = printerSettings.GetValue<double>(ActiveBedTemperatureSetting);
// check if it might be trying to use the default
if (temp == 0)
{
// it is either the default (actual bed_temperature) or a 0. This will get the true temp requested
return printerSettings.GetValue<double>(SettingsKey.bed_temperature);
}
// fonud a good temp return it
return temp;
return printerSettings.GetValue<double>(ActiveBedTemperatureSetting);
}
}

View file

@ -139,7 +139,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
{
SlicerConfigName = SettingsKey.bed_temperature_blue_tape,
PresentationName = "Blue Tape Bed Temperature".Localize(),
HelpText = "The temperature to print when the bed is coverd with blue tape. Set to 0 to use default.".Localize(),
HelpText = "The temperature to print when the bed is coverd with blue tape. Set to 0 to disable.".Localize(),
DataEditType = DataEditTypes.POSITIVE_DOUBLE,
Units = "°C".Localize(),
ShowIfSet = "has_heated_bed&has_swappable_bed",
@ -149,7 +149,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
{
SlicerConfigName = SettingsKey.bed_temperature_buildtak,
PresentationName = "BuildTak Bed Temperature".Localize(),
HelpText = "The temperature to print when the bed is using BuildTak. Set to 0 to use default.".Localize(),
HelpText = "The temperature to print when the bed is using BuildTak. Set to 0 to disable.".Localize(),
DataEditType = DataEditTypes.POSITIVE_DOUBLE,
Units = "°C".Localize(),
ShowIfSet = "has_heated_bed&has_swappable_bed",
@ -159,7 +159,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
{
SlicerConfigName = SettingsKey.bed_temperature_garolite,
PresentationName = "Garolite Bed Temperature".Localize(),
HelpText = "The temperature to print when the bed is using garolite. Set to 0 to use default.".Localize(),
HelpText = "The temperature to print when the bed is using garolite. Set to 0 to disable.".Localize(),
DataEditType = DataEditTypes.POSITIVE_DOUBLE,
Units = "°C".Localize(),
ShowIfSet = "has_heated_bed&has_swappable_bed",
@ -169,7 +169,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
{
SlicerConfigName = SettingsKey.bed_temperature_glass,
PresentationName = "Glass Bed Temperature".Localize(),
HelpText = "The temperature to print when the bed is using glass. Set to 0 to use default.".Localize(),
HelpText = "The temperature to print when the bed is using glass. Set to 0 to disable.".Localize(),
DataEditType = DataEditTypes.POSITIVE_DOUBLE,
Units = "°C".Localize(),
ShowIfSet = "has_heated_bed&has_swappable_bed",
@ -179,7 +179,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
{
SlicerConfigName = SettingsKey.bed_temperature_kapton,
PresentationName = "Kapton Bed Temperature".Localize(),
HelpText = "The temperature to print when the bed is coverd in kapton tape. Set to 0 to use default.".Localize(),
HelpText = "The temperature to print when the bed is coverd in kapton tape. Set to 0 to disable.".Localize(),
DataEditType = DataEditTypes.POSITIVE_DOUBLE,
Units = "°C".Localize(),
ShowIfSet = "has_heated_bed&has_swappable_bed",
@ -189,7 +189,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
{
SlicerConfigName = SettingsKey.bed_temperature_pei,
PresentationName = "PEI Bed Temperature".Localize(),
HelpText = "The temperature to print when the bed is using PEI. Set to 0 to use default.".Localize(),
HelpText = "The temperature to print when the bed is using PEI. Set to 0 to disable.".Localize(),
DataEditType = DataEditTypes.POSITIVE_DOUBLE,
Units = "°C".Localize(),
ShowIfSet = "has_heated_bed&has_swappable_bed",
@ -199,7 +199,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
{
SlicerConfigName = SettingsKey.bed_temperature_pp,
PresentationName = "Polypropylene Bed Temperature".Localize(),
HelpText = "The temperature to print when the bed is polypropylene. Set to 0 to use default.".Localize(),
HelpText = "The temperature to print when the bed is polypropylene. Set to 0 to disable.".Localize(),
DataEditType = DataEditTypes.POSITIVE_DOUBLE,
Units = "°C".Localize(),
ShowIfSet = "has_heated_bed&has_swappable_bed",

View file

@ -126,12 +126,10 @@ namespace MatterHackers.MatterControl.ActionBar
HAnchor = HAnchor.Stretch
};
var bedSettingBeingEdited = printer.Settings.Helpers.ActiveBedTemperatureSetting;
void SettingChanged(object s, StringEventArgs stringEvent)
{
if (stringEvent.Data == SettingsKey.bed_temperature
|| stringEvent.Data == bedSettingBeingEdited)
if (stringEvent.Data == printer.Settings.Helpers.ActiveBedTemperatureSetting
|| stringEvent.Data == SettingsKey.bed_temperature)
{
graph.GoalValue = printer.Settings.Helpers.ActiveBedTemperature;
}
@ -146,9 +144,7 @@ namespace MatterHackers.MatterControl.ActionBar
{
temperatureRow.CloseChildren();
bedSettingBeingEdited = printer.Settings.Helpers.ActiveBedTemperatureSetting;
var settingsData = PrinterSettings.SettingsData[bedSettingBeingEdited];
var settingsData = PrinterSettings.SettingsData[printer.Settings.Helpers.ActiveBedTemperatureSetting];
var bedTemperature = SliceSettingsTabView.CreateItemRow(settingsData, settingsContext, printer, menuTheme, ref tabIndex);
var settingsRow = bedTemperature.DescendantsAndSelf<SliceSettingsRow>().FirstOrDefault();

View file

@ -423,20 +423,10 @@ namespace MatterHackers.MatterControl
if (view3D.Printer == null
|| (view3D.Printer != null && view3D.Printer.ViewState.ViewMode == PartViewMode.Model))
{
if (view3D.sceneContext.Scene.SelectedItem is IObject3D object3D)
var scene = view3D.sceneContext.Scene;
if (scene.SelectedItem is IObject3D object3D)
{
DialogWindow.Show(
new InputBoxPage(
"Rename Item".Localize(),
"Name".Localize(),
object3D.Name,
"Enter New Name Here".Localize(),
"Rename".Localize(),
(newName) =>
{
// TODO: add undo data to this operation
object3D.Name = newName;
}));
object3D.ShowRenameDialog(scene.UndoBuffer);
}
}

View file

@ -56,6 +56,7 @@ using MatterHackers.Localizations;
using MatterHackers.MatterControl.CustomWidgets;
using MatterHackers.MatterControl.DataStorage;
using MatterHackers.MatterControl.DesignTools;
using MatterHackers.MatterControl.DesignTools.Operations;
using MatterHackers.MatterControl.Extensibility;
using MatterHackers.MatterControl.Library;
using MatterHackers.MatterControl.PartPreviewWindow;
@ -264,21 +265,11 @@ namespace MatterHackers.MatterControl
var renameMenuItem = popupMenu.CreateMenuItem("Rename".Localize());
renameMenuItem.Click += (s, e) =>
{
var selectedItem = sceneContext.Scene.SelectedItem;
var scene = sceneContext.Scene;
var selectedItem = scene.SelectedItem;
if (selectedItem != null)
{
DialogWindow.Show(
new InputBoxPage(
"Rename Item".Localize(),
"Name".Localize(),
selectedItem.Name,
"Enter New Name Here".Localize(),
"Rename".Localize(),
(newName) =>
{
// TODO: add undo data to this operation
selectedItem.Name = newName;
}));
selectedItem.ShowRenameDialog(scene.UndoBuffer);
}
};

View file

@ -663,6 +663,22 @@ namespace MatterHackers.MatterControl
if (this.Scene.Persistable)
{
var startingMs = UiThread.CurrentTimerMs;
// wait up to 1 second for the scene to have content
while (!Scene.Children.Any()
&& UiThread.CurrentTimerMs < startingMs + 1000)
{
Thread.Sleep(10);
}
// wait up to 5 seconds to finish loading before the save
while (Scene.Children.Where(c => c is InsertionGroupObject3D).Any()
&& UiThread.CurrentTimerMs < startingMs + 5000)
{
Thread.Sleep(10);
}
await this.Scene.PersistAssets((progress0to1, status) =>
{
if (progress != null)

View file

@ -40,6 +40,7 @@ using MatterHackers.Agg.VertexSource;
using MatterHackers.DataConverters2D;
using MatterHackers.DataConverters3D;
using MatterHackers.DataConverters3D.UndoCommands;
using MatterHackers.Localizations;
using MatterHackers.MatterControl.PartPreviewWindow.View3D;
using MatterHackers.RenderOpenGl.OpenGl;
using MatterHackers.VectorMath;
@ -86,6 +87,33 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
}
}
public static void ShowRenameDialog(this IObject3D item, UndoBuffer undoBuffer)
{
DialogWindow.Show(
new InputBoxPage(
"Rename Item".Localize(),
"Name".Localize(),
item.Name,
"Enter New Name Here".Localize(),
"Rename".Localize(),
(inputName) =>
{
var newName = inputName;
var oldName = item.Name;
if (newName != oldName)
{
undoBuffer.AddAndDo(new UndoRedoActions(() =>
{
item.Name = oldName;
},
() =>
{
item.Name = newName;
}));
}
}));
}
public static PrinterConfig ContainingPrinter(this IObject3D object3D)
{
foreach (var printer in ApplicationController.Instance.ActivePrinters)

View file

@ -51,6 +51,14 @@ namespace MatterHackers.MatterControl.DesignTools
[HideChildrenFromTreeView]
public class TextObject3D : Object3D
{
[JsonConverter(typeof(StringEnumConverter))]
public enum TextAlign
{
Left,
Center,
Right,
}
public TextObject3D()
{
Name = "Text".Localize();
@ -66,6 +74,9 @@ namespace MatterHackers.MatterControl.DesignTools
return item;
}
[EnumDisplay(IconPaths = new string[] { "align_left.png", "align_center_x.png", "align_right.png" }, InvertIcons = true)]
public TextAlign Alignment { get; set; } = TextAlign.Left;
[DisplayName("Text")]
public StringOrExpression NameToWrite { get; set; } = "Text";
@ -87,8 +98,6 @@ namespace MatterHackers.MatterControl.DesignTools
// change this from a text object to a group
var newContainer = new GroupObject3D();
newContainer.CopyProperties(this, Object3DPropertyFlags.All);
int index = 0;
var nameToWrite = NameToWrite.Value(this);
foreach (var child in this.Children)
{
var clone = child.Clone();
@ -185,7 +194,7 @@ namespace MatterHackers.MatterControl.DesignTools
{
Object3D letterObject = null;
switch (letter)
{
{
case ' ':
offset.X += letterPrinter.GetSize(" ").X * pointsToMm;
break;
@ -213,13 +222,42 @@ namespace MatterHackers.MatterControl.DesignTools
}
}
for (int i=list.Count - 1; i >= 0; i--)
for (var i = list.Count - 1; i >= 0; i--)
{
if (list[i].Children.Count == 0)
{
list.RemoveAt(i);
}
}
if (list.Count > 1 && Alignment != TextAlign.Left)
{
var widest = 0.0;
for (var i = 0; i < list.Count; i++)
{
widest = Math.Max(widest, list[i].GetAxisAlignedBoundingBox().XSize);
if (list[i].Children.Count == 0)
{
list.RemoveAt(i);
}
}
for (var i = 0; i < list.Count; i++)
{
var delta = widest - list[i].GetAxisAlignedBoundingBox().XSize;
// apply any alignment to the lines
switch (Alignment)
{
case TextAlign.Center:
list[i].Matrix *= Matrix4X4.CreateTranslation(delta / 2, 0, 0);
break;
case TextAlign.Right:
list[i].Matrix *= Matrix4X4.CreateTranslation(delta, 0, 0);
break;
}
}
}
});
}
}

View file

@ -74,7 +74,7 @@ namespace MatterHackers.MatterControl.Library
public override void SetThumbnail(ILibraryItem item, int width, int height, ImageBuffer imageBuffer)
{
#if DEBUG
throw new NotImplementedException();
//throw new NotImplementedException();
#endif
}

View file

@ -32,7 +32,6 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using MatterHackers.DataConverters3D;
using MatterHackers.DataConverters3D.UndoCommands;
using MatterHackers.MatterControl.DesignTools.Operations;
using MatterHackers.MatterControl.PartPreviewWindow;
using MatterHackers.PolygonMesh;
@ -44,7 +43,6 @@ namespace MatterHackers.MatterControl.Library
{
internal static Mesh placeHolderMesh;
private InteractiveScene scene;
private View3DWidget view3DWidget;
private Action<IObject3D, IEnumerable<IObject3D>> layoutParts;
@ -74,7 +72,6 @@ namespace MatterHackers.MatterControl.Library
this.layoutParts = layoutParts;
// Add a temporary placeholder to give us some bounds
this.scene = scene;
this.view3DWidget = view3DWidget;
this.LoadingItemsTask = Task.Run(async () =>

View file

@ -31,6 +31,7 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using MatterControlLib;
using MatterHackers.Agg;

View file

@ -193,6 +193,9 @@ Translated:Alert
English:Align
Translated:Align
English:Alignment
Translated:Alignment
English:All extrusions are multiplied by this value. Increasing it above 1 will increase the amount of filament being extruded (1.1 is a good max value); decreasing it will decrease the amount being extruded (.9 is a good minimum value).
Translated:All extrusions are multiplied by this value. Increasing it above 1 will increase the amount of filament being extruded (1.1 is a good max value); decreasing it will decrease the amount being extruded (.9 is a good minimum value).
@ -523,6 +526,9 @@ Translated:Clean Filament Page
English:Clear
Translated:Clear
English:Clear any assigned color. This may allow component colors to be visible.
Translated:Clear any assigned color. This may allow component colors to be visible.
English:Clear Bed
Translated:Clear Bed
@ -1972,6 +1978,9 @@ Translated:Mirror
English:Mirror On
Translated:Mirror On
English:Missing
Translated:Missing
English:mm
Translated:mm
@ -3814,6 +3823,9 @@ Translated:The temperature to print when the bed is using garolite. Set to 0 to
English:The temperature to print when the bed is using garolite. Set to 0 to use default.
Translated:The temperature to print when the bed is using garolite. Set to 0 to use default.
English:The temperature to print when the bed is using glass. Set to 0 to disable.
Translated:The temperature to print when the bed is using glass. Set to 0 to disable.
English:The temperature to print when the bed is using glass. Set to 0 to use default.
Translated:The temperature to print when the bed is using glass. Set to 0 to use default.

@ -1 +1 @@
Subproject commit f406b043f95c2f654f990e557abb5618c2233d3a
Subproject commit e7992a7dc95711814717f0d72a2cdd306b31720f

View file

@ -210,7 +210,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
// Assert - one part added and queue count increases by one
Assert.AreEqual(expectedCount, QueueData.Instance.ItemCount, "Queue count should increase by 1 when adding 1 item");
Assert.IsTrue(testRunner.WaitForName("Row Item Rook.amf"), "Named widget should exist after add(Rook)");
Assert.IsTrue(testRunner.WaitForName("Row Item Rook"), "Named widget should exist after add(Rook)");
return Task.CompletedTask;
});

View file

@ -444,8 +444,8 @@ namespace MatterHackers.MatterControl.Tests.Automation
testRunner.WaitFor(() => scene.Children.Count == 1);
Assert.AreEqual(1, scene.Children.Count, "Should have a Phil on the bed");
testRunner.WaitFor(() => scene.Children.First().Name == "Phil A Ment.stl");
Assert.AreEqual("Phil A Ment.stl", scene.Children.First().Name);
testRunner.WaitFor(() => scene.Children.First().Name == "Phil A Ment");
Assert.AreEqual("Phil A Ment", scene.Children.First().Name);
testRunner.Type("^a"); // clear the selection (type a space)
testRunner.WaitFor(() => scene.SelectedItem != null);

View file

@ -20,7 +20,7 @@ namespace MatterControl.Tests.MatterControl
G91
G1 Z10 E-5.0 F1800
G90
G1 X5
G1 X5 F[travel_speed]
M300 S3000 P30 ; Pause Tone
M300 S1500 P30 ; Pause Tone
@ -38,6 +38,27 @@ M300 S750 P30 ; Pause Tone
M300 S1500 P30 ; Pause Tone
M300 S750 P30 ; Pause Tone";
private string resumeGCode = @"M75 ; Start the print job timer
G91
G1 Z-10 F1800
G90
M300 S750 P30 ; Resume Tone
M300 S1500 P30 ; Resume Tone
M300 S750 P30 ; Resume Tone
M300 S1500 P30 ; Resume Tone
M300 S750 P30 ; Resume Tone
M300 S1500 P30 ; Resume Tone
M300 S750 P30 ; Resume Tone
M300 S1500 P30 ; Resume Tone
M300 S3000 P30 ; Resume Tone
M300 S1500 P30 ; Resume Tone
M300 S3000 P30 ; Resume Tone
M300 S1500 P30 ; Resume Tone
M300 S3000 P30 ; Resume Tone
M300 S1500 P30 ; Resume Tone
M300 S3000 P30 ; Resume Tone";
static OemProfileTests()
{
StaticData.RootPath = TestContext.CurrentContext.ResolveProjectPath(4, "StaticData");
@ -102,20 +123,23 @@ M300 S750 P30 ; Pause Tone";
// adheasion
printerSettings.SetValue(SettingsKey.create_skirt, "1");
// support
printerSettings.SetValue(SettingsKey.retract_lift, ".4");
printerSettings.SetValue(SettingsKey.retract_lift, ".6");
printerSettings.SetValue(SettingsKey.min_extrusion_before_retract, "0");
printerSettings.SetValue(SettingsKey.retract_before_travel_avoid, "20");
// printer gcode settings
printerSettings.SetValue(SettingsKey.pause_gcode, ConvertString(pauseGCode));
printerSettings.SetValue(SettingsKey.resume_gcode, ConvertString(resumeGCode));
// e series settings
if (printerModel.Contains('E'))
{
printerSettings.SetValue(SettingsKey.read_regex, "\"^(filament)\", \"ros_\"");
}
printerSettings.SetValue(SettingsKey.pause_gcode, ConvertString(pauseGCode));
// If the board is 32 bit we cannot update the firmware.
// 32 bit settings
if (printerModel.Contains('M') || printerModel.Contains('S'))
{
// If the board is 32 bit we cannot update the firmware.
// make sure it does not show a firmware updater
printerSettings.SetValue(SettingsKey.include_firmware_updater, "None");
}