Closed zbhujwala closed 6 years ago
The GTextArea has two functions - getText and getTextAsArray. Plus, it has setText so we can set it to the file path. http://www.lagers.org.uk/g4p/ref/classg4p__controls_1_1_g_text_area.html#a622e64a7f9f17755b7433c93ad9b377f
I figured out how to choose a file and set the file path to a variable (String STLFile) then display the selected path on the main window. `
//Select File
public void searchFileBtn_click(GButton source, GEvent event){
printIn("searchFileBtn - GButton >> GEvent." + event + "@" + millis());
selectInput("Select a STL file:", "fileSelected");
}
public void fileSelected(File selection) {
STLFile = selection.getAbsolutePath();
fileTextBox.setText(STLFile);
}
//Display Path
public void confirmBtn_click(GButton source, GEvent event) { //_CODE_:confirmBtn:275116:
println("confirmBtn - GButton >> GEvent." + event + " @ " + millis());
if (fileTextBox.getText() == STLFile) {
currentFile.setText(STLFile);
inputWindow.setVisible(false);
}
`
I have also completed the Layer Height of the slicer setting where the user can select the value of the height (0-0.4) by using a GSlider.
I am trying to create a new branch to upload my code and then use the pull request but I'm afraid I might delete something important. Can you guys break down the steps for me?
Chris Iossa thought it would be nice to put the contents of the STL file in the box below the choose file box (GTextArea box) after the file was selected.
Steve and Chris want to know if G4P GUI Builder is multithreaded? So if the user hits the print button, the user can still hit the pause or cancel button while the print function is running.
Chris Iossa thought it would be nice to put the contents of the STL file in the box below the choose file box (GTextArea box).
we could have a preview button that loads the text, since the stl file could be massive and lag the program when loading a file.
I think that text area was originally for raw g-code, but we could also put that somewhere else, depending on what the purpose is for, (printer testing??)
Steve and Chris want to know if G4P GUI Builder is multithreaded? So if the user hits the print button, the user can still hit the pause or cancel button while the print function is running.
I tested it, it's not multithreaded by default; a loop will lock the gui.
But I did get it to work using processing threads ex:
public class Test
{
public boolean flag = true;
public int counter = 0;
void runTest()
{
while (flag)
{
println(counter);
counter++;
}
}
void toogle()
{
flag = flag ? false : true;
}
}
gui file:
Test threadTest = new Test();
public void runTest()
{
threadTest.runTest();
}
public void startSliceBtn_click(GButton source, GEvent event) { //_CODE_:startSliceBtn:735941:
println("button1 - GButton >> GEvent." + event + " @ " + millis());
thread("runTest");
}
public void pauseSliceBtn_click(GButton source, GEvent event) { //_CODE_:pauseSliceBtn:624877:
println("pauseSliceBtn - GButton >> GEvent." + event + " @ " + millis());
threadTest.toogle();
}
Added nozzle diameter and layer size sliders and x, y, z textbooks in the add-Variables branch.
Should layer size be split into top and bottom? With the code in there right now, if you enter values < 1 or > 200, it crashes. We could probably put a label message on there to say "x, y, z range is 1 - 200" or some type of error message to alert user if an invalid number is entered.
DeviceController team has implemented multithreading, so we do not need to anymore.
"the DeviceController class now handles all threading and synchronization needed for printing. When a print job is started, it runs in a separate thread, allowing the UI to issue start/stop commands from the main thread."
Implementing slice code (from Andrew):
//parse STL
STLParser parser = new STLParser(
//slice object, including timing the slicing procedure
long startTime = millis();
Slicer slice = new Slicer(facets,
//draw sliced object
size(800, 800);
int layerToDraw =
li.x1 += 400; li.y1 += 400; li.x2 += 400; li.y2 += 400;
line(li.x1, li.y1, li.x2, li.y2); } println("Num lines on drawn layer (" + layerToDraw + "): " + lines.size());
I'm trying to implement this. Doesn't seem like they'll have this done for prototype submission by tomorrow.
Our job - we need to use the slicer functions to create a Model object. Then pass that Model object to the rendering team functions. The rendering team needs the facets and gcode from that object. For the slicing team functions, we need to pass the STL file path, create the facets variable and create the gcode variable. The slicing team still needs to create a function that creates the gcode and store that in a variable for the Model class.
Still in flux, but we may not need to slice the object. The rendering team may call those functions.
int layerToDraw =
I got the renders and slicers code working for rendering stl files. The render team also implemented mouse events for controling the render view, but they don't seem to be working perfect.
If I comment out the two lines I just pushed to first-prototype, I get an infinite loop of the following (using Smile.STL):
Reading file... Converting strings to floats... Allocating space in the ByteBuffer... Filling in the header... Converting floats to bytes... Moving bytes from ByteBuffer to byte[]... Conversion from ASCII to Binary is complete. STLParser.interpretBinarySTL(): STL Facet count: 1069
If I leave those two lines in, I get an infinite loop of the following:
Slicer.sliceLayer(): Intersecting facets at height 505.92166: 2
The line always looks like that starting with "at height 1: 2" to about "at height 505:2" then loops back to 1 going back to 505 again and again....
-> Sent this to Paul on the slicing team. Error might be on their end. Hopefully once they finish the Model and Slicer classes, it will work.
Changes to UI we need to make:
Change "Layer height" to "Layer scale" Get rid of "layer size" New variable "Filament diameter" - pass in as float. value - 1.75 OR 3.00 Need baud rate fill in box Need drop down for which usb port you are using Two input boxes for what temp you are preheating the bed and head to. Rename the "Back to origin" button to "Homing"
Status update:
Device Controller team - they seem to have printing GCode completely done. I saw their object they printed yesterday and it looked great.
Slicing team - Chris just showed me they are pretty much done too. The GCode is nearly perfect. It just adds a little more to corners at the moment. Should be fixed in the next day or two.
Rendering team - not sure where they stand.
Printer Settings
Slicer Settings
[x] Layer Height (Float. Range: 0 -.4)
[x] Fill Percentage (Float. Range: 0 - 1)
[x] Size of top and bottom layer (Float. Range 1 - 2)
[x] Implement status text label box. Maybe move to bottom right of UI?
[x] Implement multithreading