Okular::NormalizedPoint
#include <area.h>
Public Member Functions  
NormalizedPoint ()  
NormalizedPoint (double x, double y)  
NormalizedPoint (int x, int y, int xScale, int yScale)  
NormalizedPoint (const NormalizedPoint &)  
double  distanceSqr (double x, double y, double xScale, double yScale) const 
NormalizedPoint &  operator= (const NormalizedPoint &) 
void  transform (const QTransform &matrix) 
Static Public Member Functions  
static double  distanceSqr (double x, double y, double xScale, double yScale, const NormalizedPoint &start, const NormalizedPoint &end) 
Public Attributes  
double  x 
double  y 
Detailed Description
NormalizedPoint is a helper class which stores the coordinates of a normalized point.
 Normalized Coordinate System
Normalized means that the coordinates are always between 0 and 1, unless the point shall be outside of the reference area.
The reference area is a rectangle, and all normalized points with coordinates of 0 or 1 describe its edges.
This allows to locate things on a reference area without knowing its (current or future) actual size. When the reference area is resized, all things which are described in normalized coordinates keep their proportional position on the area.
 Transformation to and from Normalized Coordinates
To transform normalized coordinates to coordinates on the reference area, just multiply them with the size of the reference area.
To get normalized coordinates from a point on the reference area, just divide its coordinates with the size of the reference area.
Many methods have parameters
xScale
andyScale
, these are equal to the size of the reference area.
 Normalized Coordinate System Applied to Pages
Okular uses a normalized coordinate system mainly to describe positions on pages. This is useful because pages can be shown in different sizes (zoom), but all objects shall keep their proportional position on the page.
Okular maps from page to normalized coordinates as follows:
 Left edge of the page: x = 0
 Right edge of the page: x = 1
 Top edge of the page: y = 0
 Bottom edge of the page: y = 1
 Example: Draw a Point on a Page
The point is given in normalized coordinates (0.5, 0.3).
If you want to draw it on a 800x600 page, just multiply the x coordinate (0.5) with the page width (800), and the y coordinate (0.3) with the page height (600). So, the point will be drawn on the page at (400, 180).
That allows you to zoom the page by just multiplying the normalized points with the zoomed page size.
 Example: Select Text on a Page using Mouse Events
The position of all glyphs and words is stored in normalized coordinates. (This is what TextPage actually does.) Mouse press and release events are given in page coordinates (400, 180) and (600, 450), while the page has a size of 800x600.
If you want to search all text between the mouse click and release event, you need their normalized coordinates. Just divide the x coordinates (400 and 600) by the page width (800), and the y coordinates (180 and 450) by the page height (600). So, you have to search for all glyphs between (0.5, 0.3) and (0.75, 0.75).
That allows you to process all glyphs and words without having to keep any of their positions in sync with the page.
 Geometric operations
NormalizedPoint supports basic geometric operations.
 You can transform it with a QTransform matrix.
 With the size of the reference area, you can calculate the squared absolute distance to another NormalizedPoint or a line of two NormalizedPoints.
NormalizedRect provides additional geometric operations for rectangles.
 See also
 NormalizedRect
Constructor & Destructor Documentation
NormalizedPoint::NormalizedPoint  (  ) 
NormalizedPoint::NormalizedPoint  (  double  x, 
double  y  
) 
NormalizedPoint::NormalizedPoint  (  int  x, 
int  y,  
int  xScale,  
int  yScale  
) 
Member Function Documentation
double NormalizedPoint::distanceSqr  (  double  x, 
double  y,  
double  xScale,  
double  yScale  
)  const 

static 

default 
void NormalizedPoint::transform  (  const QTransform &  matrix  ) 
Member Data Documentation
double Okular::NormalizedPoint::x 
double Okular::NormalizedPoint::y 
The documentation for this class was generated from the following files:
Documentation copyright © 19962021 The KDE developers.
Generated on Sat Oct 23 2021 22:36:42 by doxygen 1.8.11 written by Dimitri van Heesch, © 19972006
KDE's Doxygen guidelines are available online.