Mapper  0.9.0
API documentation
Namespaces | Classes | Functions
OpenOrienteering::Util Namespace Reference

A collection of GUI utility functions. More...

Namespaces

 Headline
 
 Marker
 
 SpacerItem
 
 SpinBox
 
 TristateCheckbox
 

Classes

struct  InputProperties
 Provides information about the properties of Mapper types for the purpose of customizing input widgets. More...
 
struct  InputProperties< MapCoordF >
 Provides information about the properties of MapCoordF for the purpose of customizing input widgets. More...
 
struct  InputProperties< RealMeters >
 Provides information about the type double representing real meters for the purpose of customizing input widgets. More...
 
struct  InputProperties< RotationalDegrees >
 Provides information about the type double representing a rotation angle for the purpose of customizing input widgets. More...
 
struct  RealMeters
 Identifies the type double representing real meters. More...
 
struct  RotationalDegrees
 Identifies the type double representing a rotation angle in degrees. More...
 

Functions

void showHelp (QWidget *dialog_parent, const char *filename_latin1, const char *anchor_latin1)
 Show the manual in Qt assistant. More...
 
void showHelp (QWidget *dialog_parent, const char *file_and_anchor_latin1="index.html")
 Show the manual in Qt assistant. More...
 
void showHelp (QWidget *dialog_parent, const QString &file_and_anchor)
 Show the manual in Qt assistant. More...
 
QString makeWhatThis (const char *reference_latin1)
 Creates a What's-this text "See more" linking to the given page and fragment in the manual. More...
 
QString plainText (QString maybe_markup)
 Remove any HTML markup from the input text. More...
 
qreal mmToPixelPhysical (qreal millimeters)
 Converts millimeters to pixels using the physical dpi setting of Mapper's settings. More...
 
qreal pixelToMMPhysical (qreal pixels)
 Inverse of mmToPixelPhysical(). More...
 
qreal mmToPixelLogical (qreal millimeters)
 Converts millimeters to pixels using the "logical" dpi setting of the operating system. More...
 
qreal pixelToMMLogical (qreal pixels)
 Inverse of mmToPixelLogical(). More...
 
bool isAntialiasingRequired ()
 Returns true for low-dpi screens, false for high-dpi screens. More...
 
bool isAntialiasingRequired (qreal ppi)
 Returns true for low-dpi screens, false for high-dpi screens. More...
 
const char * codepageForLanguage (const QString &language_name)
 Determines the name of the 8-bit legacy codepage for a language. More...
 
QTextCodeccodecForName (const char *name)
 Determines the codec for a given name. More...
 
void hatchingOperation (const QRectF &extent, double spacing, double offset, double rotation, std::function< void(const QPointF &, const QPointF &)> &process_line)
 Generates a pattern of parallel lines inside the box given by extent. More...
 
void gridOperation (const QRectF &extent, double horz_spacing, double vert_spacing, double horz_offset, double vert_offset, double rotation, std::function< void(const QPointF &, const QPointF &)> &process_line)
 Generates a grid of lines inside the given box. More...
 
bool pointsFormCorner (const MapCoord &point1, const MapCoord &anchor_point, const MapCoord &point2, qreal quantum_size)
 Tests whether three points form what we would call a corner. More...
 

Detailed Description

A collection of GUI utility functions.

Function Documentation

◆ codecForName()

QTextCodec * OpenOrienteering::Util::codecForName ( const char *  name)

Determines the codec for a given name.

This function wraps QTextCodec::codecForName. Other than that function, it will try to lookup the codepage name for the current locale if the name is "Default" (case sensitive). It may return nullptr.

◆ codepageForLanguage()

const char * OpenOrienteering::Util::codepageForLanguage ( const QString language_name)

Determines the name of the 8-bit legacy codepage for a language.

This function accepts language names as returned by QLocale::name(). Characters after the two letter language code are ignored.

If the language is unknown, it returns "Windows-1252".

Parameters
language_nameA lowercase, two-letter ISO 639 language code
Returns
A Windows codepage name.

◆ gridOperation()

void OpenOrienteering::Util::gridOperation ( const QRectF extent,
double  horz_spacing,
double  vert_spacing,
double  horz_offset,
double  vert_offset,
double  rotation,
std::function< void(const QPointF &, const QPointF &)> &  process_line 
)
inline

Generates a grid of lines inside the given box.

See also
hatchingOperation()
Parameters
extentExtent of the box.
horz_spacingHorizontal spacing of the lines.
vert_spacingVertical spacing of the lines.
horz_offsetHorizontal offset of the first line from the origin.
vert_offsetVertical offset of the first line from the origin.
rotationAngle used to rotate the lines.
process_lineFunction object which will be called with start and end point for each line.

◆ hatchingOperation()

void OpenOrienteering::Util::hatchingOperation ( const QRectF extent,
double  spacing,
double  offset,
double  rotation,
std::function< void(const QPointF &, const QPointF &)> &  process_line 
)

Generates a pattern of parallel lines inside the box given by extent.

See also
gridOperation()
Parameters
extentExtent of the box.
spacingSpacing of the lines.
offsetOffset of the first line from the origin.
rotationAngle used to rotate the lines.
process_lineFunction object which will be called with start and end point for each line.

◆ isAntialiasingRequired() [1/2]

bool OpenOrienteering::Util::isAntialiasingRequired ( )

Returns true for low-dpi screens, false for high-dpi screens.

◆ isAntialiasingRequired() [2/2]

bool OpenOrienteering::Util::isAntialiasingRequired ( qreal  ppi)

Returns true for low-dpi screens, false for high-dpi screens.

◆ makeWhatThis()

QString OpenOrienteering::Util::makeWhatThis ( const char *  reference_latin1)

Creates a What's-this text "See more" linking to the given page and fragment in the manual.

◆ mmToPixelLogical()

qreal OpenOrienteering::Util::mmToPixelLogical ( qreal  millimeters)

Converts millimeters to pixels using the "logical" dpi setting of the operating system.

This should be used to calculate sizes of UI elements.

See also
mmToPixelPhysical()

◆ mmToPixelPhysical()

qreal OpenOrienteering::Util::mmToPixelPhysical ( qreal  millimeters)

Converts millimeters to pixels using the physical dpi setting of Mapper's settings.

This should be used to calculate sizes of map elements.

See also
mmToPixelLogical()

◆ pixelToMMLogical()

qreal OpenOrienteering::Util::pixelToMMLogical ( qreal  pixels)

Inverse of mmToPixelLogical().

◆ pixelToMMPhysical()

qreal OpenOrienteering::Util::pixelToMMPhysical ( qreal  pixels)

Inverse of mmToPixelPhysical().

◆ plainText()

QString OpenOrienteering::Util::plainText ( QString  maybe_markup)

Remove any HTML markup from the input text.

See also
QTextDocument::toPlainText

◆ pointsFormCorner()

bool OpenOrienteering::Util::pointsFormCorner ( const MapCoord point1,
const MapCoord anchor_point,
const MapCoord point2,
qreal  quantum_size 
)

Tests whether three points form what we would call a corner.

The function returns true when point2 lies at least quantum_size from continuation of line from point1 to anchor_point. quantum_size parameter is essential for use of this function in GUI code as for various zoom levels point1 position get quantized with varying step size.

Parameters
point1First point on a line.
anchor_pointPoint that is being tested as corner candidate.
point2Final point on potentially bent line.
quantum_sizeHow far can point2 lie from the line defined by point1–anchor to be considered unaligned with the two other points.
Returns
True if point2 is further than quantum_size from the line defined by point1–anchor_point or point2 is on the same side of anchor_point as point1.

◆ showHelp() [1/3]

void OpenOrienteering::Util::showHelp ( QWidget dialog_parent,
const char *  filename_latin1,
const char *  anchor_latin1 
)

Show the manual in Qt assistant.

Parameters
filename_latin1the name of the manual page html file
anchor_latin1the anchor in the specified file to jump to

◆ showHelp() [2/3]

void OpenOrienteering::Util::showHelp ( QWidget dialog_parent,
const char *  file_and_anchor_latin1 = "index.html" 
)

Show the manual in Qt assistant.

The anchor may be left out or given with the filename.

Parameters
file_and_anchor_latin1the name of the manual page html file, optionally including an anchor

◆ showHelp() [3/3]

void OpenOrienteering::Util::showHelp ( QWidget dialog_parent,
const QString file_and_anchor 
)

Show the manual in Qt assistant.

The anchor may be left out or given with the filename.

Parameters
file_and_anchorthe name of the manual page html file, optionally including an anchor