Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Added region shading for selection. And touhed up some other stuff.
  • Loading branch information
rwb11001 committed Dec 13, 2015
1 parent 28c9206 commit 911cc8d
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 21 deletions.
11 changes: 7 additions & 4 deletions RangeApp/BoundingBox.pde
@@ -1,20 +1,23 @@
class BoundingBox {
float x1, x2, y1, y2;
color _c;
public BoundingBox(float _x1, float _x2, float _y1, float _y2)
{
x1 = _x1;
x2 = _x2;
y1 = _y1;
y2 = _y2;
}

void setColor (color c) {
_c = c;
}
void draw()
{
pushStyle();
stroke(0);
line(x1, y1, x2, y1);
line(x1, y2, x2, y2);
line(x1, y1, x1, y2);
line(x2, y1, x2, y2);
fill(_c);
rect(x1, y1, x2 - x1,y2 - y1);
popStyle();
}
}
Expand Down
8 changes: 4 additions & 4 deletions RangeApp/Menu.pde
Expand Up @@ -53,10 +53,10 @@ class Menu{
_buttonList.add(pan);
pan.addHandler(new PanHandler());

Button rot = new Button (0, y, "Rotate");
y += i_buttonHeight + 10;
_buttonList.add(rot);
rot.addHandler(new RotHandler());
//Button rot = new Button (0, y, "Rotate");
//y += i_buttonHeight + 10;
//_buttonList.add(rot);
//rot.addHandler(new RotHandler());

Button place = new Button (0, y, "Place");
y += i_buttonHeight + 10;
Expand Down
32 changes: 24 additions & 8 deletions RangeApp/RangeApp.pde
Expand Up @@ -4,10 +4,11 @@ Menu menu;
Selector selector;
Point nearestNeighbor;
ArrayList<Point> pointList, selectedList;
boolean drawCon, drawHelp, drawTreeRelations, drawTreeBoundaries, drawGnoman, useSelector;
ArrayList<BoundingBox> boxList;
boolean drawCon, drawHelp, drawTreeRelations, drawTreeBoundaries, drawGnoman, useSelector, drawBoxes;

void setup() {
size(800,800);
size(1000,1000);
background(120);
ellipseMode(CENTER);
cam = new Camera();
Expand All @@ -17,12 +18,14 @@ void setup() {
menu = new Menu();
pointList = new ArrayList<Point>();
selectedList = new ArrayList<Point>();
boxList = new ArrayList <BoundingBox>();

drawCon = false;
drawHelp = false;
drawGnoman = true;
drawTreeRelations = false;
drawTreeBoundaries = true;
drawTreeBoundaries = false;
drawBoxes = false;

}

Expand All @@ -32,6 +35,12 @@ void draw() {
pushMatrix();
cam.update();
if(drawGnoman) GnomanDraw(200);

if(drawBoxes) {
for(BoundingBox bb: boxList) {
bb.draw();
}
}

if(drawTreeBoundaries) {
pot.drawBoundaries();
Expand All @@ -50,11 +59,12 @@ void draw() {
selector.draw();
}

if (drawHelp) {
/*if (drawHelp) {
drawHelpMenu();
} else {
menu.draw();
}
}*/
menu.draw();

}

Expand All @@ -64,6 +74,7 @@ void keyPressed() {
case 'C':
pointList.clear();
selectedList.clear();
boxList.clear();
pot.clearTree();
break;
case 'h':
Expand All @@ -78,6 +89,10 @@ void keyPressed() {
case 'J':
drawTreeBoundaries = !drawTreeBoundaries;
break;
case 'l':
case 'L':
drawBoxes = !drawBoxes;
break;
case 'e':
case 'E':
drawGnoman = !drawGnoman;
Expand All @@ -95,6 +110,10 @@ void keyPressed() {

void checkSelect() {}

void addBox(BoundingBox bb) {
boxList.add(bb);
}

void setSelected(ArrayList<Point> pointList) {
for(Point p: selectedList) {
p.setUnSelected();
Expand Down Expand Up @@ -161,6 +180,3 @@ void mouseReleased() {
}
}

void balanceTree (ArrayList<Point> points, boolean dir) {

}
1 change: 1 addition & 0 deletions RangeApp/Selector.pde
Expand Up @@ -22,6 +22,7 @@ class Selector{
void mousePressed(){//triggered on mousePressed()
_startX = mouseX;
_startY = mouseY;
boxList.clear();
switch(_select_mode){
case 0: _selecting = true; //rectangular selection
break;
Expand Down
24 changes: 19 additions & 5 deletions RangeApp/Tree.pde
Expand Up @@ -20,6 +20,7 @@ class KdTree {
_relationC = colorizeRelation(depth);
_left = null;
_right = null;
_bb.setColor (colorizeBox(depth));

calcBoundary();
}
Expand Down Expand Up @@ -88,15 +89,19 @@ class KdTree {
leftRes = merge(leftRes, _left.report());
if(_right != null)
rightRes = _right.report();

addBox (_bb);

return merge(rightRes, leftRes);
}

ArrayList<Point> queryBox(BoundingBox range) {
ArrayList<Point> rightRes = new ArrayList<Point>();
ArrayList<Point> leftRes = new ArrayList<Point>();

if(inBox(_loc, range))
rightRes.add(_loc);
addBox(_bb);
if(inBox(_loc, range)) {
rightRes.add(_loc);
}

if(_left != null) {
if(containsBox(range, _left._bb))
Expand All @@ -119,7 +124,7 @@ class KdTree {
ArrayList<Point> queryCircle(Point c, float r) {
ArrayList<Point> rightRes = new ArrayList<Point>();
ArrayList<Point> leftRes = new ArrayList<Point>();

addBox(_bb);
if(inCircle(c, r, _loc))
rightRes.add(_loc);

Expand Down Expand Up @@ -231,4 +236,13 @@ class KdTree {
float d = depth * 0.2;
return color((int)255*abs(sin(d + 0.3)), (int)255*abs(sin(d+3.0)), (int)255*abs(sin(d+0.7)));
}
}

color colorizeBox (int depth) {
float d = depth* 0.2;
int alpha = 0;
if (depth != 0) {
alpha = 20;
}
return color((int)255*abs(sin(5*d+0.3)), (int)255*abs(cos(3.1*d+2.0)), (int)255*abs(sin(20* d+0.7)), alpha);
}
}
Binary file added RangeApp/web-export/.DS_Store
Binary file not shown.

0 comments on commit 911cc8d

Please sign in to comment.