Okular::NormalizedRect

#include <area.h>

Public Member Functions

 NormalizedRect ()
 
 NormalizedRect (double left, double top, double right, double bottom)
 
 NormalizedRect (const QRect &rectangle, double xScale, double yScale)
 
 NormalizedRect (const NormalizedRect &)
 
NormalizedPoint center () const
 
bool contains (double x, double y) const
 
double distanceSqr (double x, double y, double xScale, double yScale) const
 
QRect geometry (int xScale, int yScale) const
 
double height () const
 
bool intersects (const NormalizedRect &other) const
 
bool intersects (const NormalizedRect *other) const
 
bool intersects (double left, double top, double right, double bottom) const
 
bool isBottom (const NormalizedPoint &pt) const
 
bool isBottomOrLevel (const NormalizedPoint &pt) const
 
bool isLeft (const NormalizedPoint &pt) const
 
bool isNull () const
 
bool isRight (const NormalizedPoint &pt) const
 
bool isTop (const NormalizedPoint &pt) const
 
bool isTopOrLevel (const NormalizedPoint &pt) const
 
NormalizedRect operator& (const NormalizedRect &other) const
 
NormalizedRectoperator= (const NormalizedRect &other)
 
bool operator== (const NormalizedRect &other) const
 
NormalizedRect operator| (const NormalizedRect &other) const
 
NormalizedRectoperator|= (const NormalizedRect &other)
 
QRect roundedGeometry (int xScale, int yScale) const
 
void transform (const QTransform &matrix)
 
double width () const
 

Static Public Member Functions

static NormalizedRect fromQRectF (const QRectF &rect)
 

Public Attributes

double bottom
 
double left
 
double right
 
double top
 

Detailed Description

A NormalizedRect is a rectangle which can be defined by two NormalizedPoints.

It describes a rectangular area on a reference area of undefined size. For more information about the normalized coordinate system, see NormalizedPoint.

In Okular, NormalizedRect can be used e. g. to describe bounding boxes of TextEntity objects, and the highlight area of text selections.

If you need to describe an area which consists of multiple rectangles, you can use RegularAreaRect instead.

See also
NormalizedPoint, RegularAreaRect, TextEntity

Definition at line 191 of file area.h.

Constructor & Destructor Documentation

NormalizedRect::NormalizedRect ( )

Creates a null normalized rectangle.

class NormalizedRect

See also
isNull()

Definition at line 124 of file area.cpp.

NormalizedRect::NormalizedRect ( double  left,
double  top,
double  right,
double  bottom 
)

Creates a normalized rectangle with the normalized coordinates left, top, right, bottom.

If you need the x, y, width and height coordinates use the following formulas:

  • x = left
  • y = top
  • width = right - left
  • height = bottom - top
Note
The coordinates for left and top should be lower than right and bottom, respectively. At negative width or height the behaviour of some operations is undefined.

Definition at line 132 of file area.cpp.

NormalizedRect::NormalizedRect ( const QRect rectangle,
double  xScale,
double  yScale 
)

Creates a normalized rectangle from the given rectangle on a reference area of size xScale x yScale.

Note
The rectangle should have positive width and height. You can use e. g. QRect::normalize() to ensure this. At negative width or height the behaviour of some operations is undefined.

Definition at line 141 of file area.cpp.

NormalizedRect::NormalizedRect ( const NormalizedRect )
default

Member Function Documentation

NormalizedPoint NormalizedRect::center ( ) const

Returns the center of the rectangle.

Since
0.10 (KDE 4.4)

Definition at line 229 of file area.cpp.

bool NormalizedRect::contains ( double  x,
double  y 
) const

Returns whether the normalized rectangle contains the normalized point (x, y).

Definition at line 167 of file area.cpp.

double Okular::NormalizedRect::distanceSqr ( double  x,
double  y,
double  xScale,
double  yScale 
) const
inline

Returns the squared distance of the normalized point (x, y) to the closest edge, or 0 if the point is within the rectangle; using a reference area of size xScale x yScale.

Since
0.17 (KDE 4.11)

Definition at line 385 of file area.h.

NormalizedRect NormalizedRect::fromQRectF ( const QRectF rect)
static

Build a normalized rect from a QRectF, which already has normalized coordinates.

Definition at line 151 of file area.cpp.

QRect NormalizedRect::geometry ( int  xScale,
int  yScale 
) const

Returns the rectangle mapped to a reference area of xScale x yScale.

Definition at line 241 of file area.cpp.

double Okular::NormalizedRect::height ( ) const
inline
Since
1.4

Definition at line 408 of file area.h.

bool NormalizedRect::intersects ( const NormalizedRect other) const

Returns whether the normalized rectangle intersects the other normalized rectangle.

Definition at line 172 of file area.cpp.

bool NormalizedRect::intersects ( const NormalizedRect other) const

This is an overloaded member function, provided for convenience.

It behaves essentially like the above function.

Definition at line 177 of file area.cpp.

bool NormalizedRect::intersects ( double  left,
double  top,
double  right,
double  bottom 
) const

Returns whether the normalized rectangle intersects an other normalized rectangle, which is defined by left, top, right and bottom.

Definition at line 182 of file area.cpp.

bool Okular::NormalizedRect::isBottom ( const NormalizedPoint pt) const
inline

Returns true if the point pt is located below the bottom of the rectangle.

Since
0.14 (KDE 4.8)

Definition at line 329 of file area.h.

bool Okular::NormalizedRect::isBottomOrLevel ( const NormalizedPoint pt) const
inline

Returns true if the point pt is located below the top of the rectangle.

Since
0.14 (KDE 4.8)

Definition at line 347 of file area.h.

bool Okular::NormalizedRect::isLeft ( const NormalizedPoint pt) const
inline

Returns true if the point pt is located to the right of the left edge of the rectangle.

Since
0.14 (KDE 4.8)

Definition at line 365 of file area.h.

bool NormalizedRect::isNull ( ) const

Returns whether this normalized rectangle is a null normalized rect.

Definition at line 162 of file area.cpp.

bool Okular::NormalizedRect::isRight ( const NormalizedPoint pt) const
inline

Returns true if the point pt is located to the left of the right edge of the rectangle.

Since
0.14 (KDE 4.8)

Definition at line 374 of file area.h.

bool Okular::NormalizedRect::isTop ( const NormalizedPoint pt) const
inline

Returns true if the point pt is located above the top of the rectangle.

Since
0.14 (KDE 4.8)

Definition at line 338 of file area.h.

bool Okular::NormalizedRect::isTopOrLevel ( const NormalizedPoint pt) const
inline

Returns true if the point pt is located above the bottom of the rectangle.

Since
0.14 (KDE 4.8)

Definition at line 356 of file area.h.

NormalizedRect NormalizedRect::operator& ( const NormalizedRect other) const

Returns the intersection of this normalized rectangle with the specified other.

If the rects do not intersect then the result is a null rectangle.

Since
0.7 (KDE 4.1)

Definition at line 207 of file area.cpp.

NormalizedRect & NormalizedRect::operator= ( const NormalizedRect other)
default
bool NormalizedRect::operator== ( const NormalizedRect other) const

Returns whether the normalized rectangle is equal to the other normalized rectangle.

Definition at line 224 of file area.cpp.

NormalizedRect NormalizedRect::operator| ( const NormalizedRect other) const

Returns the normalized bounding rectangle of the normalized rectangle combined with the other normalized rectangle.

Definition at line 187 of file area.cpp.

NormalizedRect & NormalizedRect::operator|= ( const NormalizedRect other)

Sets the normalized rectangle to the normalized bounding rectangle of itself combined with the other normalized rectangle.

Definition at line 198 of file area.cpp.

QRect NormalizedRect::roundedGeometry ( int  xScale,
int  yScale 
) const

Same functionality as geometry, but the output is now rounded before typecasting to int.

Since
0.14 (KDE 4.8)

Definition at line 248 of file area.cpp.

void NormalizedRect::transform ( const QTransform matrix)

Transforms the normalized rectangle with the operations defined by matrix.

Definition at line 255 of file area.cpp.

double Okular::NormalizedRect::width ( ) const
inline
Since
1.4

Definition at line 402 of file area.h.

Member Data Documentation

double Okular::NormalizedRect::bottom

The normalized bottom coordinate.

Definition at line 431 of file area.h.

double Okular::NormalizedRect::left

The normalized left coordinate.

Definition at line 416 of file area.h.

double Okular::NormalizedRect::right

The normalized right coordinate.

Definition at line 426 of file area.h.

double Okular::NormalizedRect::top

The normalized top coordinate.

Definition at line 421 of file area.h.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Wed Sep 23 2020 22:36:14 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.