diff --git a/AboutPage/AboutPage.cs b/AboutPage/AboutPage.cs index d8ec36cd4..9020061a0 100644 --- a/AboutPage/AboutPage.cs +++ b/AboutPage/AboutPage.cs @@ -311,24 +311,7 @@ namespace MatterHackers.MatterControl public static void DeleteCacheData() { - // delete everything in the GCodeOutputPath - // AppData\Local\MatterControl\data\gcode - // delete everything in the temp data that is not in use - // AppData\Local\MatterControl\data\temp - // plateImages - // project-assembly - // project-extract - // stl - - // first AppData\Local\MatterControl\data\gcode - string gcodeOutputPath = DataStorage.ApplicationDataStorage.Instance.GCodeOutputPath; - try - { - Directory.Delete(gcodeOutputPath, true); - } - catch (Exception) - { - } + MatterControlApplication.DeleteCacheData(); } #if false // kevin code 2014 04 22 diff --git a/CustomWidgets/PartThumbnailWidget.cs b/CustomWidgets/PartThumbnailWidget.cs index fe024712d..8b30b7db2 100644 --- a/CustomWidgets/PartThumbnailWidget.cs +++ b/CustomWidgets/PartThumbnailWidget.cs @@ -225,7 +225,7 @@ namespace MatterHackers.MatterControl return; } - string stlHashCode = thumbnailWidget.PrintItem.StlFileHashCode.ToString(); + string stlHashCode = thumbnailWidget.PrintItem.FileHashCode.ToString(); Point2D bigRenderSize = new Point2D(460, 460); ImageBuffer bigRender = LoadImageFromDisk(thumbnailWidget, stlHashCode, bigRenderSize); @@ -304,7 +304,7 @@ namespace MatterHackers.MatterControl private static ImageBuffer LoadImageFromDisk(PartThumbnailWidget thumbnailWidget, string stlHashCode, Point2D size) { ImageBuffer tempImage = new ImageBuffer(size.x, size.y, 32, new BlenderBGRA()); - string imageFileName = GetFilenameForSize(stlHashCode, ref size); + string imageFileName = GetFilenameForSize(stlHashCode, size); if (File.Exists(imageFileName)) { @@ -327,7 +327,12 @@ namespace MatterHackers.MatterControl return null; } - private static string GetFilenameForSize(string stlHashCode, ref Point2D size) + public static string GetImageFilenameForItem(PrintItemWrapper item) + { + return GetFilenameForSize(item.FileHashCode.ToString(), new Point2D(460, 460)); + } + + private static string GetFilenameForSize(string stlHashCode, Point2D size) { string folderToSaveThumbnailsTo = ThumbnailPath(); string imageFileName = Path.Combine(folderToSaveThumbnailsTo, Path.ChangeExtension("{0}_{1}x{2}".FormatWith(stlHashCode, size.x, size.y), partExtension)); @@ -384,9 +389,8 @@ namespace MatterHackers.MatterControl } // and save it to disk - string applicationUserDataPath = ApplicationDataStorage.Instance.ApplicationUserDataPath; - string folderToSavePrintsTo = Path.Combine(applicationUserDataPath, "data", "temp", "thumbnails"); - string imageFileName = Path.Combine(folderToSavePrintsTo, Path.ChangeExtension("{0}_{1}x{2}".FormatWith(stlHashCode, size.x, size.y),partExtension)); + string imageFileName = GetFilenameForSize(stlHashCode, size); + string folderToSavePrintsTo = Path.GetDirectoryName(imageFileName); if (!Directory.Exists(folderToSavePrintsTo)) { diff --git a/MatterControlApplication.cs b/MatterControlApplication.cs index 8e2f9704b..c8fc084da 100644 --- a/MatterControlApplication.cs +++ b/MatterControlApplication.cs @@ -548,5 +548,54 @@ namespace MatterHackers.MatterControl } } - } + + public static void DeleteCacheData() + { + // delete everything in the GCodeOutputPath + // AppData\Local\MatterControl\data\gcode + // delete everything in the temp data that is not in use + // AppData\Local\MatterControl\data\temp + // plateImages + // project-assembly + // project-extract + // stl + // delete all unreference models in Library + // AppData\Local\MatterControl\Library + // delete all old update downloads + // AppData\updates + + // start cleaning out unused data + // MatterControl\data\gcode + RemoveDirectory(DataStorage.ApplicationDataStorage.Instance.GCodeOutputPath); + + RemoveDirectory(Path.Combine(DataStorage.ApplicationDataStorage.Instance.ApplicationUserDataPath, "updates")); + + HashSet referencedMeshFilePaths = new HashSet(); + HashSet referencedThumbnailFiles = new HashSet(); + // Get a list of all the stl and amf files referenced in the queue or library. + foreach (PrintItemWrapper printItem in QueueData.Instance.PrintItems) + { + string fileLocation = printItem.FileLocation; + if (!referencedMeshFilePaths.Contains(fileLocation)) + { + referencedMeshFilePaths.Add(fileLocation); + referencedThumbnailFiles.Add(PartThumbnailWidget.GetImageFilenameForItem(printItem)); + } + } + } + + private static void RemoveDirectory(string directoryToRemove) + { + try + { + if (Directory.Exists(directoryToRemove)) + { + Directory.Delete(directoryToRemove, true); + } + } + catch (Exception) + { + } + } + } } diff --git a/PrintQueue/PrintItemWrapper.cs b/PrintQueue/PrintItemWrapper.cs index 9352f7a63..bc4384ea7 100644 --- a/PrintQueue/PrintItemWrapper.cs +++ b/PrintQueue/PrintItemWrapper.cs @@ -53,7 +53,7 @@ namespace MatterHackers.MatterControl.PrintQueue public PrintItem PrintItem { get; set; } String fileType; - int stlFileHashCode; + int fileHashCode; long writeTime = 0; public bool CurrentlySlicing { get; set; } @@ -152,7 +152,7 @@ namespace MatterHackers.MatterControl.PrintQueue set { this.PrintItem.FileLocation = value; } } - public int StlFileHashCode + public int FileHashCode { get { @@ -160,7 +160,7 @@ namespace MatterHackers.MatterControl.PrintQueue bool fileExists = System.IO.File.Exists(this.FileLocation); if (fileExists) { - if (this.stlFileHashCode == 0 || writeTime != currentWriteTime) + if (this.fileHashCode == 0 || writeTime != currentWriteTime) { writeTime = currentWriteTime; using (FileStream fileStream = new FileStream(this.FileLocation, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) @@ -189,12 +189,12 @@ namespace MatterHackers.MatterControl.PrintQueue int hashCode = agg_basics.ComputeHash(readData); int fileSizeInt = (int)sizeOfFile; - this.stlFileHashCode = new { hashCode, currentWriteTime, fileSizeInt }.GetHashCode(); + this.fileHashCode = new { hashCode, currentWriteTime, fileSizeInt }.GetHashCode(); } } } - return this.stlFileHashCode; + return this.fileHashCode; } } @@ -249,7 +249,7 @@ namespace MatterHackers.MatterControl.PrintQueue string engineString = ((int)ActivePrinterProfile.Instance.ActiveSliceEngineType).ToString(); - string gcodeFileName = this.StlFileHashCode.ToString() + "_" + engineString + "_" + ActiveSliceSettings.Instance.GetHashCode().ToString(); + string gcodeFileName = this.FileHashCode.ToString() + "_" + engineString + "_" + ActiveSliceSettings.Instance.GetHashCode().ToString(); string gcodePathAndFileName = Path.Combine(DataStorage.ApplicationDataStorage.Instance.GCodeOutputPath, gcodeFileName + ".gcode"); return gcodePathAndFileName; } diff --git a/PrintQueue/QueueData.cs b/PrintQueue/QueueData.cs index 7317c9083..61f5cbce6 100644 --- a/PrintQueue/QueueData.cs +++ b/PrintQueue/QueueData.cs @@ -74,7 +74,7 @@ namespace MatterHackers.MatterControl.PrintQueue public static readonly string SdCardFileName = "SD_CARD"; private List printItems = new List(); - private List PrintItems + public List PrintItems { get { return printItems; } } diff --git a/PrinterCommunication/PrinterConnectionAndCommunication.cs b/PrinterCommunication/PrinterConnectionAndCommunication.cs index ce9585274..246115b7a 100644 --- a/PrinterCommunication/PrinterConnectionAndCommunication.cs +++ b/PrinterCommunication/PrinterConnectionAndCommunication.cs @@ -1063,13 +1063,15 @@ namespace MatterHackers.MatterControl.PrinterCommunication double exturderIndex = 0; if (GCodeFile.GetFirstNumberAfter("T", foundStringEventArgs.LineToCheck, ref exturderIndex)) { - SetTargetExtruderTemperature((int)exturderIndex, tempBeingSet); + // we set the private variable so that we don't get the callbacks called and get in a loop of setting the temp + int extruderIndex0Based = Math.Min((int)exturderIndex, MAX_EXTRUDERS - 1); + SetTargetExtruderTemperature(extruderIndex0Based, tempBeingSet); } else { // we set the private variable so that we don't get the callbacks called and get in a loop of setting the temp - SetTargetExtruderTemperature(0, tempBeingSet); - } + SetTargetExtruderTemperature(0, tempBeingSet); + } OnExtruderTemperatureSet(e); } } diff --git a/SlicerConfiguration/SliceSettingsWidget.cs b/SlicerConfiguration/SliceSettingsWidget.cs index 99fd9d104..9f7a4c956 100644 --- a/SlicerConfiguration/SliceSettingsWidget.cs +++ b/SlicerConfiguration/SliceSettingsWidget.cs @@ -112,7 +112,6 @@ namespace MatterHackers.MatterControl.SlicerConfiguration } } - public class SliceSettingsDetailControl : FlowLayoutWidget { const string SliceSettingsShowHelpEntry = "SliceSettingsShowHelp"; diff --git a/SlicerConfiguration/SlicerMapping/EngineMappingMatterSlice.cs b/SlicerConfiguration/SlicerMapping/EngineMappingMatterSlice.cs index 711abcc40..ee4bf9631 100644 --- a/SlicerConfiguration/SlicerMapping/EngineMappingMatterSlice.cs +++ b/SlicerConfiguration/SlicerMapping/EngineMappingMatterSlice.cs @@ -234,6 +234,8 @@ namespace MatterHackers.MatterControl.SlicerConfiguration //startCode=M109 S210 new MapStartGCode("startCode", "start_gcode", true), + new NotPassedItem("", "heat_extruder_before_homing"), + //supportExtruder=1 new ValuePlusConstant("supportExtruder", "support_material_extruder", -1), diff --git a/SlicerConfiguration/SlicerMapping/MappingClasses.cs b/SlicerConfiguration/SlicerMapping/MappingClasses.cs index aa5aceaa4..c2c484d9b 100644 --- a/SlicerConfiguration/SlicerMapping/MappingClasses.cs +++ b/SlicerConfiguration/SlicerMapping/MappingClasses.cs @@ -151,6 +151,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration numberOfHeatedExtruders = ActiveSliceSettings.Instance.ExtruderCount; } + // Start heating all the extruder that we are going to use. for (int i = 0; i < numberOfHeatedExtruders; i++) { if (extrudersUsed.Count > i @@ -159,12 +160,30 @@ namespace MatterHackers.MatterControl.SlicerConfiguration string materialTemperature = ActiveSliceSettings.Instance.GetMaterialValue("temperature", i); if (materialTemperature != "0") { - string setTempString = "M104 T{0} S{1}".FormatWith(i, materialTemperature); + string setTempString = "M104 T{0} S{1}".FormatWith(i, materialTemperature); AddDefaultIfNotPresent(preStartGCode, setTempString, preStartGCodeLines, string.Format("start heating extruder {0}", i)); } } } + // If we need to wait for the heaters to heat up before homing then set them to M109 (heat and wait). + if (ActiveSliceSettings.Instance.GetActiveValue("heat_extruder_before_homing") == "1") + { + for (int i = 0; i < numberOfHeatedExtruders; i++) + { + if (extrudersUsed.Count > i + && extrudersUsed[i]) + { + string materialTemperature = ActiveSliceSettings.Instance.GetMaterialValue("temperature", i); + if (materialTemperature != "0") + { + string setTempString = "M109 T{0} S{1}".FormatWith(i, materialTemperature); + AddDefaultIfNotPresent(preStartGCode, setTempString, preStartGCodeLines, string.Format("wait for extruder {0}", i)); + } + } + } + } + SwitchToFirstActiveExtruder(extrudersUsed, preStartGCodeLines, preStartGCode); preStartGCode.Add("; settings from start_gcode"); @@ -199,19 +218,23 @@ namespace MatterHackers.MatterControl.SlicerConfiguration numberOfHeatedExtruders = ActiveSliceSettings.Instance.ExtruderCount; } - for (int i = 0; i < numberOfHeatedExtruders; i++) - { - if (extrudersUsed.Count > i - && extrudersUsed[i]) - { - string materialTemperature = ActiveSliceSettings.Instance.GetMaterialValue("temperature", i + 1); - if (materialTemperature != "0") - { - string setTempString = "M109 T{0} S{1}".FormatWith(i, materialTemperature); - AddDefaultIfNotPresent(postStartGCode, setTempString, postStartGCodeLines, string.Format("wait for extruder {0} to reach temperature", i)); - } - } - } + // don't set the extrudes to heating if we alread waited for them to reach temp + if (ActiveSliceSettings.Instance.GetActiveValue("heat_extruder_before_homing") != "1") + { + for (int i = 0; i < numberOfHeatedExtruders; i++) + { + if (extrudersUsed.Count > i + && extrudersUsed[i]) + { + string materialTemperature = ActiveSliceSettings.Instance.GetMaterialValue("temperature", i + 1); + if (materialTemperature != "0") + { + string setTempString = "M109 T{0} S{1}".FormatWith(i, materialTemperature); + AddDefaultIfNotPresent(postStartGCode, setTempString, postStartGCodeLines, string.Format("wait for extruder {0} to reach temperature", i)); + } + } + } + } SwitchToFirstActiveExtruder(extrudersUsed, postStartGCodeLines, postStartGCode); AddDefaultIfNotPresent(postStartGCode, "G90", postStartGCodeLines, "use absolute coordinates"); diff --git a/StaticData/PrinterSettings/3D Stuffmaker/Creator/config.ini b/StaticData/PrinterSettings/3D Stuffmaker/Creator/config.ini index fd7d3c7a2..c193b6a32 100644 --- a/StaticData/PrinterSettings/3D Stuffmaker/Creator/config.ini +++ b/StaticData/PrinterSettings/3D Stuffmaker/Creator/config.ini @@ -51,6 +51,7 @@ gcode_output_type = REPRAP has_fan = 1 has_heated_bed = 0 has_sd_card_reader = 0 +heat_extruder_before_homing = 1 infill_acceleration = 0 infill_every_layers = 1 infill_extruder = 1 diff --git a/StaticData/PrinterSettings/3D Stuffmaker/Evolution/config.ini b/StaticData/PrinterSettings/3D Stuffmaker/Evolution/config.ini index 370b5589f..33aaf6287 100644 --- a/StaticData/PrinterSettings/3D Stuffmaker/Evolution/config.ini +++ b/StaticData/PrinterSettings/3D Stuffmaker/Evolution/config.ini @@ -51,6 +51,7 @@ gcode_output_type = REPRAP has_fan = 1 has_heated_bed = 0 has_sd_card_reader = 0 +heat_extruder_before_homing = 1 infill_acceleration = 0 infill_every_layers = 1 infill_extruder = 1 diff --git a/StaticData/PrinterSettings/config.ini b/StaticData/PrinterSettings/config.ini index 5f3a4bd65..5ddf1513a 100644 --- a/StaticData/PrinterSettings/config.ini +++ b/StaticData/PrinterSettings/config.ini @@ -52,6 +52,7 @@ has_fan = 1 has_hardware_leveling = 0 has_heated_bed = 1 has_sd_card_reader = 0 +heat_extruder_before_homing = 0 infill_acceleration = 0 infill_every_layers = 1 infill_extruder = 1 diff --git a/StaticData/SliceSettings/Layouts.txt b/StaticData/SliceSettings/Layouts.txt index a360f9398..0ccc8fa19 100644 --- a/StaticData/SliceSettings/Layouts.txt +++ b/StaticData/SliceSettings/Layouts.txt @@ -240,6 +240,7 @@ Advanced has_heated_bed has_sd_card_reader extruder_count + heat_extruder_before_homing extruders_share_temperature Firmware z_can_be_negative diff --git a/StaticData/SliceSettings/Properties.json b/StaticData/SliceSettings/Properties.json index dec38e57e..f9cee21c7 100644 --- a/StaticData/SliceSettings/Properties.json +++ b/StaticData/SliceSettings/Properties.json @@ -230,6 +230,13 @@ "DataEditType": "CHECK_BOX", "ExtraSettings": "" }, + { + "SlicerConfigName": "heat_extruder_before_homing", + "PresentationName": "Heat Before Homing", + "HelpText": "Normally while printing the printer will home before heating the extruder(s). Set this to cause the heating to happen before the homing. This can help with printers that touch the bed while homing.", + "DataEditType": "CHECK_BOX", + "ExtraSettings": "" + }, { "SlicerConfigName": "extrusion_axis", "PresentationName": "Extrusion Axis", diff --git a/StaticData/Translations/Master.txt b/StaticData/Translations/Master.txt index b921242fa..8d536060a 100644 --- a/StaticData/Translations/Master.txt +++ b/StaticData/Translations/Master.txt @@ -3113,3 +3113,9 @@ Translated:Reboots the firmware on the controller English:Please wait. Slicing files {0} of {1} Translated:Please wait. Slicing files {0} of {1} +English:Normally while printing the printer will home before heating the extruder(s). Set this to cause the heating to happen before the homing. This can help with printers that touch the bed while homing. +Translated:Normally while printing the printer will home before heating the extruder(s). Set this to cause the heating to happen before the homing. This can help with printers that touch the bed while homing. + +English:Heat Before Homing +Translated:Heat Before Homing +