Split Draw pixels window out, started on draw writing

This commit is contained in:
Sandy Noble 2015-04-26 23:00:04 +01:00
parent fdf2bca1c0
commit 1abe63bba6
3 changed files with 206 additions and 187 deletions

102
DrawPixelsWindow.pde Normal file
View File

@ -0,0 +1,102 @@
///*------------------------------------------------------------------------
// Details about the "drawing" subwindow
//------------------------------------------------------------------------*/
public Integer renderStartDirection = DRAW_DIR_SE; // default start drawing in SE direction (DOWN)
public Integer renderStartPosition = DRAW_DIR_NE; // default top right hand corner for start
public Integer renderStyle = PIXEL_STYLE_SQ_FREQ; // default pixel style square wave
class DrawPixelsWindow extends ControlFrame {
public DrawPixelsWindow () {
super(parentPapplet, 450, 150);
int xPos = 100;
int yPos = 100;
String name = DRAW_PIXELS_WINDOW_NAME;
final Frame f = new Frame(DRAW_PIXELS_WINDOW_NAME);
f.add(this);
this.init();
f.setTitle(CHANGE_SERIAL_PORT_WINDOW_NAME);
f.setSize(super.w, super.h);
f.setLocation(xPos, yPos);
f.setResizable(false);
f.setVisible(true);
f.addWindowListener( new WindowAdapter() {
@Override
public void windowClosing(WindowEvent we) {
f.dispose();
}
});
RadioButton rPos = cp5().addRadioButton("radio_startPosition",10,10)
.add("Top-right", DRAW_DIR_NE)
.add("Bottom-right", DRAW_DIR_SE)
.add("Bottom-left", DRAW_DIR_SW)
.add("Top-left", DRAW_DIR_NW)
.plugTo("radio_startPosition");
RadioButton rSkip = cp5().addRadioButton("radio_pixelSkipStyle",10,100)
.add("Lift pen over masked pixels", 1)
.add("Draw masked pixels as blanks", 2)
.plugTo("radio_pixelSkipStyle");
RadioButton rStyle = cp5().addRadioButton("radio_pixelStyle",100,10);
rStyle.add("Variable frequency square wave", PIXEL_STYLE_SQ_FREQ);
rStyle.add("Variable size square wave", PIXEL_STYLE_SQ_SIZE);
rStyle.add("Solid square wave", PIXEL_STYLE_SQ_SOLID);
rStyle.add("Scribble", PIXEL_STYLE_SCRIBBLE);
if (currentHardware >= HARDWARE_VER_MEGA) {
rStyle.add("Spiral", PIXEL_STYLE_CIRCLE);
rStyle.add("Sawtooth", PIXEL_STYLE_SAW);
}
rStyle.plugTo("radio_pixelStyle");
Button submitButton = cp5().addButton("submitDrawWindow",0,280,10,120,20)
.setLabel("Generate commands")
.plugTo("submitDrawWindow");
}
void radio_startPosition(int pos) {
renderStartPosition = pos;
radio_rowStartDirection(1);
}
void radio_rowStartDirection(int dir) {
if (renderStartPosition == DRAW_DIR_NE || renderStartPosition == DRAW_DIR_SW)
renderStartDirection = (dir == 0) ? DRAW_DIR_NW : DRAW_DIR_SE;
else if (renderStartPosition == DRAW_DIR_SE || renderStartPosition == DRAW_DIR_NW)
renderStartDirection = (dir == 0) ? DRAW_DIR_NE : DRAW_DIR_SW;
}
void radio_pixelStyle(int style) {
renderStyle = style;
}
void radio_pixelSkipStyle(int style) {
if (style == 1)
liftPenOnMaskedPixels = true;
else if (style == 2)
liftPenOnMaskedPixels = false;
}
void submitDrawWindow(int theValue) {
println("draw.");
println("Style: " + renderStyle);
println("Start pos: " + renderStartPosition);
println("Start dir: " + renderStartDirection);
switch (renderStyle) {
case PIXEL_STYLE_SQ_FREQ: button_mode_renderSquarePixel(); break;
case PIXEL_STYLE_SQ_SIZE: button_mode_renderScaledSquarePixels(); break;
case PIXEL_STYLE_SQ_SOLID: button_mode_renderSolidSquarePixels(); break;
case PIXEL_STYLE_SCRIBBLE: button_mode_renderScribblePixels(); break;
case PIXEL_STYLE_CIRCLE: button_mode_renderCirclePixel(); break;
case PIXEL_STYLE_SAW: button_mode_renderSawPixel(); break;
}
}
}

View File

@ -34,6 +34,8 @@ void button_mode_sendMachineLiveMode() {
String CHANGE_SERIAL_PORT_WINDOW_NAME = "changeSerialPortWindow";
String MACHINE_STORE_WINDOW_NAME = "chooseStoreFilenameWindow";
String MACHINE_EXEC_WINDOW_NAME = "chooseExecFilenameWindow";
String DRAW_PIXELS_WINDOW_NAME = "drawPixelsWindow";
String DRAW_WRITING_WINDOW_NAME = "drawWritingWindow";
void button_mode_serialPortDialog() {
final SerialPortWindow serialPortWindow = new SerialPortWindow();
@ -51,17 +53,27 @@ void button_mode_drawPixelsDialog() {
final DrawPixelsWindow drawPixelsWindow = new DrawPixelsWindow();
}
class DrawPixelsWindow extends ControlFrame {
public DrawPixelsWindow() {
super(parentPapplet, 150, 350);
void button_mode_drawWritingDialog() {
final DrawWritingWindow drawWritingWindow = new DrawWritingWindow();
}
///*------------------------------------------------------------------------
// Details about the "writing" subwindow
//------------------------------------------------------------------------*/
String textToWrite = "";
String spriteFilePrefix = "sprite/let";
String spriteFileSuffix = ".txt";
class DrawWritingWindow extends ControlFrame {
public DrawWritingWindow() {
super(parentPapplet, 450, 250);
int xPos = 100;
int yPos = 100;
String name = DRAW_WRITING_WINDOW_NAME;
final Frame f = new Frame(CHANGE_SERIAL_PORT_WINDOW_NAME);
final Frame f = new Frame(name);
f.add(this);
this.init();
f.setTitle(CHANGE_SERIAL_PORT_WINDOW_NAME);
f.setTitle(name);
f.setSize(super.w, super.h);
f.setLocation(xPos, yPos);
f.setResizable(false);
@ -73,105 +85,92 @@ class DrawPixelsWindow extends ControlFrame {
f.dispose();
}
});
Textfield spriteFileField = cp5().addTextfield("spriteFilePrefixField",20,20,150,20)
.setText(getSpriteFilePrefix())
.setLabel("File prefix")
.plugTo("spriteFilePrefixField");
Textfield writingField = cp5().addTextfield("textToWriteField",20,60,400,20)
.setText(getTextToWrite())
.setLabel("Text to write")
.plugTo("textToWriteField");
Button importTextButton = cp5().addButton("importTextButton",0,20,100,120,20)
.setLabel("Load text from file")
.plugTo("importTextButton");
RadioButton rPos = cp5().addRadioButton("radio_drawWritingDirection",20,140);
// rPos.add("North-east", DRAW_DIR_NE);
rPos.add("South-east", DRAW_DIR_SE);
// rPos.add("South-west", DRAW_DIR_SW);
// rPos.add("North-west", DRAW_DIR_NW);
rPos.plugTo("radio_drawWritingDirection");
Button submitButton = cp5.addButton("submitWritingWindow",0,300,100,120,20)
.setLabel("Generate commands")
.plugTo("submitWritingWindow");
}
void spriteFilePrefixField(String value)
{
spriteFilePrefix = value;
}
void textToWriteField(String value)
{
textToWrite = value;
}
String getTextToWrite()
{
return textToWrite;
}
String getSpriteFilePrefix()
{
return spriteFilePrefix;
}
String getSpriteFileSuffix()
{
return spriteFileSuffix;
}
void importTextButton()
{
println("Text!");
textToWrite = importTextToWriteFromFile();
println(textToWrite);
Textfield tf = cp5().get(Textfield.class, "textToWriteField");
tf.setText(getTextToWrite());
tf.submit();
}
void submitWritingWindow(int theValue)
{
println("Write.");
Textfield tf = cp5().get(Textfield.class, "spriteFilePrefixField");
tf.submit();
tf.setText(getSpriteFilePrefix());
Textfield wf = cp5.get(Textfield.class, "textToWriteField");
wf.submit();
wf.setText(getTextToWrite());
println("Start dir: " + renderStartDirection);
println("Sprite file prefix: " + spriteFilePrefix);
println("Text: " + textToWrite);
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);
}
}
}
///*------------------------------------------------------------------------
// Details about the "drawing" subwindow
//------------------------------------------------------------------------*/
//void button_mode_drawPixelsDialog()
//{
// this.dialogWindow = cp5.addControlWindow("drawPixelsWindow",100,100,450,150);
// dialogWindow.hideCoordinates();
//
// dialogWindow.setBackground(getBackgroundColour());
//
// Radio rPos = cp5.addRadio("radio_startPosition",10,10);
// rPos.add("Top-right", DRAW_DIR_NE);
// rPos.add("Bottom-right", DRAW_DIR_SE);
// rPos.add("Bottom-left", DRAW_DIR_SW);
// rPos.add("Top-left", DRAW_DIR_NW);
// rPos.setWindow(dialogWindow);
//
// Radio rSkip = cp5.addRadio("radio_pixelSkipStyle",10,100);
// rSkip.add("Lift pen over masked pixels", 1);
// rSkip.add("Draw masked pixels as blanks", 2);
// rSkip.setWindow(dialogWindow);
//
//// Radio rDir = cp5.addRadio("radio_rowStartDirection",100,10);
//// rDir.add("Upwards", 0);
//// rDir.add("Downwards", 1);
//// rDir.setWindow(dialogWindow);
//
// Radio rStyle = cp5.addRadio("radio_pixelStyle",100,10);
// rStyle.add("Variable frequency square wave", PIXEL_STYLE_SQ_FREQ);
// rStyle.add("Variable size square wave", PIXEL_STYLE_SQ_SIZE);
// rStyle.add("Solid square wave", PIXEL_STYLE_SQ_SOLID);
// rStyle.add("Scribble", PIXEL_STYLE_SCRIBBLE);
// if (currentHardware >= HARDWARE_VER_MEGA)
// {
// rStyle.add("Spiral", PIXEL_STYLE_CIRCLE);
// rStyle.add("Sawtooth", PIXEL_STYLE_SAW);
// }
// rStyle.setWindow(dialogWindow);
//
// Button submitButton = cp5.addButton("submitDrawWindow",0,280,10,120,20);
// submitButton.setLabel("Generate commands");
// submitButton.setWindow(dialogWindow);
//
//
//}
//
public Integer renderStartPosition = DRAW_DIR_NE; // default top right hand corner for start
public Integer renderStartDirection = DRAW_DIR_SE; // default start drawing in SE direction (DOWN)
public Integer renderStyle = PIXEL_STYLE_SQ_FREQ; // default pixel style square wave
//void radio_startPosition(int pos)
//{
// this.renderStartPosition = pos;
// radio_rowStartDirection(1);
//}
//void radio_rowStartDirection(int dir)
//{
// if (renderStartPosition == DRAW_DIR_NE || renderStartPosition == DRAW_DIR_SW)
// renderStartDirection = (dir == 0) ? DRAW_DIR_NW : DRAW_DIR_SE;
// else if (renderStartPosition == DRAW_DIR_SE || renderStartPosition == DRAW_DIR_NW)
// renderStartDirection = (dir == 0) ? DRAW_DIR_NE : DRAW_DIR_SW;
//}
//void radio_pixelStyle(int style)
//{
// renderStyle = style;
//}
//void radio_pixelSkipStyle(int style)
//{
// if (style == 1)
// liftPenOnMaskedPixels = true;
// else if (style == 2)
// liftPenOnMaskedPixels = false;
//}
//void submitDrawWindow(int theValue)
//{
// println("draw.");
// println("Style: " + renderStyle);
// println("Start pos: " + renderStartPosition);
// println("Start dir: " + renderStartDirection);
//
// switch (renderStyle)
// {
// case PIXEL_STYLE_SQ_FREQ: button_mode_renderSquarePixel(); break;
// case PIXEL_STYLE_SQ_SIZE: button_mode_renderScaledSquarePixels(); break;
// case PIXEL_STYLE_SQ_SOLID: button_mode_renderSolidSquarePixels(); break;
// case PIXEL_STYLE_SCRIBBLE: button_mode_renderScribblePixels(); break;
// case PIXEL_STYLE_CIRCLE: button_mode_renderCirclePixel(); break;
// case PIXEL_STYLE_SAW: button_mode_renderSawPixel(); break;
// }
//
//
//}
//
///*------------------------------------------------------------------------
// Details about the "writing" subwindow
//------------------------------------------------------------------------*/
String textToWrite = "";
String spriteFilePrefix = "sprite/let";
String spriteFileSuffix = ".txt";
//
//void button_mode_drawWritingDialog()
//{
@ -180,88 +179,6 @@ String spriteFileSuffix = ".txt";
//
// dialogWindow.setBackground(getBackgroundColour());
//
// Textfield spriteFileField = cp5.addTextfield("spriteFilePrefixField",20,20,150,20);
// spriteFileField.setText(getSpriteFilePrefix());
// spriteFileField.setLabel("File prefix");
// spriteFileField.setWindow(dialogWindow);
//
// Textfield writingField = cp5.addTextfield("textToWriteField",20,60,400,20);
// writingField.setText(getTextToWrite());
// writingField.setLabel("Text to write");
// writingField.setWindow(dialogWindow);
//
// Button importTextButton = cp5.addButton("importTextButton",0,20,100,120,20);
// importTextButton.setLabel("Load text from file");
// importTextButton.setWindow(dialogWindow);
//
// Radio rPos = cp5.addRadio("radio_drawWritingDirection",20,140);
//// rPos.add("North-east", DRAW_DIR_NE);
// rPos.add("South-east", DRAW_DIR_SE);
//// rPos.add("South-west", DRAW_DIR_SW);
//// rPos.add("North-west", DRAW_DIR_NW);
// rPos.setWindow(dialogWindow);
//
//
//
// Button submitButton = cp5.addButton("submitWritingWindow",0,300,100,120,20);
// submitButton.setLabel("Generate commands");
// submitButton.setWindow(dialogWindow);
//}
//
//void spriteFilePrefixField(String value)
//{
// spriteFilePrefix = value;
//}
//void textToWriteField(String value)
//{
// textToWrite = value;
//}
//
//String getTextToWrite()
//{
// return textToWrite;
//}
//String getSpriteFilePrefix()
//{
// return spriteFilePrefix;
//}
//String getSpriteFileSuffix()
//{
// return spriteFileSuffix;
//}
//
//void importTextButton()
//{
// textToWrite = importTextToWriteFromFile();
// Textfield tf = (Textfield) cp5.controller("textToWriteField");
// tf.setText(getTextToWrite());
// tf.submit();
//}
//
//
//void submitWritingWindow(int theValue)
//{
// println("Write.");
//
// Textfield tf = (Textfield) cp5.controller("spriteFilePrefixField");
// tf.submit();
// tf.setText(getSpriteFilePrefix());
// tf = (Textfield) cp5.controller("textToWriteField");
// tf.submit();
// tf.setText(getTextToWrite());
//
// println("Start dir: " + renderStartDirection);
// println("Sprite file prefix: " + spriteFilePrefix);
// println("Text: " + textToWrite);
//
// 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);
// }
//
//}
//
//
///*------------------------------------------------------------------------

View File

@ -1861,8 +1861,8 @@ void fileSelected(File selection) {
println("Window was closed or the user hit cancel.");
filePath = null;
} else {
println("User selected " + selection.getAbsolutePath());
filePath = selection.getAbsolutePath();
println("User selected " + filePath);
}
}