Skip to content

Commit

Permalink
Dramatically improved GUI so it is all one size, and the fonts are no…
Browse files Browse the repository at this point in the history
…w big and legible.
  • Loading branch information
Amy Hurst committed Nov 21, 2010
1 parent 9f65bca commit 6185932
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 30 deletions.
34 changes: 22 additions & 12 deletions CaptureController.pde
Expand Up @@ -3,6 +3,7 @@ class CaptureController extends UIController{
ArrayList<String> measureLabels;
Controller cont_btn;

int instructionsFontSize = 5;
public void setup(){
measureLabels = new ArrayList<String>();
setupOpenCVcamera();
Expand All @@ -18,19 +19,23 @@ class CaptureController extends UIController{
for(int i = 0; i < lbls.length; i++){
measureLabels.add(lbls[i]);
}
frame.setSize(w+PADDING*2, h+INFO_H+PADDING*3+50);
//frame.setSize(w+PADDING*2, h+INFO_H+PADDING*3+50);

controlP5.addButton("<< Back",0, 20, h+INFO_H, 160, 35);
//controlP5.addButton("<< Back",0, 20, h+INFO_H, 160, 35);
controlP5.addButton("<< Back",0, 20, h+(INFO_H)-40, 220, 45);
controlP5.Label lbl = controlP5.controller("<< Back").captionLabel();
lbl.setControlFont(cfont);
lbl.setControlFontSize(20);
controlP5.addButton(" Continue >>",1, w-180, h+INFO_H, 160, 35);
lbl.setControlFont(continueFont);
lbl.setControlFontSize(30);

//controlP5.addButton(" Continue >>",1, w-180, h+INFO_H, 160, 35);
controlP5.addButton(" Continue >>",0, width - 220, h+(INFO_H)-40, 220, 45);
cont_btn = controlP5.controller(" Continue >>");
lbl = cont_btn.captionLabel();
lbl.setControlFont(cfont);
lbl.setControlFontSize(20);
lbl.setControlFont(continueFont);
lbl.setControlFontSize(30);
cont_btn.hide();
isCapturing = true;

}

public void draw(){
Expand Down Expand Up @@ -141,9 +146,10 @@ class CaptureController extends UIController{
String name = theEvent.controller().name();
if(name.equals("<< Back")){
lines = new ArrayList<Line>();
changeController(controllers.get("object_chooser"));

controlP5.remove("<< Back");
controlP5.remove(" Continue >>");
changeController(controllers.get("object_chooser"));
}
if(name.equals(" Continue >>")){
writeMeasurements();
Expand All @@ -156,7 +162,7 @@ class CaptureController extends UIController{
void setupOpenCVcamera(){
String[] devices = Capture.list();
println(Capture.list());
cam = new Capture(app, w, h, devices[5]);
cam = new Capture(app, w, h, devices[2]);
opencv = new OpenCV( app );
opencv.allocate(w,h);
}
Expand All @@ -178,17 +184,21 @@ class CaptureController extends UIController{
fill(255,255,255);
/* text("MM/PX: " + mm_per_px, 0, TEXT_H); */
if(isCapturing){
text("Place your hand on the paper with a nickel on top.", 0, TEXT_H);
text("Press [SPACE BAR] when your hand and the nickel are found.",0, TEXT_H*2.2);
textFont(createFont("SansSerif",25));
text("Place your hand on the paper with a nickel on top.", PADDING, TEXT_H+5);
text("Press [SPACE BAR] when we find your hand and the ",PADDING, (TEXT_H + 30)+(PADDING*2));
text("the nickel turn purple (they have been found).",PADDING, (TEXT_H + 60)+(PADDING*2));

} else {
int txtLines = 1;
for(int i = 0; i < measureLabels.size(); i++){
String measurement = "[MEASURE ME NOW!]";
String measurement = "[measure finger you want ring to fit]";
if((lines.size() > i) && (lines.get(i) != null)){
measurement = ""
+ String.format("%.03f",lines.get(i).length() * mm_per_px)
+ "mm";
}
textFont(createFont("SansSerif",25));
text(measureLabels.get(i) + ": " + measurement, 0, TEXT_H*(txtLines + .2));
}
}
Expand Down
2 changes: 1 addition & 1 deletion NickelForScale.pde
Expand Up @@ -51,7 +51,7 @@ void setup() {
font = createFont( "SansSerif", 20 );
textFont( font, 20 );
size( w+PADDING*2, h+INFO_H+PADDING*3, P3D );
frame.setResizable(true);
//frame.setResizable(true);
controlP5 = new ControlP5(this);
controllers.put("object_chooser", new ObjectChooserController());
controllers.put("capture", new CaptureController());
Expand Down
66 changes: 49 additions & 17 deletions ObjectChooserController.pde
Expand Up @@ -4,9 +4,15 @@ import unlekker.geom.*;
ArrayList<FaceList> stls;
ArrayList<String> names;
int curr_model = 1;
int deg = 0;
int deg = 150;

int modelSize_w = 480;
int modelSize_h = 480;

ControlFont cfont;
ControlFont arrowFont;
ControlFont continueFont;
ControlFont instructionsFont;

class ObjectChooserController extends UIController {

Expand All @@ -20,7 +26,7 @@ class ObjectChooserController extends UIController {
String name = obj.getName();
STL stl = new STL(app, new File(obj,name + "-bin.stl").getAbsolutePath());
FaceList poly = stl.getPolyData();
poly.normalize(200);
poly.normalize(420);
poly.center();
stls.add(poly);
names.add(name);
Expand All @@ -29,24 +35,35 @@ class ObjectChooserController extends UIController {
font = createFont( "SansSerif", 20);
textFont( font, 20 );

cfont = new ControlFont(font);

cfont = new ControlFont(createFont("SansSerif",18));
arrowFont = new ControlFont(createFont("SansSerif",40));
continueFont = new ControlFont(createFont("SansSerif",30));
instructionsFont = new ControlFont(createFont("SansSerif",40));
}

public void takeControl(){
frame.setSize(350,350 + PADDING*2 + TEXT_H);
controlP5.addButton(" Continue >>",0,180,320,160,35);
//frame.setSize(350,350 + PADDING*2 + TEXT_H);
//frame.setSize(w+PADDING*2, h+INFO_H+PADDING*3+50);

//controlP5.addButton(" Continue >>",0,(width/2) - 80,480,160,35);
controlP5.addButton(" Continue >>",0, width - 220 - PADDING, h+(INFO_H)-40, 220, 45);
controlP5.Label lbl = controlP5.controller(" Continue >>").captionLabel();
lbl.setControlFont(cfont);
lbl.setControlFontSize(20);
controlP5.addButton("<", 1, PADDING, PADDING, 25,300);
lbl.setControlFont(continueFont);
lbl.setControlFontSize(30);

controlP5.addButton("<", 1, PADDING, PADDING, 50,480);
lbl = controlP5.controller("<").captionLabel();
lbl.setControlFont(cfont);
lbl.setControlFontSize(20);
controlP5.addButton(">", 2, 295 + PADDING*2, PADDING, 25,300);
lbl.setControlFont(arrowFont);
lbl.setControlFontSize(35);

controlP5.addButton(">", 2, width - 50 - PADDING, PADDING, 50,480);
lbl = controlP5.controller(">").captionLabel();
lbl.setControlFont(cfont);
lbl.setControlFontSize(20);
lbl.setControlFont(arrowFont);
lbl.setControlFontSize(35);

controlP5.addTextlabel("info1"," ",480,290);
lbl.setControlFont(instructionsFont);
lbl.setControlFontSize(35);
}

public void controlEvent(ControlEvent theEvent) {
Expand All @@ -60,21 +77,36 @@ class ObjectChooserController extends UIController {
}
}


void drawInfo(){
pushMatrix();
translate(PADDING, PADDING*2+h);
fill(255,255,255);
textFont(createFont("SansSerif",25));
text("Choose the model you want to customize!", PADDING + 50, TEXT_H + (PADDING*2));
text("Browse models using the arrow buttons, ",PADDING + 50, (TEXT_H + 50)+(PADDING*2));
text("then click on the CONTINUE button.",PADDING + 50, (TEXT_H + 80)+(PADDING*2));
popMatrix();
}

public void draw(){
background(0);

drawInfo();

pushMatrix();
translate(175,150);
//translate(175,150);
translate(width/2,240+PADDING);
rotateY(deg*(PI/180));
rotateX(215*(PI/180));
rotateX(170*(PI/180));
fill(128,128,128);
stroke(255,255,255);
stls.get(curr_model).draw(app);
popMatrix();
deg++; if(deg > 359) { deg = 0; }
textAlign(CENTER);
fill(255,255,255);
text(name_to_readable(names.get(curr_model)), width/2, 300);
text(name_to_readable(names.get(curr_model)), width/2, 480+TEXT_H-PADDING);
textAlign(LEFT);
controlP5.draw();
}
Expand Down

0 comments on commit 6185932

Please sign in to comment.