diff --git a/RangeApp/BoundingBox.pde b/RangeApp/BoundingBox.pde index 47c08c6..578f712 100644 --- a/RangeApp/BoundingBox.pde +++ b/RangeApp/BoundingBox.pde @@ -1,5 +1,6 @@ class BoundingBox { float x1, x2, y1, y2; + color _c; public BoundingBox(float _x1, float _x2, float _y1, float _y2) { x1 = _x1; @@ -7,14 +8,16 @@ class BoundingBox { 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(); } } diff --git a/RangeApp/Menu.pde b/RangeApp/Menu.pde index 98d3235..dfc5e65 100644 --- a/RangeApp/Menu.pde +++ b/RangeApp/Menu.pde @@ -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; diff --git a/RangeApp/RangeApp.pde b/RangeApp/RangeApp.pde index 8112b4e..1c34421 100644 --- a/RangeApp/RangeApp.pde +++ b/RangeApp/RangeApp.pde @@ -4,10 +4,11 @@ Menu menu; Selector selector; Point nearestNeighbor; ArrayList pointList, selectedList; -boolean drawCon, drawHelp, drawTreeRelations, drawTreeBoundaries, drawGnoman, useSelector; +ArrayList boxList; +boolean drawCon, drawHelp, drawTreeRelations, drawTreeBoundaries, drawGnoman, useSelector, drawBoxes; void setup() { - size(800,800); + size(1000,1000); background(120); ellipseMode(CENTER); cam = new Camera(); @@ -17,12 +18,14 @@ void setup() { menu = new Menu(); pointList = new ArrayList(); selectedList = new ArrayList(); + boxList = new ArrayList (); drawCon = false; drawHelp = false; drawGnoman = true; drawTreeRelations = false; - drawTreeBoundaries = true; + drawTreeBoundaries = false; + drawBoxes = false; } @@ -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(); @@ -50,11 +59,12 @@ void draw() { selector.draw(); } - if (drawHelp) { + /*if (drawHelp) { drawHelpMenu(); } else { menu.draw(); - } + }*/ + menu.draw(); } @@ -64,6 +74,7 @@ void keyPressed() { case 'C': pointList.clear(); selectedList.clear(); + boxList.clear(); pot.clearTree(); break; case 'h': @@ -78,6 +89,10 @@ void keyPressed() { case 'J': drawTreeBoundaries = !drawTreeBoundaries; break; + case 'l': + case 'L': + drawBoxes = !drawBoxes; + break; case 'e': case 'E': drawGnoman = !drawGnoman; @@ -95,6 +110,10 @@ void keyPressed() { void checkSelect() {} +void addBox(BoundingBox bb) { + boxList.add(bb); +} + void setSelected(ArrayList pointList) { for(Point p: selectedList) { p.setUnSelected(); @@ -161,6 +180,3 @@ void mouseReleased() { } } -void balanceTree (ArrayList points, boolean dir) { - -} diff --git a/RangeApp/Selector.pde b/RangeApp/Selector.pde index 86a9dcb..848d136 100644 --- a/RangeApp/Selector.pde +++ b/RangeApp/Selector.pde @@ -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; diff --git a/RangeApp/Tree.pde b/RangeApp/Tree.pde index 70f79b8..b88c048 100644 --- a/RangeApp/Tree.pde +++ b/RangeApp/Tree.pde @@ -20,6 +20,7 @@ class KdTree { _relationC = colorizeRelation(depth); _left = null; _right = null; + _bb.setColor (colorizeBox(depth)); calcBoundary(); } @@ -88,15 +89,19 @@ class KdTree { leftRes = merge(leftRes, _left.report()); if(_right != null) rightRes = _right.report(); + + addBox (_bb); + return merge(rightRes, leftRes); } ArrayList queryBox(BoundingBox range) { ArrayList rightRes = new ArrayList(); ArrayList leftRes = new ArrayList(); - - if(inBox(_loc, range)) - rightRes.add(_loc); + addBox(_bb); + if(inBox(_loc, range)) { + rightRes.add(_loc); + } if(_left != null) { if(containsBox(range, _left._bb)) @@ -119,7 +124,7 @@ class KdTree { ArrayList queryCircle(Point c, float r) { ArrayList rightRes = new ArrayList(); ArrayList leftRes = new ArrayList(); - + addBox(_bb); if(inCircle(c, r, _loc)) rightRes.add(_loc); @@ -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))); } -} \ No newline at end of file + + 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); + } +} diff --git a/RangeApp/web-export/.DS_Store b/RangeApp/web-export/.DS_Store new file mode 100644 index 0000000..5008ddf Binary files /dev/null and b/RangeApp/web-export/.DS_Store differ