Changeset 132 for trunk/nv/position.hh


Ignore:
Timestamp:
06/25/13 18:43:24 (12 years ago)
Author:
shark
Message:
  • Added missing spaces in all of my documentation comments (whoops!)
  • nv::to_string( string ) and nv::from_string( string, string ) were missing template <>
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/nv/position.hh

    r121 r132  
    3232                position lr;
    3333                /**
    34                  *Creates a new rectangle assigned to {0, 0, 0, 0}.
     34                 * Creates a new rectangle assigned to {0, 0, 0, 0}.
    3535                 */
    3636                rectangle() : ul(), lr() {}
    3737               
    3838                /**
    39                  *Creates a new rectangle given a position.
    40                  *
    41                  *@param p The position to assign the rectangle to.
     39                 * Creates a new rectangle given a position.
     40                 *
     41                 * @param p The position to assign the rectangle to.
    4242                 */
    4343                rectangle( position p ) : ul(p), lr(p) {}
    4444               
    4545                /**
    46                  *Creates a new rectangle given an upper-left and lower-right position.
    47                  *
    48                  *@param aul The position of the upper-left corner of the rectangle.
    49                  *@param alr The position of the lower-right corner of the rectangle.
     46                 * Creates a new rectangle given an upper-left and lower-right position.
     47                 *
     48                 * @param aul The position of the upper-left corner of the rectangle.
     49                 * @param alr The position of the lower-right corner of the rectangle.
    5050                 */
    5151                rectangle( position aul, position alr ) : ul(aul), lr(alr) {}
    5252               
    5353                /**
    54                  *Creates a new rectangle given an upper-left position, width, and height.
    55                  *
    56                  *@param aul The position of the upper-left corner of the rectangle.
    57                  *@param width The width of the rectangle.
    58                  *@param height The height of the rectangle.
     54                 * Creates a new rectangle given an upper-left position, width, and height.
     55                 *
     56                 * @param aul The position of the upper-left corner of the rectangle.
     57                 * @param width The width of the rectangle.
     58                 * @param height The height of the rectangle.
    5959                 */
    6060                rectangle( position aul, value_type width, value_type height ) : ul(aul), lr(aul + position(width,height)) {}
     
    6666       
    6767        /**
    68          * Explicit Copy constructor
     68         * Explicit Copy assignment operator
    6969         */
    7070        rectangle& operator= (const rectangle& r) { ul = r.ul; lr = r.lr; return *this; }
    7171               
    7272                /**
    73                  *Sets the dimensions of the rectangle without moving the upper-left of the rectangle.
    74                  *
    75                  *@param d The new dimensions of the rectangle.
     73                 * Sets the dimensions of the rectangle without moving the upper-left of the rectangle.
     74                 *
     75                 * @param d The new dimensions of the rectangle.
    7676                 */
    7777                rectangle& dim( dimension d ) { lr = ul + d; return *this; }
    7878
    7979                /**
    80                  *Moves the rectangle to a new position while maintaining its size.
    81                  *
    82                  *@param p The new position of the rectangle's upper-left corner.
     80                 * Moves the rectangle to a new position while maintaining its size.
     81                 *
     82                 * @param p The new position of the rectangle's upper-left corner.
    8383                 */
    8484                rectangle& pos( position p )  { lr = p + (lr - ul); lr = p; return *this; }
    8585
    8686                /**
    87                  *Sets the dimensions of the rectangle without moving the upper-left of the rectangle.
    88                  *
    89                  *@param d The new dimensions of the rectangle.
     87                 * Sets the dimensions of the rectangle without moving the upper-left of the rectangle.
     88                 *
     89                 * @param d The new dimensions of the rectangle.
    9090                 */
    9191                void set_dimension( dimension d ) { lr = ul + d; }
    9292               
    9393                /**
    94                  *Moves the rectangle to a new position while maintaining its size.
    95                  *
    96                  *@param p The new position of the rectangle's upper-left corner.
     94                 * Moves the rectangle to a new position while maintaining its size.
     95                 *
     96                 * @param p The new position of the rectangle's upper-left corner.
    9797                 */
    9898                void set_position( position p ) { lr = p + (lr - ul); ul = p; }
     
    101101                position ll() const { return position( ul.x, lr.y ); }
    102102                /**
    103                  *Gets the dimensions of the rectangle.  Synonym for get_size.
    104                  *
    105                  *@returns The dimensions of the rectangle.
    106                  *@see get_size
     103                 * Gets the dimensions of the rectangle.  Synonym for get_size.
     104                 *
     105                 * @returns The dimensions of the rectangle.
     106                 * @see get_size
    107107                 */
    108108                dimension get_dimension() const { return lr - ul; }
    109109
    110110                /**
    111                  *Gets the position of the upper-left corner of the rectangle.
    112                  *
    113                  *@returns The position of the rectangle's upper-left corner.
     111                 * Gets the position of the upper-left corner of the rectangle.
     112                 *
     113                 * @returns The position of the rectangle's upper-left corner.
    114114                 */
    115115                position  get_position() const { return ul; }
    116116
    117117                /**
    118                  *Gets the dimensions of the rectangle.  Synonym for get_dimension.
    119                  *
    120                  *@returns The dimensions of the rectangle.
    121                  *@see get_dimension
     118                 * Gets the dimensions of the rectangle.  Synonym for get_dimension.
     119                 *
     120                 * @returns The dimensions of the rectangle.
     121                 * @see get_dimension
    122122                 */
    123123                dimension get_size() const { return lr - ul; }
    124124
    125125                /**
    126                  *Gets the center of the rectangle.
    127                  *
    128                  *@returns The center of the rectangle.
     126                 * Gets the center of the rectangle.
     127                 *
     128                 * @returns The center of the rectangle.
    129129                 */
    130130                position get_center() const { return ( lr + ul ) / 2; }
    131131
    132132                /**
    133                  *Gets the width of the rectangle.
    134                  *
    135                  *@returns The width of the rectangle.
     133                 * Gets the width of the rectangle.
     134                 *
     135                 * @returns The width of the rectangle.
    136136                 */
    137137                value_type get_width() const { return lr.x - ul.x; }
    138138
    139139                /**
    140                  *Gets the height of the rectangle.
    141                  *
    142                  *@returns The height of the rectangle.
     140                 * Gets the height of the rectangle.
     141                 *
     142                 * @returns The height of the rectangle.
    143143                 */
    144144                value_type get_height() const { return lr.y - ul.y; }
    145145
    146146                /**
    147                  *Gets the area of the rectangle.
    148                  *
    149                  *@returns The area of the rectangle.
     147                 * Gets the area of the rectangle.
     148                 *
     149                 * @returns The area of the rectangle.
    150150                 */
    151151                value_type get_area() const { return (lr.y - ul.y) * (lr.x - ul.x); }
    152152
    153153                /**
    154                  *Checks to see if the rectangle is backwards.
    155                  *
    156                  *@returns True if the rectangle's upper-left is above and left (or equal to) the rectangle's lower-right, false if it is not.
     154                 * Checks to see if the rectangle is backwards.
     155                 *
     156                 * @returns True if the rectangle's upper-left is above and left (or equal to) the rectangle's lower-right, false if it is not.
    157157                 */
    158158                bool is_valid() const { return lr.x >= ul.x && lr.y >= ul.y; }
    159159
    160160                /**
    161                  *Enlarges the rectangle by a given amount.  Each side is adjusted by the given amount, e.g. expanding by 1 increases the width and height by 2 each.
    162                  *
    163                  *@param value The amount to adjust each sides by.
     161                 * Enlarges the rectangle by a given amount.  Each side is adjusted by the given amount, e.g. expanding by 1 increases the width and height by 2 each.
     162                 *
     163                 * @param value The amount to adjust each sides by.
    164164                 */
    165165                void expand( value_type value ) { position p(value,value); ul -= p; lr += p; }
    166166
    167167                /**
    168                  *Reduces the rectangle by a given amount.  Each side is adjusted by the given amount, e.g. shrinking by 1 decreases the width and height by 2 each.
    169                  *
    170                  *@param value The amount to adjust each side by.
     168                 * Reduces the rectangle by a given amount.  Each side is adjusted by the given amount, e.g. shrinking by 1 decreases the width and height by 2 each.
     169                 *
     170                 * @param value The amount to adjust each side by.
    171171                 */
    172172                void shrink( value_type value ) { position p(value,value); ul += p; lr -= p; }
    173173
    174174                /**
    175                  *Gets a rectangle that is an expanded version of this rectangle.
    176                  *
    177                  *@param value The amount to adjust each side by.
    178                  *@returns An expanded rectangle.
    179                  *@see expand
     175                 * Gets a rectangle that is an expanded version of this rectangle.
     176                 *
     177                 * @param value The amount to adjust each side by.
     178                 * @returns An expanded rectangle.
     179                 * @see expand
    180180                 */
    181181                rectangle expanded( int value ) { position p(value,value); return rectangle(ul-p, lr+p); }
    182182
    183183                /**
    184                  *Gets a rectangle that is a shrunk version of this rectangle.
    185                  *
    186                  *@param value The amount to adjust each side by.
    187                  *@returns A shrunk rectangle.
    188                  *@see shrink
     184                 * Gets a rectangle that is a shrunk version of this rectangle.
     185                 *
     186                 * @param value The amount to adjust each side by.
     187                 * @returns A shrunk rectangle.
     188                 * @see shrink
    189189                 */
    190190                rectangle shrinked( int value ) { position p(value,value); return rectangle(ul+p, lr-p); }
    191191               
    192192                /**
    193                  *Shifts the rectangle by a given amount.
    194                  *
    195                  *@param pos The amount to shift the rectangle by.
     193                 * Shifts the rectangle by a given amount.
     194                 *
     195                 * @param pos The amount to shift the rectangle by.
    196196                 */
    197197                rectangle& operator+=( const position& pos ) { ul += pos; lr += pos; return (*this); }
    198198
    199199                /**
    200                  *Returns a rectangle shifted by a given amount.
    201                  *
    202                  *@param pos The amount to shift by.
    203                  *@returns The shifted rectangle.
     200                 * Returns a rectangle shifted by a given amount.
     201                 *
     202                 * @param pos The amount to shift by.
     203                 * @returns The shifted rectangle.
    204204                 */
    205205                rectangle operator+( const position& pos ) const {      rectangle r(*this); return r += pos; }
    206206
    207207                /**
    208                  *Shifts the rectangle by a given amount.
    209                  *
    210                  *@param pos The amount to shift the rectangle by.
     208                 * Shifts the rectangle by a given amount.
     209                 *
     210                 * @param pos The amount to shift the rectangle by.
    211211                 */
    212212                rectangle& operator-=( const position& pos ) { ul -= pos; lr -= pos; return (*this); }
    213213
    214214                /**
    215                  *Returns a rectangle shifted by a given amount.
    216                  *
    217                  *@oaram pos The amount to shift by.
    218                  *@returns The shifted rectangle.
     215                 * Returns a rectangle shifted by a given amount.
     216                 *
     217                 * @param pos The amount to shift by.
     218                 * @returns The shifted rectangle.
    219219                 */
    220220                rectangle operator-( const position& pos ) const {      rectangle r(*this); return r -= pos; }
    221221
    222222                /**
    223                  *Compares two rectangles to see if they are the same.
    224                  *
    225                  *@param r The rectangle to compare to.
    226                  *@returns True if the rectangles have the same positions and dimensions, false otherwise.
     223                 * Compares two rectangles to see if they are the same.
     224                 *
     225                 * @param r The rectangle to compare to.
     226                 * @returns True if the rectangles have the same positions and dimensions, false otherwise.
    227227                 */
    228228                bool operator==( const rectangle& r ) const { return r.ul == ul && r.lr == lr; }
    229229
    230230                /**
    231                  *Compares two rectangles to see if they are different.
    232                  *
    233                  *@param r The rectangle to compare to.
    234                  *@returns True if the rectangles have different positions or dimensions, false otherwise.
     231                 * Compares two rectangles to see if they are different.
     232                 *
     233                 * @param r The rectangle to compare to.
     234                 * @returns True if the rectangles have different positions or dimensions, false otherwise.
    235235                 */
    236236                bool operator!=( const rectangle& r ) const { return r.ul != ul || r.lr != lr; }
    237237
    238238                /**
    239                  *Checks if a position is within the bounds of this rectangle.
    240                  *
    241                  *@param r The position to check.
    242                  *@returns True if the position is inside or on the edge of the rectangle, false otherwise.
     239                 * Checks if a position is within the bounds of this rectangle.
     240                 *
     241                 * @param r The position to check.
     242                 * @returns True if the position is inside or on the edge of the rectangle, false otherwise.
    243243                 */
    244244                bool contains( const position& r ) const{ return lr.y >= r.y && ul.y <= r.y && lr.x >= r.x && ul.x <= r.x; }
    245245
    246246                /**
    247                  *Checks if a rectangle is within the bounds of this rectangle.
    248                  *
    249                  *@param r The rectangle to check.
    250                  *@returns True if the entire rectangle to check is inside or on the edge of this rectangle, false otherwise.
     247                 * Checks if a rectangle is within the bounds of this rectangle.
     248                 *
     249                 * @param r The rectangle to check.
     250                 * @returns True if the entire rectangle to check is inside or on the edge of this rectangle, false otherwise.
    251251                 */
    252252                bool contains( const rectangle& r ) const { return contains( r.ul ) && contains( r.lr ); }
    253253
    254254                /**
    255                  *Checks if another rectangle overlaps this one.
    256                  *
    257                  *@param r The rectangle to check.
    258                  *@returns True if any part of the rectangle to check overlaps this rectangle, false otherwise.
     255                 * Checks if another rectangle overlaps this one.
     256                 *
     257                 * @param r The rectangle to check.
     258                 * @returns True if any part of the rectangle to check overlaps this rectangle, false otherwise.
    259259                 */
    260260                bool collides( const rectangle& r ) const { return lr.y > r.ul.y && ul.y < r.lr.y && lr.x > r.ul.x && ul.x < r.lr.x; }
    261261
    262262                /**
    263                  *Limits the region of the rectangle to the inidicated rectangle.
    264                  *
    265                  *@param r The rectangle that this rectangle is confined to.
    266                  *@returns True if the rectangle was changed, false otherwise.
     263                 * Limits the region of the rectangle to the inidicated rectangle.
     264                 *
     265                 * @param r The rectangle that this rectangle is confined to.
     266                 * @returns True if the rectangle was changed, false otherwise.
    267267                 */
    268268                bool clamp_to( const rectangle& r )
     
    276276
    277277                /**
    278                  *Limits the size of the rectangle to the given rectangle's size.
    279                  *
    280                  *@param r The rectangle representing the maximum dimensions this rectangle can be.
    281                  *@returns True if the rectangle needed to be resized, false otherwise.
     278                 * Limits the size of the rectangle to the given rectangle's size.
     279                 *
     280                 * @param r The rectangle representing the maximum dimensions this rectangle can be.
     281                 * @returns True if the rectangle needed to be resized, false otherwise.
    282282                 */
    283283                bool constrain_to( const rectangle& r )
     
    290290
    291291                /**
    292                  *Fixes an invalid rectangle.
     292                 * Fixes an invalid rectangle.
    293293                 */
    294294                void repair()
     
    299299
    300300                /**
    301                  *Expands the rectangle to just include the given point.
    302                  *
    303                  *@param p The point to include in the rectangle.
     301                 * Expands the rectangle to just include the given point.
     302                 *
     303                 * @param p The point to include in the rectangle.
    304304                 */
    305305                void include_point( position p )
Note: See TracChangeset for help on using the changeset viewer.