Added buttons

This commit is contained in:
Sandy Noble 2013-03-30 10:41:40 +00:00
parent b2f61582f9
commit 5c1755f1a0
6 changed files with 135 additions and 28 deletions

View File

@ -352,40 +352,17 @@ class DisplayMachine extends Machine
noStroke();
// draw machine outline
// fill(80);
// rect(getOutline().getLeft()+DROP_SHADOW_DISTANCE, getOutline().getTop()+DROP_SHADOW_DISTANCE, getOutline().getWidth(), getOutline().getHeight());
fill(getMachineColour());
rect(getOutline().getLeft(), getOutline().getTop(), getOutline().getWidth(), getOutline().getHeight());
// if (displayingGuides)
// {
// // draw some guides
// stroke(getGuideColour());
// strokeWeight(1);
// // centre line
// line(getOutline().getLeft()+(getOutline().getWidth()/2), getOutline().getTop(),
// getOutline().getLeft()+(getOutline().getWidth()/2), getOutline().getBottom());
//
// // page top line
// line(getOutline().getLeft(), getOutline().getTop()+sc(getHomePoint().y),
// getOutline().getRight(), getOutline().getTop()+sc(getHomePoint().y));
// }
// draw page
fill(getPageColour());
rect(getOutline().getLeft()+sc(getPage().getLeft()),
getOutline().getTop()+sc(getPage().getTop()),
sc(getPage().getWidth()),
sc(getPage().getHeight()));
text("page " + getDimensionsAsText(getPage()), getOutline().getLeft()+sc(getPage().getLeft()),
getOutline().getTop()+sc(getPage().getTop())-3);
noFill();
stroke(getBackgroundColour(),150);
strokeWeight(3);
noFill();
@ -406,12 +383,11 @@ class DisplayMachine extends Machine
if (drawingLiveVideo)
{
drawLiveVideo();
displayLiveVideo();
}
if (displayingVector && getVectorShape() != null)
{
stroke(100);
displayVectorImage(color(200));
}
@ -427,7 +403,41 @@ class DisplayMachine extends Machine
{
cursor(ARROW);
}
}
}
public void displayLiveVideo()
{
buildLiveImage();
// draw actual image
if (liveImage != null)
{
float ox = getOutline().getLeft()+sc(getImageFrame().getLeft());
float oy = getOutline().getTop()+sc(getImageFrame().getTop());
float w = sc(getImageFrame().getWidth());
float h = sc(getImageFrame().getHeight());
tint(255, getImageTransparency());
translate(ox, oy);
rotate(radians(270));
image(liveImage, 0, 0, w, h);
rotate(radians(-270));
translate(-ox,-oy);
noTint();
noFill();
}
}
public void buildLiveImage()
{
liveCamera.update();
liveImage = createImage(640,480, RGB);
liveImage.loadPixels();
// rotate it
liveImage.pixels = liveCamera.image();
liveImage.filter(BLUR, blurValue);
liveImage.filter(GRAY);
liveImage.filter(POSTERIZE, posterizeValue);
liveImage.updatePixels();
}
public void displayVectorImage()
{

View File

@ -131,10 +131,13 @@ class Panel
{
for (Controller c : this.getControls())
{
println("Control: " + c.name());
PVector pos = getControlPositions().get(c.name());
float x = pos.x+getOutline().getLeft();
float y = pos.y+getOutline().getTop();
c.setPosition(x, y);
println("controlsizes: " + getControlSizes());
PVector cSize = getControlSizes().get(c.name());
c.setSize((int)cSize.x, (int)cSize.y);

View File

@ -108,6 +108,24 @@ void button_mode_sendPenliftRange()
addToCommandQueue(CMD_SETPENLIFTRANGE+penLiftDownPosition+","+penLiftUpPosition+",END");
}
void numberbox_mode_liveBlurValue(int value)
{
blurValue = value;
}
void numberbox_mode_liveSimplificationValue(int value)
{
liveSimplification = value;
}
void numberbox_mode_livePosteriseValue(int value)
{
posterizeValue = value;
}
void button_mode_liveCaptureFromLive()
{
addToCommandQueue(CMD_SETPENLIFTRANGE+penLiftDownPosition+","+penLiftUpPosition+",END");
}
void toggle_mode_inputBoxTopLeft(boolean flag)
{
if (flag)

View File

@ -469,6 +469,30 @@ Map<String, Controller> initialiseNumberboxValues(Map<String, Controller> map)
n.setMax(360);
n.setMultiplier(0.1);
}
else if (MODE_LIVE_BLUR_VALUE.equals(key))
{
n.setDecimalPrecision(1);
n.setValue(blurValue);
n.setMin(1);
n.setMax(100);
n.setMultiplier(0.1);
}
else if (MODE_LIVE_SIMPLIFICATION_VALUE.equals(key))
{
n.setDecimalPrecision(1);
n.setValue(liveSimplification);
n.setMin(0);
n.setMax(360);
n.setMultiplier(0.1);
}
else if (MODE_LIVE_POSTERISE_VALUE.equals(key))
{
n.setDecimalPrecision(1);
n.setValue(posterizeValue);
n.setMin(2);
n.setMax(32);
n.setMultiplier(0.1);
}
}
}
return map;
@ -586,6 +610,7 @@ Map<String, List<Controller>> buildControlsForPanels()
map.put(PANEL_NAME_DETAILS, getControllersForControllerNames(getControlNamesForDetailPanel()));
map.put(PANEL_NAME_QUEUE, getControllersForControllerNames(getControlNamesForQueuePanel()));
map.put(PANEL_NAME_GENERAL, getControllersForControllerNames(getControlNamesForGeneralPanel()));
map.put(PANEL_NAME_WEBCAM, getControllersForControllerNames(getControlNamesForWebcamPanel()));
return map;
}
@ -669,6 +694,16 @@ List<String> getControlNamesForRovingPanel()
return controlNames;
}
List<String> getControlNamesForWebcamPanel()
{
List<String> controlNames = new ArrayList<String>();
controlNames.add(MODE_LIVE_BLUR_VALUE);
controlNames.add(MODE_LIVE_SIMPLIFICATION_VALUE);
controlNames.add(MODE_LIVE_POSTERISE_VALUE);
controlNames.add(MODE_LIVE_CAPTURE_FROM_LIVE);
return controlNames;
}
List<String> getControlNamesForDetailPanel()
{
List<String> controlNames = new ArrayList<String>();
@ -862,6 +897,12 @@ Map<String, String> buildControlLabels()
result.put(MODE_START_RANDOM_SPRITES, "Random sprites");
result.put(MODE_STOP_RANDOM_SPRITES, "Stop sprites");
result.put(MODE_DRAW_NORWEGIAN_DIALOG, "Draw norwegian...");
result.put(MODE_LIVE_BLUR_VALUE, "Blur");
result.put(MODE_LIVE_SIMPLIFICATION_VALUE, "Simplify");
result.put(MODE_LIVE_POSTERISE_VALUE, "Posterise");
result.put(MODE_LIVE_CAPTURE_FROM_LIVE, "Capture");
return result;
}
@ -987,6 +1028,11 @@ Set<String> buildControlNames()
result.add(MODE_STOP_RANDOM_SPRITES);
result.add(MODE_DRAW_NORWEGIAN_DIALOG);
result.add(MODE_LIVE_BLUR_VALUE);
result.add(MODE_LIVE_SIMPLIFICATION_VALUE);
result.add(MODE_LIVE_POSTERISE_VALUE);
result.add(MODE_LIVE_CAPTURE_FROM_LIVE);
return result;
}

View File

@ -306,6 +306,12 @@ static final String MODE_START_RANDOM_SPRITES = "button_mode_startRandomSprite";
static final String MODE_STOP_RANDOM_SPRITES = "button_mode_stopRandomSprites";
static final String MODE_DRAW_NORWEGIAN_DIALOG = "button_mode_drawNorwegianDialog";
static final String MODE_LIVE_BLUR_VALUE = "numberbox_mode_liveBlurValue";
static final String MODE_LIVE_SIMPLIFICATION_VALUE = "numberbox_mode_liveSimplificationValue";
static final String MODE_LIVE_POSTERISE_VALUE = "numberbox_mode_livePosteriseValue";
static final String MODE_LIVE_CAPTURE_FROM_LIVE = "button_mode_liveCaptureFromLive";
PVector statusTextPosition = new PVector(240.0, 12.0);
static String currentMode = MODE_BEGIN;
@ -442,6 +448,18 @@ boolean overwriteExistingStoreFile = true;
public static Console console;
public boolean useWindowedConsole = false;
static boolean drawingLiveVideo = true;
static PImage liveImage = null;
JMyron liveCamera;
BlobDetector blob_detector;
int liveSimplification = 0;
int blurValue = 1;
int posterizeValue = 6;
Set<Integer> colours = null;
List<Integer> colourList = null;
void setup()
{
println("Running polargraph controller");
@ -510,6 +528,17 @@ void setup()
changeTab(TAB_NAME_INPUT, TAB_NAME_INPUT);
addEventListeners();
liveCamera = new JMyron();
liveCamera.start(640,480);
blob_detector = new BlobDetector( 640, 480);
blob_detector.setResolution(1);
blob_detector.computeContours(true);
blob_detector.computeBlobPixels(true);
blob_detector.setMinMaxPixels(10*10, 640*480);
blob_detector.setBLOBable(new BLOBable_blueBlobs(liveImage));
}
void addEventListeners()
@ -766,6 +795,7 @@ void drawWebcamPage()
for (Panel panel : getPanelsForTab(TAB_NAME_WEBCAM))
{
println("Panel:" + panel);
panel.draw();
}
text(propertiesFilename, getPanel(PANEL_NAME_GENERAL).getOutline().getLeft(), getPanel(PANEL_NAME_GENERAL).getOutline().getTop()-7);

View File

@ -72,7 +72,7 @@ Map<String, Set<Panel>> buildPanelsForTabs()
List<String> buildTabNames()
{
List<String> list = new ArrayList<String>(4);
List<String> list = new ArrayList<String>(5);
list.add(TAB_NAME_INPUT);
list.add(TAB_NAME_ROVING);
list.add(TAB_NAME_WEBCAM);
@ -106,7 +106,7 @@ void initTabs()
public Set<String> buildPanelNames()
{
Set<String> set = new HashSet<String>(5);
Set<String> set = new HashSet<String>(6);
set.add(PANEL_NAME_INPUT);
set.add(PANEL_NAME_ROVING);
set.add(PANEL_NAME_WEBCAM);