Changeset 33
- Timestamp:
- 03/19/08 10:10:08 (9 months ago)
- Files:
-
- trunk/pihlaja/src/dsss.conf (modified) (1 diff)
- trunk/pihlaja/src/helpers/gdkkeysyms.d (modified) (1 diff)
- trunk/pihlaja/src/lqt/colormodels.d (modified) (1 diff)
- trunk/pihlaja/src/pihlaja/PihlajaMain.d (modified) (5 diffs)
- trunk/pihlaja/src/shiraz/av/AudioFileQT.d (modified) (1 diff)
- trunk/pihlaja/src/shiraz/av/PortAudioPlaybackCore.d (modified) (2 diffs)
- trunk/pihlaja/src/shiraz/canvas/ICanvasItem.d (modified) (3 diffs)
- trunk/pihlaja/src/shiraz/canvas/Rectangle.d (modified) (34 diffs)
- trunk/pihlaja/src/shiraz/canvas/rtree/AblNode.d (modified) (1 diff)
- trunk/pihlaja/src/shiraz/canvas/rtree/AbstractNode.d (modified) (28 diffs)
- trunk/pihlaja/src/shiraz/canvas/rtree/Comparator.d (modified) (1 diff)
- trunk/pihlaja/src/shiraz/canvas/rtree/Data.d (modified) (1 diff)
- trunk/pihlaja/src/shiraz/canvas/rtree/HashTable.d (moved) (moved from trunk/pihlaja/src_old/ptl/hashtable.d) (4 diffs)
- trunk/pihlaja/src/shiraz/canvas/rtree/HyperCube.d (modified) (1 diff)
- trunk/pihlaja/src/shiraz/canvas/rtree/Index.d (modified) (19 diffs)
- trunk/pihlaja/src/shiraz/canvas/rtree/Leaf.d (modified) (25 diffs)
- trunk/pihlaja/src/shiraz/canvas/rtree/MemoryPageFile.d (modified) (8 diffs)
- trunk/pihlaja/src/shiraz/canvas/rtree/Node.d (modified) (5 diffs)
- trunk/pihlaja/src/shiraz/canvas/rtree/PageFile.d (modified) (5 diffs)
- trunk/pihlaja/src/shiraz/canvas/rtree/RTree.d (modified) (65 diffs)
- trunk/pihlaja/src/shiraz/canvas/rtree/Sort.d (modified) (1 diff)
- trunk/pihlaja/src/shiraz/exception/IllegalArgumentException.d (moved) (moved from trunk/pihlaja/src/shiraz/exception/illegalargumentexception.d) (2 diffs)
- trunk/pihlaja/src/shiraz/exception/RuntimeException.d (added)
- trunk/pihlaja/src/shiraz/exception/runtimeexception.d (deleted)
- trunk/pihlaja/src/shiraz/ui/Animator.d (modified) (1 diff)
- trunk/pihlaja/src/shiraz/ui/SubWindow.d (modified) (2 diffs)
- trunk/pihlaja/src/shiraz/ui/Widget.d (modified) (8 diffs)
- trunk/pihlaja/src/shiraz/ui/Window.d (modified) (8 diffs)
- trunk/pihlaja/src_old/ptl/exception (deleted)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/pihlaja/src/dsss.conf
r30 r33 33 33 buildflags += -debug=Widget 34 34 buildflags += -debug=Window 35 buildflags += -debug=RTree 35 36 #buildflags += -debug=Animator 36 37 #buildflags += -debug=Window trunk/pihlaja/src/helpers/gdkkeysyms.d
r26 r33 1 1 /* Converted to D from ./gdkkeysyms.h by htod */ 2 module gdkkeysyms;2 module helpers.gdkkeysyms; 3 3 //module gdk.Keysyms; 4 4 /* GDK - The GIMP Drawing Kit trunk/pihlaja/src/lqt/colormodels.d
r26 r33 1 1 /* Converted to D from colormodels.h by htod */ 2 module colormodels;2 module lqt.colormodels; 3 3 /******************************************************************************* 4 4 colormodels.h trunk/pihlaja/src/pihlaja/PihlajaMain.d
r31 r33 771 771 } 772 772 773 void mouseHandler( InputState input, Widgetwid )773 void mouseHandler( InputState input, Rectangle wid ) 774 774 { 775 775 switch( input.eventType ) … … 797 797 798 798 799 void rotateAnimatorHandler( InputState input, Widgetwid )799 void rotateAnimatorHandler( InputState input, Rectangle wid ) 800 800 { 801 801 //Trace.formatln("mouseHandler."); … … 818 818 } 819 819 820 void clickHandler3( InputState input, Widgetwid )820 void clickHandler3( InputState input, Rectangle wid ) 821 821 { 822 822 Trace.formatln("You clicked me {}.", wid.name); 823 823 } 824 824 825 void exportButtonHandler( InputState input, Widgetwid )825 void exportButtonHandler( InputState input, Rectangle wid ) 826 826 { 827 827 Trace.formatln("You clicked the exportButton."); … … 933 933 } 934 934 935 void playHandler( InputState input, Widgetwid )935 void playHandler( InputState input, Rectangle wid ) 936 936 { 937 937 static bool clickcol = false; … … 952 952 } 953 953 954 void clickHandler( InputState input, Widgetwid )954 void clickHandler( InputState input, Rectangle wid ) 955 955 { 956 956 //Trace.formatln("VideoViewer.clickHandler() START!"); trunk/pihlaja/src/shiraz/av/AudioFileQT.d
r27 r33 22 22 */ 23 23 24 module shiraz.av. IAudioFileQT;24 module shiraz.av.AudioFileQT; 25 25 26 26 debug(logging) import tango.util.log.Trace;//Thread safe console output. trunk/pihlaja/src/shiraz/av/PortAudioPlaybackCore.d
r27 r33 220 220 return true; 221 221 error: 222 //New Tango: Trace.formatln("Soundoutput failed: ")( stringz.fromStringz(Pa_GetErrorText( err )) ); 222 //New Tango: 223 Trace.formatln("Soundoutput failed: {}", stringz.fromStringz(Pa_GetErrorText( err )) ); 223 224 //Old Tango: 224 Trace.formatln("Soundoutput failed: {}", stringz.fromUtf8z(Pa_GetErrorText( err )) );225 //Trace.formatln("Soundoutput failed: {}", stringz.fromUtf8z(Pa_GetErrorText( err )) ); 225 226 return false; 226 227 } … … 243 244 244 245 error: 245 //New Tango: Trace.formatln("Portaudio Error: ")( stringz.fromStringz(Pa_GetErrorText( err )) ); 246 //New Tango: 247 Trace.formatln("Portaudio Error: {}", stringz.fromStringz(Pa_GetErrorText( err )) ); 246 248 //Old Tango: 247 Trace.formatln("Portaudio Error: {}", stringz.fromUtf8z(Pa_GetErrorText( err )) );249 //Trace.formatln("Portaudio Error: {}", stringz.fromUtf8z(Pa_GetErrorText( err )) ); 248 250 return false; 249 251 } trunk/pihlaja/src/shiraz/canvas/ICanvasItem.d
r31 r33 19 19 module shiraz.canvas.ICanvasItem; 20 20 21 //Circular import/LinkSeq/GDC bug is the reason 22 //for this insanity. ICanvasItem and stuff is all 23 //in Rectangle until that bug is fixed in GDC. 24 25 26 27 /+ 28 21 29 debug(logging) import tango.util.log.Trace;//Thread safe console output. 30 31 import tango.util.collection.LinkSeq; 22 32 23 33 import shiraz.ui.Animator; 24 34 import shiraz.canvas.Point; 25 import shiraz.canvas.rtree.Node; 35 //import shiraz.canvas.rtree.Node; 36 import shiraz.canvas.rtree.RTree; 37 import shiraz.ui.InputState; 38 39 40 26 41 27 42 /* … … 169 184 170 185 void adjustTree(); 186 187 LinkSeq!(ICanvasItem) enclosureList( double tx, double ty, inout LinkSeq!(ICanvasItem) hit_items = null ); 188 LinkSeq!(ICanvasItem) enclosureList( double tx, double ty, double tw, double th, inout LinkSeq!(ICanvasItem) hit_items = null ); 189 bool mouseEvent( InputState input, bool bypass_hittest = false ); 171 190 172 191 //END HyperCube compatibility stuff for RTree: 173 192 //******************************************* 174 193 194 char[] name(); 195 char[] name(char[] set); 196 197 bool isSelected(); 198 bool isSelected(bool set); 199 200 char[] toString(); 175 201 176 202 //Returns a newly allocated copy of this object. … … 261 287 262 288 void add( Animator set_anim ); 289 290 //LinkSeq!(ICanvasItem) enclosureList( double tx, double ty, double tw, double th, inout LinkSeq!(ICanvasItem) hit_items = null ); 263 291 } 264 292 293 +/ 294 295 trunk/pihlaja/src/shiraz/canvas/Rectangle.d
r31 r33 22 22 import Float = tango.text.convert.Float; 23 23 24 import tango.core.Signal; 25 import tango.util.collection.LinkSeq; 24 26 25 27 version(sdl) … … 38 40 39 41 import shiraz.canvas.ICanvasItem; 42 import shiraz.canvas.PlainRectangle; 40 43 import shiraz.canvas.Image; 44 import shiraz.canvas.Bezier; 41 45 import shiraz.ui.Animator; 46 import shiraz.ui.InputState; 42 47 import shiraz.canvas.Point; 43 import shiraz.canvas.rtree.Node; 44 import shiraz.canvas.rtree.AbstractNode; 45 import shiraz.canvas.rtree.Index; 48 import shiraz.canvas.rtree.RTree; 49 //import shiraz.canvas.rtree.Node; 50 //import shiraz.canvas.rtree.AbstractNode; 51 //import shiraz.canvas.rtree.Index; 52 53 /* 54 There propably should be two versions of 55 Rectangles. PlainRectangle or just Rectangle 56 and RRectangle or RTreeRect or RTreeRectangle or 57 TreeRectangle. The following is specific to 58 RTreeRectangle and should go just there. 59 */ 60 61 //I've decided that Widget's should be versatile containers 62 //so that you can use any widget as a vbox or any other layout 63 //you want and add child widget's to any other widget. 64 65 enum DefaultAnimator 66 { 67 ROTATE_180, 68 ROTATE_360 69 } 70 71 enum ArrangeType 72 { 73 VBOX, 74 HBOX, 75 GRID, 76 FREE 77 } 78 79 /* 80 //What about anchor points? 81 enum Anchor 82 { 83 CENTER, 84 TOP, 85 BOTTOM, 86 LEFT, 87 RIGHT, 88 TOP_LEFT, 89 TOP_RIGHT, 90 BOTTOM_LEFT, 91 BOTTOM_RIGHT, 92 CUSTOM_POINT //And a customAnchorX customAnchorY... 93 } 94 */ 95 96 //Packing options for adding child widgets to a Widget 97 enum PackOptions 98 { 99 SHRINK, //Space is contracted to the child widget size. 100 EXPAND_PADDING, //Space is expanded, with extra space filled with padding. 101 EXPAND //Space is expanded, with extra space filled by increasing the child widget size. 102 } 103 104 105 //---------------------------------------------------- 106 //Circular import/LinkSeq/GDC bug is the reason 107 //for this insanity. ICanvasItem and stuff is all 108 //here until that bug is fixed in GDC. 109 110 /* 111 112 113 x1-y1 w-x2-y 114 ------------------------- 115 | | 116 | | 117 | | 118 | | 119 | | 120 | + | 121 | cx,cy | 122 | | 123 | | 124 | | 125 | | 126 ------------------------- 127 h-x-y2 w-x2-y2 128 129 w = 130 h = 131 132 */ 133 134 interface ICanvasItem 135 { 136 public: 137 138 //**************************************** 139 //HyperCube compatibility stuff for RTree: 140 141 142 /*this(Point p1, Point p2) 143 { 144 super(); 145 146 if (p1 is null || p2 is null) throw new IllegalArgumentException("Rectangle.this(p1, p2) Error: Points cannot be null."); 147 148 if (p1.getDimension() != p2.getDimension()) throw new IllegalArgumentException("Rectangle.this(p1, p2) Error: Points must be of the same dimension."); 149 150 for (int i = 0; i < p1.getDimension(); i++) 151 { 152 if (p1.getFloatCoordinate(i) > p2.getFloatCoordinate(i)) throw new IllegalArgumentException("Rectangle.this(p1, p2) Error: Give lower left corner first and upper right corner afterwards."); 153 } 154 155 //this.p1 = cast(Point) p1.clone(); 156 //this.p2 = cast(Point) p2.clone(); 157 158 setAlt( p1.x, p1.y, p2.x, p2.y ); 159 160 }*/ 161 162 int getDimension(); 163 164 //This is just stupid, but this is for HyperCube and RTree compatibility. 165 //It should be changed. 166 protected Point p1(); 167 protected Point p2(); 168 169 Point getP1(); 170 Point getP2(); 171 bool equals(ICanvasItem h); 172 173 /** 174 * Tests to see whether <B>h</B> has any common points with this Rectangle. If <B>h</B> is inside this 175 * object (or vice versa), it returns true. 176 * 177 * @return True if <B>h</B> and this Rectangle intersect, false otherwise. 178 */ 179 bool intersection(ICanvasItem h); 180 181 /** 182 * Tests to see whether <B>h</B> is inside this Rectangle. If <B>h</B> is exactly the same shape 183 * as this object, it is considered to be inside. 184 * 185 * @return True if <B>h</B> is inside, false otherwise. 186 */ 187 bool enclosure(ICanvasItem h); 188 189 /** 190 * Tests to see whether <B>p</B> is inside this Rectangle. If <B>p</B> lies on the boundary 191 * of the Rectangle, it is considered to be inside the object. 192 * 193 * @return True if <B>p</B> is inside, false otherwise. 194 */ 195 bool enclosure(Point p); 196 197 /** 198 * Returns the area of the intersecting region between this Rectangle and the argument. 199 * 200 * Below, all possible situations are depicted. 201 * 202 * ------- ------- --------- --------- ------ ------ 203 * |2 | |2 | |2 | |1 | |2 | |1 | 204 * --|-- | | --|-- | ------ | | ------ | --|------|-- --|------|-- 205 * |1 | | | | |1 | | ||1 | | ||2 | | |1 | | | |2 | | | 206 * --|-- | | --|-- | ------ | | ------ | --|------|-- --|------|-- 207 * ------- ------- --------- --------- ------ ------ 208 * 209 * @param h Given Rectangle. 210 * @return Area of intersecting region. 211 */ 212 float intersectingArea(ICanvasItem h); 213 214 /** 215 * Static impementation. Takes an array of Rectangles and calculates the mbb of their 216 * union. 217 * 218 * @param a The array of Rectangles. 219 * @return The mbb of their union. 220 */ 221 static ICanvasItem getUnionMbb(ICanvasItem[] a); 222 223 /** 224 * Return a new Rectangle representing the mbb of the union of this Rectangle and <B>h</B> 225 * 226 * @param h The Rectangle that we want to union with this Rectangle. 227 * @return A Rectangle representing the mbb of their union. 228 */ 229 public ICanvasItem getUnionMbb(ICanvasItem h); 230 231 /** 232 * Returns the area of this Rectangle. 233 * 234 * @return The area as a float. 235 */ 236 float getArea(); 237 238 /* The MINDIST criterion as described by Roussopoulos. 239 FIXME: better description here... 240 */ 241 float getMinDist(Point p); 242 243 ///////////CanvasItem clone();//Object clone() 244 245 /*String toString() 246 { 247 return "P1" ~ p1.toString() ~ ":P2" ~ p2.toString(); 248 }*/ 249 250 Node rtreeNode();//This is not quaranteed to be up to date at any time. It's only updated on a call to enclosureList(). 251 Node rtreeNode( Node set ); 252 253 void adjustTree(); 254 255 LinkSeq!(ICanvasItem) enclosureList( double tx, double ty, inout LinkSeq!(ICanvasItem) hit_items = null ); 256 LinkSeq!(ICanvasItem) enclosureList( double tx, double ty, double tw, double th, inout LinkSeq!(ICanvasItem) hit_items = null ); 257 bool mouseEvent( InputState input, bool bypass_hittest = false ); 258 259 //END HyperCube compatibility stuff for RTree: 260 //******************************************* 261 262 char[] name(); 263 char[] name(char[] set); 264 265 bool isSelected(); 266 bool isSelected(bool set); 267 268 char[] toString(); 269 270 //Returns a newly allocated copy of this object. 271 ICanvasItem dup(); 272 273 void setXYWH( float sx1, float sy1, float sw, float sh); 274 void setXYXY( float sx1, float sy1, float sx2, float sy2); 275 276 //Position 277 float xPos(); 278 float xPos(float set); 279 float yPos(); 280 float yPos(float set); 281 float zPos(); 282 float zPos(float set); 283 284 //Move pos with a delta value 285 void move( float delta_x, float delta_y ); 286 //Moves the pos 287 void moveTo( float to_x, float to_y ); 288 289 //ZOrder 290 uint zOrder(); 291 uint zOrder(uint set); 292 293 //3D rotations 294 float xRot(); 295 float xRot(float set); 296 float yRot(); 297 float yRot(float set); 298 float zRot(); 299 float zRot(float set); 300 301 //Parent coordinate wrappers for RectangleMesh: 302 303 float cx(); 304 //float cx(float set); 305 float cy(); 306 //float cy(float set); 307 //x1(left) 308 float x1(); 309 float x1(float set); 310 //y1(top) 311 float y1(); 312 float y1(float set); 313 314 float x2(); 315 float x2(float set); 316 317 float y2(); 318 float y2(float set); 319 320 float z(); 321 float z(float set); 322 323 //Width and X2(right) 324 float w(); 325 float w(float set); 326 //Height and Y2(bottom) 327 float h(); 328 float h(float set); 329 330 /* 331 //move x and y in relation to w and h. (change w and h) rarely used. 332 float yh(float set); 333 //Change height while the center stays the same. Maybe hc()? 334 float hc(float set); 335 //move x and y in relation to w and h. (change w and h) rarely used. 336 float xw(float set); 337 //Change width while the center stays the same. Maybe wc()? 338 float wc(float set); 339 */ 340 void colour( float sr, float sg, float sb, float sa ); 341 float r(); 342 float r(float set); 343 float g(); 344 float g(float set); 345 float b(); 346 float b(float set); 347 float a(); 348 float a(float set); 349 350 void render(); 351 //is the point (tx,ty) inside the rectangle 352 bool enclosure( float tx, float ty ); 353 //aspect ratio of the rectangle 354 float aspect(); 355 356 void add( Animator set_anim ); 357 358 //LinkSeq!(ICanvasItem) enclosureList( double tx, double ty, double tw, double th, inout LinkSeq!(ICanvasItem) hit_items = null ); 359 } 360 361 362 363 364 //---------------------------------------------------- 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 46 393 47 394 /* … … 67 414 unittest 68 415 { 69 Trace.formatln("unittest Rectangle.");70 71 //scope Rectangle rect = newRectangle(0.0f, 0.0f, -0.0f, 0.0f, 1.0f, 1.0f);72 scope Rectangle rect = newRectangle();416 Trace.formatln("unittest PlainRectangle."); 417 418 //scope PlainRectangle rect = new PlainRectangle(0.0f, 0.0f, -0.0f, 0.0f, 1.0f, 1.0f); 419 scope PlainRectangle rect = new PlainRectangle(); 73 420 Trace.formatln("rect: {}", rect.toString() ); 74 421 rect.setXYWH( 0.0, 0.0, 1.0, 1.0 ); … … 146 493 147 494 //class ICanvasItem : public ICanvasItem //TODO 148 class Rectangle : public ICanvasItem495 class PlainRectangle : public ICanvasItem 149 496 { 150 497 public: … … 156 503 this(Point p1, Point p2) 157 504 { 158 debug( Rectangle) Trace.formatln("Rectangle.this(p1,p2) START.");159 debug( Rectangle) scope(exit) Trace.formatln("Rectangle.this(p1,p2) END.");505 debug(PlainRectangle) Trace.formatln("PlainRectangle.this(p1,p2) START."); 506 debug(PlainRectangle) scope(exit) Trace.formatln("PlainRectangle.this(p1,p2) END."); 160 507 //super(); 161 508 162 if (p1 is null || p2 is null) throw new Exception(" Rectangle.this(p1, p2) Error: Points cannot be null.");163 164 if (p1.getDimension() != p2.getDimension()) throw new Exception(" Rectangle.this(p1, p2) Error: Points must be of the same dimension.");509 if (p1 is null || p2 is null) throw new Exception("PlainRectangle.this(p1, p2) Error: Points cannot be null."); 510 511 if (p1.getDimension() != p2.getDimension()) throw new Exception("PlainRectangle.this(p1, p2) Error: Points must be of the same dimension."); 165 512 166 513 for (int i = 0; i < p1.getDimension(); i++) 167 514 { 168 if (p1.getFloatCoordinate(i) > p2.getFloatCoordinate(i)) throw new Exception(" Rectangle.this(p1, p2) Error: Give lower left corner first and upper right corner afterwards.");515 if (p1.getFloatCoordinate(i) > p2.getFloatCoordinate(i)) throw new Exception("PlainRectangle.this(p1, p2) Error: Give lower left corner first and upper right corner afterwards."); 169 516 } 170 517 … … 217 564 218 565 /** 219 * Tests to see whether <B>h</B> has any common points with this Rectangle. If <B>h</B> is inside this566 * Tests to see whether <B>h</B> has any common points with this PlainRectangle. If <B>h</B> is inside this 220 567 * object (or vice versa), it returns true. 221 568 * 222 * @return True if <B>h</B> and this Rectangle intersect, false otherwise.569 * @return True if <B>h</B> and this PlainRectangle intersect, false otherwise. 223 570 */ 224 571 bool intersection(ICanvasItem rect) 225 572 { 226 if (rect is null) throw new Exception(" Rectangle.intersection(..) :Rectangle cannot be null.");227 228 //if (h.getDimension() != getDimension()) throw new Exception(" Rectangle.intersection(..) :Rectangle dimension is different from current dimension.");573 if (rect is null) throw new Exception("PlainRectangle.intersection(..) : PlainRectangle cannot be null."); 574 575 //if (h.getDimension() != getDimension()) throw new Exception("PlainRectangle.intersection(..) : PlainRectangle dimension is different from current dimension."); 229 576 /* 230 577 bool intersect = true; … … 241 588 //return isOverlap( h );//I guess this is the same thing as the above??? 242 589 243 debug( Rectangle) Trace.formatln("Rectangle.isOverlap(Rectangle rect) START and END.");590 debug(PlainRectangle) Trace.formatln("PlainRectangle.isOverlap(PlainRectangle rect) START and END."); 244 591 /* 245 592 //This version thinks that if they are equal they overlap. … … 267 614 268 615 /** 269 * Tests to see whether <B>h</B> is inside this Rectangle. If <B>h</B> is exactly the same shape616 * Tests to see whether <B>h</B> is inside this PlainRectangle. If <B>h</B> is exactly the same shape 270 617 * as this object, it is considered to be inside. 271 618 * … … 275 622 { 276 623 //if (h is null) 277 // throw new Exception(" Rectangle.enclosure(..) :Rectangle cannot be null.");624 // throw new Exception("PlainRectangle.enclosure(..) : PlainRectangle cannot be null."); 278 625 279 626 //if (h.getDimension() != getDimension()) throw new 280 //Exception(" Rectangle.enclosure(..) :Rectangle dimension is different from current dimension.");627 //Exception("PlainRectangle.enclosure(..) : PlainRectangle dimension is different from current dimension."); 281 628 282 629 /*bool inside = true; … … 365 712 366 713 /** 367 * Tests to see whether <B>p</B> is inside this Rectangle. If <B>p</B> lies on the boundary368 * of the Rectangle, it is considered to be inside the object.714 * Tests to see whether <B>p</B> is inside this PlainRectangle. If <B>p</B> lies on the boundary 715 * of the PlainRectangle, it is considered to be inside the object. 369 716 * 370 717 * @return True if <B>p</B> is inside, false otherwise. … … 373 720 { 374 721 if (p is null) throw new 375 Exception(" Rectangle.enclosure(Point p) Error: Point cannot be null.");722 Exception("PlainRectangle.enclosure(Point p) Error: Point cannot be null."); 376 723 377 724 if (p.getDimension() != getDimension()) throw new 378 Exception(" Rectangle.enclosure(Point p) Error: Point dimension is different fromRectangle dimension.");379 380 return enclosure( p.x, p.y );//enclosure(new Rectangle(p, p) );725 Exception("PlainRectangle.enclosure(Point p) Error: Point dimension is different from PlainRectangle dimension."); 726 727 return enclosure( p.x, p.y );//enclosure(new PlainRectangle(p, p) ); 381 728 } 382 729 383 730 /** 384 * Returns the area of the intersecting region between this Rectangle and the argument.731 * Returns the area of the intersecting region between this PlainRectangle and the argument. 385 732 * 386 733 * Below, all possible situations are depicted. … … 393 740 * ------- ------- --------- --------- ------ ------ 394 741 * 395 * @param h Given Rectangle.742 * @param h Given PlainRectangle. 396 743 * @return Area of intersecting region. 397 744 */ 398 745 float intersectingArea(ICanvasItem h) 399 746 { 400 //This might all be wrong, as it seems that our Rectangle is747 //This might all be wrong, as it seems that our PlainRectangle is 401 748 //defined differently than the HyperCubes... Let's make a 402 749 //unittest. … … 461 808 static ICanvasItem getUnionMbb(ICanvasItem[] a) 462 809 { 463 debug( Rectangle) Trace.formatln("Rectangle.getUnionMbb(Rectangle[] a)...START.");464 debug( Rectangle) scope(exit) Trace.formatln("Rectangle.getUnionMbb(Rectangle[] a)...END.");810 debug(PlainRectangle) Trace.formatln("PlainRectangle.getUnionMbb(PlainRectangle[] a)...START."); 811 debug(PlainRectangle) scope(exit) Trace.formatln("PlainRectangle.getUnionMbb(PlainRectangle[] a)...END."); 465 812 466 813 if (a is null || a.length == 0) throw new 467 Exception(" Rectangle.getUnionMbb(Rectangle a[]) :Rectangle array is empty.");468 469 //PlainRectangle h = new PlainRectangle( a[0] );//cast( Rectangle) a[0].clone();470 Rectangle h = newRectangle( a[0] );471 472 /*debug( Rectangle)473 { 474 if( h is null) Trace.formatln(" Rectangle.getUnionMbb(Rectangle a[]) : Error: h is null.");475 else if( h is a[0]) Trace.formatln(" Rectangle.getUnionMbb(Rectangle a[]) : Error: h is a[0].");476 else Trace.formatln(" Rectangle.getUnionMbb(Rectangle a[]) : h is OK.");814 Exception("PlainRectangle.getUnionMbb(PlainRectangle a[]) : PlainRectangle array is empty."); 815 816 //PlainRectangle h = new PlainRectangle( a[0] );//cast(PlainRectangle) a[0].clone(); 817 PlainRectangle h = new PlainRectangle( a[0] ); 818 819 /*debug(PlainRectangle) 820 { 821 if( h is null) Trace.formatln("PlainRectangle.getUnionMbb(PlainRectangle a[]) : Error: h is null."); 822 else if( h is a[0]) Trace.formatln("PlainRectangle.getUnionMbb(PlainRectangle a[]) : Error: h is a[0]."); 823 else Trace.formatln("PlainRectangle.getUnionMbb(PlainRectangle a[]) : h is OK."); 477 824 }*/ 478 825 … … 481 828 if(a[i] is null) Trace.formatln("a[i] is null i:", i); 482 829 //h = cast(PlainRectangle) h.getUnionMbb(a[i]); 483 h = cast( Rectangle) h.getUnionMbb(a[i]);830 h = cast(PlainRectangle) h.getUnionMbb(a[i]); 484 831 } 485 832 … … 488 835 489 836 /** 490 * Return a new Rectangle representing the mbb of the union of thisRectangle and <B>h</B>837 * Return a new PlainRectangle representing the mbb of the union of this PlainRectangle and <B>h</B> 491 838 * 492 * @param h The Rectangle that we want to union with thisRectangle.493 * @return A Rectangle representing the mbb of their union.839 * @param h The PlainRectangle that we want to union with this PlainRectangle. 840 * @return A PlainRectangle representing the mbb of their union. 494 841 */ 495 842 public ICanvasItem getUnionMbb(ICanvasItem h) 496 843 { 497 844 if (h is null) 498 throw new Exception(" Rectangle.getUnionMbb(Rectangle h) :Rectangle cannot be null.");499 500 //debug( Rectangle) Trace.formatln( "this rect: ", toString(), " and test rect: ", h.toString() );845 throw new Exception("PlainRectangle.getUnionMbb(PlainRectangle h) : PlainRectangle cannot be null."); 846 847 //debug(PlainRectangle) Trace.formatln( "this rect: ", toString(), " and test rect: ", h.toString() ); 501 848 502 849 //if (h.getDimension() != getDimension()) 503 // throw new Exception(" Rectangle.getUnionMbb(Rectangle h) : Rectangles must be of the same dimension.");850 // throw new Exception("PlainRectangle.getUnionMbb(PlainRectangle h) : Rectangles must be of the same dimension."); 504 851 505 852 float[2] min;// = new float[2];//getDimension()];//2 … … 519 866 520 867 //PlainRectangle reslt = new PlainRectangle(); 521 Rectangle reslt = newRectangle();868 PlainRectangle reslt = new PlainRectangle(); 522 869 reslt.setXYXY( min[0], min[1], max[0], max[1] ); 523 870 524 return reslt;//new Rectangle(min[0], min[1], max[0], max[1]);//new Point(min), new Point(max));871 return reslt;//new PlainRectangle(min[0], min[1], max[0], max[1]);//new Point(min), new Point(max)); 525 872 } 526 873 527 874 /** 528 * Returns the area of this Rectangle.875 * Returns the area of this PlainRectangle. 529 876 * 530 877 * @return The area as a float. … … 550 897 { 551 898 if (p is null) throw new 552 Exception(" Rectangle.getMinDist(Point p) Error: Point cannot be null.");899 Exception("PlainRectangle.getMinDist(Point p) Error: Point cannot be null."); 553 900 554 901 if (p.getDimension() != getDimension()) throw new 555 Exception(" Rectangle.getMinDist(Point p) Error: Point dimension is different fromRectangle dimension.");902 Exception("PlainRectangle.getMinDist(Point p) Error: Point dimension is different from PlainRectangle dimension."); 556 903 557 904 float ret = 0; … … 575 922 //ICanvasItem clone()//Object clone() 576 923 //{ 577 // return new Rectangle(x, y, w, h);//cast(Point) p1.clone(), cast(Point) p2.clone());924 // return new PlainRectangle(x, y, w, h);//cast(Point) p1.clone(), cast(Point) p2.clone()); 578 925 //} 579 926 … … 584 931 debug(RTree) 585 932 { 586 Stdout("CanvasItemAbstract.rtreeNode(Node set) This item:", toString() );587 if( m_rtreeNode !is null ) Stdout(" new rtreeNode:", m_rtreeNode.toString() );933 Trace.formatln("CanvasItemAbstract.rtreeNode(Node set) This item:{}", toString() ); 934 if( m_rtreeNode !is null ) Trace.formatln(" new rtreeNode: {}", m_rtreeNode.toString() ); 588 935 } 589 936 return m_rtreeNode; … … 633 980 } 634 981 635 if( parent !is null )982 /*if( parent !is null ) 636 983 { 637 984 debug(AdjustTree) Stdout("CanvasItemAbstract.adjustTree() going to call parent.adjustTree()."); … … 640 987 } 641 988 else debug(AdjustTree) Stdout("CanvasItemAbstract.adjustTree() Didn't have a parent."); 989 */ 642 990 643 991 debug(AdjustTree) Stdout("CanvasItemAbstract.adjustTree() END.").newline; 644 992 } 993 994 995 LinkSeq!(ICanvasItem) enclosureList( double tx, double ty, inout LinkSeq!(ICanvasItem) hit_items = null ) 996 { 997 return enclosureList( tx, ty, 0.0, 0.0, hit_items ); 998 } 999 1000 LinkSeq!(ICanvasItem) enclosureList( double tx, double ty, double tw, double th, inout LinkSeq!(ICanvasItem) hit_items = null ) 1001 { 1002 throw new Exception("PlainRectangle.enclosureList(...) is not implemented."); 1003 return null; 1004 } 1005 1006 bool mouseEvent( InputState input, bool bypass_hittest = false ) 1007 { 1008 throw new Exception("PlainRectangle.mouseEvent(...) is not implemented."); 1009 return false; 1010 } 645 1011 646 1012 //End hypercube compatibility stuff. 647 1013 //******************************************** 648 1014 1015 1016 649 1017 this() 650 1018 { 651 debug( Rectangle) Trace.formatln("Rectangle.this() START.");652 debug( Rectangle) scope(exit) Trace.formatln("Rectangle.this() END.");1019 debug(PlainRectangle) Trace.formatln("PlainRectangle.this() START."); 1020 debug(PlainRectangle) scope(exit) Trace.formatln("PlainRectangle.this() END."); 653 1021 654 1022 colour( 1.0f, 1.0f, 1.0f, 1.0f ); … … 658 1026 this( float sx1, float sy1, float sx2, float sy2 ) 659 1027 { 660 debug( Rectangle) Trace.formatln("Rectangle.this(4) START.");661 debug( Rectangle) scope(exit) Trace.formatln("Rectangle.this(4) END.");1028 debug(PlainRectangle) Trace.formatln("PlainRectangle.this(4) START."); 1029 debug(PlainRectangle) scope(exit) Trace.formatln("PlainRectangle.this(4) END."); 662 1030 663 1031 /* … … 679 1047 this( float set_pos_x, float set_pos_y, float six1, float siy1, float six2, float siy2 ) 680 1048 { 681 debug( Rectangle) Trace.formatln("Rectangle.this(6) START.");682 debug( Rectangle) scope(exit) Trace.formatln("Rectangle.this(6) END.");1049 debug(PlainRectangle) Trace.formatln("PlainRectangle.this(6) START."); 1050 debug(PlainRectangle) scope(exit) Trace.formatln("PlainRectangle.this(6) END."); 683 1051 684 1052 _xPos = set_pos_x; … … 705 1073 } 706 1074 707 this( Rectangle setme )1075 this( PlainRectangle setme ) 708 1076 { 709 1077 _xPos = setme.xPos; … … 725 1093 ICanvasItem dup() 726 1094 { 727 return new Rectangle(this);1095 return new PlainRectangle(this); 728 1096 } 729 1097 … … 757 1125 //name 758 1126 759 char[] name(){ return m_name; }; 760 char[] name(char[] set){ return m_name = set; }; 761 char[] m_name = ""; 1127 public char[] name(){ return m_name; } 1128 public char[] name(char[] set){ return m_name = set; } 1129 protected char[] m_name = ""; 1130 1131 //isSelected or not. 1132 public bool isSelected() { return m_isSelected; } 1133 public bool isSelected(bool set) 1134 { 1135 m_isSelected = set; 1136 //applyMainColour(); 1137 return m_isSelected; 1138 } 1139 protected bool m_isSelected = false; 762 1140 763 1141 //Position … … 791 1169 //drawn. This is usually 0.0 in Shiraz. It doesn't reflect 792 1170 //which of the objects is topmost. 793 //The z() is a z position for the actual rectangle that1171 //The z() is a z position for the actual PlainRectangle that 794 1172 //is drawn. It could be different than zPos, but usually 795 1173 //it's just 0.0. Maybe it is redundant? I don't know yet. … … 823 1201 else glDisable(GL_TEXTURE_2D); 824 1202 825 //Trace.formatln(" Rectangle.render() START.");1203 //Trace.formatln(" PlainRectangle.render() START."); 826 1204 glPushMatrix(); 827 1205 applyPosition(); … … 899 1277 } 900 1278 901 //Currently Rectangle doesn't keep it's animations...1279 //Currently PlainRectangle doesn't keep it's animations... 902 1280 void add( Animator a_anim ) 903 1281 { … … 925 1303 926 1304 //LinkSeq!(RectangleMesh) m_mesh; //How about something like this later on... 927 // Rectangle should stay simple, but some inherited class1305 //PlainRectangle should stay simple, but some inherited class 928 1306 //could do something like this. 929 1307 … … 969 1347 bool enclosure( float tx, float ty ) 970 1348 { 971 debug( Rectangle) Trace.formatln("Rectangle.enclosure( tx: ", tx, " ty: ", ty, " ) START and END.\n");1349 debug(PlainRectangle) Trace.formatln("PlainRectangle.enclosure( tx: ", tx, " ty: ", ty, " ) START and END.\n"); 972 1350 973 1351 /*Trace.formatln("tx: ")(tx); … … 999 1377 */ 1000 1378 1379 //These will translate the incoming coordinates 1380 //into this widgets coordinates. It's the same 1381 //as xp2i() in the old system. 1001 1382 tx -= xPos; 1002 1383 ty -= yPos; … … 1235 1616 protected float _iz = 0.0f; 1236 1617 1237 1238 1618 /*char[] toString() 1619 { 1620 char[] ret = "\nSTART "; 1621 ret ~= name; 1622 ret ~= "\nxPos: "; 1623 ret ~= Float.toString(xPos); 1624 ret ~= " yPos: "; 1625 ret ~= Float.toString(yPos); 1626 ret ~= " x: "; 1627 ret ~= Float.toString(x1); 1628 ret ~= " y: "; 1629 ret ~= Float.toString(y1); 1630 ret ~= " w: "; 1631 ret ~= Float.toString(w); 1632 ret ~= " h: "; 1633 ret ~= Float.toString(h); 1634 ret ~= "\nEND " ~ name; 1635 1636 return ret; 1637 }*/ 1638 1639 //Ignored in PlainRectangle: 1640 /*Huoh... 1641 LinkSeq!(ICanvasItem) enclosureList( double tx, double ty, inout LinkSeq!(Rectangle) hit_items = null ) { return null; } 1642 LinkSeq!(ICanvasItem) enclosureList( double tx, double ty, double tw, double th, inout LinkSeq!(ICanvasItem) hit_items = null ) { return null; } 1643 public Rectangle rootWindow(Rectangle set){ return null; }///Don't use this yourself. 1644 public Rectangle rootWindow() { return null; }///Don't use this yourself. 1645 public ICanvasItem parent() { return null; } 1646 public ICanvasItem parent(ICanvasItem set) { return null; } 1647 LinkSeq!(ICanvasItem) itemList() { return null; } 1648 RTree itemTree() { return null; } 1649 void add( Animator a_anim ){} 1650 bool hasAnimators(){ false; } 1651 void addDefaultAnimator( DefaultAnimator def_anim ){} 1652 void grabInput(){}
