Okular::NormalizedRect

Search for usage in LXR

#include <area.h>

Public Member Functions

 NormalizedRect ()
 
 NormalizedRect (const NormalizedRect &)
 
 NormalizedRect (const QRect rectangle, double xScale, double yScale)
 
 NormalizedRect (double left, double top, double right, double bottom)
 
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
 
QRectF geometryF (float xScale, float 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 188 of file area.h.

Constructor & Destructor Documentation

◆ NormalizedRect() [1/4]

NormalizedRect::NormalizedRect ( )

Creates a null normalized rectangle.

class NormalizedRect

See also
isNull()

Definition at line 117 of file area.cpp.

◆ NormalizedRect() [2/4]

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 125 of file area.cpp.

◆ NormalizedRect() [3/4]

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 134 of file area.cpp.

◆ NormalizedRect() [4/4]

NormalizedRect::NormalizedRect ( const NormalizedRect & )
default

Member Function Documentation

◆ center()

NormalizedPoint NormalizedRect::center ( ) const

Returns the center of the rectangle.

Since
0.10 (KDE 4.4)

Definition at line 220 of file area.cpp.

◆ contains()

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

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

Definition at line 160 of file area.cpp.

◆ distanceSqr()

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 387 of file area.h.

◆ fromQRectF()

NormalizedRect NormalizedRect::fromQRectF ( const QRectF & rect)
static

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

Definition at line 144 of file area.cpp.

◆ geometry()

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

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

Definition at line 232 of file area.cpp.

◆ geometryF()

QRectF NormalizedRect::geometryF ( float xScale,
float yScale ) const

Same functionality as geometry, but nothing is converted into int.

Definition at line 246 of file area.cpp.

◆ height()

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

Definition at line 412 of file area.h.

◆ intersects() [1/3]

bool NormalizedRect::intersects ( const NormalizedRect & other) const

Returns whether the normalized rectangle intersects the other normalized rectangle.

Definition at line 165 of file area.cpp.

◆ intersects() [2/3]

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 170 of file area.cpp.

◆ intersects() [3/3]

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 175 of file area.cpp.

◆ isBottom()

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 331 of file area.h.

◆ isBottomOrLevel()

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 349 of file area.h.

◆ isLeft()

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 367 of file area.h.

◆ isNull()

bool NormalizedRect::isNull ( ) const

Returns whether this normalized rectangle is a null normalized rect.

Definition at line 155 of file area.cpp.

◆ isRight()

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 376 of file area.h.

◆ isTop()

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 340 of file area.h.

◆ isTopOrLevel()

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 358 of file area.h.

◆ operator&()

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 199 of file area.cpp.

◆ operator=()

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

◆ operator==()

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

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

Definition at line 215 of file area.cpp.

◆ operator|()

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 180 of file area.cpp.

◆ operator|=()

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 190 of file area.cpp.

◆ roundedGeometry()

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 239 of file area.cpp.

◆ transform()

void NormalizedRect::transform ( const QTransform & matrix)

Transforms the normalized rectangle with the operations defined by matrix.

Definition at line 253 of file area.cpp.

◆ width()

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

Definition at line 406 of file area.h.

Member Data Documentation

◆ bottom

double Okular::NormalizedRect::bottom

The normalized bottom coordinate.

Definition at line 435 of file area.h.

◆ left

double Okular::NormalizedRect::left

The normalized left coordinate.

Definition at line 420 of file area.h.

◆ right

double Okular::NormalizedRect::right

The normalized right coordinate.

Definition at line 430 of file area.h.

◆ top

double Okular::NormalizedRect::top

The normalized top coordinate.

Definition at line 425 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-2024 The KDE developers.
Generated on Fri Nov 29 2024 11:47:54 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.