mirror of
https://github.com/euphy/polargraphcontroller
synced 2024-11-15 02:37:56 +01:00
Fixing merge
This commit is contained in:
commit
69ab977f90
@ -535,7 +535,7 @@ class DisplayMachine extends Machine
|
||||
p = scaleToScreen(p);
|
||||
stroke(strokeColour);
|
||||
vertex(p.x, p.y);
|
||||
//ellipse(p.x, p.y, 3, 3);
|
||||
// ellipse(p.x, p.y, 3, 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -719,7 +719,12 @@ class DisplayMachine extends Machine
|
||||
// scale em, danno.
|
||||
PVector scaledPos = scaleToScreen(cartesianPos);
|
||||
noStroke();
|
||||
fill(cartesianPos.z);
|
||||
|
||||
// Posterize the density value
|
||||
int reduced = int(map(cartesianPos.z, 1, 255, 1, densityPreviewPosterize)+0.5);
|
||||
int brightness = int(map(reduced, 1, densityPreviewPosterize, 1, 255));
|
||||
|
||||
fill(brightness);
|
||||
switch (getDensityPreviewStyle())
|
||||
{
|
||||
case DENSITY_PREVIEW_ROUND:
|
||||
@ -727,21 +732,20 @@ class DisplayMachine extends Machine
|
||||
break;
|
||||
case DENSITY_PREVIEW_ROUND_SIZE:
|
||||
fill(0);
|
||||
previewRoundPixel(scaledPos, map(cartesianPos.z, 1, 255, pixelSize, 1));
|
||||
previewRoundPixel(scaledPos, map(brightness, 1, densityPreviewPosterize, pixelSize, 1));
|
||||
break;
|
||||
case DENSITY_PREVIEW_DIAMOND:
|
||||
previewDiamondPixel(scaledPos, pixelSize, pixelSize, cartesianPos.z);
|
||||
previewDiamondPixel(scaledPos, pixelSize, pixelSize, brightness);
|
||||
break;
|
||||
case DENSITY_PREVIEW_NATIVE:
|
||||
previewNativePixel(scaledPos, pixelSize, cartesianPos.z);
|
||||
previewNativePixel(scaledPos, pixelSize, brightness);
|
||||
break;
|
||||
case DENSITY_PREVIEW_NATIVE_SIZE:
|
||||
previewNativePixel(scaledPos, map(cartesianPos.z, 1, 255, pixelSize, 1), 50);
|
||||
previewNativePixel(scaledPos, map(brightness, 1, densityPreviewPosterize, pixelSize, 1), 50);
|
||||
break;
|
||||
case DENSITY_PREVIEW_NATIVE_ARC:
|
||||
previewNativePixel(scaledPos, map(cartesianPos.z, 1, 255, pixelSize, 1), 50);
|
||||
// previewRoundPixel(scaledPos, pixelSize*0.8);
|
||||
previewNativeArcPixel(scaledPos, pixelSize, cartesianPos.z);
|
||||
previewRoundPixel(scaledPos, pixelSize*0.8);
|
||||
previewNativeArcPixel(scaledPos, pixelSize, brightness);
|
||||
break;
|
||||
default:
|
||||
previewRoundPixel(scaledPos, pixelSize);
|
||||
|
@ -21,7 +21,7 @@ ControlFrameSimple addDrawPixelsControlFrame(String theName, int theWidth, int t
|
||||
p.dispose();
|
||||
f.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
f.setResizable( true );
|
||||
f.setVisible( true );
|
||||
|
10
Machine.pde
10
Machine.pde
@ -39,7 +39,7 @@ class Machine
|
||||
protected Rectangle imageFrame = new Rectangle(1500,1500,1000,1000);
|
||||
protected Rectangle pictureFrame = new Rectangle(1600,1600,800,800);
|
||||
|
||||
protected Float stepsPerRev = 800.0;
|
||||
protected Float stepsPerRev = 200.0;
|
||||
protected Float mmPerRev = 95.0;
|
||||
|
||||
protected Float mmPerStep = null;
|
||||
@ -364,7 +364,7 @@ class Machine
|
||||
public void loadDefinitionFromProperties(Properties props)
|
||||
{
|
||||
// get these first because they are important to convert the rest of them
|
||||
setStepsPerRev(getFloatProperty("machine.motors.stepsPerRev", 800.0));
|
||||
setStepsPerRev(getFloatProperty("machine.motors.stepsPerRev", 200.0));
|
||||
setMMPerRev(getFloatProperty("machine.motors.mmPerRev", 95.0));
|
||||
|
||||
// now stepsPerMM and mmPerStep should have been calculated. It's safe to get the rest.
|
||||
@ -383,12 +383,12 @@ class Machine
|
||||
String pos = getStringProperty("controller.page.position.x", "CENTRE");
|
||||
float px = 0.0;
|
||||
println("machine size: " + getSize().x + ", " + inSteps(pageSize.x));
|
||||
if (pos.equalsIgnoreCase("CENTRE"))
|
||||
{
|
||||
if (pos.equalsIgnoreCase("CENTRE")) {
|
||||
px = inMM((getSize().x - pageSize.x) / 2.0);
|
||||
}
|
||||
else
|
||||
else {
|
||||
px = getFloatProperty("controller.page.position.x", (int) getDisplayMachine().getPageCentrePosition(pageSize.x));
|
||||
}
|
||||
|
||||
float py = getFloatProperty("controller.page.position.y", 120);
|
||||
|
||||
|
@ -738,4 +738,11 @@ void button_mode_cycleDensityPreviewStyle()
|
||||
}
|
||||
}
|
||||
|
||||
void numberbox_mode_changeDensityPreviewPosterize(int value) {
|
||||
if (value < 1) value = 1;
|
||||
else if (value > 255) value = 255;
|
||||
|
||||
densityPreviewPosterize = value;
|
||||
}
|
||||
|
||||
|
||||
|
@ -183,6 +183,18 @@ void updateNumberboxValues()
|
||||
initialiseNumberboxValues(getAllControls());
|
||||
}
|
||||
|
||||
void initConsoleWindow() {
|
||||
consoleArea = cp5.addTextarea("txt")
|
||||
.setPosition(300, 100)
|
||||
.setSize(400, 600)
|
||||
.setFont(createFont("", 12))
|
||||
.setLineHeight(14)
|
||||
.setColor(color(255))
|
||||
.setColorBackground(color(0, 200))
|
||||
.setColorForeground(color(255, 100))
|
||||
.setVisible(false);
|
||||
}
|
||||
|
||||
Set<String> buildControlsToLockIfBoxNotSpecified()
|
||||
{
|
||||
Set<String> result = new HashSet<String>();
|
||||
@ -220,6 +232,8 @@ Set<String> buildControlsToLockIfImageNotLoaded()
|
||||
|
||||
Map<String, Controller> buildAllControls()
|
||||
{
|
||||
|
||||
initConsoleWindow();
|
||||
|
||||
Map<String, Controller> map = new HashMap<String, Controller>();
|
||||
|
||||
@ -507,6 +521,14 @@ Map<String, Controller> initialiseNumberboxValues(Map<String, Controller> map)
|
||||
{
|
||||
n.setValue(densityPreviewStyle);
|
||||
}
|
||||
else if (MODE_CHANGE_DENSITY_PREVIEW_POSTERIZE.equals(key))
|
||||
{
|
||||
n.setValue(densityPreviewPosterize);
|
||||
n.setMin(1);
|
||||
n.setMax(255);
|
||||
n.setDecimalPrecision(1);
|
||||
n.setMultiplier(0.1);
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
@ -680,6 +702,7 @@ List<String> getControlNamesForInputPanel()
|
||||
controlNames.add(MODE_CHANGE_SAMPLE_AREA);
|
||||
controlNames.add(MODE_CHOOSE_CHROMA_KEY_COLOUR);
|
||||
controlNames.add(MODE_CHANGE_PIXEL_SCALING);
|
||||
controlNames.add(MODE_CHANGE_DENSITY_PREVIEW_POSTERIZE);
|
||||
controlNames.add(MODE_CYCLE_DENSITY_PREVIEW_STYLE);
|
||||
|
||||
controlNames.add(MODE_RENDER_PIXEL_DIALOG);
|
||||
@ -970,6 +993,8 @@ Map<String, String> buildControlLabels()
|
||||
|
||||
result.put(MODE_ADJUST_PREVIEW_CORD_OFFSET, "Cord offset");
|
||||
result.put(MODE_CYCLE_DENSITY_PREVIEW_STYLE, "Cycle preview style");
|
||||
|
||||
result.put(MODE_CHANGE_DENSITY_PREVIEW_POSTERIZE, "Pixel posterize");
|
||||
|
||||
|
||||
|
||||
@ -1118,6 +1143,8 @@ Set<String> buildControlNames()
|
||||
result.add(MODE_ADJUST_PREVIEW_CORD_OFFSET);
|
||||
result.add(MODE_CYCLE_DENSITY_PREVIEW_STYLE);
|
||||
|
||||
result.add(MODE_CHANGE_DENSITY_PREVIEW_POSTERIZE);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
14
drawing.pde
14
drawing.pde
@ -199,13 +199,13 @@ void sendTestPenWidth()
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(testPenWidthCommand)
|
||||
.append(int(gridSize))
|
||||
.append(",")
|
||||
.append(df.format(testPenWidthStartSize))
|
||||
.append(",")
|
||||
.append(df.format(testPenWidthEndSize))
|
||||
.append(",")
|
||||
.append(df.format(testPenWidthIncrementSize))
|
||||
.append(",END");
|
||||
.append(",")
|
||||
.append(df.format(testPenWidthStartSize))
|
||||
.append(",")
|
||||
.append(df.format(testPenWidthEndSize))
|
||||
.append(",")
|
||||
.append(df.format(testPenWidthIncrementSize))
|
||||
.append(",END");
|
||||
addToCommandQueue(sb.toString());
|
||||
}
|
||||
|
||||
|
@ -57,8 +57,8 @@ import java.awt.BorderLayout;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
int majorVersionNo = 2;
|
||||
int minorVersionNo = 1;
|
||||
int buildNo = 0;
|
||||
int minorVersionNo = 2;
|
||||
int buildNo = 2;
|
||||
|
||||
String programTitle = "Polargraph Controller v" + majorVersionNo + "." + minorVersionNo + " build " + buildNo;
|
||||
ControlP5 cp5;
|
||||
@ -190,7 +190,7 @@ float testPenWidthStartSize = 0.5;
|
||||
float testPenWidthEndSize = 2.0;
|
||||
float testPenWidthIncrementSize = 0.5;
|
||||
|
||||
int machineStepMultiplier = 1;
|
||||
int machineStepMultiplier = 8;
|
||||
|
||||
int maxSegmentLength = 2;
|
||||
|
||||
@ -342,6 +342,8 @@ static final String MODE_ADJUST_PREVIEW_CORD_OFFSET = "numberbox_mode_previewCor
|
||||
|
||||
static final String MODE_CYCLE_DENSITY_PREVIEW_STYLE = "button_mode_cycleDensityPreviewStyle";
|
||||
|
||||
static final String MODE_CHANGE_DENSITY_PREVIEW_POSTERIZE = "numberbox_mode_changeDensityPreviewPosterize";
|
||||
|
||||
|
||||
PVector statusTextPosition = new PVector(300.0, 12.0);
|
||||
|
||||
@ -387,6 +389,7 @@ static final int DENSITY_PREVIEW_NATIVE_SIZE = 5;
|
||||
|
||||
static final int DEFAULT_DENSITY_PREVIEW_STYLE = DENSITY_PREVIEW_NATIVE;
|
||||
int densityPreviewStyle = DEFAULT_DENSITY_PREVIEW_STYLE;
|
||||
int densityPreviewPosterize = 255;
|
||||
|
||||
static final byte COORD_MODE_NATIVE_STEPS = 0;
|
||||
static final byte COORD_MODE_NATIVE_MM = 1;
|
||||
@ -422,6 +425,9 @@ public Integer windowHeight = 400;
|
||||
|
||||
public static Integer serialPortNumber = -1;
|
||||
|
||||
public Textarea consoleArea = null;
|
||||
public Println console = null;
|
||||
public PrintStream savedOut = null;
|
||||
|
||||
Properties props = null;
|
||||
public static String propertiesFilename = "default.properties.txt";
|
||||
@ -485,9 +491,6 @@ public static final int VECTOR_FILTER_LOW_PASS = 0;
|
||||
|
||||
String storeFilename = "comm.txt";
|
||||
boolean overwriteExistingStoreFile = true;
|
||||
//private static Logger logger;
|
||||
public static Console console;
|
||||
public boolean useWindowedConsole = false;
|
||||
|
||||
static boolean drawingTraceShape = true;
|
||||
static boolean retraceShape = true;
|
||||
@ -537,7 +540,8 @@ void setup()
|
||||
parentPapplet = this;
|
||||
|
||||
RG.init(this);
|
||||
RG.setPolygonizer(RG.ADAPTATIVE);
|
||||
RG.setPolygonizer(RG.UNIFORMLENGTH);
|
||||
// RG.setPolygonizer(RG.ADAPTATIVE);
|
||||
|
||||
try
|
||||
{
|
||||
@ -600,6 +604,7 @@ void setup()
|
||||
addEventListeners();
|
||||
|
||||
frameRate(8);
|
||||
noLoop();
|
||||
}
|
||||
|
||||
void fitDisplayMachineToWindow() {
|
||||
@ -619,6 +624,10 @@ void fitDisplayMachineToWindow() {
|
||||
machineScaling = (targetHeight / machineHeight);
|
||||
println(machineScaling);
|
||||
|
||||
if (machineScaling < 0) {
|
||||
machineScaling = 1.0;
|
||||
}
|
||||
|
||||
getDisplayMachine().getOffset().x = ((gr.getRight() > ir.getRight()) ? gr.getRight() : ir.getRight()) + CONTROL_SPACING.x;
|
||||
getDisplayMachine().getOffset().y = gr.getTop();
|
||||
|
||||
@ -675,6 +684,7 @@ void windowResized()
|
||||
}
|
||||
void draw()
|
||||
{
|
||||
|
||||
if (getCurrentTab() == TAB_NAME_INPUT) {
|
||||
drawImagePage();
|
||||
}
|
||||
@ -1680,12 +1690,7 @@ void keyPressed()
|
||||
}
|
||||
else if (checkKey(CONTROL) && checkKey(KeyEvent.VK_C))
|
||||
{
|
||||
if (isUseWindowedConsole())
|
||||
setUseWindowedConsole(false);
|
||||
else
|
||||
setUseWindowedConsole(true);
|
||||
|
||||
initLogging();
|
||||
toggleShowConsole();
|
||||
}
|
||||
else if (checkKey(CONTROL) && checkKey(KeyEvent.VK_S))
|
||||
{
|
||||
@ -1893,7 +1898,7 @@ void mouseWheel(int delta)
|
||||
|
||||
void setChromaKey(PVector p)
|
||||
{
|
||||
color col = getDisplayMachine().getPixelAtScreenCoords(p);
|
||||
color col = getDisplayMachine().getPixelAtScreenCoords(p);
|
||||
chromaKeyColour = col;
|
||||
if (getDisplayMachine().pixelsCanBeExtracted() && isBoxSpecified())
|
||||
{
|
||||
@ -1915,6 +1920,26 @@ boolean isPreviewable(String command)
|
||||
}
|
||||
}
|
||||
|
||||
boolean toggleShowConsole() {
|
||||
if (console == null) {
|
||||
savedOut = System.out;
|
||||
console = cp5.addConsole(consoleArea);
|
||||
consoleArea.setVisible(true);
|
||||
console.play();
|
||||
}
|
||||
else {
|
||||
console.pause();
|
||||
consoleArea.setVisible(false);
|
||||
cp5.remove(console);
|
||||
console = null;
|
||||
System.setOut(savedOut);
|
||||
}
|
||||
|
||||
println("Ow");
|
||||
|
||||
return console == null;
|
||||
}
|
||||
|
||||
/**
|
||||
This will comb the command queue and attempt to draw a picture of what it contains.
|
||||
Coordinates here are in pixels.
|
||||
@ -1930,6 +1955,8 @@ void previewQueue(boolean forceRebuild)
|
||||
{
|
||||
println("regenerating preview queue.");
|
||||
previewCommandList.clear();
|
||||
|
||||
|
||||
for (String command : commandQueue)
|
||||
{
|
||||
if (command.startsWith(CMD_CHANGELENGTHDIRECT) || command.startsWith(CMD_CHANGELENGTH) || command.startsWith(CMD_DRAWPIXEL))
|
||||
@ -1943,8 +1970,8 @@ void previewQueue(boolean forceRebuild)
|
||||
String bLenStr = splitted[2];
|
||||
|
||||
PVector endPoint = new PVector(Integer.parseInt(aLenStr)+previewCordOffset, Integer.parseInt(bLenStr)+previewCordOffset);
|
||||
endPoint = getDisplayMachine().asCartesianCoords(endPoint);
|
||||
endPoint = getDisplayMachine().inMM(endPoint);
|
||||
endPoint = getDisplayMachine().asCartesianCoords(endPoint);
|
||||
|
||||
pv.x = endPoint.x;
|
||||
pv.y = endPoint.y;
|
||||
@ -2537,7 +2564,7 @@ public PVector getHomePoint()
|
||||
public DisplayMachine getDisplayMachine()
|
||||
{
|
||||
if (displayMachine == null)
|
||||
displayMachine = new DisplayMachine(new Machine(5000, 5000, 800.0, 95.0), machinePosition, machineScaling);
|
||||
displayMachine = new DisplayMachine(new Machine(5000, 5000, 200.0, 95.0), machinePosition, machineScaling);
|
||||
|
||||
displayMachine.setOffset(machinePosition);
|
||||
displayMachine.setScale(machineScaling);
|
||||
@ -2953,9 +2980,9 @@ void loadFromPropertiesFile()
|
||||
this.currentPenWidth = getFloatProperty("machine.pen.size", 0.8);
|
||||
|
||||
// motor settings
|
||||
this.currentMachineMaxSpeed = getFloatProperty("machine.motors.maxSpeed", 600.0);
|
||||
this.currentMachineAccel = getFloatProperty("machine.motors.accel", 400.0);
|
||||
this.machineStepMultiplier = getIntProperty("machine.step.multiplier", 1);
|
||||
this.currentMachineMaxSpeed = getFloatProperty("machine.motors.maxSpeed", 2000.0);
|
||||
this.currentMachineAccel = getFloatProperty("machine.motors.accel", 2000.0);
|
||||
this.machineStepMultiplier = getIntProperty("machine.step.multiplier", 8);
|
||||
|
||||
// serial port
|
||||
this.serialPortNumber = getIntProperty("controller.machine.serialport", 0);
|
||||
@ -3248,16 +3275,6 @@ Integer getBaudRate()
|
||||
return baudRate;
|
||||
}
|
||||
|
||||
boolean isUseWindowedConsole()
|
||||
{
|
||||
return this.useWindowedConsole;
|
||||
}
|
||||
|
||||
void setUseWindowedConsole(boolean use)
|
||||
{
|
||||
this.useWindowedConsole = use;
|
||||
}
|
||||
|
||||
void initLogging()
|
||||
{
|
||||
try
|
||||
|
Loading…
Reference in New Issue
Block a user