mirror of
https://github.com/euphy/polargraphcontroller
synced 2025-01-24 01:55:11 +01:00
Quite a few things working. The window focus is still a bit weird.
This commit is contained in:
parent
1abe63bba6
commit
cbb2678aef
@ -5,12 +5,12 @@ public class ControlFrame extends PApplet {
|
||||
public int w, h;
|
||||
int abc = 100;
|
||||
public ControlP5 cp5;
|
||||
protected Object parent;
|
||||
protected PApplet parent;
|
||||
|
||||
private ControlFrame() {
|
||||
}
|
||||
|
||||
public ControlFrame(Object theParent, int theWidth, int theHeight) {
|
||||
public ControlFrame(PApplet theParent, int theWidth, int theHeight) {
|
||||
this.parent = theParent;
|
||||
this.w = theWidth;
|
||||
this.h = theHeight;
|
||||
@ -23,6 +23,10 @@ public class ControlFrame extends PApplet {
|
||||
return this.cp5;
|
||||
}
|
||||
|
||||
public PApplet getParent() {
|
||||
return this.parent;
|
||||
}
|
||||
|
||||
public void setup() {
|
||||
size(w, h);
|
||||
frameRate(5);
|
||||
|
@ -767,8 +767,6 @@ class DisplayMachine extends Machine
|
||||
void previewNativePixel(PVector pos, float size, float brightness)
|
||||
{
|
||||
float half = size / 2.0;
|
||||
fill(0,0,0, 255-brightness);
|
||||
beginShape();
|
||||
|
||||
// arcs from the left-hand corner
|
||||
float distFromPointA = getOutline().getTopLeft().dist(pos);
|
||||
@ -777,6 +775,10 @@ class DisplayMachine extends Machine
|
||||
List<PVector> int1 = findIntersections(getOutline().getLeft(), distFromPointA-half, getOutline().getRight(), distFromPointB-half, size);
|
||||
List<PVector> int2 = findIntersections(getOutline().getLeft(), distFromPointA+half, getOutline().getRight(), distFromPointB-half, size);
|
||||
|
||||
if (!int1.isEmpty() && !int2.isEmpty()) {
|
||||
fill(0,0,0, 255-brightness);
|
||||
beginShape();
|
||||
|
||||
// plot out the vertexes
|
||||
vertex(int1.get(0).x, int1.get(0).y);
|
||||
vertex(int2.get(0).x, int2.get(0).y);
|
||||
@ -785,6 +787,7 @@ class DisplayMachine extends Machine
|
||||
vertex(int1.get(0).x, int1.get(0).y);
|
||||
endShape();
|
||||
}
|
||||
}
|
||||
|
||||
void previewNativeArcPixel(PVector pos, float size, float brightness)
|
||||
{
|
||||
|
@ -15,7 +15,7 @@ class SerialPortWindow extends ControlFrame {
|
||||
f.setTitle(CHANGE_SERIAL_PORT_WINDOW_NAME);
|
||||
f.setSize(super.w, super.h);
|
||||
f.setLocation(xPos, yPos);
|
||||
f.setResizable(false);
|
||||
f.setResizable(true);
|
||||
f.setVisible(true);
|
||||
|
||||
f.addWindowListener( new WindowAdapter() {
|
||||
@ -31,6 +31,8 @@ class SerialPortWindow extends ControlFrame {
|
||||
.setSpacingRow(5)
|
||||
.plugTo(parentPapplet, "radio_serialPort");
|
||||
|
||||
r.addItem("No serial connection", -1);
|
||||
|
||||
String[] ports = Serial.list();
|
||||
|
||||
for (int i = 0; i < ports.length; i++) {
|
||||
|
@ -63,7 +63,7 @@ void button_mode_drawWritingDialog() {
|
||||
String textToWrite = "";
|
||||
String spriteFilePrefix = "sprite/let";
|
||||
String spriteFileSuffix = ".txt";
|
||||
class DrawWritingWindow extends ControlFrame {
|
||||
public class DrawWritingWindow extends ControlFrame {
|
||||
public DrawWritingWindow() {
|
||||
super(parentPapplet, 450, 250);
|
||||
int xPos = 100;
|
||||
@ -111,39 +111,47 @@ class DrawWritingWindow extends ControlFrame {
|
||||
.plugTo("submitWritingWindow");
|
||||
}
|
||||
|
||||
|
||||
void spriteFilePrefixField(String value)
|
||||
{
|
||||
void spriteFilePrefixField(String value) {
|
||||
spriteFilePrefix = value;
|
||||
}
|
||||
void textToWriteField(String value)
|
||||
{
|
||||
void textToWriteField(String value) {
|
||||
textToWrite = value;
|
||||
}
|
||||
|
||||
String getTextToWrite()
|
||||
{
|
||||
String getTextToWrite() {
|
||||
return textToWrite;
|
||||
}
|
||||
String getSpriteFilePrefix()
|
||||
{
|
||||
String getSpriteFilePrefix() {
|
||||
return spriteFilePrefix;
|
||||
}
|
||||
String getSpriteFileSuffix()
|
||||
{
|
||||
String getSpriteFileSuffix() {
|
||||
return spriteFileSuffix;
|
||||
}
|
||||
|
||||
void importTextButton()
|
||||
{
|
||||
void importTextButton() {
|
||||
println("Text!");
|
||||
textToWrite = importTextToWriteFromFile();
|
||||
println(textToWrite);
|
||||
selectInput("Select the text file to load the text from:", "importTextToWriteFromFile", null, this);
|
||||
}
|
||||
|
||||
public void importTextToWriteFromFile(File selection) {
|
||||
if (selection != null) {
|
||||
String fp = selection.getAbsolutePath();
|
||||
println("Input file: " + fp);
|
||||
List<String> rows = java.util.Arrays.asList(loadStrings(fp));
|
||||
StringBuilder sb = new StringBuilder(200);
|
||||
for (String row : rows) {
|
||||
sb.append(row);
|
||||
}
|
||||
textToWriteField(sb.toString());
|
||||
println("Completed text import, " + getTextToWrite().length() + " characters found.");
|
||||
|
||||
println("Text: " + getTextToWrite());
|
||||
|
||||
Textfield tf = cp5().get(Textfield.class, "textToWriteField");
|
||||
tf.setText(getTextToWrite());
|
||||
tf.submit();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void submitWritingWindow(int theValue)
|
||||
{
|
||||
@ -161,15 +169,12 @@ class DrawWritingWindow extends ControlFrame {
|
||||
println("Sprite file prefix: " + spriteFilePrefix);
|
||||
println("Text: " + textToWrite);
|
||||
|
||||
for (int i=0; i<getTextToWrite().length(); i++)
|
||||
{
|
||||
for (int i=0; i<getTextToWrite().length(); i++) {
|
||||
String filename = getSpriteFilePrefix() + (int) getTextToWrite().charAt(i) + getSpriteFileSuffix();
|
||||
addToCommandQueue(CMD_DRAW_SPRITE + int(gridSize * pixelScalingOverGridSize) + "," + filename+",END");
|
||||
println(filename);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
//
|
||||
//void button_mode_drawWritingDialog()
|
||||
|
@ -1816,14 +1816,7 @@ boolean isHiddenPixel(PVector p)
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void sizeImageToFitBox()
|
||||
{
|
||||
// PVector mmBoxSize = getDisplayMachine().inSteps(getBoxSize());
|
||||
// PVector mmBoxPos = getDisplayMachine().inSteps(getBoxVector1());
|
||||
// println("mm box: " + mmBoxSize);
|
||||
|
||||
void sizeImageToFitBox() {
|
||||
PVector boxSize = getDisplayMachine().inSteps(getBoxSize());
|
||||
PVector boxPos = getDisplayMachine().inSteps(getBoxVector1());
|
||||
println("image: " + boxSize);
|
||||
@ -1832,18 +1825,16 @@ void sizeImageToFitBox()
|
||||
getDisplayMachine().setImageFrame(r);
|
||||
}
|
||||
|
||||
void exportQueueToFile()
|
||||
{
|
||||
if (!commandQueue.isEmpty() || !realtimeCommandQueue.isEmpty())
|
||||
{
|
||||
selectOutput("Enter a filename to save to:", "fileSelected"); // Opens file chooser
|
||||
if (filePath == null)
|
||||
{
|
||||
// If a file was not selected
|
||||
println("No output file was selected...");
|
||||
void exportQueueToFile() {
|
||||
if (!commandQueue.isEmpty() || !realtimeCommandQueue.isEmpty()) {
|
||||
selectOutput("Enter a filename to save to:", "exportQueueToFile"); // Opens file chooser
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
|
||||
void exportQueueToFile(File selection) {
|
||||
if (selection != null) {
|
||||
filePath = selection.getAbsolutePath();
|
||||
println("User selected " + filePath);
|
||||
// If a file was selected, print path to folder
|
||||
println("Output file: " + filePath);
|
||||
List<String> allCommands = new ArrayList<String>(realtimeCommandQueue);
|
||||
@ -1853,7 +1844,6 @@ void exportQueueToFile()
|
||||
saveStrings(filePath, list);
|
||||
println("Completed queue export, " + list.length + " commands exported.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void fileSelected(File selection) {
|
||||
@ -1866,50 +1856,20 @@ void fileSelected(File selection) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void importQueueFromFile()
|
||||
{
|
||||
void importQueueFromFile() {
|
||||
commandQueue.clear();
|
||||
selectInput("Select file to import queue from", "fileSelected");
|
||||
if (filePath == null)
|
||||
{
|
||||
if (filePath == null) {
|
||||
// nothing selected
|
||||
println("No input file was selected.");
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
println("Input file: " + filePath);
|
||||
String commands[] = loadStrings(filePath);
|
||||
// List<String> list = Arrays
|
||||
commandQueue.addAll(Arrays.asList(commands));
|
||||
println("Completed queue import, " + commandQueue.size() + " commands found.");
|
||||
}
|
||||
}
|
||||
|
||||
String importTextToWriteFromFile()
|
||||
{
|
||||
selectInput("Select the text file to load the text from:", "fileSelected");
|
||||
String result = "";
|
||||
if (filePath == null)
|
||||
{
|
||||
// nothing selected
|
||||
println("No input file was selected.");
|
||||
}
|
||||
else
|
||||
{
|
||||
println("Input file: " + filePath);
|
||||
List<String> rows = java.util.Arrays.asList(loadStrings(filePath));
|
||||
StringBuilder sb = new StringBuilder(200);
|
||||
for (String row : rows)
|
||||
{
|
||||
sb.append(row);
|
||||
}
|
||||
result = sb.toString();
|
||||
|
||||
println("Completed text import, " + result.length() + " characters found.");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user