This commit is contained in:
Kevin Pope 2014-03-12 15:19:21 -07:00
commit c970ca7de4
10 changed files with 138 additions and 61 deletions

View file

@ -210,7 +210,7 @@ namespace MatterHackers.MatterControl
if (streamToSaveTo != null)
{
streamToSaveTo.Close ();
Close ();
Close();
}
// windows vista +: filePathToSave 'test.stl'
// windows xp: filePathToSave 'test'

BIN
ICSharpCode.SharpZipLib.dll Normal file

Binary file not shown.

Binary file not shown.

View file

@ -194,8 +194,9 @@
<Compile Include="EeProm\EePromRepetierStorage.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="Ionic.Zip">
<HintPath>Ionic.Zip.dll</HintPath>
<Reference Include="ICSharpCode.SharpZipLib, Version=0.86.0.518, Culture=neutral, PublicKeyToken=1b03e6acf1164f73, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>.\ICSharpCode.SharpZipLib.dll</HintPath>
</Reference>
<Reference Include="PdfSharp">
<HintPath>PdfSharp.dll</HintPath>

View file

@ -231,6 +231,7 @@ namespace MatterHackers.MatterControl
document.Info.Subject = "This is a list of the parts that are in a queue from MatterControl.";
document.Info.Keywords = "MatterControl, STL, 3D Printing";
int nextPartToPrintIndex = 0;
int plateNumber = 1;
bool done = false;
@ -241,11 +242,14 @@ namespace MatterHackers.MatterControl
}
try
{
// save the final document
document.Save(pathAndFileToSaveTo);
// Now try and open the document. This will lanch whatever PDF viewer is on the system and ask it
// to show the file (at least on Windows).
Process.Start(pathAndFileToSaveTo);
}
catch {
catch (Exception)
{
}
OnDoneSaving();

View file

@ -56,17 +56,34 @@ namespace MatterHackers.MatterControl.PrintQueue
void SetMenuItems()
{
//Set the name and callback function of the menu items
menuItems = new TupleList<string, Func<bool>>
// The pdf export library is not working on the mac at the moment so we don't include the
// part sheet export option on mac.
if (MatterHackers.Agg.UI.WindowsFormsAbstract.GetOSType() == WindowsFormsAbstract.OSType.Mac)
{
{"STL", null},
{new LocalizedString(" Import from Zip").Translated, importQueueFromZipMenu_Click},
{new LocalizedString(" Export to Zip").Translated, exportQueueToZipMenu_Click},
{"GCode", null},
{new LocalizedString(" Export to Folder").Translated, exportGCodeToFolderButton_Click},
{new LocalizedString("Extra").Translated, null},
{new LocalizedString(" Create Part Sheet").Translated, createPartsSheetsButton_Click},
};
//Set the name and callback function of the menu items
menuItems = new TupleList<string, Func<bool>>
{
{"STL", null},
{new LocalizedString(" Import from Zip").Translated, importQueueFromZipMenu_Click},
{new LocalizedString(" Export to Zip").Translated, exportQueueToZipMenu_Click},
{"GCode", null},
{new LocalizedString(" Export to Folder").Translated, exportGCodeToFolderButton_Click},
};
}
else
{
//Set the name and callback function of the menu items
menuItems = new TupleList<string, Func<bool>>
{
{"STL", null},
{new LocalizedString(" Import from Zip").Translated, importQueueFromZipMenu_Click},
{new LocalizedString(" Export to Zip").Translated, exportQueueToZipMenu_Click},
{"GCode", null},
{new LocalizedString(" Export to Folder").Translated, exportGCodeToFolderButton_Click},
{new LocalizedString("Extra").Translated, null},
{new LocalizedString(" Create Part Sheet").Translated, createPartsSheetsButton_Click},
};
}
BorderDouble padding = MenuDropList.MenuItemsPadding;
//Add the menu items to the menu itself
@ -99,13 +116,19 @@ namespace MatterHackers.MatterControl.PrintQueue
if (parts.Count > 0)
{
SaveFileDialogParams saveParams = new SaveFileDialogParams("Save Parts Sheet|*.pdf");
saveParams.ActionButtonLabel = new LocalizedString("Save Parts Sheet").Translated;
string saveParamsTitleLbl = new LocalizedString("MatterContol").Translated;
string saveParamsTitleLblFull = new LocalizedString ("Save").Translated;
saveParams.Title = string.Format("{0}: {1}",saveParamsTitleLbl,saveParamsTitleLblFull);
System.IO.Stream streamToSaveTo = FileDialog.SaveFileDialog(ref saveParams);
if (streamToSaveTo != null)
if (streamToSaveTo != null)
{
streamToSaveTo.Close ();
}
if (saveParams.FileName != null)
{
PartsSheet currentPartsInQueue = new PartsSheet(parts, saveParams.FileName);

View file

@ -665,6 +665,8 @@ namespace MatterHackers.MatterControl
{
string lineToWrite = LinesToWriteQueue[0];
lineToWrite = ApplyPrintLeveling(lineToWrite, false, false);
WriteToPrinter(lineToWrite + "\r\n", lineToWrite);
LinesToWriteQueue.RemoveAt(0);
System.Threading.Thread.Sleep(1);
@ -830,18 +832,18 @@ namespace MatterHackers.MatterControl
string lineToParse = foundStringEventArgs.LineToCheck;
Vector3 positionRead = Vector3.Zero;
GCodeFile.GetFirstNumberAfter('X', lineToParse, ref positionRead.x);
GCodeFile.GetFirstNumberAfter('Y', lineToParse, ref positionRead.y);
GCodeFile.GetFirstNumberAfter('Z', lineToParse, ref positionRead.z);
GCodeFile.GetFirstNumberAfter("X:", lineToParse, ref positionRead.x);
GCodeFile.GetFirstNumberAfter("Y:", lineToParse, ref positionRead.y);
GCodeFile.GetFirstNumberAfter("Z:", lineToParse, ref positionRead.z);
int xPosition = lineToParse.IndexOf('X');
int secondXPosition = lineToParse.IndexOf("Count", xPosition);
if (secondXPosition != -1)
{
Vector3 currentPositionRead = Vector3.Zero;
GCodeFile.GetFirstNumberAfter('X', lineToParse, ref currentPositionRead.x, secondXPosition - 1);
GCodeFile.GetFirstNumberAfter('Y', lineToParse, ref currentPositionRead.y, secondXPosition - 1);
GCodeFile.GetFirstNumberAfter('Z', lineToParse, ref currentPositionRead.z, secondXPosition - 1);
GCodeFile.GetFirstNumberAfter("X:", lineToParse, ref currentPositionRead.x, secondXPosition - 1);
GCodeFile.GetFirstNumberAfter("Y:", lineToParse, ref currentPositionRead.y, secondXPosition - 1);
GCodeFile.GetFirstNumberAfter("Z:", lineToParse, ref currentPositionRead.z, secondXPosition - 1);
lastReportedPosition = currentPositionRead;
}
@ -1312,9 +1314,9 @@ namespace MatterHackers.MatterControl
newDestination = Vector3.Zero;
}
GCodeFile.GetFirstNumberAfter('X', lineBeingSent, ref newDestination.x);
GCodeFile.GetFirstNumberAfter('Y', lineBeingSent, ref newDestination.y);
GCodeFile.GetFirstNumberAfter('Z', lineBeingSent, ref newDestination.z);
GCodeFile.GetFirstNumberAfter("X", lineBeingSent, ref newDestination.x);
GCodeFile.GetFirstNumberAfter("Y", lineBeingSent, ref newDestination.y);
GCodeFile.GetFirstNumberAfter("Z", lineBeingSent, ref newDestination.z);
if (movementMode == PrinterMachineInstruction.MovementTypes.Relative)
{
@ -1329,7 +1331,8 @@ namespace MatterHackers.MatterControl
if (ActivePrinter.DoPrintLeveling)
{
lineBeingSent = PrintLeveling.Instance.ApplyLeveling(currentDestination, movementMode, lineBeingSent, addLFCR, includeSpaces);
string inputLine = lineBeingSent;
lineBeingSent = PrintLeveling.Instance.ApplyLeveling(currentDestination, movementMode, inputLine, addLFCR, includeSpaces);
}
}
@ -1341,7 +1344,7 @@ namespace MatterHackers.MatterControl
lineBeingSent = lineBeingSent.ToUpper().Trim();
if (lineBeingSent.StartsWith("G0") || lineBeingSent.StartsWith("G1"))
{
if (GCodeFile.GetFirstNumberAfter('E', lineBeingSent, ref gcodeRequestedExtrusionPosition))
if (GCodeFile.GetFirstNumberAfter("E", lineBeingSent, ref gcodeRequestedExtrusionPosition))
{
double delta = gcodeRequestedExtrusionPosition - previousGcodeRequestedExtrusionPosition;
if (extruderMode == PrinterMachineInstruction.MovementTypes.Relative)
@ -1356,7 +1359,7 @@ namespace MatterHackers.MatterControl
}
else if (lineBeingSent.StartsWith("G92"))
{
if (GCodeFile.GetFirstNumberAfter('E', lineBeingSent, ref gcodeRequestedExtrusionPosition))
if (GCodeFile.GetFirstNumberAfter("E", lineBeingSent, ref gcodeRequestedExtrusionPosition))
{
previousGcodeRequestedExtrusionPosition = gcodeRequestedExtrusionPosition;
currentActualExtrusionPosition = gcodeRequestedExtrusionPosition;
@ -1374,7 +1377,7 @@ namespace MatterHackers.MatterControl
if (lineBeingSent.StartsWith("G0") || lineBeingSent.StartsWith("G1"))
{
double feedRate = 0;
if (GCodeFile.GetFirstNumberAfter('F', lineBeingSent, ref feedRate))
if (GCodeFile.GetFirstNumberAfter("F", lineBeingSent, ref feedRate))
{
lineBeingSent = GCodeFile.ReplaceNumberAfter('F', lineBeingSent, feedRate * FeedRateRatio);
}

View file

@ -85,9 +85,9 @@ namespace MatterHackers.MatterControl
&& lineBeingSent[2] == ' ')
{
double extruderDelta = 0;
GCodeFile.GetFirstNumberAfter('E', lineBeingSent, ref extruderDelta);
GCodeFile.GetFirstNumberAfter("E", lineBeingSent, ref extruderDelta);
double feedRate = 0;
GCodeFile.GetFirstNumberAfter('F', lineBeingSent, ref feedRate);
GCodeFile.GetFirstNumberAfter("F", lineBeingSent, ref feedRate);
string newLine = "G1 ";
@ -97,9 +97,9 @@ namespace MatterHackers.MatterControl
if (movementMode == PrinterMachineInstruction.MovementTypes.Relative)
{
Vector3 relativeMove = Vector3.Zero;
GCodeFile.GetFirstNumberAfter('X', lineBeingSent, ref relativeMove.x);
GCodeFile.GetFirstNumberAfter('Y', lineBeingSent, ref relativeMove.y);
GCodeFile.GetFirstNumberAfter('Z', lineBeingSent, ref relativeMove.z);
GCodeFile.GetFirstNumberAfter("X", lineBeingSent, ref relativeMove.x);
GCodeFile.GetFirstNumberAfter("Y", lineBeingSent, ref relativeMove.y);
GCodeFile.GetFirstNumberAfter("Z", lineBeingSent, ref relativeMove.z);
outPosition = PrintLeveling.Instance.ApplyLevelingRotation(relativeMove);
}

View file

@ -37,7 +37,7 @@ using System.IO;
using System.Diagnostics;
using System.Collections.Generic;
using Ionic.Zip;
using ICSharpCode.SharpZipLib.Zip;
using MatterHackers.Agg.UI;
using MatterHackers.MatterControl.DataStorage;
@ -173,7 +173,6 @@ namespace MatterHackers.MatterControl
public void ExportToProjectArchive(string savedFileName = null)
{
if (savedFileName == null)
{
savedFileName = defaultProjectPathAndFileName;
@ -197,24 +196,54 @@ namespace MatterHackers.MatterControl
StreamWriter sw = new System.IO.StreamWriter(fs);
sw.Write(jsonString);
sw.Close();
ZipFile zip = new ZipFile();
zip.AddFile(defaultManifestPathAndFileName).FileName = Path.GetFileName(defaultManifestPathAndFileName);
FileStream outputFileStream = File.Create(savedFileName);
ZipOutputStream zipStream = new ZipOutputStream(outputFileStream);
zipStream.SetLevel(3);
CopyFileToZip(zipStream, defaultManifestPathAndFileName);
{
foreach (KeyValuePair<string, ManifestItem> item in this.sourceFiles)
{
zip.AddFile(item.Key).FileName = Path.GetFileName(item.Key);
CopyFileToZip(zipStream, item.Key);
}
}
zip.Save(savedFileName);
zipStream.IsStreamOwner = true; // Makes the Close also Close the underlying stream
zipStream.Close();
}
private static void CopyFileToZip(ZipOutputStream zipStream, string sourceFile)
{
if (File.Exists(sourceFile))
{
ZipEntry newEntry = new ZipEntry(Path.GetFileName(sourceFile));
FileInfo fi = new FileInfo(sourceFile);
newEntry.DateTime = fi.LastWriteTime;
newEntry.Size = fi.Length;
zipStream.PutNextEntry(newEntry);
using (FileStream streamReader = File.OpenRead(sourceFile))
{
CopyStream(streamReader, zipStream);
}
zipStream.CloseEntry();
}
}
public static void CopyStream(Stream input, Stream output)
{
byte[] buffer = new byte[4096];
int read;
while ((read = input.Read(buffer, 0, buffer.Length)) > 0)
{
output.Write(buffer, 0, read);
}
}
public List<PrintItem> OpenFromDialog()
{
OpenFileDialogParams openParams = new OpenFileDialogParams("Zip file|*.zip");
System.IO.Stream streamToLoadFrom = FileDialog.OpenFileDialog(ref openParams);
if (streamToLoadFrom != null)
FileDialog.OpenFileDialog(ref openParams);
if (openParams.FileNames != null)
{
string loadedFileName = openParams.FileName;
return ImportFromProjectArchive(loadedFileName);
@ -233,9 +262,9 @@ namespace MatterHackers.MatterControl
}
if (System.IO.File.Exists(loadedFileName))
{
ZipFile zip = ZipFile.Read(loadedFileName);
{
FileStream fs = File.OpenRead(loadedFileName);
ZipFile zip = new ZipFile(fs);
int projectHashCode = zip.GetHashCode();
//If the temp folder doesn't exist - create it, otherwise clear it
@ -253,20 +282,37 @@ namespace MatterHackers.MatterControl
List<PrintItem> printItemList = new List<PrintItem>();
Project projectManifest = null;
foreach (ZipEntry e in zip)
{
e.Extract(stagingFolder, ExtractExistingFileAction.OverwriteSilently);
if (e.FileName == "manifest.json")
foreach (ZipEntry zipEntry in zip)
{
if (!zipEntry.IsFile)
{
e.Extract(stagingFolder, ExtractExistingFileAction.OverwriteSilently);
string extractedFileName = Path.Combine(stagingFolder, e.FileName);
StreamReader sr = new System.IO.StreamReader(extractedFileName);
projectManifest = (Project)Newtonsoft.Json.JsonConvert.DeserializeObject(sr.ReadToEnd(), typeof(Project));
sr.Close();
continue; // Ignore directories
}
else if (System.IO.Path.GetExtension(e.FileName).ToUpper() == ".STL" || System.IO.Path.GetExtension(e.FileName).ToUpper() == ".GCODE")
if (zipEntry.Name == "manifest.json"
|| System.IO.Path.GetExtension(zipEntry.Name).ToUpper() == ".STL"
|| System.IO.Path.GetExtension(zipEntry.Name).ToUpper() == ".GCODE")
{
e.Extract(stagingFolder, ExtractExistingFileAction.OverwriteSilently);
string extractedFileName = Path.Combine(stagingFolder, zipEntry.Name);
string neededPathForZip = Path.GetDirectoryName(extractedFileName);
if (!Directory.Exists(neededPathForZip))
{
Directory.CreateDirectory(neededPathForZip);
}
Stream zipStream = zip.GetInputStream(zipEntry);
using (FileStream streamWriter = File.Create(extractedFileName))
{
CopyStream(zipStream, streamWriter);
}
if (zipEntry.Name == "manifest.json")
{
StreamReader sr = new System.IO.StreamReader(extractedFileName);
projectManifest = (Project)Newtonsoft.Json.JsonConvert.DeserializeObject(sr.ReadToEnd(), typeof(Project));
sr.Close();
}
}
}

View file

@ -1,7 +1,7 @@
avoid_crossing_perimeters = 1
bed_shape = circular
bed_size = 260,260
bed_temperature = 70
bed_temperature = 90
bottom_solid_layers = 5
bridge_acceleration = 0
bridge_fan_speed = 100
@ -32,11 +32,11 @@ filament_diameter = 1.75
fill_angle = 0
fill_density = 0.2
fill_pattern = rectilinear
first_layer_bed_temperature = 70
first_layer_bed_temperature = 90
first_layer_extrusion_width = 0.6
first_layer_height = 0.35
first_layer_speed = 40%
first_layer_temperature = 182
first_layer_temperature = 230
g0 = 0
gap_fill_speed = 30
gcode_arcs = 0
@ -102,7 +102,7 @@ support_material_pattern = rectilinear
support_material_spacing = 2.5
support_material_speed = 3
support_material_threshold = 0
temperature = 188
temperature = 230
threads = 4
toolchange_gcode =
top_infill_extrusion_width = 0.6