Making it easier to start a print that will not ask for feedback
Ability to ask what printer an object is on Starting work on ability to have a button on an object to execute arbitrary code Cleanup and dead code removal
This commit is contained in:
parent
5dbcf8c06c
commit
9fa1061f1e
13 changed files with 100 additions and 38 deletions
|
|
@ -1747,7 +1747,7 @@ namespace MatterHackers.MatterControl
|
|||
leftChild.Padding = new BorderDouble(padding.Left, padding.Bottom, sourceExentionArea.Width, padding.Height);
|
||||
}
|
||||
|
||||
public async Task PrintPart(EditContext editContext, PrinterConfig printer, IProgress<ProgressStatus> reporter, CancellationToken cancellationToken)
|
||||
public async Task PrintPart(EditContext editContext, PrinterConfig printer, IProgress<ProgressStatus> reporter, CancellationToken cancellationToken, bool recordPrintHistory)
|
||||
{
|
||||
var partFilePath = editContext.SourceFilePath;
|
||||
var gcodeFilePath = await editContext.GCodeFilePath(printer);
|
||||
|
|
@ -1818,7 +1818,7 @@ namespace MatterHackers.MatterControl
|
|||
if (messageBoxResponse)
|
||||
{
|
||||
printer.Connection.CommunicationState = CommunicationStates.PreparingToPrint;
|
||||
this.ArchiveAndStartPrint(partFilePath, gcodeFilePath, printer);
|
||||
this.ArchiveAndStartPrint(partFilePath, gcodeFilePath, printer, recordPrintHistory);
|
||||
}
|
||||
},
|
||||
"The file you are attempting to print is a GCode file.\n\nIt is recommended that you only print Gcode files known to match your printer's configuration.\n\nAre you sure you want to print this GCode file?".Localize(),
|
||||
|
|
@ -1833,7 +1833,7 @@ namespace MatterHackers.MatterControl
|
|||
else
|
||||
{
|
||||
printer.Connection.CommunicationState = CommunicationStates.PreparingToPrint;
|
||||
this.ArchiveAndStartPrint(partFilePath, gcodeFilePath, printer);
|
||||
this.ArchiveAndStartPrint(partFilePath, gcodeFilePath, printer, recordPrintHistory);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
@ -1848,7 +1848,7 @@ namespace MatterHackers.MatterControl
|
|||
// Only start print if slicing completed
|
||||
if (slicingSucceeded)
|
||||
{
|
||||
this.ArchiveAndStartPrint(partFilePath, finalPath, printer);
|
||||
this.ArchiveAndStartPrint(partFilePath, finalPath, printer, recordPrintHistory);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -2013,7 +2013,7 @@ namespace MatterHackers.MatterControl
|
|||
/// </summary>
|
||||
/// <param name="sourcePath">The source file which originally caused the slice->print operation</param>
|
||||
/// <param name="gcodeFilePath">The resulting GCode to print</param>
|
||||
private async void ArchiveAndStartPrint(string sourcePath, string gcodeFilePath, PrinterConfig printer)
|
||||
private async void ArchiveAndStartPrint(string sourcePath, string gcodeFilePath, PrinterConfig printer, bool recordPrintHistory)
|
||||
{
|
||||
if (File.Exists(sourcePath)
|
||||
&& File.Exists(gcodeFilePath))
|
||||
|
|
@ -2044,7 +2044,7 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
if (originalIsGCode)
|
||||
{
|
||||
await printer.Connection.StartPrint(gcodeFilePath);
|
||||
await printer.Connection.StartPrint(gcodeFilePath, recordPrintHistory: recordPrintHistory);
|
||||
|
||||
MonitorPrintTask(printer);
|
||||
|
||||
|
|
@ -2055,7 +2055,7 @@ namespace MatterHackers.MatterControl
|
|||
// Ask for slicer specific gcode validation
|
||||
if (printer.Settings.Slicer.ValidateFile(gcodeFilePath))
|
||||
{
|
||||
await printer.Connection.StartPrint(gcodeFilePath);
|
||||
await printer.Connection.StartPrint(gcodeFilePath, recordPrintHistory: recordPrintHistory);
|
||||
MonitorPrintTask(printer);
|
||||
return;
|
||||
}
|
||||
|
|
@ -2276,7 +2276,7 @@ namespace MatterHackers.MatterControl
|
|||
public void Connection_PrintFinished(object sender, string e)
|
||||
{
|
||||
if (sender is PrinterConnection printerConnection
|
||||
&& !printerConnection.CalibrationPrint)
|
||||
&& printerConnection.RecordPrintHistory)
|
||||
{
|
||||
var printTasks = PrintHistoryData.Instance.GetHistoryItems(10);
|
||||
var printHistoryEditor = new PrintHistoryEditor(((PrinterConnection)sender).Printer, AppContext.Theme, printerConnection.ActivePrintTask, printTasks);
|
||||
|
|
@ -2290,7 +2290,7 @@ namespace MatterHackers.MatterControl
|
|||
public void Connection_PrintCanceled(object sender, EventArgs e)
|
||||
{
|
||||
if (sender is PrinterConnection printerConnection
|
||||
&& !printerConnection.CalibrationPrint)
|
||||
&& printerConnection.RecordPrintHistory)
|
||||
{
|
||||
var printTasks = PrintHistoryData.Instance.GetHistoryItems(10);
|
||||
var printHistoryEditor = new PrintHistoryEditor(((PrinterConnection)sender).Printer, AppContext.Theme, printerConnection.CanceledPrintTask, printTasks);
|
||||
|
|
|
|||
|
|
@ -328,7 +328,8 @@ namespace MatterHackers.MatterControl
|
|||
this.EditContext,
|
||||
this.Printer,
|
||||
null,
|
||||
CancellationToken.None);
|
||||
CancellationToken.None,
|
||||
true);
|
||||
}
|
||||
|
||||
public async Task StashAndPrint(IEnumerable<ILibraryItem> selectedLibraryItems)
|
||||
|
|
@ -348,7 +349,8 @@ namespace MatterHackers.MatterControl
|
|||
this.EditContext,
|
||||
this.Printer,
|
||||
null,
|
||||
CancellationToken.None);
|
||||
CancellationToken.None,
|
||||
true);
|
||||
}
|
||||
|
||||
private GCodeFile loadedGCode;
|
||||
|
|
|
|||
|
|
@ -188,7 +188,7 @@ namespace MatterHackers.MatterControl
|
|||
ContentStore = null // No content store for GCode
|
||||
});
|
||||
|
||||
await printer.Connection.StartPrint(finalGCodePath, calibrationPrint: true);
|
||||
await printer.Connection.StartPrint(finalGCodePath, recordPrintHistory: false);
|
||||
ApplicationController.Instance.MonitorPrintTask(printer);
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
Copyright (c) 2018, Lars Brubaker, John Lewin
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
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
|
||||
of the authors and should not be interpreted as representing official policies,
|
||||
either expressed or implied, of the FreeBSD Project.
|
||||
*/
|
||||
|
||||
using System;
|
||||
|
||||
namespace MatterHackers.MatterControl.DesignTools
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Method)]
|
||||
public class ShowAsButtonAttribute : Attribute
|
||||
{
|
||||
public string HelpText { get; private set; }
|
||||
|
||||
public ShowAsButtonAttribute(string helpText)
|
||||
{
|
||||
HelpText = helpText;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -28,25 +28,11 @@ either expressed or implied, of the FreeBSD Project.
|
|||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using Markdig.Agg;
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.Image;
|
||||
using MatterHackers.Agg.Platform;
|
||||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.DataConverters3D;
|
||||
using MatterHackers.Localizations;
|
||||
using MatterHackers.MatterControl.CustomWidgets;
|
||||
using MatterHackers.MatterControl.DesignTools.EditableTypes;
|
||||
using MatterHackers.MatterControl.DesignTools.Operations;
|
||||
using MatterHackers.MatterControl.PartPreviewWindow;
|
||||
using MatterHackers.MatterControl.PartPreviewWindow.View3D;
|
||||
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||
using MatterHackers.VectorMath;
|
||||
|
||||
namespace MatterHackers.MatterControl.DesignTools
|
||||
{
|
||||
|
|
|
|||
|
|
@ -85,6 +85,19 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
|
|||
}
|
||||
}
|
||||
|
||||
public static PrinterConfig ContainingPrinter(this IObject3D object3D)
|
||||
{
|
||||
foreach (var printer in ApplicationController.Instance.ActivePrinters)
|
||||
{
|
||||
if (printer.Bed.Scene.Descendants().Contains(object3D))
|
||||
{
|
||||
return printer;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static int EstimatedMemory(this IObject3D object3D)
|
||||
{
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -140,6 +140,10 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
}
|
||||
}
|
||||
|
||||
foreach (var property in GetEditablePropreties(context.item))
|
||||
{
|
||||
}
|
||||
|
||||
AddWebPageLinkIfRequired(context, mainContainer, theme);
|
||||
|
||||
// add in an Update button if applicable
|
||||
|
|
@ -230,6 +234,17 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
.Select(p => new EditableProperty(p, item));
|
||||
}
|
||||
|
||||
public static IEnumerable<EditableProperty> GetExecutableFunctions(IObject3D item)
|
||||
{
|
||||
BindingFlags buttonFunctionsOnly = BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly;
|
||||
|
||||
return item.GetType().GetProperties(buttonFunctionsOnly)
|
||||
.Where(pi => (AllowedTypes.Contains(pi.PropertyType) || pi.PropertyType.IsEnum)
|
||||
&& pi.GetGetMethod() != null
|
||||
&& pi.GetSetMethod() != null)
|
||||
.Select(p => new EditableProperty(p, item));
|
||||
}
|
||||
|
||||
public static GuiWidget CreatePropertyEditor(EditableProperty property, UndoBuffer undoBuffer, PPEContext context, ThemeConfig theme)
|
||||
{
|
||||
var object3D = property.Item;
|
||||
|
|
|
|||
|
|
@ -327,7 +327,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
printer.Bed.EditContext,
|
||||
printer,
|
||||
null,
|
||||
CancellationToken.None);
|
||||
CancellationToken.None,
|
||||
true);
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -517,7 +517,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
printer.Bed.EditContext,
|
||||
printer,
|
||||
null,
|
||||
CancellationToken.None).ConfigureAwait(false);
|
||||
CancellationToken.None,
|
||||
true).ConfigureAwait(false);
|
||||
});
|
||||
}
|
||||
else if (ProfileManager.Instance.ActiveProfiles.Count() <= 0)
|
||||
|
|
@ -627,7 +628,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
printer.Bed.EditContext,
|
||||
printer,
|
||||
null,
|
||||
CancellationToken.None);
|
||||
CancellationToken.None,
|
||||
true);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -449,7 +449,6 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io
|
|||
|
||||
var feedRates = printer.Settings.Helpers.ManualMovementSpeeds();
|
||||
|
||||
queuedCommands.Enqueue("G90");
|
||||
queuedCommands.Enqueue($"G1 Z{positionToSample.Z:0.###} F{feedRates.Z}");
|
||||
queuedCommands.Enqueue($"G1 X{positionToSampleWithProbeOffset.X:0.###}Y{positionToSampleWithProbeOffset.Y:0.###}Z{positionToSampleWithProbeOffset.Z:0.###} F{feedRates.X}");
|
||||
|
||||
|
|
|
|||
|
|
@ -2075,24 +2075,24 @@ Make sure that your printer is turned on. Some printers will appear to be connec
|
|||
}
|
||||
}
|
||||
|
||||
public bool CalibrationPrint { get; private set; }
|
||||
public bool RecordPrintHistory { get; private set; }
|
||||
|
||||
private CancellationTokenSource printingCancellation;
|
||||
|
||||
public async Task StartPrint(string gcodeFilename, PrintTask printTaskToUse = null, bool calibrationPrint = false)
|
||||
public async Task StartPrint(string gcodeFilename, PrintTask printTaskToUse = null, bool recordPrintHistory = true)
|
||||
{
|
||||
var gcodeStream = new StreamReader(gcodeFilename);
|
||||
await StartPrint(gcodeStream.BaseStream, gcodeFilename, printTaskToUse, calibrationPrint);
|
||||
await StartPrint(gcodeStream.BaseStream, gcodeFilename, printTaskToUse, recordPrintHistory);
|
||||
}
|
||||
|
||||
public async Task StartPrint(Stream gcodeStream, string gcodeFileNameForTask = null, PrintTask printTaskToUse = null, bool calibrationPrint = false)
|
||||
public async Task StartPrint(Stream gcodeStream, string gcodeFileNameForTask, PrintTask printTaskToUse, bool recordPrintHistory)
|
||||
{
|
||||
if (!this.IsConnected || Printing)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this.CalibrationPrint = calibrationPrint;
|
||||
this.RecordPrintHistory = recordPrintHistory;
|
||||
|
||||
printingCancellation = new CancellationTokenSource();
|
||||
|
||||
|
|
@ -2134,7 +2134,7 @@ Make sure that your printer is turned on. Some printers will appear to be connec
|
|||
|
||||
if (gcodeFileNameForTask != null
|
||||
&& ActivePrintTask == null
|
||||
&& !CalibrationPrint)
|
||||
&& RecordPrintHistory)
|
||||
{
|
||||
// TODO: Fix printerItemID int requirement
|
||||
ActivePrintTask = new PrintTask
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit d068e8a22a62eda3c6c1725baf368ad6df0df5b1
|
||||
Subproject commit 29d00eeb921283046b22d96b5bc991d01b87eac7
|
||||
|
|
@ -595,7 +595,7 @@ namespace MatterControl.Tests.MatterControl.ToolChanges
|
|||
|
||||
// start a print
|
||||
printer.Connection.CommunicationState = CommunicationStates.PreparingToPrint;
|
||||
await printer.Connection.StartPrint(inputStream);
|
||||
await printer.Connection.StartPrint(inputStream, null, null, true);
|
||||
|
||||
// wait up to 40 seconds for the print to finish
|
||||
timer = Stopwatch.StartNew();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue