From 263e2325f5edeb36c821472929c39d672f05ee8a Mon Sep 17 00:00:00 2001 From: larsbrubaker Date: Sat, 15 Feb 2014 18:06:03 -0800 Subject: [PATCH] Put the slicing configuration files in their own folder updated copy write date added bsd to a few files Made the mapping to slice engines more procedural to support more engines. --- ActionBar/PrintActionRow.cs | 1 + ActivePrinterProfile.cs | 64 ++- CustomWidgets/ExportQueueItemWindow.cs | 1 + FieldValidation.cs | 2 +- JsonResponseDictionary.cs | 31 +- MainSlidePanel.cs | 1 + MatterControl.csproj | 17 +- MatterControlApplication.cs | 3 +- PartPreviewWindow/CreateDiscreteMeshes.cs | 2 +- PartPreviewWindow/GcodeViewBasic.cs | 3 +- PartPreviewWindow/PartPreviewBaseWidget.cs | 2 +- PartPreviewWindow/PartPreviewMainWindow.cs | 3 +- PartPreviewWindow/PlatingHelper.cs | 2 +- PartPreviewWindow/ProgressControl.cs | 2 +- PartPreviewWindow/View3DTransfromPart.cs | 2 +- PrintLevelWizard.cs | 3 +- PrintLibrary/ExportLibraryItemWindow.cs | 1 + PrintLibrary/PluginChooserWindow.cs | 2 +- PrintLibrary/PrintLibraryWidget.cs | 2 +- PrintQueue/ExportToFolderProcess.cs | 1 + PrintQueue/ExportToSdCardProcess.cs | 1 + PrintQueue/PrintItemWrapper.cs | 9 +- PrinterCommunication.cs | 2 +- PrinterControls/EditMacrosWindow.cs | 2 +- .../EditManualMovementSpeedsWindow.cs | 2 +- .../EditTemperaturePresetsWindow.cs | 2 +- PrinterControls/MacroControls.cs | 2 +- PrinterControls/ManualPrinterControls.cs | 2 +- PrinterControls/OutputScrollWindow.cs | 2 +- PrinterControls/PrintLeveling.cs | 1 + .../SetupStepMakeModelName.cs | 2 +- PrinterControls/SDCardManager.cs | 2 +- PrinterControls/TemperatureIndicator.cs | 2 +- RequestManager.cs | 2 +- SliceConfiguration/CuraEnginMappings.cs | 480 ----------------- .../ActiveSliceSettings.cs | 33 +- .../SettingsControlBar.cs | 12 +- .../SliceSettingsLayerSelector.cs | 2 +- .../SliceSettingsOrganizer.cs | 2 +- .../SliceSettingsWidget.cs | 39 +- .../SlicerMapping/EngineMapingBase.cs | 41 ++ .../SlicerMapping/EngineMappingCura.cs | 509 ++++++++++++++++++ .../SlicerMapping/EngineMappingSlic3r.cs | 73 +++ .../SlicerMapping/MappingClasses.cs | 27 + .../SlicingQueue.cs | 55 +- TupleList.cs | 2 +- WidescreenPanel.cs | 1 + 47 files changed, 902 insertions(+), 552 deletions(-) delete mode 100644 SliceConfiguration/CuraEnginMappings.cs rename {SliceConfiguration => SlicerConfiguration}/ActiveSliceSettings.cs (93%) rename {SliceConfiguration => SlicerConfiguration}/SettingsControlBar.cs (97%) rename {SliceConfiguration => SlicerConfiguration}/SliceSettingsLayerSelector.cs (92%) rename {SliceConfiguration => SlicerConfiguration}/SliceSettingsOrganizer.cs (99%) rename {SliceConfiguration => SlicerConfiguration}/SliceSettingsWidget.cs (95%) create mode 100644 SlicerConfiguration/SlicerMapping/EngineMapingBase.cs create mode 100644 SlicerConfiguration/SlicerMapping/EngineMappingCura.cs create mode 100644 SlicerConfiguration/SlicerMapping/EngineMappingSlic3r.cs create mode 100644 SlicerConfiguration/SlicerMapping/MappingClasses.cs rename {SliceConfiguration => SlicerConfiguration}/SlicingQueue.cs (81%) diff --git a/ActionBar/PrintActionRow.cs b/ActionBar/PrintActionRow.cs index acccc1b83..69b78bfe7 100644 --- a/ActionBar/PrintActionRow.cs +++ b/ActionBar/PrintActionRow.cs @@ -14,6 +14,7 @@ using MatterHackers.VectorMath; using MatterHackers.MatterControl; using MatterHackers.MatterControl.PrintQueue; using MatterHackers.Localizations; +using MatterHackers.MatterControl.SlicerConfiguration; namespace MatterHackers.MatterControl.ActionBar { diff --git a/ActivePrinterProfile.cs b/ActivePrinterProfile.cs index d86ad28f5..203e61888 100644 --- a/ActivePrinterProfile.cs +++ b/ActivePrinterProfile.cs @@ -1,4 +1,33 @@ -using System; +/* +Copyright (c) 2014, Lars Brubaker +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; using System.Collections.Generic; using System.Linq; using System.Text; @@ -16,14 +45,15 @@ using MatterHackers.VectorMath; using MatterHackers.MatterControl.ContactForm; using MatterHackers.MatterControl.DataStorage; using MatterHackers.Localizations; +using MatterHackers.MatterControl.SlicerConfiguration; namespace MatterHackers.MatterControl { public class ActivePrinterProfile { - public enum SlicingEngine { Slic3r, CuraEngine, MatterSlice }; + public enum SlicingEngineTypes { Slic3r, CuraEngine, MatterSlice }; - static readonly SlicingEngine defaultEngine = SlicingEngine.Slic3r; + static readonly SlicingEngineTypes defaultEngineType = SlicingEngineTypes.Slic3r; static ActivePrinterProfile globalInstance = null; public RootedObjectEventHandler ActivePrinterChanged = new RootedObjectEventHandler(); @@ -62,13 +92,13 @@ namespace MatterHackers.MatterControl } } - public SlicingEngine ActiveSliceEngine + public SlicingEngineTypes ActiveSliceEngineType { get { if (ActivePrinter != null) { - foreach (SlicingEngine engine in SlicingEngine.GetValues(typeof(SlicingEngine))) + foreach (SlicingEngineTypes engine in SlicingEngineTypes.GetValues(typeof(SlicingEngineTypes))) { if (ActivePrinter.CurrentSlicingEngine == engine.ToString()) { @@ -77,15 +107,15 @@ namespace MatterHackers.MatterControl } // It is not set in the slice settings, so set it and save it. - ActivePrinter.CurrentSlicingEngine = defaultEngine.ToString(); + ActivePrinter.CurrentSlicingEngine = defaultEngineType.ToString(); ActivePrinter.Commit(); } - return defaultEngine; + return defaultEngineType; } set { - if (ActiveSliceEngine != value) + if (ActiveSliceEngineType != value) { ActivePrinter.CurrentSlicingEngine = value.ToString(); ActivePrinter.Commit(); @@ -93,6 +123,24 @@ namespace MatterHackers.MatterControl } } + public SliceEngineMaping ActiveSliceEngine + { + get + { + switch (ActiveSliceEngineType) + { + case SlicingEngineTypes.Slic3r: + return Slic3rEngineMappings.Instance; + + case SlicingEngineTypes.CuraEngine: + return CuraEngineMappings.Instance; + + default: + return null; + } + } + } + public void OnActivePrinterChanged(EventArgs e) { ActivePrinterChanged.CallEvents(this, e); diff --git a/CustomWidgets/ExportQueueItemWindow.cs b/CustomWidgets/ExportQueueItemWindow.cs index ccb25611d..f25cd14b6 100644 --- a/CustomWidgets/ExportQueueItemWindow.cs +++ b/CustomWidgets/ExportQueueItemWindow.cs @@ -10,6 +10,7 @@ using MatterHackers.MatterControl.DataStorage; using MatterHackers.MatterControl.PrintQueue; using MatterHackers.GCodeVisualizer; using MatterHackers.Localizations; +using MatterHackers.MatterControl.SlicerConfiguration; namespace MatterHackers.MatterControl { diff --git a/FieldValidation.cs b/FieldValidation.cs index 194f00a1c..de24dece7 100644 --- a/FieldValidation.cs +++ b/FieldValidation.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2013, Lars Brubaker +Copyright (c) 2014, Lars Brubaker All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/JsonResponseDictionary.cs b/JsonResponseDictionary.cs index 37f1e2c33..dd39a5316 100644 --- a/JsonResponseDictionary.cs +++ b/JsonResponseDictionary.cs @@ -1,4 +1,33 @@ -using System; +/* +Copyright (c) 2014, Lars Brubaker +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; using System.Collections.Generic; using System.Linq; using System.Text; diff --git a/MainSlidePanel.cs b/MainSlidePanel.cs index 206c73bb0..9396458f8 100644 --- a/MainSlidePanel.cs +++ b/MainSlidePanel.cs @@ -14,6 +14,7 @@ using MatterHackers.VectorMath; using MatterHackers.MatterControl; using MatterHackers.MatterControl.PrintQueue; using MatterHackers.MatterControl.PrintLibrary; +using MatterHackers.MatterControl.SlicerConfiguration; using MatterHackers.MatterControl.ToolsPage; using MatterHackers.MatterControl.DataStorage; using MatterHackers.Localizations; diff --git a/MatterControl.csproj b/MatterControl.csproj index 0c5d9fb07..f89b1bf9d 100644 --- a/MatterControl.csproj +++ b/MatterControl.csproj @@ -93,6 +93,10 @@ + + + + @@ -162,13 +166,12 @@ - - - - - - - + + + + + + diff --git a/MatterControlApplication.cs b/MatterControlApplication.cs index 5df4aa867..cd27b9f8e 100644 --- a/MatterControlApplication.cs +++ b/MatterControlApplication.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2013, Lars Brubaker +Copyright (c) 2014, Lars Brubaker All rights reserved. Redistribution and use in source and binary forms, with or without @@ -54,6 +54,7 @@ using MatterHackers.MatterControl.DataStorage; using MatterHackers.MatterControl.VersionManagement; using MatterHackers.MatterControl.PluginSystem; using MatterHackers.MatterControl.PartPreviewWindow; +using MatterHackers.MatterControl.SlicerConfiguration; using Newtonsoft.Json; using Newtonsoft.Json.Converters; diff --git a/PartPreviewWindow/CreateDiscreteMeshes.cs b/PartPreviewWindow/CreateDiscreteMeshes.cs index a6f966af8..b20d81a85 100644 --- a/PartPreviewWindow/CreateDiscreteMeshes.cs +++ b/PartPreviewWindow/CreateDiscreteMeshes.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2013, Lars Brubaker +Copyright (c) 2014, Lars Brubaker All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/PartPreviewWindow/GcodeViewBasic.cs b/PartPreviewWindow/GcodeViewBasic.cs index 7434123bd..152473baa 100644 --- a/PartPreviewWindow/GcodeViewBasic.cs +++ b/PartPreviewWindow/GcodeViewBasic.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2013, Lars Brubaker +Copyright (c) 2014, Lars Brubaker All rights reserved. Redistribution and use in source and binary forms, with or without @@ -39,6 +39,7 @@ using MatterHackers.Agg; using MatterHackers.Agg.Image; using MatterHackers.Agg.UI; using MatterHackers.Agg.OpenGlGui; +using MatterHackers.MatterControl.SlicerConfiguration; using MatterHackers.PolygonMesh; using MatterHackers.RenderOpenGl; using MatterHackers.VectorMath; diff --git a/PartPreviewWindow/PartPreviewBaseWidget.cs b/PartPreviewWindow/PartPreviewBaseWidget.cs index b8e9b4703..486ea82b2 100644 --- a/PartPreviewWindow/PartPreviewBaseWidget.cs +++ b/PartPreviewWindow/PartPreviewBaseWidget.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2013, Lars Brubaker +Copyright (c) 2014, Lars Brubaker All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/PartPreviewWindow/PartPreviewMainWindow.cs b/PartPreviewWindow/PartPreviewMainWindow.cs index 604b86697..9eebdf286 100644 --- a/PartPreviewWindow/PartPreviewMainWindow.cs +++ b/PartPreviewWindow/PartPreviewMainWindow.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2013, Lars Brubaker +Copyright (c) 2014, Lars Brubaker All rights reserved. Redistribution and use in source and binary forms, with or without @@ -36,6 +36,7 @@ using MatterHackers.Agg.Font; using MatterHackers.Localizations; using MatterHackers.MatterControl.DataStorage; using MatterHackers.MatterControl.PrintQueue; +using MatterHackers.MatterControl.SlicerConfiguration; using MatterHackers.VectorMath; namespace MatterHackers.MatterControl.PartPreviewWindow diff --git a/PartPreviewWindow/PlatingHelper.cs b/PartPreviewWindow/PlatingHelper.cs index 4056e1072..5749fed02 100644 --- a/PartPreviewWindow/PlatingHelper.cs +++ b/PartPreviewWindow/PlatingHelper.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2013, Lars Brubaker +Copyright (c) 2014, Lars Brubaker All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/PartPreviewWindow/ProgressControl.cs b/PartPreviewWindow/ProgressControl.cs index a8653df75..3858e58f9 100644 --- a/PartPreviewWindow/ProgressControl.cs +++ b/PartPreviewWindow/ProgressControl.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2013, Lars Brubaker +Copyright (c) 2014, Lars Brubaker All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/PartPreviewWindow/View3DTransfromPart.cs b/PartPreviewWindow/View3DTransfromPart.cs index 190dae45f..14f46a164 100644 --- a/PartPreviewWindow/View3DTransfromPart.cs +++ b/PartPreviewWindow/View3DTransfromPart.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2013, Lars Brubaker +Copyright (c) 2014, Lars Brubaker All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/PrintLevelWizard.cs b/PrintLevelWizard.cs index 039a00513..397afd416 100644 --- a/PrintLevelWizard.cs +++ b/PrintLevelWizard.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2013, Lars Brubaker +Copyright (c) 2014, Lars Brubaker All rights reserved. Redistribution and use in source and binary forms, with or without @@ -38,6 +38,7 @@ using MatterHackers.Agg.UI; using MatterHackers.VectorMath; using MatterHackers.Agg.Font; using MatterHackers.Localizations; +using MatterHackers.MatterControl.SlicerConfiguration; namespace MatterHackers.MatterControl { diff --git a/PrintLibrary/ExportLibraryItemWindow.cs b/PrintLibrary/ExportLibraryItemWindow.cs index f6038739c..c1cfd4c8c 100644 --- a/PrintLibrary/ExportLibraryItemWindow.cs +++ b/PrintLibrary/ExportLibraryItemWindow.cs @@ -9,6 +9,7 @@ using MatterHackers.Agg.UI; using MatterHackers.MatterControl.DataStorage; using MatterHackers.MatterControl.PrintQueue; using MatterHackers.GCodeVisualizer; +using MatterHackers.MatterControl.SlicerConfiguration; namespace MatterHackers.MatterControl.PrintLibrary { diff --git a/PrintLibrary/PluginChooserWindow.cs b/PrintLibrary/PluginChooserWindow.cs index 4dc433463..362c2d7bf 100644 --- a/PrintLibrary/PluginChooserWindow.cs +++ b/PrintLibrary/PluginChooserWindow.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2013, Lars Brubaker +Copyright (c) 2014, Lars Brubaker All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/PrintLibrary/PrintLibraryWidget.cs b/PrintLibrary/PrintLibraryWidget.cs index ef22eab41..2e427fab7 100644 --- a/PrintLibrary/PrintLibraryWidget.cs +++ b/PrintLibrary/PrintLibraryWidget.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2013, Lars Brubaker +Copyright (c) 2014, Lars Brubaker All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/PrintQueue/ExportToFolderProcess.cs b/PrintQueue/ExportToFolderProcess.cs index 03bcde744..835077283 100644 --- a/PrintQueue/ExportToFolderProcess.cs +++ b/PrintQueue/ExportToFolderProcess.cs @@ -7,6 +7,7 @@ using MatterHackers.MatterControl.DataStorage; using MatterHackers.MatterControl.PrintQueue; using MatterHackers.Agg.UI; using MatterHackers.GCodeVisualizer; +using MatterHackers.MatterControl.SlicerConfiguration; namespace MatterHackers.MatterControl.PrintQueue { diff --git a/PrintQueue/ExportToSdCardProcess.cs b/PrintQueue/ExportToSdCardProcess.cs index 639077cfd..1e1293ebe 100644 --- a/PrintQueue/ExportToSdCardProcess.cs +++ b/PrintQueue/ExportToSdCardProcess.cs @@ -5,6 +5,7 @@ using System.IO; using MatterHackers.MatterControl.DataStorage; using MatterHackers.MatterControl.PrintQueue; +using MatterHackers.MatterControl.SlicerConfiguration; using MatterHackers.Agg.UI; using MatterHackers.GCodeVisualizer; diff --git a/PrintQueue/PrintItemWrapper.cs b/PrintQueue/PrintItemWrapper.cs index aa858ed47..1e6b69313 100644 --- a/PrintQueue/PrintItemWrapper.cs +++ b/PrintQueue/PrintItemWrapper.cs @@ -10,6 +10,7 @@ using System.Diagnostics; using MatterHackers.Agg.UI; using MatterHackers.Agg; using MatterHackers.MatterControl.DataStorage; +using MatterHackers.MatterControl.SlicerConfiguration; namespace MatterHackers.MatterControl.PrintQueue { @@ -168,10 +169,10 @@ namespace MatterHackers.MatterControl.PrintQueue } // check if there is a known line at the end of the file (this will let us know if slicer finished building the file). - switch (ActivePrinterProfile.Instance.ActiveSliceEngine) + switch (ActivePrinterProfile.Instance.ActiveSliceEngineType) { - case ActivePrinterProfile.SlicingEngine.CuraEngine: - case ActivePrinterProfile.SlicingEngine.Slic3r: + case ActivePrinterProfile.SlicingEngineTypes.CuraEngine: + case ActivePrinterProfile.SlicingEngineTypes.Slic3r: if (gcodeFileContents.Contains("filament used =")) { gCodeFileIsComplete = true; @@ -193,7 +194,7 @@ namespace MatterHackers.MatterControl.PrintQueue return FileLocation; } - string engineString = ((int)ActivePrinterProfile.Instance.ActiveSliceEngine).ToString(); + string engineString = ((int)ActivePrinterProfile.Instance.ActiveSliceEngineType).ToString(); string gcodeFileName = this.StlFileHashCode.ToString() + "_" + engineString + "_" + ActiveSliceSettings.Instance.GetHashCode().ToString(); string gcodePathAndFileName = Path.Combine(DataStorage.ApplicationDataStorage.Instance.GCodeOutputPath, gcodeFileName + ".gcode"); diff --git a/PrinterCommunication.cs b/PrinterCommunication.cs index fac383115..e0a60933e 100644 --- a/PrinterCommunication.cs +++ b/PrinterCommunication.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2013, Lars Brubaker +Copyright (c) 2014, Lars Brubaker All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/PrinterControls/EditMacrosWindow.cs b/PrinterControls/EditMacrosWindow.cs index 8dab8f148..5fc89c939 100644 --- a/PrinterControls/EditMacrosWindow.cs +++ b/PrinterControls/EditMacrosWindow.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2013, Lars Brubaker +Copyright (c) 2014, Lars Brubaker All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/PrinterControls/EditManualMovementSpeedsWindow.cs b/PrinterControls/EditManualMovementSpeedsWindow.cs index fc5ef488f..f49dc3d08 100644 --- a/PrinterControls/EditManualMovementSpeedsWindow.cs +++ b/PrinterControls/EditManualMovementSpeedsWindow.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2013, Kevin Pope +Copyright (c) 2014, Kevin Pope All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/PrinterControls/EditTemperaturePresetsWindow.cs b/PrinterControls/EditTemperaturePresetsWindow.cs index 8be20292e..411db1389 100644 --- a/PrinterControls/EditTemperaturePresetsWindow.cs +++ b/PrinterControls/EditTemperaturePresetsWindow.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2013, Lars Brubaker +Copyright (c) 2014, Lars Brubaker All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/PrinterControls/MacroControls.cs b/PrinterControls/MacroControls.cs index 7a3da7e49..5a3c45643 100644 --- a/PrinterControls/MacroControls.cs +++ b/PrinterControls/MacroControls.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2013, Lars Brubaker +Copyright (c) 2014, Lars Brubaker All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/PrinterControls/ManualPrinterControls.cs b/PrinterControls/ManualPrinterControls.cs index 184fe60d4..e5c03f2f3 100644 --- a/PrinterControls/ManualPrinterControls.cs +++ b/PrinterControls/ManualPrinterControls.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2013, Lars Brubaker +Copyright (c) 2014, Lars Brubaker All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/PrinterControls/OutputScrollWindow.cs b/PrinterControls/OutputScrollWindow.cs index 4dfd5f5cd..330e8d876 100644 --- a/PrinterControls/OutputScrollWindow.cs +++ b/PrinterControls/OutputScrollWindow.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2013, Lars Brubaker +Copyright (c) 2014, Lars Brubaker All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/PrinterControls/PrintLeveling.cs b/PrinterControls/PrintLeveling.cs index 0cbf79de0..89bfe5b0b 100644 --- a/PrinterControls/PrintLeveling.cs +++ b/PrinterControls/PrintLeveling.cs @@ -6,6 +6,7 @@ using System.Text; using MatterHackers.VectorMath; using MatterHackers.RayTracer; using MatterHackers.GCodeVisualizer; +using MatterHackers.MatterControl.SlicerConfiguration; namespace MatterHackers.MatterControl { diff --git a/PrinterControls/PrinterConnections/SetupStepMakeModelName.cs b/PrinterControls/PrinterConnections/SetupStepMakeModelName.cs index 1d6303087..cca9d40ca 100644 --- a/PrinterControls/PrinterConnections/SetupStepMakeModelName.cs +++ b/PrinterControls/PrinterConnections/SetupStepMakeModelName.cs @@ -204,7 +204,7 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections string defaultSliceEngine; if (settingsDict.TryGetValue("default_slice_engine", out defaultSliceEngine)) { - if (Enum.IsDefined(typeof(ActivePrinterProfile.SlicingEngine), defaultSliceEngine)) + if (Enum.IsDefined(typeof(ActivePrinterProfile.SlicingEngineTypes), defaultSliceEngine)) { ActivePrinter.CurrentSlicingEngine = defaultSliceEngine; } diff --git a/PrinterControls/SDCardManager.cs b/PrinterControls/SDCardManager.cs index a2428e52a..6be2e7264 100644 --- a/PrinterControls/SDCardManager.cs +++ b/PrinterControls/SDCardManager.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2013, Lars Brubaker +Copyright (c) 2014, Lars Brubaker All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/PrinterControls/TemperatureIndicator.cs b/PrinterControls/TemperatureIndicator.cs index 9a10b92eb..e4690d822 100644 --- a/PrinterControls/TemperatureIndicator.cs +++ b/PrinterControls/TemperatureIndicator.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2013, Lars Brubaker +Copyright (c) 2014, Lars Brubaker All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/RequestManager.cs b/RequestManager.cs index 9833706c0..08c1e243b 100644 --- a/RequestManager.cs +++ b/RequestManager.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2013, Lars Brubaker +Copyright (c) 2014, Lars Brubaker All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/SliceConfiguration/CuraEnginMappings.cs b/SliceConfiguration/CuraEnginMappings.cs deleted file mode 100644 index 688ca6402..000000000 --- a/SliceConfiguration/CuraEnginMappings.cs +++ /dev/null @@ -1,480 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -using MatterHackers.VectorMath; - -namespace MatterHackers.MatterControl -{ - public static class CuraEngineMappings - { - public static bool MapContains(string defaultKey) - { - foreach (MapItem mapItem in curaToDefaultMapping) - { - if (mapItem.DefaultKey == defaultKey) - { - return true; - } - } - - return false; - } - - static MapItem[] curaToDefaultMapping = - { - new ScaledSingleNumber("layerThickness", "layer_height", 1000), - new AsPercentOfReferenceOrDirect("initialLayerThickness", "first_layer_height", "layer_height", 1000), - new ScaledSingleNumber("filamentDiameter", "filament_diameter", 1000), - new ScaledSingleNumber("extrusionWidth", "nozzle_diameter", 1000), - - new MapItem("printSpeed", "perimeter_speed"), - new MapItem("infillSpeed", "infill_speed"), - new MapItem("moveSpeed", "travel_speed"), - new AsPercentOfReferenceOrDirect("initialLayerSpeed", "first_layer_speed", "infill_speed"), - - new NotPassedItem("", "temperature"), - new NotPassedItem("", "bed_temperature"), - new NotPassedItem("", "bed_shape"), - - new MapItem("insetCount", "perimeters"), - - new MapItem("skirtLineCount", "skirts"), - new SkirtLengthMaping("skirtMinLength", "min_skirt_length"), - new ScaledSingleNumber("skirtDistance", "skirt_distance", 1000), - - new MapItem("fanSpeedMin", "max_fan_speed"), - new MapItem("fanSpeedMax", "min_fan_speed"), - - new MapItem("downSkinCount", "bottom_solid_layers"), - new MapItem("upSkinCount", "top_solid_layers"), - - new FanTranslator("fanFullOnLayerNr", "disable_fan_first_layers"), - new MapItem("coolHeadLift", "cool_extruder_lift"), - - new ScaledSingleNumber("retractionAmount", "retract_length", 1000), - new MapItem("retractionSpeed", "retract_speed"), - new ScaledSingleNumber("retractionMinimalDistance", "retract_before_travel", 1000), - - new MapItem("spiralizeMode", "spiral_vase"), - - new NotPassedItem("", "bed_size"), - - new PrintCenterX("posx", "print_center"), - new PrintCenterY("posy", "print_center"), - - new NotPassedItem("", "build_height"), - - // needs testing, not working - new ScaledSingleNumber("supportLineDistance", "support_material_spacing", 1000), - new SupportMatterial("supportAngle", "support_material"), - new NotPassedItem("", "support_material_threshold"), - new MapItem("supportEverywhere", "support_material_create_internal_support"), - new ScaledSingleNumber("supportXYDistance", "support_material_xy_distance", 1000), - new ScaledSingleNumber("supportZDistance", "support_material_z_distance", 1000), - - new MapItem("minimalLayerTime", "slowdown_below_layer_time"), - - new InfillTranslator("sparseInfillLineDistance", "fill_density"), - - new MapStartGCode("startCode", "start_gcode"), - new MapEndGCode("endCode", "end_gcode"), - -#if false - SETTING(filamentFlow); - SETTING(infillOverlap); - - SETTING(initialSpeedupLayers); - - SETTING(supportExtruder); - - SETTING(retractionAmountExtruderSwitch); - SETTING(minimalExtrusionBeforeRetraction); - SETTING(enableCombing); - SETTING(multiVolumeOverlap); - SETTING(objectSink); - - SETTING(raftMargin); - SETTING(raftLineSpacing); - SETTING(raftBaseThickness); - SETTING(raftBaseLinewidth); - SETTING(raftInterfaceThickness); - SETTING(raftInterfaceLinewidth); - - SETTING(minimalFeedrate); - -fanFullOnLayerNr = 2; - - SETTING(fixHorrible); - SETTING(gcodeFlavor); - -/* -objectPosition.X = 102500; -objectPosition.Y = 102500; -enableOozeShield = 0; -*/ -#endif - }; - - public static string GetCuraCommandLineSettings() - { - StringBuilder settings = new StringBuilder(); - for (int i = 0; i < curaToDefaultMapping.Length; i++) - { - string curaValue = curaToDefaultMapping[i].CuraValue; - if(curaValue != null && curaValue != "") - { - settings.Append(string.Format("-s {0}=\"{1}\" ", curaToDefaultMapping[i].CuraKey, curaValue)); - } - } - - return settings.ToString(); - } - } - - public class MapItem - { - string curaKey; - string defaultKey; - - internal MapItem(string curaKey, string defaultKey) - { - this.curaKey = curaKey; - this.defaultKey = defaultKey; - } - - public string CuraKey { get { return curaKey; } } - public string DefaultKey { get { return defaultKey; } } - - public string SlicerValue { get { return ActiveSliceSettings.Instance.GetActiveValue(defaultKey); } } - - public virtual string CuraValue { get { return SlicerValue; } } - } - - public class NotPassedItem : MapItem - { - public override string CuraValue - { - get - { - return null; - } - } - - public NotPassedItem(string cura, string slicer) - : base(cura, slicer) - { - } - } - - public class FanTranslator : MapItem - { - public override string CuraValue - { - get - { - int numLayersFanIsDisabledOn = int.Parse(base.CuraValue); - int layerToEnableFanOn = numLayersFanIsDisabledOn+1; - return layerToEnableFanOn.ToString(); - } - } - - public FanTranslator(string cura, string slicer) - : base(cura, slicer) - { - } - } - - public class SupportMatterial : MapItem - { - public override string CuraValue - { - get - { - string supportMaterial = ActiveSliceSettings.Instance.GetActiveValue("support_material"); - if (supportMaterial == "0") - { - return "-1"; - } - - return (90 - double.Parse(ActiveSliceSettings.Instance.GetActiveValue("support_material_threshold"))).ToString(); - } - } - - public SupportMatterial(string cura, string slicer) - : base(cura, slicer) - { - } - } - - public class InfillTranslator : MapItem - { - public override string CuraValue - { - get - { - double infillRatio0To1 = Double.Parse(base.CuraValue); - // 400 = solid (extruder width) - double nozzle_diameter = double.Parse(ActiveSliceSettings.Instance.GetActiveValue("nozzle_diameter")); - double linespacing = 1000; - if (infillRatio0To1 > .01) - { - linespacing = nozzle_diameter / infillRatio0To1; - } - - return ((int)(linespacing * 1000)).ToString(); - } - } - - public InfillTranslator(string cura, string slicer) - : base(cura, slicer) - { - } - } - - public class PrintCenterX : MapItem - { - public override string CuraValue - { - get - { - Vector2 PrinteCenter = ActiveSliceSettings.Instance.PrintCenter; - return (PrinteCenter.x * 1000).ToString(); - } - } - - public PrintCenterX(string cura, string slicer) - : base(cura, slicer) - { - } - } - - public class PrintCenterY : MapItem - { - public override string CuraValue - { - get - { - Vector2 PrinteCenter = ActiveSliceSettings.Instance.PrintCenter; - return (PrinteCenter.y * 1000).ToString(); - } - } - - public PrintCenterY(string cura, string slicer) - : base(cura, slicer) - { - } - } - - public class ConvertCRs : MapItem - { - public override string CuraValue - { - get - { - string actualCRs = base.CuraValue.Replace("\\n", "\n"); - return actualCRs; - } - } - - public ConvertCRs(string cura, string slicer) - : base(cura, slicer) - { - } - } - - public class InjectGCodeCommands : ConvertCRs - { - public InjectGCodeCommands(string cura, string slicer) - : base(cura, slicer) - { - } - - protected void AddDefaultIfNotPresent(List linesAdded, string commandToAdd, string[] linesToCheckIfAlreadyPresent, string comment) - { - string command = commandToAdd.Split(' ')[0].Trim(); - bool foundCommand = false; - foreach (string line in linesToCheckIfAlreadyPresent) - { - if (line.StartsWith(command)) - { - foundCommand = true; - break; - } - } - - if (!foundCommand) - { - linesAdded.Add(string.Format("{0} ; {1}", commandToAdd, comment)); - } - } - } - - public class MapStartGCode : InjectGCodeCommands - { - public override string CuraValue - { - get - { - StringBuilder curaStartGCode = new StringBuilder(); - foreach (string line in PreStartGCode()) - { - curaStartGCode.Append(line + "\n"); - } - - curaStartGCode.Append(base.CuraValue); - - bool first = true; - foreach (string line in PostStartGCode()) - { - if (!first) - { - curaStartGCode.Append("\n"); - } - curaStartGCode.Append(line); - first = false; - } - - return curaStartGCode.ToString(); - } - } - - public MapStartGCode(string cura, string slicer) - : base(cura, slicer) - { - } - - public List PreStartGCode() - { - string startGCode = ActiveSliceSettings.Instance.GetActiveValue("start_gcode"); - string[] preStartGCodeLines = startGCode.Split(new string[] {"\\n"}, StringSplitOptions.RemoveEmptyEntries); - - List preStartGCode = new List(); - preStartGCode.Add("; automatic settings before start_gcode"); - AddDefaultIfNotPresent(preStartGCode, "G21", preStartGCodeLines, "set units to millimeters"); - AddDefaultIfNotPresent(preStartGCode, "M107", preStartGCodeLines, "fan off"); - double bed_temperature = double.Parse(ActiveSliceSettings.Instance.GetActiveValue("bed_temperature")); - if (bed_temperature > 0) - { - string setBedTempString = string.Format("M190 S{0}", bed_temperature); - AddDefaultIfNotPresent(preStartGCode, setBedTempString, preStartGCodeLines, "wait for bed temperature to be reached"); - } - string setTempString = string.Format("M104 S{0}", ActiveSliceSettings.Instance.GetActiveValue("temperature")); - AddDefaultIfNotPresent(preStartGCode, setTempString, preStartGCodeLines, "set temperature"); - preStartGCode.Add("; settings from start_gcode"); - - return preStartGCode; - } - - public List PostStartGCode() - { - string startGCode = ActiveSliceSettings.Instance.GetActiveValue("start_gcode"); - string[] postStartGCodeLines = startGCode.Split(new string[] { "\\n" }, StringSplitOptions.RemoveEmptyEntries); - - List postStartGCode = new List(); - postStartGCode.Add("; automatic settings after start_gcode"); - string setTempString = string.Format("M109 S{0}", ActiveSliceSettings.Instance.GetActiveValue("temperature")); - AddDefaultIfNotPresent(postStartGCode, setTempString, postStartGCodeLines, "wait for temperature"); - AddDefaultIfNotPresent(postStartGCode, "G90", postStartGCodeLines, "use absolute coordinates"); - postStartGCode.Add(string.Format("{0} ; {1}", "G92 E0", "reset the expected extruder position")); - AddDefaultIfNotPresent(postStartGCode, "M82", postStartGCodeLines, "use absolute distance for extrusion"); - - return postStartGCode; - } - } - - public class MapEndGCode : InjectGCodeCommands - { - public override string CuraValue - { - get - { - StringBuilder curaEndGCode = new StringBuilder(); - - curaEndGCode.Append(base.CuraValue); - - curaEndGCode.Append("\n; filament used = filament_used_replace_mm (filament_used_replace_cm3)"); - - return curaEndGCode.ToString(); - } - } - - public MapEndGCode(string cura, string slicer) - : base(cura, slicer) - { - } - } - - public class SkirtLengthMaping : MapItem - { - public SkirtLengthMaping(string curaKey, string defaultKey) - : base(curaKey, defaultKey) - { - } - - public override string CuraValue - { - get - { - double lengthToExtrudeMm = double.Parse(base.CuraValue); - // we need to convert mm of filament to mm of extrusion path - double amountOfFilamentCubicMms = ActiveSliceSettings.Instance.FillamentDiameter * MathHelper.Tau * lengthToExtrudeMm; - double extrusionSquareSize = ActiveSliceSettings.Instance.FirstLayerHeight * ActiveSliceSettings.Instance.NozzleDiameter; - double lineLength = amountOfFilamentCubicMms / extrusionSquareSize; - - return (lineLength * 1000).ToString(); - } - } - } - - public class ScaledSingleNumber : MapItem - { - internal double scale; - public override string CuraValue - { - get - { - if (scale != 1) - { - return (double.Parse(base.CuraValue) * scale).ToString(); - } - return base.CuraValue; - } - } - - internal ScaledSingleNumber(string cura, string slicer, double scale = 1) - : base(cura, slicer) - { - this.scale = scale; - } - } - - public class AsPercentOfReferenceOrDirect : ScaledSingleNumber - { - internal string slicerReference; - public override string CuraValue - { - get - { - if (SlicerValue.Contains("%")) - { - string withoutPercent = SlicerValue.Replace("%", ""); - double ratio = double.Parse(withoutPercent) / 100.0; - string slicerReferenceString = ActiveSliceSettings.Instance.GetActiveValue(slicerReference); - double valueToModify = double.Parse(slicerReferenceString); - double finalValue = valueToModify * ratio * scale; - return finalValue.ToString(); - } - - return base.CuraValue; - } - } - - internal AsPercentOfReferenceOrDirect(string cura, string slicer, string slicerReference, double scale = 1) - : base(cura, slicer, scale) - { - this.slicerReference = slicerReference; - } - } -} diff --git a/SliceConfiguration/ActiveSliceSettings.cs b/SlicerConfiguration/ActiveSliceSettings.cs similarity index 93% rename from SliceConfiguration/ActiveSliceSettings.cs rename to SlicerConfiguration/ActiveSliceSettings.cs index 084c0119f..397828376 100644 --- a/SliceConfiguration/ActiveSliceSettings.cs +++ b/SlicerConfiguration/ActiveSliceSettings.cs @@ -1,4 +1,33 @@ -using System; +/* +Copyright (c) 2014, Lars Brubaker +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; using System.Collections.Generic; using System.Globalization; using System.Diagnostics; @@ -12,7 +41,7 @@ using MatterHackers.MatterControl.ContactForm; using MatterHackers.MatterControl.DataStorage; using MatterHackers.Localizations; -namespace MatterHackers.MatterControl +namespace MatterHackers.MatterControl.SlicerConfiguration { public class SettingsLayer { diff --git a/SliceConfiguration/SettingsControlBar.cs b/SlicerConfiguration/SettingsControlBar.cs similarity index 97% rename from SliceConfiguration/SettingsControlBar.cs rename to SlicerConfiguration/SettingsControlBar.cs index 36e23b8f1..e061aa10c 100644 --- a/SliceConfiguration/SettingsControlBar.cs +++ b/SlicerConfiguration/SettingsControlBar.cs @@ -13,7 +13,7 @@ using MatterHackers.Agg.UI; using MatterHackers.VectorMath; using MatterHackers.Localizations; -namespace MatterHackers.MatterControl +namespace MatterHackers.MatterControl.SlicerConfiguration { public class SettingsControlBar : FlowLayoutWidget { @@ -135,17 +135,17 @@ namespace MatterHackers.MatterControl StyledDropDownList engineMenuDropList = new StyledDropDownList("Engine "); engineMenuDropList.Margin = new BorderDouble(top: 3, left:0); { - MenuItem slic3rMenuItem = engineMenuDropList.AddItem(ActivePrinterProfile.SlicingEngine.Slic3r.ToString()); + MenuItem slic3rMenuItem = engineMenuDropList.AddItem(ActivePrinterProfile.SlicingEngineTypes.Slic3r.ToString()); slic3rMenuItem.Selected += (sender, e) => { - ActivePrinterProfile.Instance.ActiveSliceEngine = ActivePrinterProfile.SlicingEngine.Slic3r; + ActivePrinterProfile.Instance.ActiveSliceEngineType = ActivePrinterProfile.SlicingEngineTypes.Slic3r; MainSlidePanel.Instance.ReloadBackPanel(); }; - MenuItem curaEnginMenuItem = engineMenuDropList.AddItem(ActivePrinterProfile.SlicingEngine.CuraEngine.ToString()); + MenuItem curaEnginMenuItem = engineMenuDropList.AddItem(ActivePrinterProfile.SlicingEngineTypes.CuraEngine.ToString()); curaEnginMenuItem.Selected += (sender, e) => { - ActivePrinterProfile.Instance.ActiveSliceEngine = ActivePrinterProfile.SlicingEngine.CuraEngine; + ActivePrinterProfile.Instance.ActiveSliceEngineType = ActivePrinterProfile.SlicingEngineTypes.CuraEngine; MainSlidePanel.Instance.ReloadBackPanel(); }; @@ -158,7 +158,7 @@ namespace MatterHackers.MatterControl }; #endif - engineMenuDropList.SelectedValue = ActivePrinterProfile.Instance.ActiveSliceEngine.ToString(); + engineMenuDropList.SelectedValue = ActivePrinterProfile.Instance.ActiveSliceEngineType.ToString(); } engineMenuDropList.MinimumSize = new Vector2(engineMenuDropList.LocalBounds.Width, engineMenuDropList.LocalBounds.Height); return engineMenuDropList; diff --git a/SliceConfiguration/SliceSettingsLayerSelector.cs b/SlicerConfiguration/SliceSettingsLayerSelector.cs similarity index 92% rename from SliceConfiguration/SliceSettingsLayerSelector.cs rename to SlicerConfiguration/SliceSettingsLayerSelector.cs index 5d300e8df..75af319e5 100644 --- a/SliceConfiguration/SliceSettingsLayerSelector.cs +++ b/SlicerConfiguration/SliceSettingsLayerSelector.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; -namespace MatterHackers.MatterControl +namespace MatterHackers.MatterControl.SlicerConfiguration { class SliceSettingsLayerSelector { diff --git a/SliceConfiguration/SliceSettingsOrganizer.cs b/SlicerConfiguration/SliceSettingsOrganizer.cs similarity index 99% rename from SliceConfiguration/SliceSettingsOrganizer.cs rename to SlicerConfiguration/SliceSettingsOrganizer.cs index 5eb71bb5a..88590d00a 100644 --- a/SliceConfiguration/SliceSettingsOrganizer.cs +++ b/SlicerConfiguration/SliceSettingsOrganizer.cs @@ -15,7 +15,7 @@ using MatterHackers.VectorMath; using MatterHackers.MatterControl.DataStorage; using MatterHackers.Localizations; -namespace MatterHackers.MatterControl +namespace MatterHackers.MatterControl.SlicerConfiguration { public class OrganizerSettingsData { diff --git a/SliceConfiguration/SliceSettingsWidget.cs b/SlicerConfiguration/SliceSettingsWidget.cs similarity index 95% rename from SliceConfiguration/SliceSettingsWidget.cs rename to SlicerConfiguration/SliceSettingsWidget.cs index 8c3d08597..85dd73617 100644 --- a/SliceConfiguration/SliceSettingsWidget.cs +++ b/SlicerConfiguration/SliceSettingsWidget.cs @@ -1,12 +1,42 @@ -using System; +/* +Copyright (c) 2014, Lars Brubaker +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; using System.Collections.Generic; using MatterHackers.Agg; using MatterHackers.Agg.Font; using MatterHackers.Agg.UI; using MatterHackers.Localizations; using MatterHackers.VectorMath; +using MatterHackers.MatterControl.SlicerConfiguration; -namespace MatterHackers.MatterControl +namespace MatterHackers.MatterControl.SlicerConfiguration { public class SliceSettingsWidget : GuiWidget { @@ -144,7 +174,7 @@ namespace MatterHackers.MatterControl categoryPage.AddChild(sideTabs); } - if (showAllDetails.Checked && ActivePrinterProfile.Instance.ActiveSliceEngine == ActivePrinterProfile.SlicingEngine.Slic3r) + if (showAllDetails.Checked && ActivePrinterProfile.Instance.ActiveSliceEngineType == ActivePrinterProfile.SlicingEngineTypes.Slic3r) { TabPage extraSettingsPage = new TabPage("Other"); SimpleTextTabWidget extraSettingsTextTabWidget = new SimpleTextTabWidget(extraSettingsPage, 16, @@ -295,8 +325,7 @@ namespace MatterHackers.MatterControl foreach (OrganizerSettingsData settingInfo in subGroup.SettingDataList) { - if (ActivePrinterProfile.Instance.ActiveSliceEngine == ActivePrinterProfile.SlicingEngine.Slic3r - || CuraEngineMappings.MapContains(settingInfo.SlicerConfigName)) + if (ActivePrinterProfile.Instance.ActiveSliceEngine.MapContains(settingInfo.SlicerConfigName)) { addedSettingToSubGroup = true; GuiWidget controlsForThisSetting = CreateSettingInfoUIControls(settingInfo, minSettingNameWidth); diff --git a/SlicerConfiguration/SlicerMapping/EngineMapingBase.cs b/SlicerConfiguration/SlicerMapping/EngineMapingBase.cs new file mode 100644 index 000000000..3af074de0 --- /dev/null +++ b/SlicerConfiguration/SlicerMapping/EngineMapingBase.cs @@ -0,0 +1,41 @@ +/* +Copyright (c) 2014, Lars Brubaker +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; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace MatterHackers.MatterControl.SlicerConfiguration +{ + public abstract class SliceEngineMaping + { + public abstract bool MapContains(string defaultKey); + } +} diff --git a/SlicerConfiguration/SlicerMapping/EngineMappingCura.cs b/SlicerConfiguration/SlicerMapping/EngineMappingCura.cs new file mode 100644 index 000000000..1d3b21819 --- /dev/null +++ b/SlicerConfiguration/SlicerMapping/EngineMappingCura.cs @@ -0,0 +1,509 @@ +/* +Copyright (c) 2014, Lars Brubaker +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; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using MatterHackers.VectorMath; +using MatterHackers.MatterControl.SlicerConfiguration; + +namespace MatterHackers.MatterControl.SlicerConfiguration +{ + public class CuraEngineMappings : SliceEngineMaping + { + // private so that this class is a sigleton + CuraEngineMappings() + { + } + + static CuraEngineMappings instance = null; + public static CuraEngineMappings Instance + { + get + { + if (instance == null) + { + instance = new CuraEngineMappings(); + } + return instance; + } + } + + public override bool MapContains(string defaultKey) + { + foreach (MapItem mapItem in curaToDefaultMapping) + { + if (mapItem.DefaultKey == defaultKey) + { + return true; + } + } + + return false; + } + + static MapItem[] curaToDefaultMapping = + { + new ScaledSingleNumber("layerThickness", "layer_height", 1000), + new AsPercentOfReferenceOrDirect("initialLayerThickness", "first_layer_height", "layer_height", 1000), + new ScaledSingleNumber("filamentDiameter", "filament_diameter", 1000), + new ScaledSingleNumber("extrusionWidth", "nozzle_diameter", 1000), + + new MapItem("printSpeed", "perimeter_speed"), + new MapItem("infillSpeed", "infill_speed"), + new MapItem("moveSpeed", "travel_speed"), + new AsPercentOfReferenceOrDirect("initialLayerSpeed", "first_layer_speed", "infill_speed"), + + new NotPassedItem("", "temperature"), + new NotPassedItem("", "bed_temperature"), + new NotPassedItem("", "bed_shape"), + + new MapItem("insetCount", "perimeters"), + + new MapItem("skirtLineCount", "skirts"), + new SkirtLengthMaping("skirtMinLength", "min_skirt_length"), + new ScaledSingleNumber("skirtDistance", "skirt_distance", 1000), + + new MapItem("fanSpeedMin", "max_fan_speed"), + new MapItem("fanSpeedMax", "min_fan_speed"), + + new MapItem("downSkinCount", "bottom_solid_layers"), + new MapItem("upSkinCount", "top_solid_layers"), + + new FanTranslator("fanFullOnLayerNr", "disable_fan_first_layers"), + new MapItem("coolHeadLift", "cool_extruder_lift"), + + new ScaledSingleNumber("retractionAmount", "retract_length", 1000), + new MapItem("retractionSpeed", "retract_speed"), + new ScaledSingleNumber("retractionMinimalDistance", "retract_before_travel", 1000), + + new MapItem("spiralizeMode", "spiral_vase"), + + new NotPassedItem("", "bed_size"), + + new PrintCenterX("posx", "print_center"), + new PrintCenterY("posy", "print_center"), + + new NotPassedItem("", "build_height"), + + // needs testing, not working + new ScaledSingleNumber("supportLineDistance", "support_material_spacing", 1000), + new SupportMatterial("supportAngle", "support_material"), + new NotPassedItem("", "support_material_threshold"), + new MapItem("supportEverywhere", "support_material_create_internal_support"), + new ScaledSingleNumber("supportXYDistance", "support_material_xy_distance", 1000), + new ScaledSingleNumber("supportZDistance", "support_material_z_distance", 1000), + + new MapItem("minimalLayerTime", "slowdown_below_layer_time"), + + new InfillTranslator("sparseInfillLineDistance", "fill_density"), + + new MapStartGCode("startCode", "start_gcode"), + new MapEndGCode("endCode", "end_gcode"), + +#if false + SETTING(filamentFlow); + SETTING(infillOverlap); + + SETTING(initialSpeedupLayers); + + SETTING(supportExtruder); + + SETTING(retractionAmountExtruderSwitch); + SETTING(minimalExtrusionBeforeRetraction); + SETTING(enableCombing); + SETTING(multiVolumeOverlap); + SETTING(objectSink); + + SETTING(raftMargin); + SETTING(raftLineSpacing); + SETTING(raftBaseThickness); + SETTING(raftBaseLinewidth); + SETTING(raftInterfaceThickness); + SETTING(raftInterfaceLinewidth); + + SETTING(minimalFeedrate); + +fanFullOnLayerNr = 2; + + SETTING(fixHorrible); + SETTING(gcodeFlavor); + +/* +objectPosition.X = 102500; +objectPosition.Y = 102500; +enableOozeShield = 0; +*/ +#endif + }; + + public static string GetCuraCommandLineSettings() + { + StringBuilder settings = new StringBuilder(); + for (int i = 0; i < curaToDefaultMapping.Length; i++) + { + string curaValue = curaToDefaultMapping[i].CuraValue; + if (curaValue != null && curaValue != "") + { + settings.Append(string.Format("-s {0}=\"{1}\" ", curaToDefaultMapping[i].CuraKey, curaValue)); + } + } + + return settings.ToString(); + } + + public class NotPassedItem : MapItem + { + public override string CuraValue + { + get + { + return null; + } + } + + public NotPassedItem(string cura, string slicer) + : base(cura, slicer) + { + } + } + + public class FanTranslator : MapItem + { + public override string CuraValue + { + get + { + int numLayersFanIsDisabledOn = int.Parse(base.CuraValue); + int layerToEnableFanOn = numLayersFanIsDisabledOn + 1; + return layerToEnableFanOn.ToString(); + } + } + + public FanTranslator(string cura, string slicer) + : base(cura, slicer) + { + } + } + + public class SupportMatterial : MapItem + { + public override string CuraValue + { + get + { + string supportMaterial = ActiveSliceSettings.Instance.GetActiveValue("support_material"); + if (supportMaterial == "0") + { + return "-1"; + } + + return (90 - double.Parse(ActiveSliceSettings.Instance.GetActiveValue("support_material_threshold"))).ToString(); + } + } + + public SupportMatterial(string cura, string slicer) + : base(cura, slicer) + { + } + } + + public class InfillTranslator : MapItem + { + public override string CuraValue + { + get + { + double infillRatio0To1 = Double.Parse(base.CuraValue); + // 400 = solid (extruder width) + double nozzle_diameter = double.Parse(ActiveSliceSettings.Instance.GetActiveValue("nozzle_diameter")); + double linespacing = 1000; + if (infillRatio0To1 > .01) + { + linespacing = nozzle_diameter / infillRatio0To1; + } + + return ((int)(linespacing * 1000)).ToString(); + } + } + + public InfillTranslator(string cura, string slicer) + : base(cura, slicer) + { + } + } + + public class PrintCenterX : MapItem + { + public override string CuraValue + { + get + { + Vector2 PrinteCenter = ActiveSliceSettings.Instance.PrintCenter; + return (PrinteCenter.x * 1000).ToString(); + } + } + + public PrintCenterX(string cura, string slicer) + : base(cura, slicer) + { + } + } + + public class PrintCenterY : MapItem + { + public override string CuraValue + { + get + { + Vector2 PrinteCenter = ActiveSliceSettings.Instance.PrintCenter; + return (PrinteCenter.y * 1000).ToString(); + } + } + + public PrintCenterY(string cura, string slicer) + : base(cura, slicer) + { + } + } + + public class ConvertCRs : MapItem + { + public override string CuraValue + { + get + { + string actualCRs = base.CuraValue.Replace("\\n", "\n"); + return actualCRs; + } + } + + public ConvertCRs(string cura, string slicer) + : base(cura, slicer) + { + } + } + + public class InjectGCodeCommands : ConvertCRs + { + public InjectGCodeCommands(string cura, string slicer) + : base(cura, slicer) + { + } + + protected void AddDefaultIfNotPresent(List linesAdded, string commandToAdd, string[] linesToCheckIfAlreadyPresent, string comment) + { + string command = commandToAdd.Split(' ')[0].Trim(); + bool foundCommand = false; + foreach (string line in linesToCheckIfAlreadyPresent) + { + if (line.StartsWith(command)) + { + foundCommand = true; + break; + } + } + + if (!foundCommand) + { + linesAdded.Add(string.Format("{0} ; {1}", commandToAdd, comment)); + } + } + } + + public class MapStartGCode : InjectGCodeCommands + { + public override string CuraValue + { + get + { + StringBuilder curaStartGCode = new StringBuilder(); + foreach (string line in PreStartGCode()) + { + curaStartGCode.Append(line + "\n"); + } + + curaStartGCode.Append(base.CuraValue); + + bool first = true; + foreach (string line in PostStartGCode()) + { + if (!first) + { + curaStartGCode.Append("\n"); + } + curaStartGCode.Append(line); + first = false; + } + + return curaStartGCode.ToString(); + } + } + + public MapStartGCode(string cura, string slicer) + : base(cura, slicer) + { + } + + public List PreStartGCode() + { + string startGCode = ActiveSliceSettings.Instance.GetActiveValue("start_gcode"); + string[] preStartGCodeLines = startGCode.Split(new string[] { "\\n" }, StringSplitOptions.RemoveEmptyEntries); + + List preStartGCode = new List(); + preStartGCode.Add("; automatic settings before start_gcode"); + AddDefaultIfNotPresent(preStartGCode, "G21", preStartGCodeLines, "set units to millimeters"); + AddDefaultIfNotPresent(preStartGCode, "M107", preStartGCodeLines, "fan off"); + double bed_temperature = double.Parse(ActiveSliceSettings.Instance.GetActiveValue("bed_temperature")); + if (bed_temperature > 0) + { + string setBedTempString = string.Format("M190 S{0}", bed_temperature); + AddDefaultIfNotPresent(preStartGCode, setBedTempString, preStartGCodeLines, "wait for bed temperature to be reached"); + } + string setTempString = string.Format("M104 S{0}", ActiveSliceSettings.Instance.GetActiveValue("temperature")); + AddDefaultIfNotPresent(preStartGCode, setTempString, preStartGCodeLines, "set temperature"); + preStartGCode.Add("; settings from start_gcode"); + + return preStartGCode; + } + + public List PostStartGCode() + { + string startGCode = ActiveSliceSettings.Instance.GetActiveValue("start_gcode"); + string[] postStartGCodeLines = startGCode.Split(new string[] { "\\n" }, StringSplitOptions.RemoveEmptyEntries); + + List postStartGCode = new List(); + postStartGCode.Add("; automatic settings after start_gcode"); + string setTempString = string.Format("M109 S{0}", ActiveSliceSettings.Instance.GetActiveValue("temperature")); + AddDefaultIfNotPresent(postStartGCode, setTempString, postStartGCodeLines, "wait for temperature"); + AddDefaultIfNotPresent(postStartGCode, "G90", postStartGCodeLines, "use absolute coordinates"); + postStartGCode.Add(string.Format("{0} ; {1}", "G92 E0", "reset the expected extruder position")); + AddDefaultIfNotPresent(postStartGCode, "M82", postStartGCodeLines, "use absolute distance for extrusion"); + + return postStartGCode; + } + } + + public class MapEndGCode : InjectGCodeCommands + { + public override string CuraValue + { + get + { + StringBuilder curaEndGCode = new StringBuilder(); + + curaEndGCode.Append(base.CuraValue); + + curaEndGCode.Append("\n; filament used = filament_used_replace_mm (filament_used_replace_cm3)"); + + return curaEndGCode.ToString(); + } + } + + public MapEndGCode(string cura, string slicer) + : base(cura, slicer) + { + } + } + + public class SkirtLengthMaping : MapItem + { + public SkirtLengthMaping(string curaKey, string defaultKey) + : base(curaKey, defaultKey) + { + } + + public override string CuraValue + { + get + { + double lengthToExtrudeMm = double.Parse(base.CuraValue); + // we need to convert mm of filament to mm of extrusion path + double amountOfFilamentCubicMms = ActiveSliceSettings.Instance.FillamentDiameter * MathHelper.Tau * lengthToExtrudeMm; + double extrusionSquareSize = ActiveSliceSettings.Instance.FirstLayerHeight * ActiveSliceSettings.Instance.NozzleDiameter; + double lineLength = amountOfFilamentCubicMms / extrusionSquareSize; + + return (lineLength * 1000).ToString(); + } + } + } + + public class ScaledSingleNumber : MapItem + { + internal double scale; + public override string CuraValue + { + get + { + if (scale != 1) + { + return (double.Parse(base.CuraValue) * scale).ToString(); + } + return base.CuraValue; + } + } + + internal ScaledSingleNumber(string cura, string slicer, double scale = 1) + : base(cura, slicer) + { + this.scale = scale; + } + } + + public class AsPercentOfReferenceOrDirect : ScaledSingleNumber + { + internal string slicerReference; + public override string CuraValue + { + get + { + if (SlicerValue.Contains("%")) + { + string withoutPercent = SlicerValue.Replace("%", ""); + double ratio = double.Parse(withoutPercent) / 100.0; + string slicerReferenceString = ActiveSliceSettings.Instance.GetActiveValue(slicerReference); + double valueToModify = double.Parse(slicerReferenceString); + double finalValue = valueToModify * ratio * scale; + return finalValue.ToString(); + } + + return base.CuraValue; + } + } + + internal AsPercentOfReferenceOrDirect(string cura, string slicer, string slicerReference, double scale = 1) + : base(cura, slicer, scale) + { + this.slicerReference = slicerReference; + } + } + } +} diff --git a/SlicerConfiguration/SlicerMapping/EngineMappingSlic3r.cs b/SlicerConfiguration/SlicerMapping/EngineMappingSlic3r.cs new file mode 100644 index 000000000..3ac52703c --- /dev/null +++ b/SlicerConfiguration/SlicerMapping/EngineMappingSlic3r.cs @@ -0,0 +1,73 @@ +/* +Copyright (c) 2014, Lars Brubaker +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; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using MatterHackers.VectorMath; + +namespace MatterHackers.MatterControl.SlicerConfiguration +{ + public class Slic3rEngineMappings : SliceEngineMaping + { + static List hideItems = null; + + // private so that this class is a sigleton + Slic3rEngineMappings() + { + } + + static Slic3rEngineMappings instance = null; + public static Slic3rEngineMappings Instance + { + get + { + if (instance == null) + { + instance = new Slic3rEngineMappings(); + hideItems = new List(); + hideItems.Add("cool_extruder_lift"); + hideItems.Add("support_material_create_internal_support"); + } + return instance; + } + } + + public override bool MapContains(string defaultKey) + { + if (hideItems.Contains(defaultKey)) + { + return false; + } + return true; + } + } +} diff --git a/SlicerConfiguration/SlicerMapping/MappingClasses.cs b/SlicerConfiguration/SlicerMapping/MappingClasses.cs new file mode 100644 index 000000000..9aae3aa6e --- /dev/null +++ b/SlicerConfiguration/SlicerMapping/MappingClasses.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using MatterHackers.MatterControl; + +namespace MatterHackers.MatterControl.SlicerConfiguration +{ + public class MapItem + { + string curaKey; + string defaultKey; + + internal MapItem(string curaKey, string defaultKey) + { + this.curaKey = curaKey; + this.defaultKey = defaultKey; + } + + public string CuraKey { get { return curaKey; } } + public string DefaultKey { get { return defaultKey; } } + + public string SlicerValue { get { return ActiveSliceSettings.Instance.GetActiveValue(defaultKey); } } + + public virtual string CuraValue { get { return SlicerValue; } } + } +} diff --git a/SliceConfiguration/SlicingQueue.cs b/SlicerConfiguration/SlicingQueue.cs similarity index 81% rename from SliceConfiguration/SlicingQueue.cs rename to SlicerConfiguration/SlicingQueue.cs index 9b99d2cd9..2660f9492 100644 --- a/SliceConfiguration/SlicingQueue.cs +++ b/SlicerConfiguration/SlicingQueue.cs @@ -1,4 +1,33 @@ -using System; +/* +Copyright (c) 2014, Lars Brubaker +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; using System.IO; using System.Collections.Generic; using System.Linq; @@ -13,7 +42,7 @@ using MatterHackers.MatterControl.PrintQueue; using MatterHackers.Agg.UI; using MatterHackers.Localizations; -namespace MatterHackers.MatterControl +namespace MatterHackers.MatterControl.SlicerConfiguration { public class SlicingQueue { @@ -77,9 +106,9 @@ namespace MatterHackers.MatterControl switch (MatterHackers.Agg.UI.WindowsFormsAbstract.GetOSType()) { case Agg.UI.WindowsFormsAbstract.OSType.Windows: - switch (ActivePrinterProfile.Instance.ActiveSliceEngine) + switch (ActivePrinterProfile.Instance.ActiveSliceEngineType) { - case ActivePrinterProfile.SlicingEngine.Slic3r: + case ActivePrinterProfile.SlicingEngineTypes.Slic3r: { string slic3rRelativePath = Path.Combine("..", "Slic3r", "slic3r.exe"); if (!File.Exists(slic3rRelativePath)) @@ -89,7 +118,7 @@ namespace MatterHackers.MatterControl return System.IO.Path.GetFullPath(slic3rRelativePath); } - case ActivePrinterProfile.SlicingEngine.CuraEngine: + case ActivePrinterProfile.SlicingEngineTypes.CuraEngine: { string curaEngineRelativePath = Path.Combine("..", "CuraEngine.exe"); if (!File.Exists(curaEngineRelativePath)) @@ -99,7 +128,7 @@ namespace MatterHackers.MatterControl return System.IO.Path.GetFullPath(curaEngineRelativePath); } - case ActivePrinterProfile.SlicingEngine.MatterSlice: + case ActivePrinterProfile.SlicingEngineTypes.MatterSlice: { string materSliceRelativePath = Path.Combine(".", "MatterSlice.exe"); return System.IO.Path.GetFullPath(materSliceRelativePath); @@ -110,15 +139,15 @@ namespace MatterHackers.MatterControl } case Agg.UI.WindowsFormsAbstract.OSType.Mac: - switch (ActivePrinterProfile.Instance.ActiveSliceEngine) + switch (ActivePrinterProfile.Instance.ActiveSliceEngineType) { - case ActivePrinterProfile.SlicingEngine.Slic3r: + case ActivePrinterProfile.SlicingEngineTypes.Slic3r: { //string parentLocation = Directory.GetParent (ApplicationDataStorage.Instance.ApplicationPath).ToString (); string applicationPath = System.IO.Path.Combine(ApplicationDataStorage.Instance.ApplicationPath, "Slic3r.app", "Contents", "MacOS", "slic3r"); return applicationPath; } - case ActivePrinterProfile.SlicingEngine.CuraEngine: + case ActivePrinterProfile.SlicingEngineTypes.CuraEngine: { string applicationPath = System.IO.Path.Combine(ApplicationDataStorage.Instance.ApplicationPath, "CuraEngine"); return applicationPath; @@ -153,18 +182,18 @@ namespace MatterHackers.MatterControl { slicerProcess = new Process(); - switch (ActivePrinterProfile.Instance.ActiveSliceEngine) + switch (ActivePrinterProfile.Instance.ActiveSliceEngineType) { - case ActivePrinterProfile.SlicingEngine.Slic3r: + case ActivePrinterProfile.SlicingEngineTypes.Slic3r: slicerProcess.StartInfo.Arguments = "--load \"" + currentConfigurationFileAndPath + "\" --output \"" + gcodePathAndFileName + "\" \"" + itemToSlice.PartToSlicePathAndFileName + "\""; break; - case ActivePrinterProfile.SlicingEngine.CuraEngine: + case ActivePrinterProfile.SlicingEngineTypes.CuraEngine: slicerProcess.StartInfo.Arguments = "-v -o \"" + gcodePathAndFileName + "\" " + CuraEngineMappings.GetCuraCommandLineSettings() + " \"" + itemToSlice.PartToSlicePathAndFileName + "\""; //Debug.Write(slicerProcess.StartInfo.Arguments); break; - case ActivePrinterProfile.SlicingEngine.MatterSlice: + case ActivePrinterProfile.SlicingEngineTypes.MatterSlice: slicerProcess.StartInfo.Arguments = "--load \"" + currentConfigurationFileAndPath + "\" --output \"" + gcodePathAndFileName + "\" \"" + itemToSlice.PartToSlicePathAndFileName + "\""; break; } diff --git a/TupleList.cs b/TupleList.cs index d28c5e936..73cecb9b8 100644 --- a/TupleList.cs +++ b/TupleList.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2013, Lars Brubaker +Copyright (c) 2014, Lars Brubaker All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/WidescreenPanel.cs b/WidescreenPanel.cs index 26cb00133..52f05bd07 100644 --- a/WidescreenPanel.cs +++ b/WidescreenPanel.cs @@ -13,6 +13,7 @@ using MatterHackers.VectorMath; using MatterHackers.MatterControl; using MatterHackers.MatterControl.PrintQueue; +using MatterHackers.MatterControl.SlicerConfiguration; using MatterHackers.MatterControl.PrintLibrary; using MatterHackers.MatterControl.DataStorage; using MatterHackers.Localizations;