• Skip to content
  • Skip to link menu
KDE 3.5 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

kviewshell

GRect Class Reference

Rectangle class. More...

#include <GRect.h>

List of all members.


Public Types

enum  OrientationBits { BOTTOM_UP = 0x1, MIRROR = 0x2, ROTATE90_CW = 0x4 }
enum  Orientations {
  TDLRNR = 0, BULRNR = BOTTOM_UP, TDRLNR = MIRROR, BURLNR = MIRROR|BOTTOM_UP,
  TDLRCW = ROTATE90_CW, BULRCW = ROTATE90_CW|BOTTOM_UP, TDRLCW = ROTATE90_CW|MIRROR, BURLCW = ROTATE90_CW|MIRROR|BOTTOM_UP
}

Public Member Functions

int area () const
void clear ()
int contains (const GRect &rect) const
int contains (int x, int y) const
 GRect (int xmin, int ymin, unsigned int width=0, unsigned int height=0)
 GRect ()
int height () const
int inflate (int dx, int dy)
int intersect (const GRect &rect1, const GRect &rect2)
int isempty () const
int recthull (const GRect &rect1, const GRect &rect2)
void scale (float xfactor, float yfactor)
void scale (float factor)
int translate (int dx, int dy)
int width () const

Static Public Member Functions

static int findangle (const Orientations orientation)
static Orientations rotate (const int angle, Orientations orientation)

Public Attributes

int xmax
int xmin
int ymax
int ymin

Friends

int operator!= (const GRect &r1, const GRect &r2)
int operator== (const GRect &r1, const GRect &r2)

Detailed Description

Rectangle class.

Each instance of this class represents a rectangle whose sides are parallel to the axis. Such a rectangle represents all the points whose coordinates lies between well defined minimal and maximal values. Member functions can combine several rectangles by computing the intersection of rectangles ({intersect}) or the smallest rectangle enclosing two rectangles ({recthull}).

Definition at line 132 of file GRect.h.


Member Enumeration Documentation

enum GRect::OrientationBits

OrientationBits# defines 3 mutually exclusive bits to indicate the image orientation.

There are four possible rotation values for an image which are 0 degrees, 90 degrees, 180 degrees, and 270 degrees. In addition the image can be mirrored backwards in any of these orientations, giving a possible of 8 orientations. To sanely deal with these orientations, we have defined 3 mutually exclusive bits. These are BOTTOM_UP, MIRROR, and ROTATE90_CW.

Enumerator:
BOTTOM_UP 
MIRROR 
ROTATE90_CW 

Definition at line 145 of file GRect.h.

enum GRect::Orientations

Orientations# defines all 8 possible orientations, using the three {OrientationBits}.

{itemize} {TDLRNR} for Top Down, Left to Right, No Rotation. {BULRNR} for Bottom Up, Left to Right, No Rotation. {TDRLNR} for Top Down, Right to Left, No Rotation. {BURLNR} for Bottom Up, Right to Left, No Rotation. {TDLRCW} for Top Down, Left to Right, 90 degree CW rotation. {BULRCW} for Bottom Up, Left to Right, 90 degree CW rotation. {TDRLCW} for Top Down, Right to Left, 90 degree CW rotation. {BURLCW} for Bottom Up, Right to Left, 90 degree CW rotation. {itemize}

Enumerator:
TDLRNR 
BULRNR 
TDRLNR 
BURLNR 
TDLRCW 
BULRCW 
TDRLCW 
BURLCW 

Definition at line 165 of file GRect.h.


Constructor & Destructor Documentation

GRect::GRect (  )  [inline]

Constructs an empty rectangle.

Definition at line 346 of file GRect.h.

GRect::GRect ( int  xmin,
int  ymin,
unsigned int  width = 0,
unsigned int  height = 0 
) [inline]

Constructs a rectangle given its minimal coordinates xmin# and ymin#, and its measurements width# and height#.

Setting width# or height# to zero produces an empty rectangle.

Definition at line 352 of file GRect.h.


Member Function Documentation

int GRect::area (  )  const [inline]

Returns the area of the rectangle.

Definition at line 376 of file GRect.h.

void GRect::clear ( void   )  [inline]

Resets the rectangle to the empty rectangle.

Definition at line 388 of file GRect.h.

int GRect::contains ( const GRect &  rect  )  const

Returns true if this rectangle contains the passed rectangle rect#.

The function basically checks, that the intersection of this rectangle with rect# is rect#.

Definition at line 187 of file GRect.cpp.

int GRect::contains ( int  x,
int  y 
) const [inline]

Returns true if the rectangle contains pixel (x#,y#).

A rectangle contains all pixels with horizontal pixel coordinates in range xmin# (inclusive) to xmax# (exclusive) and vertical coordinates ymin# (inclusive) to ymax# (exclusive).

Definition at line 382 of file GRect.h.

static int GRect::findangle ( const Orientations  orientation  )  [inline, static]

Definition at line 186 of file GRect.h.

int GRect::height (  )  const [inline]

Returns the rectangle height.

Definition at line 364 of file GRect.h.

int GRect::inflate ( int  dx,
int  dy 
)

Fatten the rectangle.

Both vertical sides of the rectangle are pushed apart by dx# units. Both horizontal sides of the rectangle are pushed apart by dy# units. Setting arguments dx# (resp. dy#) to a negative value reduces the rectangle horizontal (resp. vertical) size.

Definition at line 122 of file GRect.cpp.

int GRect::intersect ( const GRect &  rect1,
const GRect &  rect2 
)

Sets the rectangle to the intersection of rectangles rect1# and rect2#.

This function returns true if the intersection rectangle is not empty.

Definition at line 148 of file GRect.cpp.

int GRect::isempty (  )  const [inline]

Returns true if the rectangle is empty.

Definition at line 370 of file GRect.h.

int GRect::recthull ( const GRect &  rect1,
const GRect &  rect2 
)

Sets the rectangle to the smallest rectangle containing the points of both rectangles rect1# and rect2#.

This function returns true if the created rectangle is not empty.

Definition at line 161 of file GRect.cpp.

static Orientations GRect::rotate ( const int  angle,
Orientations  orientation 
) [inline, static]

Definition at line 178 of file GRect.h.

void GRect::scale ( float  xfactor,
float  yfactor 
)

Multiplies xmin, xmax by xfactor and ymin, ymax by yfactor and scales the rectangle.

Definition at line 204 of file GRect.cpp.

void GRect::scale ( float  factor  ) 

Multiplies xmin, ymin, xmax, ymax by factor and scales the rectangle.

Definition at line 195 of file GRect.cpp.

int GRect::translate ( int  dx,
int  dy 
)

Translate the rectangle.

The new rectangle is composed of all the points of the old rectangle translated by dx# units horizontally and dy# units vertically.

Definition at line 135 of file GRect.cpp.

int GRect::width (  )  const [inline]

Returns the rectangle width.

Definition at line 358 of file GRect.h.


Friends And Related Function Documentation

int operator!= ( const GRect &  r1,
const GRect &  r2 
) [friend]

Returns true if rectangles r1# and r2# are not equal.

Definition at line 394 of file GRect.h.

int operator== ( const GRect &  r1,
const GRect &  r2 
) [friend]

Returns true if rectangles r1# and r2# are equal.

Definition at line 108 of file GRect.cpp.


Member Data Documentation

int GRect::xmax

Maximal horizontal point coordinate of the rectangle.

Definition at line 248 of file GRect.h.

int GRect::xmin

Minimal horizontal point coordinate of the rectangle.

Definition at line 244 of file GRect.h.

int GRect::ymax

Maximal vertical point coordinate of the rectangle.

Definition at line 250 of file GRect.h.

int GRect::ymin

Minimal vertical point coordinate of the rectangle.

Definition at line 246 of file GRect.h.


The documentation for this class was generated from the following files:
  • GRect.h
  • GRect.cpp

kviewshell

Skip menu "kviewshell"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

API Reference

Skip menu "API Reference"
  • kviewshell
Generated for API Reference by doxygen 1.5.9
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal