• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

kig

  • sources
  • kde-4.12
  • kdeedu
  • kig
  • misc
rect.h
Go to the documentation of this file.
1 
22 #ifndef RECT_H
23 #define RECT_H
24 
25 #include "coordinate.h"
26 
27 #include <qrect.h>
28 #include <kdebug.h>
29 
34 class Rect
35 {
36 public:
40  Rect( const Coordinate bottomLeft, const Coordinate topRight );
41  Rect( const Coordinate bottomLeft, const double width, const double height );
42  Rect( double xa, double ya, double width, double height );
43  Rect( const Rect& r );
44  Rect();
45  static Rect invalidRect();
46 
47 
48  bool valid();
49 
50  void setBottomLeft( const Coordinate p );
51  void setTopLeft( const Coordinate p );
52  void setTopRight( const Coordinate p );
53  void setBottomRight( const Coordinate p );
54  void setCenter( const Coordinate p );
55  void setLeft( const double p);
56  void setRight( const double p);
57  void setTop( const double p );
58  void setBottom( const double p );
59  void setWidth( const double w );
60  void setHeight( const double h );
64  void normalize();
68  void setContains( Coordinate p );
72  void moveBy( const Coordinate p );
76  Rect& operator+=( const Coordinate p ) { moveBy(p); return *this; }
80  void scale( const double r );
84  Rect& operator*=( const double r ) { scale(r); return *this; }
85  Rect& operator/=( const double r ) { scale(1/r); return *this; }
86 
91  void eat( const Rect& r );
92 
96  Rect& operator|=( const Rect& rhs ) { eat( rhs ); return *this; }
97 
104  Rect matchShape( const Rect& rhs, bool shrink = false ) const;
105 
106  QRect toQRect() const;
107  Coordinate bottomLeft() const;
108  Coordinate bottomRight() const;
109  Coordinate topLeft() const;
110  Coordinate topRight() const;
111  Coordinate center() const;
112  double left() const;
113  double right() const;
114  double bottom() const;
115  double top() const;
116  double width() const;
117  double height() const;
118  bool contains( const Coordinate& p ) const;
119  bool contains( const Coordinate& p, double allowed_miss ) const;
120  bool intersects( const Rect& p ) const;
121  Rect normalized() const;
122  friend kdbgstream& operator<<( kdbgstream& s, const Rect& t );
123 
124  static Rect fromQRect( const QRect& );
125 protected:
126  Coordinate mBottomLeft;
127  double mwidth;
128  double mheight;
129 };
130 
131 bool operator==( const Rect& r, const Rect& s );
132 kdbgstream& operator<<( kdbgstream& s, const Rect& t );
137 Rect operator|( const Rect& lhs, const Rect& rhs );
138 
139 #endif
140 
Rect::setTopLeft
void setTopLeft(const Coordinate p)
Definition: rect.cc:261
Rect::moveBy
void moveBy(const Coordinate p)
moves the rect while keeping the size constant...
Definition: rect.cc:144
Rect::normalize
void normalize()
this makes sure width and height are > 0 ...
Definition: rect.cc:130
Rect::mheight
double mheight
Definition: rect.h:128
Rect::setRight
void setRight(const double p)
Definition: rect.cc:103
Rect::width
double width() const
Definition: rect.cc:204
Rect::valid
bool valid()
Definition: rect.cc:300
Rect::bottomLeft
Coordinate bottomLeft() const
Definition: rect.cc:161
Rect::Rect
Rect()
Definition: rect.cc:70
Rect::left
double left() const
Definition: rect.cc:186
Rect
This file is part of Kig, a KDE program for Interactive Geometry...
Definition: rect.h:34
operator|
Rect operator|(const Rect &lhs, const Rect &rhs)
this operator returns a Rect that contains both the given rects.
Definition: rect.cc:267
Rect::operator/=
Rect & operator/=(const double r)
Definition: rect.h:85
Rect::setBottom
void setBottom(const double p)
Definition: rect.cc:108
Rect::eat
void eat(const Rect &r)
This expands the rect so that it contains r.
Definition: rect.cc:274
Rect::right
double right() const
Definition: rect.cc:190
operator==
bool operator==(const Rect &r, const Rect &s)
Definition: rect.cc:21
Rect::intersects
bool intersects(const Rect &p) const
Definition: rect.cc:230
Rect::invalidRect
static Rect invalidRect()
Definition: rect.cc:305
Rect::setHeight
void setHeight(const double h)
Definition: rect.cc:125
Coordinate
The Coordinate class is the basic class representing a 2D location by its x and y components...
Definition: coordinate.h:33
Rect::operator|=
Rect & operator|=(const Rect &rhs)
synonym for eat.
Definition: rect.h:96
Rect::fromQRect
static Rect fromQRect(const QRect &)
Definition: rect.cc:256
Rect::contains
bool contains(const Coordinate &p) const
Definition: rect.cc:222
Rect::topLeft
Coordinate topLeft() const
Definition: rect.cc:171
Rect::bottom
double bottom() const
Definition: rect.cc:194
Rect::setCenter
void setCenter(const Coordinate p)
Definition: rect.cc:91
Rect::center
Coordinate center() const
Definition: rect.cc:181
Rect::mwidth
double mwidth
Definition: rect.h:127
Rect::top
double top() const
Definition: rect.cc:199
Rect::matchShape
Rect matchShape(const Rect &rhs, bool shrink=false) const
return a rect which is a copy of this rect, but has an aspect ratio equal to rhs's one...
Definition: rect.cc:282
Rect::setContains
void setContains(Coordinate p)
this makes sure p is in the rect, extending it if necessary...
Definition: rect.cc:240
Rect::setWidth
void setWidth(const double w)
Definition: rect.cc:120
Rect::setTopRight
void setTopRight(const Coordinate p)
Definition: rect.cc:86
Rect::topRight
Coordinate topRight() const
Definition: rect.cc:176
Rect::scale
void scale(const double r)
scale: only the size changes, topLeft is kept where it is...
Definition: rect.cc:149
Rect::normalized
Rect normalized() const
Definition: rect.cc:249
Rect::operator<<
friend kdbgstream & operator<<(kdbgstream &s, const Rect &t)
Definition: rect.cc:28
Rect::setTop
void setTop(const double p)
Definition: rect.cc:115
Rect::height
double height() const
Definition: rect.cc:209
Rect::setLeft
void setLeft(const double p)
Definition: rect.cc:96
Rect::operator+=
Rect & operator+=(const Coordinate p)
synonym for moveBy...
Definition: rect.h:76
Rect::bottomRight
Coordinate bottomRight() const
Definition: rect.cc:166
coordinate.h
Rect::toQRect
QRect toQRect() const
Definition: rect.cc:156
operator<<
kdbgstream & operator<<(kdbgstream &s, const Rect &t)
Definition: rect.cc:28
Rect::mBottomLeft
Coordinate mBottomLeft
Definition: rect.h:126
Rect::setBottomRight
void setBottomRight(const Coordinate p)
Definition: rect.cc:81
Rect::setBottomLeft
void setBottomLeft(const Coordinate p)
Definition: rect.cc:76
Rect::operator*=
Rect & operator*=(const double r)
synonym for scale...
Definition: rect.h:84
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:35:40 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kig

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

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal