diff --git a/DisplayMachine.pde b/DisplayMachine.pde
index 56090c6..feba66d 100644
--- a/DisplayMachine.pde
+++ b/DisplayMachine.pde
@@ -1,32 +1,32 @@
/**
- Polargraph controller
- Copyright Sandy Noble 2012.
-
- This file is part of Polargraph Controller.
-
- Polargraph Controller is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- Polargraph Controller is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Polargraph Controller. If not, see .
-
- Requires the excellent ControlP5 GUI library available from http://www.sojamo.de/libraries/controlP5/.
- Requires the excellent Geomerative library available from http://www.ricardmarxer.com/geomerative/.
-
- This is an application for controlling a polargraph machine, communicating using ASCII command language over a serial link.
-
- sandy.noble@gmail.com
- http://www.polargraph.co.uk/
- http://code.google.com/p/polargraph/
- */
+ Polargraph controller
+ Copyright Sandy Noble 2015.
+ This file is part of Polargraph Controller.
+
+ Polargraph Controller is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Polargraph Controller is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Polargraph Controller. If not, see .
+
+ Requires the excellent ControlP5 GUI library available from http://www.sojamo.de/libraries/controlP5/.
+ Requires the excellent Geomerative library available from http://www.ricardmarxer.com/geomerative/.
+
+ This is an application for controlling a polargraph machine, communicating using ASCII command language over a serial link.
+
+ sandy.noble@gmail.com
+ http://www.polargraph.co.uk/
+ https://github.com/euphy/polargraphcontroller
+
+*/
class DisplayMachine extends Machine
{
private Rectangle outline = null;
diff --git a/Machine.pde b/Machine.pde
index 1a0f008..cb1ca9b 100644
--- a/Machine.pde
+++ b/Machine.pde
@@ -1,6 +1,6 @@
/**
Polargraph controller
- Copyright Sandy Noble 2012.
+ Copyright Sandy Noble 2015.
This file is part of Polargraph Controller.
@@ -24,12 +24,8 @@
sandy.noble@gmail.com
http://www.polargraph.co.uk/
- http://code.google.com/p/polargraph/
-*/
-/**
-*
-*
-*
+ https://github.com/euphy/polargraphcontroller
+
*/
class Machine
{
diff --git a/Misc.pde b/Misc.pde
index c415e60..652a854 100644
--- a/Misc.pde
+++ b/Misc.pde
@@ -1,6 +1,6 @@
/**
Polargraph controller
- Copyright Sandy Noble 2012.
+ Copyright Sandy Noble 2015.
This file is part of Polargraph Controller.
@@ -24,7 +24,8 @@
sandy.noble@gmail.com
http://www.polargraph.co.uk/
- http://code.google.com/p/polargraph/
+ https://github.com/euphy/polargraphcontroller
+
*/
class Scaler
diff --git a/Panel.pde b/Panel.pde
index cfaca11..fdff5e0 100644
--- a/Panel.pde
+++ b/Panel.pde
@@ -1,6 +1,6 @@
/**
Polargraph controller
- Copyright Sandy Noble 2012.
+ Copyright Sandy Noble 2015.
This file is part of Polargraph Controller.
@@ -24,7 +24,8 @@
sandy.noble@gmail.com
http://www.polargraph.co.uk/
- http://code.google.com/p/polargraph/
+ https://github.com/euphy/polargraphcontroller
+
*/
class Panel
{
diff --git a/Rectangle.pde b/Rectangle.pde
index f8c2709..0685fab 100644
--- a/Rectangle.pde
+++ b/Rectangle.pde
@@ -1,6 +1,6 @@
/**
Polargraph controller
- Copyright Sandy Noble 2012.
+ Copyright Sandy Noble 2015.
This file is part of Polargraph Controller.
@@ -24,7 +24,8 @@
sandy.noble@gmail.com
http://www.polargraph.co.uk/
- http://code.google.com/p/polargraph/
+ https://github.com/euphy/polargraphcontroller
+
*/
class Rectangle
{
diff --git a/controlsActions.pde b/controlsActions.pde
index 66223c2..df29267 100644
--- a/controlsActions.pde
+++ b/controlsActions.pde
@@ -1,6 +1,6 @@
/**
Polargraph controller
- Copyright Sandy Noble 2012.
+ Copyright Sandy Noble 2015.
This file is part of Polargraph Controller.
@@ -24,9 +24,10 @@
sandy.noble@gmail.com
http://www.polargraph.co.uk/
- http://code.google.com/p/polargraph/
+ https://github.com/euphy/polargraphcontroller
+
*/
-void button_mode_begin()
+void button_mode_begin()
{
button_mode_clearQueue();
}
@@ -719,4 +720,10 @@ void button_mode_sendButtonDeactivate()
addToCommandQueue(CMD_DEACTIVATE_MACHINE_BUTTON+",END");
}
+void numberbox_mode_previewCordOffsetValue(int value)
+{
+ previewCordOffset = value;
+ lastCommandQueueHash = 0;
+}
+
diff --git a/controlsActionsWindows.pde b/controlsActionsWindows.pde
index b59e450..6ad6cc6 100644
--- a/controlsActionsWindows.pde
+++ b/controlsActionsWindows.pde
@@ -1,6 +1,6 @@
/**
Polargraph controller
- Copyright Sandy Noble 2012.
+ Copyright Sandy Noble 2015.
This file is part of Polargraph Controller.
@@ -24,7 +24,8 @@
sandy.noble@gmail.com
http://www.polargraph.co.uk/
- http://code.google.com/p/polargraph/
+ https://github.com/euphy/polargraphcontroller
+
*/
diff --git a/controlsSetup.pde b/controlsSetup.pde
index a0347dd..385cb8e 100644
--- a/controlsSetup.pde
+++ b/controlsSetup.pde
@@ -1,31 +1,33 @@
/**
- Polargraph controller
- Copyright Sandy Noble 2012.
-
- This file is part of Polargraph Controller.
-
- Polargraph Controller is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- Polargraph Controller is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Polargraph Controller. If not, see .
-
- Requires the excellent ControlP5 GUI library available from http://www.sojamo.de/libraries/controlP5/.
- Requires the excellent Geomerative library available from http://www.ricardmarxer.com/geomerative/.
-
- This is an application for controlling a polargraph machine, communicating using ASCII command language over a serial link.
-
- sandy.noble@gmail.com
- http://www.polargraph.co.uk/
- http://code.google.com/p/polargraph/
- */
+ Polargraph controller
+ Copyright Sandy Noble 2015.
+
+ This file is part of Polargraph Controller.
+
+ Polargraph Controller is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Polargraph Controller is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Polargraph Controller. If not, see .
+
+ Requires the excellent ControlP5 GUI library available from http://www.sojamo.de/libraries/controlP5/.
+ Requires the excellent Geomerative library available from http://www.ricardmarxer.com/geomerative/.
+
+ This is an application for controlling a polargraph machine, communicating using ASCII command language over a serial link.
+
+ sandy.noble@gmail.com
+ http://www.polargraph.co.uk/
+ https://github.com/euphy/polargraphcontroller
+
+*/
+
Set getPanelNames()
{
if (this.panelNames == null)
@@ -500,6 +502,12 @@ Map initialiseNumberboxValues(Map map)
n.setMax(PATH_LENGTH_HIGHPASS_CUTOFF_MAX);
n.setMultiplier(0.5);
}
+ else if (MODE_ADJUST_PREVIEW_CORD_OFFSET.equals(key))
+ {
+ n.setDecimalPrecision(1);
+ n.setValue(0);
+ n.setMultiplier(0.5);
+ }
}
}
return map;
@@ -688,6 +696,8 @@ List getControlNamesForInputPanel()
controlNames.add(MODE_CHANGE_MIN_VECTOR_LINE_LENGTH);
//controlNames.add(MODE_VECTOR_PATH_LENGTH_HIGHPASS_CUTOFF);
controlNames.add(MODE_RENDER_VECTORS);
+
+ controlNames.add(MODE_ADJUST_PREVIEW_CORD_OFFSET);
controlNames.add(MODE_SHOW_IMAGE);
controlNames.add(MODE_SHOW_VECTOR);
@@ -784,7 +794,7 @@ List getControlNamesForDetailPanel()
controlNames.add(MODE_SEND_BUTTON_ACTIVATE);
controlNames.add(MODE_SEND_BUTTON_DEACTIVATE);
-
+
controlNames.add(MODE_CHANGE_SERIAL_PORT);
return controlNames;
@@ -960,6 +970,8 @@ Map buildControlLabels()
result.put(MODE_SEND_BUTTON_ACTIVATE, "Activate button");
result.put(MODE_SEND_BUTTON_DEACTIVATE, "Deactivate button");
+ result.put(MODE_ADJUST_PREVIEW_CORD_OFFSET, "Preview cord offset");
+
return result;
}
@@ -1103,6 +1115,7 @@ Set buildControlNames()
result.add(MODE_SEND_BUTTON_ACTIVATE);
result.add(MODE_SEND_BUTTON_DEACTIVATE);
+ result.add(MODE_ADJUST_PREVIEW_CORD_OFFSET);
return result;
}
diff --git a/drawing.pde b/drawing.pde
index 4952b13..16996d0 100644
--- a/drawing.pde
+++ b/drawing.pde
@@ -1,31 +1,32 @@
/**
- Polargraph controller
- Copyright Sandy Noble 2012.
-
- This file is part of Polargraph Controller.
-
- Polargraph Controller is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- Polargraph Controller is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Polargraph Controller. If not, see .
-
- Requires the excellent ControlP5 GUI library available from http://www.sojamo.de/libraries/controlP5/.
- Requires the excellent Geomerative library available from http://www.ricardmarxer.com/geomerative/.
-
- This is an application for controlling a polargraph machine, communicating using ASCII command language over a serial link.
-
- sandy.noble@gmail.com
- http://www.polargraph.co.uk/
- http://code.google.com/p/polargraph/
- */
+ Polargraph controller
+ Copyright Sandy Noble 2015.
+
+ This file is part of Polargraph Controller.
+
+ Polargraph Controller is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Polargraph Controller is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Polargraph Controller. If not, see .
+
+ Requires the excellent ControlP5 GUI library available from http://www.sojamo.de/libraries/controlP5/.
+ Requires the excellent Geomerative library available from http://www.ricardmarxer.com/geomerative/.
+
+ This is an application for controlling a polargraph machine, communicating using ASCII command language over a serial link.
+
+ sandy.noble@gmail.com
+ http://www.polargraph.co.uk/
+ https://github.com/euphy/polargraphcontroller
+
+*/
static final String CMD_CHANGELENGTH = "C01,";
static final String CMD_CHANGEPENWIDTH = "C02,";
static final String CMD_CHANGEMOTORSPEED = "C03,";
diff --git a/polargraphcontroller.pde b/polargraphcontroller.pde
index 7688662..5b02bd7 100644
--- a/polargraphcontroller.pde
+++ b/polargraphcontroller.pde
@@ -1,32 +1,32 @@
/**
- Polargraph controller
- Copyright Sandy Noble 2014.
-
- This file is part of Polargraph Controller.
-
- Polargraph Controller is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- Polargraph Controller is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Polargraph Controller. If not, see .
-
- Requires the excellent ControlP5 GUI library available from http://www.sojamo.de/libraries/controlP5/.
- Requires the excellent Geomerative library available from http://www.ricardmarxer.com/geomerative/.
-
- This is an application for controlling a polargraph machine, communicating using ASCII command language over a serial link.
-
- sandy.noble@gmail.com
- http://www.polargraph.co.uk/
- http://code.google.com/p/polargraph/
-
-*/
+ Polargraph controller
+ Copyright Sandy Noble 2015.
+
+ This file is part of Polargraph Controller.
+
+ Polargraph Controller is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Polargraph Controller is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Polargraph Controller. If not, see .
+
+ Requires the excellent ControlP5 GUI library available from http://www.sojamo.de/libraries/controlP5/.
+ Requires the excellent Geomerative library available from http://www.ricardmarxer.com/geomerative/.
+
+ This is an application for controlling a polargraph machine, communicating using ASCII command language over a serial link.
+
+ sandy.noble@gmail.com
+ http://www.polargraph.co.uk/
+ https://github.com/euphy/polargraphcontroller
+
+ */
//import processing.video.*;
import diewald_CV_kit.libraryinfo.*;
import diewald_CV_kit.utility.*;
@@ -51,8 +51,8 @@ import java.awt.event.KeyEvent;
import java.awt.event.*;
int majorVersionNo = 1;
-int minorVersionNo = 10;
-int buildNo = 2;
+int minorVersionNo = 2;
+int buildNo = 1;
String programTitle = "Polargraph Controller v" + majorVersionNo + "." + minorVersionNo + " build " + buildNo;
ControlP5 cp5;
@@ -329,6 +329,8 @@ static final String MODE_ROTATE_WEBCAM_INPUT = "toggle_mode_rotateWebcam";
static final String MODE_SEND_BUTTON_ACTIVATE = "button_mode_sendButtonActivate";
static final String MODE_SEND_BUTTON_DEACTIVATE = "button_mode_sendButtonDeactivate";
+static final String MODE_ADJUST_PREVIEW_CORD_OFFSET = "numberbox_mode_previewCordOffsetValue";
+
PVector statusTextPosition = new PVector(300.0, 12.0);
@@ -385,16 +387,18 @@ static final char BITMAP_BACKGROUND_COLOUR = 0x0F;
PVector homePointCartesian = null;
-public color chromaKeyColour = color(0,255,0);
+public color chromaKeyColour = color(0, 255, 0);
// used in the preview page
public color pageColour = color(220);
-public color frameColour = color(200,0,0);
+public color frameColour = color(200, 0, 0);
public color machineColour = color(150);
public color guideColour = color(255);
public color backgroundColour = color(100);
public color densityPreviewColour = color(0);
+public Integer previewCordOffset = 0;
+
public boolean showingSummaryOverlay = true;
public boolean showingDialogBox = false;
@@ -460,7 +464,7 @@ public final float MAX_SCALING = 15.0;
RShape vectorShape = null;
String vectorFilename = null;
float vectorScaling = 100;
-PVector vectorPosition = new PVector(0.0,0.0);
+PVector vectorPosition = new PVector(0.0, 0.0);
int minimumVectorLineLength = 0;
public static final int VECTOR_FILTER_LOW_PASS = 0;
@@ -505,36 +509,29 @@ String shapeSavePath = "../../savedcaptures/";
String shapeSavePrefix = "shape-";
String shapeSaveExtension = ".svg";
-//boolean displayGamepadOverlay = false;
-//PImage yButtonImage = null;
-//PImage xButtonImage = null;
-//PImage aButtonImage = null;
-//PImage bButtonImage = null;
-//
-//PImage dpadXImage = null;
-//PImage dpadYImage = null;
+static Float gcodeZAxisDrawingHeight = 1.0; //-0.125000;
void setup()
{
println("Running polargraph controller");
frame.setResizable(true);
initLogging();
-
+
initImages();
-
+
RG.init(this);
RG.setPolygonizer(RG.ADAPTATIVE);
try
{
- UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
+ UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
catch (Exception e)
{
- e.printStackTrace();
+ e.printStackTrace();
}
loadFromPropertiesFile();
-
+
this.cp5 = new ControlP5(this);
initTabs();
@@ -542,7 +539,7 @@ void setup()
println("Serial ports available on your machine:");
println(serialPorts);
-// println("getSerialPortNumber()"+getSerialPortNumber());
+ // println("getSerialPortNumber()"+getSerialPortNumber());
if (getSerialPortNumber() >= 0)
{
println("About to connect to serial port in slot " + getSerialPortNumber());
@@ -563,8 +560,8 @@ void setup()
catch (Exception e)
{
println("Attempting to connect to serial port "
- + portName + " in slot " + getSerialPortNumber()
- + " caused an exception: " + e.getMessage());
+ + portName + " in slot " + getSerialPortNumber()
+ + " caused an exception: " + e.getMessage());
}
}
else
@@ -590,24 +587,24 @@ void setup()
void addEventListeners()
{
frame.addComponentListener(new ComponentAdapter()
+ {
+ public void componentResized(ComponentEvent event)
{
- public void componentResized(ComponentEvent event)
+ if (event.getSource()==frame)
{
- if (event.getSource()==frame)
- {
- windowResized();
- }
+ windowResized();
}
}
+ }
);
addMouseWheelListener(new java.awt.event.MouseWheelListener()
+ {
+ public void mouseWheelMoved(java.awt.event.MouseWheelEvent evt)
{
- public void mouseWheelMoved(java.awt.event.MouseWheelEvent evt)
- {
- mouseWheel(evt.getWheelRotation());
- }
+ mouseWheel(evt.getWheelRotation());
}
- );
+ }
+ );
}
@@ -627,7 +624,6 @@ void windowResized()
Panel p = getPanels().get(key);
p.setHeight(frame.getHeight() - p.getOutline().getTop() - (DEFAULT_CONTROL_SIZE.y*2));
}
-
}
void draw()
{
@@ -670,7 +666,6 @@ void draw()
{
dispatchCommandQueue();
}
-
}
String getCurrentTab()
@@ -691,7 +686,6 @@ boolean isShowingDialogBox()
}
void drawDialogBox()
{
-
}
String getVectorFilename()
{
@@ -749,12 +743,12 @@ void drawImagePage()
getDisplayMachine().draw();
drawMoveImageOutline();
stroke(255, 0, 0);
-
+
for (Panel panel : getPanelsForTab(TAB_NAME_INPUT))
{
panel.draw();
}
- stroke(200,200);
+ stroke(200, 200);
text(propertiesFilename, getPanel(PANEL_NAME_GENERAL).getOutline().getLeft(), getPanel(PANEL_NAME_GENERAL).getOutline().getTop()-7);
showGroupBox();
@@ -762,7 +756,7 @@ void drawImagePage()
if (displayingQueuePreview)
previewQueue();
if (displayingInfoTextOnInputPage)
- showText(250,45);
+ showText(250, 45);
drawStatusText((int)statusTextPosition.x, (int)statusTextPosition.y);
showCommandQueue((int) getDisplayMachine().getOutline().getRight()+6, 20);
@@ -770,7 +764,7 @@ void drawImagePage()
void drawMachineOutline()
{
- rect(machinePosition.x,machinePosition.y, machinePosition.x+getDisplayMachine().getWidth(), machinePosition.y+getDisplayMachine().getHeight());
+ rect(machinePosition.x, machinePosition.y, machinePosition.x+getDisplayMachine().getWidth(), machinePosition.y+getDisplayMachine().getHeight());
}
void drawDetailsPage()
{
@@ -783,16 +777,16 @@ void drawDetailsPage()
noFill();
getDisplayMachine().drawForSetup();
stroke(255, 0, 0);
-
+
for (Panel panel : getPanelsForTab(TAB_NAME_DETAILS))
{
panel.draw();
}
text(propertiesFilename, getPanel(PANEL_NAME_GENERAL).getOutline().getLeft(), getPanel(PANEL_NAME_GENERAL).getOutline().getTop()-7);
-// showCurrentMachinePosition();
+ // showCurrentMachinePosition();
if (displayingInfoTextOnInputPage)
- showText(250,45);
+ showText(250, 45);
drawStatusText((int)statusTextPosition.x, (int)statusTextPosition.y);
showCommandQueue((int) getDisplayMachine().getOutline().getRight()+6, 20);
@@ -809,18 +803,18 @@ void drawRovingPage()
noFill();
getDisplayMachine().drawForSetup();
stroke(255, 0, 0);
-
+
for (Panel panel : getPanelsForTab(TAB_NAME_ROVING))
{
panel.draw();
}
text(propertiesFilename, getPanel(PANEL_NAME_GENERAL).getOutline().getLeft(), getPanel(PANEL_NAME_GENERAL).getOutline().getTop()-7);
-// showCurrentMachinePosition();
+ // showCurrentMachinePosition();
showGroupBox();
showCurrentMachinePosition();
if (displayingInfoTextOnInputPage)
- showText(250,45);
+ showText(250, 45);
drawStatusText((int)statusTextPosition.x, (int)statusTextPosition.y);
showCommandQueue((int) getDisplayMachine().getOutline().getRight()+6, 20);
@@ -845,7 +839,7 @@ void drawTracePage()
}
stroke(255, 0, 0);
-
+
for (Panel panel : getPanelsForTab(TAB_NAME_TRACE))
{
panel.draw();
@@ -854,15 +848,15 @@ void drawTracePage()
if (displayingInfoTextOnInputPage)
- showText(250,45);
+ showText(250, 45);
drawStatusText((int)statusTextPosition.x, (int)statusTextPosition.y);
showCommandQueue((int) width-200, 20);
-// processGamepadInput();
-//
-// if (displayGamepadOverlay)
-// displayGamepadOverlay();
+ // processGamepadInput();
+ //
+ // if (displayGamepadOverlay)
+ // displayGamepadOverlay();
}
@@ -875,9 +869,9 @@ void drawCommandQueuePage()
fill(100);
drawMachineOutline();
showingSummaryOverlay = false;
-
-
+
+
int right = 0;
for (Panel panel : getPanelsForTab(TAB_NAME_QUEUE))
{
@@ -888,9 +882,8 @@ void drawCommandQueuePage()
}
text(propertiesFilename, getPanel(PANEL_NAME_GENERAL).getOutline().getLeft(), getPanel(PANEL_NAME_GENERAL).getOutline().getTop()-7);
showCommandQueue(right, (int)mainPanelPosition.y);
-
+
drawStatusText((int)statusTextPosition.x, (int)statusTextPosition.y);
-
}
void drawImageLoadPage()
@@ -909,15 +902,15 @@ void drawMoveImageOutline()
PVector imageSizeOnScreen = getDisplayMachine().scaleToScreen(imageSize);
imageSizeOnScreen.sub(getDisplayMachine().getOutline().getTopLeft());
PVector offset = new PVector(imageSizeOnScreen.x/2.0, imageSizeOnScreen.y/2.0);
-
+
PVector mVect = getMouseVector();
PVector imagePos = new PVector(mVect.x-offset.x, mVect.y-offset.y);
- fill(80,50);
+ fill(80, 50);
noStroke();
rect(imagePos.x+imageSizeOnScreen.x, imagePos.y+4, 4, imageSizeOnScreen.y);
rect(imagePos.x+4, imageSizeOnScreen.y+imagePos.y, imageSizeOnScreen.x-4, 4);
- tint(255,180);
+ tint(255, 180);
image(getDisplayMachine().getImage(), imagePos.x, imagePos.y, imageSizeOnScreen.x, imageSizeOnScreen.y);
noTint();
// decorate image
@@ -959,12 +952,12 @@ void drawMoveImageOutline()
void showCurrentMachinePosition()
{
noStroke();
- fill(255,0,255,150);
+ fill(255, 0, 255, 150);
PVector pgCoord = getDisplayMachine().scaleToScreen(currentMachinePos);
ellipse(pgCoord.x, pgCoord.y, 20, 20);
// also show cartesian position if reported
- fill(255,255,0,150);
+ fill(255, 255, 0, 150);
ellipse(currentCartesianMachinePos.x, currentCartesianMachinePos.y, 15, 15);
noFill();
@@ -988,14 +981,14 @@ void showGroupBox()
noFill();
stroke(getFrameColour());
strokeWeight(1);
-
+
if (getBoxVector1() != null)
{
PVector topLeft = getDisplayMachine().scaleToScreen(boxVector1);
line(topLeft.x, topLeft.y, topLeft.x-10, topLeft.y);
line(topLeft.x, topLeft.y, topLeft.x, topLeft.y-10);
}
-
+
if (getBoxVector2() != null)
{
PVector botRight = getDisplayMachine().scaleToScreen(boxVector2);
@@ -1004,7 +997,6 @@ void showGroupBox()
}
}
}
-
}
void loadImageWithFileChooser()
@@ -1014,7 +1006,7 @@ void loadImageWithFileChooser()
public void run() {
JFileChooser fc = new JFileChooser();
fc.setFileFilter(new ImageFileFilter());
-
+
fc.setDialogTitle("Choose an image file...");
int returned = fc.showOpenDialog(frame);
@@ -1034,21 +1026,22 @@ void loadImageWithFileChooser()
}
}
}
- });
+ }
+ );
}
class ImageFileFilter extends javax.swing.filechooser.FileFilter
{
public boolean accept(File file) {
- String filename = file.getName();
- filename.toLowerCase();
- if (file.isDirectory() || filename.endsWith(".png") || filename.endsWith(".jpg") || filename.endsWith(".jpeg"))
- return true;
- else
- return false;
+ String filename = file.getName();
+ filename.toLowerCase();
+ if (file.isDirectory() || filename.endsWith(".png") || filename.endsWith(".jpg") || filename.endsWith(".jpeg"))
+ return true;
+ else
+ return false;
}
public String getDescription() {
- return "Image files (PNG or JPG)";
+ return "Image files (PNG or JPG)";
}
}
@@ -1059,7 +1052,7 @@ void loadVectorWithFileChooser()
public void run() {
JFileChooser fc = new JFileChooser();
fc.setFileFilter(new VectorFileFilter());
-
+
fc.setDialogTitle("Choose a vector file...");
int returned = fc.showOpenDialog(frame);
@@ -1068,7 +1061,7 @@ void loadVectorWithFileChooser()
File file = fc.getSelectedFile();
if (file.exists())
{
- RShape shape = RG.loadShape(file.getPath());
+ RShape shape = loadShapeFromFile(file.getPath());
if (shape != null)
{
setVectorFilename(file.getPath());
@@ -1081,23 +1074,25 @@ void loadVectorWithFileChooser()
}
}
}
- });
+ }
+ );
}
class VectorFileFilter extends javax.swing.filechooser.FileFilter
{
public boolean accept(File file) {
- String filename = file.getName();
- filename.toLowerCase();
- if (file.isDirectory() || filename.endsWith(".svg"))
- return true;
- else
- return false;
+ String filename = file.getName();
+ filename.toLowerCase();
+ if (file.isDirectory() || filename.endsWith(".svg") || filename.endsWith(".gco") || filename.endsWith(".g"))
+ return true;
+ else
+ return false;
}
public String getDescription() {
- return "Vector graphic files (SVG)";
+ return "Vector graphic files (SVG, GCode)";
}
}
+
void loadNewPropertiesFilenameWithFileChooser()
{
SwingUtilities.invokeLater(new Runnable()
@@ -1106,7 +1101,7 @@ void loadNewPropertiesFilenameWithFileChooser()
{
JFileChooser fc = new JFileChooser();
fc.setFileFilter(new PropertiesFileFilter());
-
+
fc.setDialogTitle("Choose a config file...");
int returned = fc.showOpenDialog(frame);
@@ -1122,27 +1117,28 @@ void loadNewPropertiesFilenameWithFileChooser()
// clear old properties.
props = null;
loadFromPropertiesFile();
-
+
// set values of number spinners etc
updateNumberboxValues();
- }
+ }
}
}
- });
+ }
+ );
}
class PropertiesFileFilter extends javax.swing.filechooser.FileFilter
{
public boolean accept(File file) {
- String filename = file.getName();
- filename.toLowerCase();
- if (file.isDirectory() || filename.endsWith(".properties.txt"))
- return true;
- else
- return false;
+ String filename = file.getName();
+ filename.toLowerCase();
+ if (file.isDirectory() || filename.endsWith(".properties.txt"))
+ return true;
+ else
+ return false;
}
public String getDescription() {
- return "Properties files (*.properties.txt)";
+ return "Properties files (*.properties.txt)";
}
}
@@ -1154,7 +1150,7 @@ void saveNewPropertiesFileWithFileChooser()
{
JFileChooser fc = new JFileChooser();
fc.setFileFilter(new PropertiesFileFilter());
-
+
fc.setDialogTitle("Enter a config file name...");
int returned = fc.showSaveDialog(frame);
@@ -1165,7 +1161,7 @@ void saveNewPropertiesFileWithFileChooser()
newPropertiesFilename.toLowerCase();
if (!newPropertiesFilename.endsWith(".properties.txt"))
newPropertiesFilename+=".properties.txt";
-
+
println("new propertiesFilename: "+ newPropertiesFilename);
propertiesFilename = newPropertiesFilename;
savePropertiesFile();
@@ -1174,18 +1170,154 @@ void saveNewPropertiesFileWithFileChooser()
loadFromPropertiesFile();
}
}
- });
+ }
+ );
}
+RShape loadShapeFromFile(String filename) {
+ RShape sh = null;
+ if (filename.toLowerCase().endsWith(".svg")) {
+ sh = RG.loadShape(filename);
+ }
+ else if (filename.toLowerCase().endsWith(".gco") || filename.toLowerCase().endsWith(".g")) {
+ sh = loadShapeFromGCodeFile(filename);
+ }
+ return sh;
+}
+
+RShape loadShapeFromGCodeFile(String filename) {
+ RShape parent = null;
+ BufferedReader reader = null;
+ RShape child = null;
+
+ try {
+ reader = createReader(filename);
+ parent = new RShape();
+ String line;
+ boolean drawLine = false;
+ int gCodeZAxisChanges = 0;
+
+ long lineNo = 0;
+ while ((line = reader.readLine ()) != null) {
+ lineNo++;
+ if (line.toUpperCase().startsWith("G")) {
+ println("" + lineNo + ": " + line);
+ Map ins = null;
+ try {
+ ins = unpackGCodeInstruction(line);
+ }
+ catch (Exception e) {
+ println("Exception while unpacking a gcode line " + line);
+ continue;
+ }
+ Integer code = Math.round(ins.get("G"));
+ if (code >= 2) {
+ continue;
+ }
+
+
+ Float z = ins.get("Z");
+ if (z != null) {
+ gCodeZAxisChanges++;
+ if (gCodeZAxisChanges == 2) {
+ println("Assume second z axis change is to drop the pen to start drawing " + z);
+ gcodeZAxisDrawingHeight = z;
+ drawLine = true;
+ }
+ else if (gCodeZAxisChanges > 2) {
+ drawLine = isGCodeZAxisForDrawing(z);
+ }
+ else {
+ println("Assume first z axis change is to RAISE the pen " + z);
+ drawLine = false;
+ }
+ }
+
+ Float x = ins.get("X");
+ Float y = ins.get("Y");
+ RPoint[][] points = parent.getPointsInPaths();
+ if (points != null) {
+ for (int i = 0; i unpackGCodeInstruction(String line) throws NumberFormatException {
+ Map instruction = new HashMap();
+ try {
+ String[] splitted = line.trim().split(" ");
+ for (int i = 0; i < splitted.length; i++) {
+ String axis = splitted[i].substring(0, 1);
+ Float value = Float.parseFloat(splitted[i].substring(1));
+ if ("X".equalsIgnoreCase(axis) || "Y".equalsIgnoreCase(axis) || "Z".equalsIgnoreCase(axis) || "G".equalsIgnoreCase(axis)) {
+ instruction.put(axis, value);
+ }
+ }
+// println("instruction: " + instruction);
+ }
+ catch (NumberFormatException e) {
+ println("Exception while reading the lines from a gcode file: " + line);
+ throw e;
+ }
+ return instruction;
+}
void setPictureFrameDimensionsToBox()
{
-// if (getDisplayMachine().pixelsCanBeExtracted() && isBoxSpecified())
-// {
- Rectangle r = new Rectangle(getDisplayMachine().inSteps(getBoxVector1()), getDisplayMachine().inSteps(getBoxVectorSize()));
- getDisplayMachine().setPictureFrame(r);
-// }
+ // if (getDisplayMachine().pixelsCanBeExtracted() && isBoxSpecified())
+ // {
+ Rectangle r = new Rectangle(getDisplayMachine().inSteps(getBoxVector1()), getDisplayMachine().inSteps(getBoxVectorSize()));
+ getDisplayMachine().setPictureFrame(r);
+ // }
}
void setBoxToPictureframeDimensions()
{
@@ -1201,7 +1333,6 @@ void setBoxToPictureframeDimensions()
t = (Toggle) getAllControls().get(MODE_SHOW_DENSITY_PREVIEW);
t.setValue(1);
t.update();
-
}
}
@@ -1234,7 +1365,7 @@ void controlEvent(ControlEvent controlEvent)
changeTab(currentTab, controlEvent.tab().name());
}
}
- else if(controlEvent.isGroup())
+ else if (controlEvent.isGroup())
{
print("got an event from "+controlEvent.group().name()+"\t");
@@ -1246,12 +1377,11 @@ void controlEvent(ControlEvent controlEvent)
}
println();
}
-
}
void changeTab(String from, String to)
{
-
+
// hide old panels
currentTab = to;
for (Panel panel : getPanelsForTab(currentTab))
@@ -1262,7 +1392,6 @@ void changeTab(String from, String to)
c.show();
}
}
-
}
@@ -1370,14 +1499,14 @@ void changeMachineScaling(int delta)
boolean checkKey(int k)
{
if (keys.length >= k) {
- return keys[k];
+ return keys[k];
}
return false;
}
void keyReleased()
{
- keys[keyCode] = false;
+ keys[keyCode] = false;
}
void keyPressed()
@@ -1387,7 +1516,7 @@ void keyPressed()
//println("key: " + KeyEvent.getKeyText(keyCode));
//println("Keys: " + keys);
//println("Keycode: " + keyCode);
-
+
if (checkKey(CONTROL) && checkKey(KeyEvent.VK_PAGE_UP))
changeMachineScaling(1);
else if (checkKey(CONTROL) && checkKey(KeyEvent.VK_PAGE_DOWN))
@@ -1403,8 +1532,8 @@ void keyPressed()
else if (checkKey(KeyEvent.VK_ESCAPE))
key = 0;
-// if (checkKey(CONTROL) && checkKey(KeyEvent.VK_G))
-// println("CTRL+G");
+ // if (checkKey(CONTROL) && checkKey(KeyEvent.VK_G))
+ // println("CTRL+G");
else if (checkKey(CONTROL) && checkKey(KeyEvent.VK_G))
{
@@ -1427,7 +1556,7 @@ void keyPressed()
setUseWindowedConsole(false);
else
setUseWindowedConsole(true);
-
+
initLogging();
}
else if (checkKey(CONTROL) && checkKey(KeyEvent.VK_S))
@@ -1439,60 +1568,60 @@ void keyPressed()
{
displayingInfoTextOnInputPage = (displayingInfoTextOnInputPage) ? false : true;
}
-// else if (key == '+')
-// {
-// currentMachineMaxSpeed = currentMachineMaxSpeed+MACHINE_MAXSPEED_INCREMENT;
-// currentMachineMaxSpeed = Math.round(currentMachineMaxSpeed*100.0)/100.0;
-// NumberFormat nf = NumberFormat.getNumberInstance(Locale.UK);
-// DecimalFormat df = (DecimalFormat)nf;
-// df.applyPattern("###.##");
-// addToRealtimeCommandQueue(CMD_SETMOTORSPEED+df.format(currentMachineMaxSpeed)+",END");
-// }
-// else if (key == '-')
-// {
-// currentMachineMaxSpeed = currentMachineMaxSpeed+(0.0 - MACHINE_MAXSPEED_INCREMENT);
-// currentMachineMaxSpeed = Math.round(currentMachineMaxSpeed*100.0)/100.0;
-// NumberFormat nf = NumberFormat.getNumberInstance(Locale.UK);
-// DecimalFormat df = (DecimalFormat)nf;
-// df.applyPattern("###.##");
-// addToRealtimeCommandQueue(CMD_SETMOTORSPEED+df.format(currentMachineMaxSpeed)+",END");
-// }
-// else if (key == '*')
-// {
-// currentMachineAccel = currentMachineAccel+MACHINE_ACCEL_INCREMENT;
-// currentMachineAccel = Math.round(currentMachineAccel*100.0)/100.0;
-// NumberFormat nf = NumberFormat.getNumberInstance(Locale.UK);
-// DecimalFormat df = (DecimalFormat)nf;
-// df.applyPattern("###.##");
-// addToRealtimeCommandQueue(CMD_SETMOTORACCEL+df.format(currentMachineAccel)+",END");
-// }
-// else if (key == '/')
-// {
-// currentMachineAccel = currentMachineAccel+(0.0 - MACHINE_ACCEL_INCREMENT);
-// currentMachineAccel = Math.round(currentMachineAccel*100.0)/100.0;
-// NumberFormat nf = NumberFormat.getNumberInstance(Locale.UK);
-// DecimalFormat df = (DecimalFormat)nf;
-// df.applyPattern("###.##");
-// addToRealtimeCommandQueue(CMD_SETMOTORACCEL+df.format(currentMachineAccel)+",END");
-// }
-// else if (key == ']')
-// {
-// currentPenWidth = currentPenWidth+penIncrement;
-// currentPenWidth = Math.round(currentPenWidth*100.0)/100.0;
-// NumberFormat nf = NumberFormat.getNumberInstance(Locale.UK);
-// DecimalFormat df = (DecimalFormat)nf;
-// df.applyPattern("###.##");
-// addToRealtimeCommandQueue(CMD_CHANGEPENWIDTH+df.format(currentPenWidth)+",END");
-// }
-// else if (key == '[')
-// {
-// currentPenWidth = currentPenWidth-penIncrement;
-// currentPenWidth = Math.round(currentPenWidth*100.0)/100.0;
-// NumberFormat nf = NumberFormat.getNumberInstance(Locale.UK);
-// DecimalFormat df = (DecimalFormat)nf;
-// df.applyPattern("###.##");
-// addToRealtimeCommandQueue(CMD_CHANGEPENWIDTH+df.format(currentPenWidth)+",END");
-// }
+ // else if (key == '+')
+ // {
+ // currentMachineMaxSpeed = currentMachineMaxSpeed+MACHINE_MAXSPEED_INCREMENT;
+ // currentMachineMaxSpeed = Math.round(currentMachineMaxSpeed*100.0)/100.0;
+ // NumberFormat nf = NumberFormat.getNumberInstance(Locale.UK);
+ // DecimalFormat df = (DecimalFormat)nf;
+ // df.applyPattern("###.##");
+ // addToRealtimeCommandQueue(CMD_SETMOTORSPEED+df.format(currentMachineMaxSpeed)+",END");
+ // }
+ // else if (key == '-')
+ // {
+ // currentMachineMaxSpeed = currentMachineMaxSpeed+(0.0 - MACHINE_MAXSPEED_INCREMENT);
+ // currentMachineMaxSpeed = Math.round(currentMachineMaxSpeed*100.0)/100.0;
+ // NumberFormat nf = NumberFormat.getNumberInstance(Locale.UK);
+ // DecimalFormat df = (DecimalFormat)nf;
+ // df.applyPattern("###.##");
+ // addToRealtimeCommandQueue(CMD_SETMOTORSPEED+df.format(currentMachineMaxSpeed)+",END");
+ // }
+ // else if (key == '*')
+ // {
+ // currentMachineAccel = currentMachineAccel+MACHINE_ACCEL_INCREMENT;
+ // currentMachineAccel = Math.round(currentMachineAccel*100.0)/100.0;
+ // NumberFormat nf = NumberFormat.getNumberInstance(Locale.UK);
+ // DecimalFormat df = (DecimalFormat)nf;
+ // df.applyPattern("###.##");
+ // addToRealtimeCommandQueue(CMD_SETMOTORACCEL+df.format(currentMachineAccel)+",END");
+ // }
+ // else if (key == '/')
+ // {
+ // currentMachineAccel = currentMachineAccel+(0.0 - MACHINE_ACCEL_INCREMENT);
+ // currentMachineAccel = Math.round(currentMachineAccel*100.0)/100.0;
+ // NumberFormat nf = NumberFormat.getNumberInstance(Locale.UK);
+ // DecimalFormat df = (DecimalFormat)nf;
+ // df.applyPattern("###.##");
+ // addToRealtimeCommandQueue(CMD_SETMOTORACCEL+df.format(currentMachineAccel)+",END");
+ // }
+ // else if (key == ']')
+ // {
+ // currentPenWidth = currentPenWidth+penIncrement;
+ // currentPenWidth = Math.round(currentPenWidth*100.0)/100.0;
+ // NumberFormat nf = NumberFormat.getNumberInstance(Locale.UK);
+ // DecimalFormat df = (DecimalFormat)nf;
+ // df.applyPattern("###.##");
+ // addToRealtimeCommandQueue(CMD_CHANGEPENWIDTH+df.format(currentPenWidth)+",END");
+ // }
+ // else if (key == '[')
+ // {
+ // currentPenWidth = currentPenWidth-penIncrement;
+ // currentPenWidth = Math.round(currentPenWidth*100.0)/100.0;
+ // NumberFormat nf = NumberFormat.getNumberInstance(Locale.UK);
+ // DecimalFormat df = (DecimalFormat)nf;
+ // df.applyPattern("###.##");
+ // addToRealtimeCommandQueue(CMD_CHANGEPENWIDTH+df.format(currentPenWidth)+",END");
+ // }
else if (key == '#' )
{
addToRealtimeCommandQueue(CMD_PENUP+"END");
@@ -1510,15 +1639,15 @@ void keyPressed()
{
this.maxSegmentLength++;
}
-// else if (key == ',')
-// {
-// if (this.minimumVectorLineLength > 0)
-// this.minimumVectorLineLength--;
-// }
-// else if (key == '.')
-// {
-// this.minimumVectorLineLength++;
-// }
+ // else if (key == ',')
+ // {
+ // if (this.minimumVectorLineLength > 0)
+ // this.minimumVectorLineLength--;
+ // }
+ // else if (key == '.')
+ // {
+ // this.minimumVectorLineLength++;
+ // }
}
void mouseDragged()
{
@@ -1539,12 +1668,12 @@ void mouseDragged()
}
}
}
-
+
void mouseClicked()
{
if (mouseOverPanel())
{ // changing mode
-// panelClicked();
+ // panelClicked();
}
else
{
@@ -1554,10 +1683,10 @@ void mouseClicked()
PVector mVect = getDisplayMachine().scaleToDisplayMachine(getMouseVector());
PVector offset = new PVector(imageSize.x/2.0, imageSize.y/2.0);
PVector imagePos = new PVector(mVect.x-offset.x, mVect.y-offset.y);
-
+
imagePos = getDisplayMachine().inSteps(imagePos);
getDisplayMachine().getImageFrame().setPosition(imagePos.x, imagePos.y);
-
+
if (getDisplayMachine().pixelsCanBeExtracted() && isBoxSpecified())
getDisplayMachine().extractPixelsFromArea(getBoxVector1(), getBoxVectorSize(), getGridSize(), sampleArea);
}
@@ -1604,9 +1733,9 @@ void machineClicked()
}
void mousePressed()
{
-// println("mouse pressed");
-// println("mouse button: "+mouseButton);
-// println("Current mode: " +currentMode);
+ // println("mouse pressed");
+ // println("mouse button: "+mouseButton);
+ // println("Current mode: " +currentMode);
if (mouseButton == CENTER)
{
middleButtonMachinePress();
@@ -1623,13 +1752,13 @@ void mousePressed()
if (getDisplayMachine().pixelsCanBeExtracted() && isBoxSpecified())
{
getDisplayMachine().extractPixelsFromArea(getBoxVector1(), getBoxVectorSize(), getGridSize(), sampleArea);
-// minitoggle_mode_showImage(false);
-// minitoggle_mode_showDensityPreview(true);
+ // minitoggle_mode_showImage(false);
+ // minitoggle_mode_showDensityPreview(true);
}
}
else
{
-// println("Do nothing.");
+ // println("Do nothing.");
}
}
}
@@ -1689,7 +1818,6 @@ void leftButtonMachineClick()
setChromaKey(getMouseVector());
else if (currentMode.equals(MODE_SEND_START_TEXT))
sendStartTextAtPoint();
-
}
void mouseWheel(int delta)
@@ -1722,13 +1850,13 @@ boolean isPreviewable(String command)
}
/**
- This will comb the command queue and attempt to draw a picture of what it contains.
- Coordinates here are in pixels.
-*/
+ This will comb the command queue and attempt to draw a picture of what it contains.
+ Coordinates here are in pixels.
+ */
void previewQueue()
{
PVector startPoint = null;
-
+
if (commandQueue.hashCode() != lastCommandQueueHash)
{
println("regenerating preview queue.");
@@ -1744,27 +1872,27 @@ void previewQueue()
String aLenStr = splitted[1];
String bLenStr = splitted[2];
-
- PVector endPoint = new PVector(Integer.parseInt(aLenStr), Integer.parseInt(bLenStr));
+
+ PVector endPoint = new PVector(Integer.parseInt(aLenStr)+previewCordOffset, Integer.parseInt(bLenStr)+previewCordOffset);
endPoint = getDisplayMachine().asCartesianCoords(endPoint);
endPoint = getDisplayMachine().inMM(endPoint);
-
+
pv.x = endPoint.x;
pv.y = endPoint.y;
pv.z = -1.0;
-
+
if (command.startsWith(CMD_DRAWPIXEL))
{
String densStr = splitted[4];
pv.z = Integer.parseInt(densStr);
}
-
+
previewCommandList.add(pv);
}
}
lastCommandQueueHash = commandQueue.hashCode();
}
-
+
for (PreviewVector pv : previewCommandList)
{
PVector p = (PVector) pv;
@@ -1773,37 +1901,35 @@ void previewQueue()
if (startPoint == null)
{
noStroke();
- fill(255,0,255,150);
+ fill(255, 0, 255, 150);
startPoint = getDisplayMachine().scaleToScreen(currentMachinePos);
ellipse(p.x, p.y, 20, 20);
noFill();
}
-
+
if (pv.command.equals(CMD_CHANGELENGTHDIRECT))
stroke(0);
else
- stroke(200,0,0);
+ stroke(200, 0, 0);
line(startPoint.x, startPoint.y, p.x, p.y);
startPoint = p;
if (pv.z >= 0.0)
{
noStroke();
- fill(255,pv.z,pv.z);
- ellipse(p.x, p.y, 5,5);
+ fill(255, pv.z, pv.z);
+ ellipse(p.x, p.y, 5, 5);
noFill();
}
-
}
if (startPoint != null)
{
noStroke();
- fill(200,0,0,128);
- ellipse(startPoint.x, startPoint.y, 15,15);
+ fill(200, 0, 0, 128);
+ ellipse(startPoint.x, startPoint.y, 15, 15);
noFill();
}
-
}
boolean isHiddenPixel(PVector p)
@@ -1813,19 +1939,19 @@ boolean isHiddenPixel(PVector p)
else
return false;
}
-
+
void sizeImageToFitBox()
{
-// PVector mmBoxSize = getDisplayMachine().inSteps(getBoxSize());
-// PVector mmBoxPos = getDisplayMachine().inSteps(getBoxVector1());
-// println("mm box: " + mmBoxSize);
-
+ // PVector mmBoxSize = getDisplayMachine().inSteps(getBoxSize());
+ // PVector mmBoxPos = getDisplayMachine().inSteps(getBoxVector1());
+ // println("mm box: " + mmBoxSize);
+
PVector boxSize = getDisplayMachine().inSteps(getBoxSize());
PVector boxPos = getDisplayMachine().inSteps(getBoxVector1());
println("image: " + boxSize);
-
+
Rectangle r = new Rectangle(boxPos, boxSize);
getDisplayMachine().setImageFrame(r);
}
@@ -1846,11 +1972,11 @@ void exportQueueToFile()
println("Output file: " + savePath);
List allCommands = new ArrayList(realtimeCommandQueue);
allCommands.addAll(commandQueue);
-
+
String[] list = (String[]) allCommands.toArray(new String[0]);
saveStrings(savePath, list);
println("Completed queue export, " + list.length + " commands exported.");
- }
+ }
}
}
void importQueueFromFile()
@@ -1866,7 +1992,7 @@ void importQueueFromFile()
{
println("Input file: " + loadPath);
String commands[] = loadStrings(loadPath);
-// List list = Arrays
+ // List list = Arrays
commandQueue.addAll(Arrays.asList(commands));
println("Completed queue import, " + commandQueue.size() + " commands found.");
}
@@ -1904,7 +2030,7 @@ void queueClicked()
int relativeCoord = (mouseY-topEdgeOfQueue);
int rowClicked = relativeCoord / queueRowHeight;
int totalCommands = commandQueue.size()+realtimeCommandQueue.size();
-
+
if (rowClicked < 1) // its the header - start or stop queue
{
if (commandQueueRunning)
@@ -1930,7 +2056,7 @@ void queueClicked()
{
cmdNumber-=(realtimeCommandQueue.size()+1);
commandQueue.remove(cmdNumber);
- }
+ }
}
else
{
@@ -1977,7 +2103,7 @@ PVector getBoxVector2()
}
PVector getBoxVectorSize()
{
- return PVector.sub(getBoxVector2(),getBoxVector1());
+ return PVector.sub(getBoxVector2(), getBoxVector1());
}
float getSampleArea()
@@ -1998,32 +2124,32 @@ void showText(int xPosOrigin, int yPosOrigin)
noStroke();
fill(0, 0, 0, 80);
rect(xPosOrigin, yPosOrigin, 220, 550);
-
-
+
+
textSize(12);
fill(255);
int tRow = 15;
int textPositionX = xPosOrigin+4;
int textPositionY = yPosOrigin+4;
-
+
int tRowNo = 1;
PVector screenCoordsCart = getMouseVector();
-
+
text(programTitle, textPositionX, textPositionY+(tRow*tRowNo++));
tRowNo++;
text("Cursor position: " + mouseX + ", " + mouseY, textPositionX, textPositionY+(tRow*tRowNo++));
-
+
text("MM Per Step: " + getDisplayMachine().getMMPerStep(), textPositionX, textPositionY+(tRow*tRowNo++));
- text("Steps Per MM: " + getDisplayMachine().getStepsPerMM() ,textPositionX, textPositionY+(tRow*tRowNo++));
+ text("Steps Per MM: " + getDisplayMachine().getStepsPerMM(), textPositionX, textPositionY+(tRow*tRowNo++));
if (getDisplayMachine().getOutline().surrounds(screenCoordsCart))
{
PVector posOnMachineCartesianInMM = getDisplayMachine().scaleToDisplayMachine(screenCoordsCart);
text("Machine x/y mm: " + posOnMachineCartesianInMM.x+","+posOnMachineCartesianInMM.y, textPositionX, textPositionY+(tRow*tRowNo++));
-
+
PVector posOnMachineNativeInMM = getDisplayMachine().convertToNative(posOnMachineCartesianInMM);
text("Machine a/b mm: " + posOnMachineNativeInMM.x+","+posOnMachineNativeInMM.y, textPositionX, textPositionY+(tRow*tRowNo++));
-
+
PVector posOnMachineNativeInSteps = getDisplayMachine().inSteps(posOnMachineNativeInMM);
text("Machine a/b steps: " + posOnMachineNativeInSteps.x+","+posOnMachineNativeInSteps.y, textPositionX, textPositionY+(tRow*tRowNo++));
}
@@ -2033,24 +2159,24 @@ void showText(int xPosOrigin, int yPosOrigin)
text("Machine a/b mm: --,--", textPositionX, textPositionY+(tRow*tRowNo++));
text("Machine a/b steps: --,--", textPositionX, textPositionY+(tRow*tRowNo++));
}
-
+
drawStatusText(textPositionX, textPositionY+(tRow*tRowNo++));
-
+
text(commandStatus, textPositionX, textPositionY+(tRow*tRowNo++));
-
+
text("Mode: " + currentMode, textPositionX, textPositionY+(tRow*tRowNo++));
// middle side
text("Grid size: " + getGridSize(), textPositionX, textPositionY+(tRow*tRowNo++));
-
+
text("Box width: " + getBoxWidth(), textPositionX, textPositionY+(tRow*tRowNo++));
text("Box height: " + getBoxHeight(), textPositionX, textPositionY+(tRow*tRowNo++));
text("Box offset left: " + getBoxPosition().x, textPositionX, textPositionY+(tRow*tRowNo++));
text("Box offset top: " + getBoxPosition().y, textPositionX, textPositionY+(tRow*tRowNo++));
-
+
text("Available memory: " + machineAvailMem + " (min: " + machineMinAvailMem +", used: "+ machineUsedMem+")", textPositionX, textPositionY+(tRow*tRowNo++));
text("Time cmd: " + getCurrentPixelTime() + ", total: " + getTimeSoFar(), textPositionX, textPositionY+(tRow*tRowNo++));
@@ -2082,13 +2208,13 @@ void showText(int xPosOrigin, int yPosOrigin)
noFill();
noStroke();
tRowNo++;
-
+
}
void drawStatusText(int x, int y)
{
String drawbotStatus = null;
-
+
if (useSerialPortConnection)
{
if (isDrawbotConnected())
@@ -2112,20 +2238,20 @@ void drawStatusText(int x, int y)
if ("".equals(busyDoing))
busyDoing = commandHistory.get(commandHistory.size()-1);
drawbotStatus = "BUSY: " + busyDoing;
- }
+ }
}
else
{
fill(255, 0, 0);
drawbotStatus = "Polargraph is not connected.";
- }
+ }
}
else
{
fill(255, 0, 0);
drawbotStatus = "No serial connection.";
}
-
+
text(drawbotStatus, x, y);
fill(255);
}
@@ -2149,29 +2275,29 @@ void showCommandQueue(int xPos, int yPos)
leftEdgeOfQueue = textPositionX;
rightEdgeOfQueue = textPositionX+300;
bottomEdgeOfQueue = height;
-
+
drawCommandQueueStatus(textPositionX, commandQueuePos, 14);
commandQueuePos+=queueRowHeight;
text("Last command: " + ((commandHistory.isEmpty()) ? "-" : commandHistory.get(commandHistory.size()-1)), textPositionX, commandQueuePos);
commandQueuePos+=queueRowHeight;
text("Current command: " + lastCommand, textPositionX, commandQueuePos);
commandQueuePos+=queueRowHeight;
-
- fill(128,255,255);
+
+ fill(128, 255, 255);
int queueNumber = commandQueue.size()+realtimeCommandQueue.size();
for (String s : realtimeCommandQueue)
{
text((queueNumber--)+". "+ s, textPositionX, commandQueuePos);
commandQueuePos+=queueRowHeight;
}
-
+
fill(255);
try
{
// Write out the commands into the window, stop when you fall off the bottom of the window
// Or run out of commands
int commandNo = 0;
- while (commandQueuePos <= height && commandNo < commandQueue.size())
+ while (commandQueuePos <= height && commandNo < commandQueue.size ())
{
String s = commandQueue.get(commandNo);
text((queueNumber--)+". "+ s, textPositionX, commandQueuePos);
@@ -2185,7 +2311,6 @@ void showCommandQueue(int xPos, int yPos)
println("Caught the pesky ConcurrentModificationException: " + cme.getMessage());
}
showmachineMessageLog(rightEdgeOfQueue, 20);
-
}
void drawCommandQueueStatus(int x, int y, int tSize)
@@ -2217,7 +2342,7 @@ void showmachineMessageLog(int xPos, int yPos)
int pos = textPositionY+(tRow*tRowNo++);
pos+=queueRowHeight;
-
+
fill(255);
// Write out the commands into the window, stop when you fall off the bottom of the window
// Or run out of commands
@@ -2225,9 +2350,9 @@ void showmachineMessageLog(int xPos, int yPos)
while (pos <= height && entryNo >= 0)
{
String s = machineMessageLog.get(entryNo);
- String type = s.substring(0,1);
- if ("E".equals(type)) fill(255,128,128);
- else if ("D".equals(type)) fill(50,50,50);
+ String type = s.substring(0, 1);
+ if ("E".equals(type)) fill(255, 128, 128);
+ else if ("D".equals(type)) fill(50, 50, 50);
else if ("I".equals(type)) fill(255);
text(s, textPositionX, pos);
pos+=queueRowHeight;
@@ -2369,7 +2494,7 @@ public DisplayMachine getDisplayMachine()
{
if (displayMachine == null)
displayMachine = new DisplayMachine(new Machine(5000, 5000, 800.0, 95.0), machinePosition, machineScaling);
-
+
displayMachine.setOffset(machinePosition);
displayMachine.setScale(machineScaling);
return displayMachine;
@@ -2394,12 +2519,12 @@ void changeHardwareVersionTo(int newVer)
switch (newVer)
{
- case HARDWARE_VER_MEGA :
- currentSram = HARDWARE_ATMEGA1280_SRAM;
- default :
- currentSram = HARDWARE_ATMEGA328_SRAM;
+ case HARDWARE_VER_MEGA :
+ currentSram = HARDWARE_ATMEGA1280_SRAM;
+ default :
+ currentSram = HARDWARE_ATMEGA328_SRAM;
}
-// windowResized();
+ // windowResized();
}
void setHardwareVersionFromIncoming(String readyString)
@@ -2422,14 +2547,14 @@ void setHardwareVersionFromIncoming(String readyString)
println("Bad format for hardware version - defaulting to ATMEGA328 (Uno)");
verInt = HARDWARE_VER_UNO;
}
-
+
if (HARDWARE_VER_MEGA == verInt
- || HARDWARE_VER_MEGA_POLARSHIELD == verInt)
+ || HARDWARE_VER_MEGA_POLARSHIELD == verInt)
newHardwareVersion = verInt;
else
newHardwareVersion = HARDWARE_VER_UNO;
}
-
+
// now see if it's different to last time.
if (newHardwareVersion != currentHardware)
{
@@ -2446,7 +2571,7 @@ void serialEvent(Serial myPort)
// if you got any bytes other than the linefeed:
incoming = trim(incoming);
println("incoming: " + incoming);
-
+
if (incoming.startsWith("READY"))
{
drawbotReady = true;
@@ -2472,14 +2597,14 @@ void serialEvent(Serial myPort)
readPenLiftRange(incoming);
else if (incoming.startsWith("PGSPEED"))
readMachineSpeed(incoming);
-
+
else if ("RESEND".equals(incoming))
resendLastCommand();
else if ("DRAWING".equals(incoming))
drawbotReady = false;
else if (incoming.startsWith("MEMORY"))
extractMemoryUsage(incoming);
-
+
else if (incoming.startsWith("BUTTON"))
handleMachineButton(incoming);
@@ -2507,10 +2632,10 @@ void extractMemoryUsage(String mem)
void readMachineMessage(String msg)
{
msg = msg.substring(4, msg.length());
- String type = msg.substring(0,1);
+ String type = msg.substring(0, 1);
msg = msg.substring(2, msg.length());
String timestamp = new SimpleDateFormat("HH:mm:ss").format(new Date());
-
+
msg = type + timestamp + " " + msg;
machineMessageLog.add(msg);
if (machineMessageLog.size() > 200)
@@ -2543,7 +2668,7 @@ void readCartesianMachinePosition(String sync)
Float a = Float.valueOf(currentAPos).floatValue();
Float b = Float.valueOf(currentBPos).floatValue();
currentCartesianMachinePos.x = a;
- currentCartesianMachinePos.y = b;
+ currentCartesianMachinePos.y = b;
}
}
@@ -2553,7 +2678,7 @@ void readMmPerRev(String in)
if (splitted.length == 3)
{
String mmStr = splitted[1];
-
+
float mmPerRev = Float.parseFloat(mmStr);
getDisplayMachine().setMMPerRev(mmPerRev);
updateNumberboxValues();
@@ -2566,7 +2691,7 @@ void readStepsPerRev(String in)
if (splitted.length == 3)
{
String stepsStr = splitted[1];
-
+
Float stepsPerRev = Float.parseFloat(stepsStr);
getDisplayMachine().setStepsPerRev(stepsPerRev);
updateNumberboxValues();
@@ -2579,7 +2704,7 @@ void readStepMultiplier(String in)
if (splitted.length == 3)
{
String stepsStr = splitted[1];
-
+
machineStepMultiplier = Integer.parseInt(stepsStr);
updateNumberboxValues();
}
@@ -2593,13 +2718,13 @@ void readMachineSize(String in)
{
String mWidth = splitted[1];
String mHeight = splitted[2];
-
+
Integer intWidth = Integer.parseInt(mWidth);
Integer intHeight = Integer.parseInt(mHeight);
-
+
float fWidth = getDisplayMachine().inSteps(intWidth);
float fHeight = getDisplayMachine().inSteps(intHeight);
-
+
getDisplayMachine().setSize(int(fWidth+0.5), int(fHeight+0.5));
updateNumberboxValues();
}
@@ -2611,7 +2736,6 @@ void readMachineName(String sync)
if (splitted.length == 3)
{
String name = splitted[1];
-
}
}
@@ -2622,10 +2746,10 @@ void readMachineSpeed(String in)
{
String speed = splitted[1];
String accel = splitted[2];
-
+
currentMachineMaxSpeed = Float.parseFloat(speed);
currentMachineAccel = Float.parseFloat(accel);
-
+
updateNumberboxValues();
}
}
@@ -2637,7 +2761,7 @@ void readPenLiftRange(String in)
{
String downPos = splitted[1];
String upPos = splitted[2];
-
+
penLiftDownPosition = Integer.parseInt(downPos);
penLiftUpPosition = Integer.parseInt(upPos);
@@ -2678,9 +2802,9 @@ void dispatchCommandQueue()
commandQueue.remove(0);
println("Dispatching command: " + command);
}
-// Checksum crc = new CRC32();
-// crc.update(lastCommand.getBytes(), 0, lastCommand.length());
-// lastCommand = lastCommand+":"+crc.getValue();
+ // Checksum crc = new CRC32();
+ // crc.update(lastCommand.getBytes(), 0, lastCommand.length());
+ // lastCommand = lastCommand+":"+crc.getValue();
println("Last command:" + lastCommand);
myPort.write(lastCommand);
myPort.write(10); // OH *$%! of COURSE you should terminate it.
@@ -2689,7 +2813,7 @@ void dispatchCommandQueue()
else if (commandQueue.isEmpty())
{
stopPixelTimer();
- }
+ }
}
void addToCommandQueue(String command)
@@ -2736,7 +2860,7 @@ Properties getProperties()
{
props = new Properties();
String fileToLoad = sketchPath(propertiesFilename);
-
+
File propertiesFile = new File(fileToLoad);
if (!propertiesFile.exists())
{
@@ -2744,7 +2868,7 @@ Properties getProperties()
savePropertiesFile();
println("saved.");
}
-
+
propertiesFileStream = new FileInputStream(propertiesFile);
props.load(propertiesFileStream);
println("Successfully loaded properties file " + fileToLoad);
@@ -2773,12 +2897,12 @@ void loadFromPropertiesFile()
{
getDisplayMachine().loadDefinitionFromProperties(getProperties());
this.pageColour = getColourProperty("controller.page.colour", color(220));
- this.frameColour = getColourProperty("controller.frame.colour", color(200,0,0));
+ this.frameColour = getColourProperty("controller.frame.colour", color(200, 0, 0));
this.machineColour = getColourProperty("controller.machine.colour", color(150));
this.guideColour = getColourProperty("controller.guide.colour", color(255));
this.backgroundColour = getColourProperty("controller.background.colour", color(100));
this.densityPreviewColour = getColourProperty("controller.densitypreview.colour", color(0));
- this.chromaKeyColour = getColourProperty("controller.pixel.mask.color", color(0,255,0));
+ this.chromaKeyColour = getColourProperty("controller.pixel.mask.color", color(0, 255, 0));
// pen size
this.currentPenWidth = getFloatProperty("machine.pen.size", 0.8);
@@ -2787,7 +2911,7 @@ void loadFromPropertiesFile()
this.currentMachineMaxSpeed = getFloatProperty("machine.motors.maxSpeed", 600.0);
this.currentMachineAccel = getFloatProperty("machine.motors.accel", 400.0);
this.machineStepMultiplier = getIntProperty("machine.step.multiplier", 1);
-
+
// serial port
this.serialPortNumber = getIntProperty("controller.machine.serialport", 0);
this.baudRate = getIntProperty("controller.machine.baudrate", 57600);
@@ -2796,36 +2920,36 @@ void loadFromPropertiesFile()
this.gridSize = getFloatProperty("controller.grid.size", 100.0);
this.sampleArea = getIntProperty("controller.pixel.samplearea", 2);
this.pixelScalingOverGridSize = getFloatProperty("controller.pixel.scaling", 1.0);
-
+
// pixel renderer
this.densityPreviewStyle = getIntProperty("controller.density.preview.style", 1);
-
+
// initial screen size
this.windowWidth = getIntProperty("controller.window.width", 650);
this.windowHeight = getIntProperty("controller.window.height", 400);
-
+
println("windowHeight:" + this.windowHeight);
this.testPenWidthStartSize = getFloatProperty("controller.testPenWidth.startSize", 0.5);
this.testPenWidthEndSize = getFloatProperty("controller.testPenWidth.endSize", 2.0);
this.testPenWidthIncrementSize = getFloatProperty("controller.testPenWidth.incrementSize", 0.5);
-
+
this.maxSegmentLength = getIntProperty("controller.maxSegmentLength", 2);
-
+
float homePointX = getFloatProperty("controller.homepoint.x", 0.0);
float homePointY = getFloatProperty("controller.homepoint.y", 0.0);
-
+
if (homePointX == 0.0)
{
float defaultX = getDisplayMachine().getWidth() / 2.0; // in steps
float defaultY = getDisplayMachine().getPage().getTop(); // in steps
-// homePointX = getDisplayMachine().inMM(defaultX);
-// homePointY = getDisplayMachine().inMM(defaultY);
+ // homePointX = getDisplayMachine().inMM(defaultX);
+ // homePointY = getDisplayMachine().inMM(defaultY);
println("Loading default homepoint.");
}
this.homePointCartesian = new PVector(getDisplayMachine().inSteps(homePointX), getDisplayMachine().inSteps(homePointY));
-// println("home point loaded: " + homePointCartesian + ", " + getHomePoint());
-
+ // println("home point loaded: " + homePointCartesian + ", " + getHomePoint());
+
setVectorFilename(getStringProperty("controller.vector.filename", null));
if (getVectorFilename() != null)
{
@@ -2838,7 +2962,7 @@ void loadFromPropertiesFile()
{
shape = null;
}
-
+
if (shape != null)
{
setVectorShape(shape);
@@ -2853,29 +2977,27 @@ void loadFromPropertiesFile()
getVectorPosition().y = getFloatProperty("controller.vector.position.y", 0.0);
this.minimumVectorLineLength = getIntProperty("controller.vector.minLineLength", 0);
-
-
println("Finished loading configuration from properties file.");
}
void savePropertiesFile()
{
Properties props = new Properties();
-
+
props = getDisplayMachine().loadDefinitionIntoProperties(props);
NumberFormat nf = NumberFormat.getNumberInstance(Locale.UK);
DecimalFormat df = (DecimalFormat)nf;
df.applyPattern("###.##");
-
- props.setProperty("controller.page.colour", hex(this.pageColour, 6));
- props.setProperty("controller.frame.colour", hex(this.frameColour,6));
- props.setProperty("controller.machine.colour", hex(this.machineColour,6));
- props.setProperty("controller.guide.colour", hex(this.guideColour,6));
- props.setProperty("controller.background.colour", hex(this.backgroundColour,6));
- props.setProperty("controller.densitypreview.colour", hex(this.densityPreviewColour,6));
-
+ props.setProperty("controller.page.colour", hex(this.pageColour, 6));
+ props.setProperty("controller.frame.colour", hex(this.frameColour, 6));
+ props.setProperty("controller.machine.colour", hex(this.machineColour, 6));
+ props.setProperty("controller.guide.colour", hex(this.guideColour, 6));
+ props.setProperty("controller.background.colour", hex(this.backgroundColour, 6));
+ props.setProperty("controller.densitypreview.colour", hex(this.densityPreviewColour, 6));
+
+
// pen size
props.setProperty("machine.pen.size", df.format(currentPenWidth));
// serial port
@@ -2897,15 +3019,15 @@ void savePropertiesFile()
props.setProperty("controller.testPenWidth.startSize", df.format(testPenWidthStartSize));
props.setProperty("controller.testPenWidth.endSize", df.format(testPenWidthEndSize));
props.setProperty("controller.testPenWidth.incrementSize", df.format(testPenWidthIncrementSize));
-
+
props.setProperty("controller.maxSegmentLength", new Integer(getMaxSegmentLength()).toString());
-
+
props.setProperty("machine.motors.maxSpeed", df.format(currentMachineMaxSpeed));
props.setProperty("machine.motors.accel", df.format(currentMachineAccel));
props.setProperty("machine.step.multiplier", new Integer(machineStepMultiplier).toString());
-
+
props.setProperty("controller.pixel.mask.color", hex(this.chromaKeyColour, 6));
-
+
PVector hp = null;
if (getHomePoint() != null)
{
@@ -2913,21 +3035,20 @@ void savePropertiesFile()
}
else
hp = new PVector(2000.0, 1000.0);
-
+
hp = getDisplayMachine().inMM(hp);
-
+
props.setProperty("controller.homepoint.x", df.format(hp.x));
props.setProperty("controller.homepoint.y", df.format(hp.y));
-
+
if (getVectorFilename() != null)
props.setProperty("controller.vector.filename", getVectorFilename());
-
+
props.setProperty("controller.vector.scaling", df.format(vectorScaling));
props.setProperty("controller.vector.position.x", df.format(getVectorPosition().x));
props.setProperty("controller.vector.position.y", df.format(getVectorPosition().y));
props.setProperty("controller.vector.minLineLength", new Integer(this.minimumVectorLineLength).toString());
-
FileOutputStream propertiesOutput = null;
try
@@ -2941,14 +3062,14 @@ void savePropertiesFile()
FileInputStream propertiesFileStream = new FileInputStream(propertiesFile);
oldProps.load(propertiesFileStream);
oldProps.putAll(props);
- oldProps.store(propertiesOutput," *** Polargraph properties file *** ");
+ oldProps.store(propertiesOutput, " *** Polargraph properties file *** ");
println("Saved settings.");
}
else
{ // create it
propertiesFile.createNewFile();
propertiesOutput = new FileOutputStream(propertiesFile);
- props.store(propertiesOutput," *** Polargraph properties file *** ");
+ props.store(propertiesOutput, " *** Polargraph properties file *** ");
println("Created file.");
}
}
@@ -2964,24 +3085,26 @@ void savePropertiesFile()
{
propertiesOutput.close();
}
- catch (Exception e2) {println("what now!"+e2.getMessage());}
+ catch (Exception e2) {
+ println("what now!"+e2.getMessage());
+ }
}
}
}
boolean getBooleanProperty(String id, boolean defState)
{
- return boolean(getProperties().getProperty(id,""+defState));
+ return boolean(getProperties().getProperty(id, ""+defState));
}
-
+
int getIntProperty(String id, int defVal)
{
- return int(getProperties().getProperty(id,""+defVal));
+ return int(getProperties().getProperty(id, ""+defVal));
}
-
+
float getFloatProperty(String id, float defVal)
{
- return float(getProperties().getProperty(id,""+defVal));
+ return float(getProperties().getProperty(id, ""+defVal));
}
String getStringProperty(String id, String defVal)
{
@@ -2995,7 +3118,7 @@ color getColourProperty(String id, color defVal)
{
col = defVal;
}
-
+
if (colStr.length() == 1)
{
// single value grey
@@ -3005,25 +3128,25 @@ color getColourProperty(String id, color defVal)
else if (colStr.length() == 3)
{
// 3 digit rgb
- String d1 = colStr.substring(0,1);
- String d2 = colStr.substring(1,2);
- String d3 = colStr.substring(2,3);
+ String d1 = colStr.substring(0, 1);
+ String d2 = colStr.substring(1, 2);
+ String d3 = colStr.substring(2, 3);
d1 = d1+d1;
d2 = d2+d2;
d3 = d3+d3;
-
+
col = color(unhex(d1), unhex(d2), unhex(d3));
}
else if (colStr.length() == 6)
{
// 6 digit rgb
- String d1 = colStr.substring(0,2);
- String d2 = colStr.substring(2,4);
- String d3 = colStr.substring(4,6);
-
+ String d1 = colStr.substring(0, 2);
+ String d2 = colStr.substring(2, 4);
+ String d3 = colStr.substring(4, 6);
+
col = color(unhex(d1), unhex(d2), unhex(d3));
}
-
+
return col;
}
@@ -3048,7 +3171,7 @@ void setOverwriteExistingStoreFile(boolean over)
{
this.overwriteExistingStoreFile = over;
}
-
+
void initProperties()
{
getProperties();
@@ -3088,12 +3211,12 @@ void initLogging()
{
try
{
-// logger = Logger.getLogger("uk.co.polargraph.controller");
-// FileHandler fileHandler = new FileHandler("mylog.txt");
-// fileHandler.setFormatter(new SimpleFormatter());
-// logger.addHandler(fileHandler);
-// logger.setLevel(Level.INFO);
-// logger.info("Hello");
+ // logger = Logger.getLogger("uk.co.polargraph.controller");
+ // FileHandler fileHandler = new FileHandler("mylog.txt");
+ // fileHandler.setFormatter(new SimpleFormatter());
+ // logger.addHandler(fileHandler);
+ // logger.setLevel(Level.INFO);
+ // logger.info("Hello");
if (isUseWindowedConsole())
{
console = new Console();
@@ -3111,29 +3234,30 @@ void initLogging()
}
void initImages()
{
-// try
-// {
-// yButtonImage = loadImage("y.png");
-// xButtonImage = loadImage("x.png");
-// aButtonImage = loadImage("a.png");
-// bButtonImage = loadImage("b.png");
-// dpadXImage = loadImage("dpadlr.png");
-// dpadYImage = loadImage("dpadud.png");
-// }
-// catch (Exception e)
-// {
-// yButtonImage = makeColourImage(64,64,color(180,180,0));
-// xButtonImage = makeColourImage(64,64,color(0,0,180));
-// aButtonImage = makeColourImage(64,64,color(0,180,0));
-// bButtonImage = makeColourImage(64,64,color(180,0,0));
-// }
+ // try
+ // {
+ // yButtonImage = loadImage("y.png");
+ // xButtonImage = loadImage("x.png");
+ // aButtonImage = loadImage("a.png");
+ // bButtonImage = loadImage("b.png");
+ // dpadXImage = loadImage("dpadlr.png");
+ // dpadYImage = loadImage("dpadud.png");
+ // }
+ // catch (Exception e)
+ // {
+ // yButtonImage = makeColourImage(64,64,color(180,180,0));
+ // xButtonImage = makeColourImage(64,64,color(0,0,180));
+ // aButtonImage = makeColourImage(64,64,color(0,180,0));
+ // bButtonImage = makeColourImage(64,64,color(180,0,0));
+ // }
}
PImage makeColourImage(int w, int h, int colour)
{
- PImage img = createImage(w,h,RGB);
- for(int i=0; i < img.pixels.length; i++) {
- img.pixels[i] = colour;
+ PImage img = createImage(w, h, RGB);
+ for (int i=0; i < img.pixels.length; i++) {
+ img.pixels[i] = colour;
}
return img;
}
+
diff --git a/tabSetup.pde b/tabSetup.pde
index 67f6ac6..afb57cf 100644
--- a/tabSetup.pde
+++ b/tabSetup.pde
@@ -1,6 +1,6 @@
/**
Polargraph controller
- Copyright Sandy Noble 2012.
+ Copyright Sandy Noble 2015.
This file is part of Polargraph Controller.
@@ -24,7 +24,8 @@
sandy.noble@gmail.com
http://www.polargraph.co.uk/
- http://code.google.com/p/polargraph/
+ https://github.com/euphy/polargraphcontroller
+
*/
Set getPanelsForTab(String tabName)