Mapper  0.9.0
API documentation
Public Types | Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Friends | List of all members
OpenOrienteering::TextSymbol Class Reference

Symbol for text, can be applied to TextObjects. More...

#include <text_symbol.h>

Inheritance diagram for OpenOrienteering::TextSymbol:
Inheritance graph
[legend]
Collaboration diagram for OpenOrienteering::TextSymbol:
Collaboration graph
[legend]

Public Types

enum  FramingMode { NoFraming = 0, LineFraming = 1, ShadowFraming = 2 }
 Modes for text framing. More...
 
- Public Types inherited from OpenOrienteering::Symbol
enum  Type {
  Point = 1, Line = 2, Area = 4, Text = 8,
  Combined = 16, NoSymbol = 0, AllSymbols = Point | Line | Area | Text | Combined
}
 Enumeration of all possible symbol types. More...
 
enum  RenderableOption { RenderBaselines = 1 << 0, RenderAreasHatched = 1 << 1, RenderNormal = 0 }
 RenderableOptions denominate variations in painting symbols. More...
 

Public Member Functions

 TextSymbol ()
 Creates an empty text symbol. More...
 
 ~TextSymbol () override
 
void createRenderables (const Object *object, const VirtualCoordVector &coords, ObjectRenderables &output, Symbol::RenderableOptions options) const override
 Creates renderables for a generic object. More...
 
void createBaselineRenderables (const TextObject *text_object, const VirtualCoordVector &coords, ObjectRenderables &output) const
 
void createLineBelowRenderables (const Object *object, ObjectRenderables &output) const
 
void colorDeletedEvent (const MapColor *color) override
 Called when a color is removed from the map. More...
 
bool containsColor (const MapColor *color) const override
 Returns if the given color is used by this symbol. More...
 
const MapColorguessDominantColor () const override
 Returns the dominant color of this symbol. More...
 
void replaceColors (const MapColorMap &color_map) override
 Replaces colors used by this symbol. More...
 
void scale (double factor) override
 Scales the symbol. More...
 
void updateQFont ()
 Updates the internal QFont from the font settings. More...
 
double calculateInternalScaling () const
 Calculates the factor to convert from the real font size to the internal font size. More...
 
const MapColorgetColor () const
 
void setColor (const MapColor *color)
 
const QStringgetFontFamily () const
 
double getFontSize () const
 
bool isBold () const
 
bool isItalic () const
 
bool isUnderlined () const
 
float getLineSpacing () const
 
double getParagraphSpacing () const
 
double getCharacterSpacing () const
 
bool usesKerning () const
 
QString getIconText () const
 
bool usesFraming () const
 
const MapColorgetFramingColor () const
 
int getFramingMode () const
 
int getFramingLineHalfWidth () const
 
int getFramingShadowXOffset () const
 
int getFramingShadowYOffset () const
 
bool hasLineBelow () const
 
const MapColorgetLineBelowColor () const
 
double getLineBelowWidth () const
 
double getLineBelowDistance () const
 
int getNumCustomTabs () const
 
int getCustomTab (int index) const
 
const QFontgetQFont () const
 
const QFontMetricsFgetFontMetrics () const
 
double getNextTab (double pos) const
 
SymbolPropertiesWidgetcreatePropertiesWidget (SymbolSettingDialog *dialog) override
 Creates a properties widget for the symbol. More...
 
- Public Member Functions inherited from OpenOrienteering::Symbol
 Symbol (Type type) noexcept
 
virtual ~Symbol ()
 
Symboloperator= (const Symbol &)=delete
 
Symboloperator= (Symbol &&)=delete
 
virtual bool validate () const
 
bool equals (const Symbol *other, Qt::CaseSensitivity case_sensitivity=Qt::CaseSensitive) const
 Checks for equality to the other symbol. More...
 
bool stateEquals (const Symbol *other) const
 Checks protected/hidden state for equality to the other symbol. More...
 
Type getType () const
 Returns the type of the symbol. More...
 
const PointSymbolasPoint () const
 Case to PointSymbol with type checking. More...
 
PointSymbolasPoint ()
 Case to PointSymbol with type checking. More...
 
const LineSymbolasLine () const
 Case to LineSymbol with type checking. More...
 
LineSymbolasLine ()
 Case to LineSymbol with type checking. More...
 
const AreaSymbolasArea () const
 Case to AreaSymbol with type checking. More...
 
AreaSymbolasArea ()
 Case to AreaSymbol with type checking. More...
 
const TextSymbolasText () const
 Case to TextSymbol with type checking. More...
 
TextSymbolasText ()
 Case to TextSymbol with type checking. More...
 
const CombinedSymbolasCombined () const
 Case to CombinedSymbol with type checking. More...
 
CombinedSymbolasCombined ()
 Case to CombinedSymbol with type checking. More...
 
virtual TypeCombination getContainedTypes () const
 Returns the combined bitmask of all symbol types this symbol contains. More...
 
bool isTypeCompatibleTo (const Object *object) const
 Checks if the symbol can be applied to the given object. More...
 
bool numberEquals (const Symbol *other) const
 Returns if the symbol numbers are exactly equal. More...
 
bool numberEqualsRelaxed (const Symbol *other) const
 Returns if the symbol numbers are equal, ignoring trailing zeros. More...
 
void save (QXmlStreamWriter &xml, const Map &map) const
 Saves the symbol in xml format. More...
 
virtual bool loadingFinishedEvent (Map *map)
 Called when loading the map is finished. More...
 
virtual void createRenderables (const PathObject *object, const PathPartVector &path_parts, ObjectRenderables &output, Symbol::RenderableOptions options) const
 Creates renderables for a path object. More...
 
virtual void createBaselineRenderables (const PathObject *object, const PathPartVector &path_parts, ObjectRenderables &output, const MapColor *color) const
 Creates baseline renderables for a path object. More...
 
virtual bool symbolChangedEvent (const Symbol *old_symbol, const Symbol *new_symbol)
 Called when a symbol was changed, replaced, or removed. More...
 
virtual bool containsSymbol (const Symbol *symbol) const
 Returns true if the given symbol is referenced by this symbol. More...
 
QImage getCustomIcon () const
 Returns the custom symbol icon. More...
 
void setCustomIcon (const QImage &image)
 Sets a custom symbol icon. More...
 
QImage getIcon (const Map *map) const
 Returns the symbol's icon. More...
 
QImage createIcon (const Map &map, int side_length, bool antialiasing=true, qreal zoom=0) const
 Creates a symbol icon with the given side length (pixels). More...
 
void resetIcon ()
 Clear the symbol's cached icon. More...
 
virtual qreal dimensionForIcon () const
 Returns the dimension which shall considered when scaling the icon. More...
 
virtual qreal calculateLargestLineExtent () const
 Returns the largest extent of all primitive lines which are part of the symbol. More...
 
const QStringgetName () const
 Returns the symbol name. More...
 
QString getPlainTextName () const
 Returns the symbol name with all HTML markup stripped. More...
 
void setName (const QString &new_name)
 Sets the symbol name. More...
 
QString getNumberAsString () const
 Returns the symbol number as string. More...
 
int getNumberComponent (int i) const
 Returns the i-th component of the symbol number as int. More...
 
void setNumberComponent (int i, int new_number)
 Sets the i-th component of the symbol number. More...
 
const QStringgetDescription () const
 Returns the symbol description. More...
 
void setDescription (const QString &new_description)
 Sets the symbol description. More...
 
bool isHelperSymbol () const
 Returns if this is a helper symbol (which is not printed in the final map). More...
 
void setIsHelperSymbol (bool value)
 Sets if this is a helper symbol, see isHelperSymbol(). More...
 
bool isHidden () const
 Returns if this symbol is hidden. More...
 
void setHidden (bool value)
 Sets the hidden state of this symbol. More...
 
bool isProtected () const
 Returns if this symbol is protected. More...
 
void setProtected (bool value)
 Sets the protected state of this symbol. More...
 
bool isRotatable () const
 Returns if objects with this symbol can be rotated in arbitrary directions. More...
 

Static Public Attributes

static constexpr qreal internal_point_size = 256
 
- Static Public Attributes inherited from OpenOrienteering::Symbol
static constexpr auto number_components = 3u
 Number of components of symbol numbers. More...
 

Protected Member Functions

 TextSymbol (const TextSymbol &proto)
 
TextSymbolduplicate () const override
 
void saveImpl (QXmlStreamWriter &xml, const Map &map) const override
 Must be overridden to save type-specific symbol properties. More...
 
bool loadImpl (QXmlStreamReader &xml, const Map &map, SymbolDictionary &symbol_dict, int version) override
 Must be overridden to load type-specific symbol properties. More...
 
bool equalsImpl (const Symbol *other, Qt::CaseSensitivity case_sensitivity) const override
 Must be overridden to compare specific attributes. More...
 
- Protected Member Functions inherited from OpenOrienteering::Symbol
 Symbol (const Symbol &proto)
 
void setRotatable (bool value)
 Sets the rotatability state of the symbol. More...
 

Protected Attributes

QFont qfont
 
QFontMetricsF metrics
 
QString font_family
 
QString icon_text
 
const MapColorcolor
 
const MapColorframing_color
 
const MapColorline_below_color
 
std::vector< int > custom_tabs
 
double tab_interval
 
float line_spacing
 default tab interval length in text coordinates More...
 
float character_spacing
 
int font_size
 
int paragraph_spacing
 
int framing_mode
 
int framing_line_half_width
 
int framing_shadow_x_offset
 
int framing_shadow_y_offset
 
int line_below_width
 
int line_below_distance
 
bool bold
 
bool italic
 
bool underline
 
bool kerning
 
bool framing
 
bool line_below
 

Friends

class TextSymbolSettings
 
class PointSymbolEditorWidget
 
class OCAD8FileImport
 

Additional Inherited Members

- Static Public Member Functions inherited from OpenOrienteering::Symbol
template<class S >
static std::unique_ptr< S > duplicate (const S &s)
 Duplicates a symbol. More...
 
static std::unique_ptr< Symbolload (QXmlStreamReader &xml, const Map &map, SymbolDictionary &symbol_dict, int version)
 Load the symbol in xml format. More...
 
static std::unique_ptr< SymbolmakeSymbolForType (Type type)
 Returns a newly created symbol of the given type. More...
 
static bool areTypesCompatible (Type a, Type b)
 Returns if the symbol types can be applied to the same object types. More...
 
static TypeCombination getCompatibleTypes (Type type)
 Returns a bitmask of all types which can be applied to the same objects as the given type. More...
 
static bool lessByNumber (const Symbol *s1, const Symbol *s2)
 Compares two symbols by number. More...
 
static bool lessByColorPriority (const Symbol *s1, const Symbol *s2)
 Compares two symbols by the dominant colors' priorities. More...
 

Detailed Description

Symbol for text, can be applied to TextObjects.

NOTE: Uses a hack to disable hinting for fonts: Uses a big internal font size, internal_point_size, where hinting is neglegible and scales it down for output. TODO: A maybe better solution would be to use FreeType directly.

Member Enumeration Documentation

◆ FramingMode

Modes for text framing.

Enumerator
NoFraming 

Only the text itself is displayed.

LineFraming 

The text path is drawn with a QPainter with active QPen in addition to the normal fill, resulting in a line around the letters.

ShadowFraming 

The text is drawn a second time with a slight offset to the main text, creating a shadow effect.

Constructor & Destructor Documentation

◆ TextSymbol() [1/2]

OpenOrienteering::TextSymbol::TextSymbol ( )

Creates an empty text symbol.

◆ ~TextSymbol()

OpenOrienteering::TextSymbol::~TextSymbol ( )
overridedefault

◆ TextSymbol() [2/2]

OpenOrienteering::TextSymbol::TextSymbol ( const TextSymbol proto)
explicitprotected

Member Function Documentation

◆ calculateInternalScaling()

double OpenOrienteering::TextSymbol::calculateInternalScaling ( ) const
inline

Calculates the factor to convert from the real font size to the internal font size.

◆ colorDeletedEvent()

void OpenOrienteering::TextSymbol::colorDeletedEvent ( const MapColor color)
overridevirtual

Called when a color is removed from the map.

Symbols need to remove all references to the given color when this event occurs.

Implements OpenOrienteering::Symbol.

◆ containsColor()

bool OpenOrienteering::TextSymbol::containsColor ( const MapColor color) const
overridevirtual

Returns if the given color is used by this symbol.

Implements OpenOrienteering::Symbol.

◆ createBaselineRenderables()

void OpenOrienteering::TextSymbol::createBaselineRenderables ( const TextObject text_object,
const VirtualCoordVector coords,
ObjectRenderables output 
) const

◆ createLineBelowRenderables()

void OpenOrienteering::TextSymbol::createLineBelowRenderables ( const Object object,
ObjectRenderables output 
) const

◆ createPropertiesWidget()

SymbolPropertiesWidget * OpenOrienteering::TextSymbol::createPropertiesWidget ( SymbolSettingDialog dialog)
overridevirtual

Creates a properties widget for the symbol.

Implements OpenOrienteering::Symbol.

◆ createRenderables()

void OpenOrienteering::TextSymbol::createRenderables ( const Object object,
const VirtualCoordVector coords,
ObjectRenderables output,
Symbol::RenderableOptions  options 
) const
overridevirtual

Creates renderables for a generic object.

This will create the renderables according to the object's properties and the given coordinates.

Implementations must use the coordinates (coords) instead of the object's coordinates.

Implements OpenOrienteering::Symbol.

◆ duplicate()

TextSymbol * OpenOrienteering::TextSymbol::duplicate ( ) const
overrideprotectedvirtual

◆ equalsImpl()

bool OpenOrienteering::TextSymbol::equalsImpl ( const Symbol other,
Qt::CaseSensitivity  case_sensitivity 
) const
overrideprotectedvirtual

Must be overridden to compare specific attributes.

Implements OpenOrienteering::Symbol.

◆ getCharacterSpacing()

double OpenOrienteering::TextSymbol::getCharacterSpacing ( ) const
inline

◆ getColor()

const MapColor* OpenOrienteering::TextSymbol::getColor ( ) const
inline

◆ getCustomTab()

int OpenOrienteering::TextSymbol::getCustomTab ( int  index) const
inline

◆ getFontFamily()

const QString& OpenOrienteering::TextSymbol::getFontFamily ( ) const
inline

◆ getFontMetrics()

const QFontMetricsF& OpenOrienteering::TextSymbol::getFontMetrics ( ) const
inline

◆ getFontSize()

double OpenOrienteering::TextSymbol::getFontSize ( ) const
inline

◆ getFramingColor()

const MapColor* OpenOrienteering::TextSymbol::getFramingColor ( ) const
inline

◆ getFramingLineHalfWidth()

int OpenOrienteering::TextSymbol::getFramingLineHalfWidth ( ) const
inline

◆ getFramingMode()

int OpenOrienteering::TextSymbol::getFramingMode ( ) const
inline

◆ getFramingShadowXOffset()

int OpenOrienteering::TextSymbol::getFramingShadowXOffset ( ) const
inline

◆ getFramingShadowYOffset()

int OpenOrienteering::TextSymbol::getFramingShadowYOffset ( ) const
inline

◆ getIconText()

QString OpenOrienteering::TextSymbol::getIconText ( ) const

◆ getLineBelowColor()

const MapColor* OpenOrienteering::TextSymbol::getLineBelowColor ( ) const
inline

◆ getLineBelowDistance()

double OpenOrienteering::TextSymbol::getLineBelowDistance ( ) const
inline

◆ getLineBelowWidth()

double OpenOrienteering::TextSymbol::getLineBelowWidth ( ) const
inline

◆ getLineSpacing()

float OpenOrienteering::TextSymbol::getLineSpacing ( ) const
inline

◆ getNextTab()

double OpenOrienteering::TextSymbol::getNextTab ( double  pos) const

◆ getNumCustomTabs()

int OpenOrienteering::TextSymbol::getNumCustomTabs ( ) const
inline

◆ getParagraphSpacing()

double OpenOrienteering::TextSymbol::getParagraphSpacing ( ) const
inline

◆ getQFont()

const QFont& OpenOrienteering::TextSymbol::getQFont ( ) const
inline

◆ guessDominantColor()

const MapColor * OpenOrienteering::TextSymbol::guessDominantColor ( ) const
overridevirtual

Returns the dominant color of this symbol.

If it is not possible to efficiently determine this color exactly, an appropriate heuristic should be used.

Implements OpenOrienteering::Symbol.

◆ hasLineBelow()

bool OpenOrienteering::TextSymbol::hasLineBelow ( ) const
inline

◆ isBold()

bool OpenOrienteering::TextSymbol::isBold ( ) const
inline

◆ isItalic()

bool OpenOrienteering::TextSymbol::isItalic ( ) const
inline

◆ isUnderlined()

bool OpenOrienteering::TextSymbol::isUnderlined ( ) const
inline

◆ loadImpl()

bool OpenOrienteering::TextSymbol::loadImpl ( QXmlStreamReader xml,
const Map map,
SymbolDictionary symbol_dict,
int  version 
)
overrideprotectedvirtual

Must be overridden to load type-specific symbol properties.

See also
saveImpl()

Returns false if the current xml tag does not belong to the symbol and should be skipped, true if the element has been read completely.

Implements OpenOrienteering::Symbol.

◆ replaceColors()

void OpenOrienteering::TextSymbol::replaceColors ( const MapColorMap color_map)
overridevirtual

Replaces colors used by this symbol.

Implements OpenOrienteering::Symbol.

◆ saveImpl()

void OpenOrienteering::TextSymbol::saveImpl ( QXmlStreamWriter xml,
const Map map 
) const
overrideprotectedvirtual

Must be overridden to save type-specific symbol properties.

The map pointer can be used to get persistent indices to any pointers on map data.

Implements OpenOrienteering::Symbol.

◆ scale()

void OpenOrienteering::TextSymbol::scale ( double  factor)
overridevirtual

Scales the symbol.

Implements OpenOrienteering::Symbol.

◆ setColor()

void OpenOrienteering::TextSymbol::setColor ( const MapColor color)
inline

◆ updateQFont()

void OpenOrienteering::TextSymbol::updateQFont ( )

Updates the internal QFont from the font settings.

◆ usesFraming()

bool OpenOrienteering::TextSymbol::usesFraming ( ) const
inline

◆ usesKerning()

bool OpenOrienteering::TextSymbol::usesKerning ( ) const
inline

Friends And Related Function Documentation

◆ OCAD8FileImport

friend class OCAD8FileImport
friend

◆ PointSymbolEditorWidget

friend class PointSymbolEditorWidget
friend

◆ TextSymbolSettings

friend class TextSymbolSettings
friend

Member Data Documentation

◆ bold

bool OpenOrienteering::TextSymbol::bold
protected

◆ character_spacing

float OpenOrienteering::TextSymbol::character_spacing
protected

◆ color

const MapColor* OpenOrienteering::TextSymbol::color
protected

◆ custom_tabs

std::vector<int> OpenOrienteering::TextSymbol::custom_tabs
protected

◆ font_family

QString OpenOrienteering::TextSymbol::font_family
protected

◆ font_size

int OpenOrienteering::TextSymbol::font_size
protected

◆ framing

bool OpenOrienteering::TextSymbol::framing
protected

◆ framing_color

const MapColor* OpenOrienteering::TextSymbol::framing_color
protected

◆ framing_line_half_width

int OpenOrienteering::TextSymbol::framing_line_half_width
protected

◆ framing_mode

int OpenOrienteering::TextSymbol::framing_mode
protected

◆ framing_shadow_x_offset

int OpenOrienteering::TextSymbol::framing_shadow_x_offset
protected

◆ framing_shadow_y_offset

int OpenOrienteering::TextSymbol::framing_shadow_y_offset
protected

◆ icon_text

QString OpenOrienteering::TextSymbol::icon_text
protected

◆ internal_point_size

constexpr qreal OpenOrienteering::TextSymbol::internal_point_size = 256
static

◆ italic

bool OpenOrienteering::TextSymbol::italic
protected

◆ kerning

bool OpenOrienteering::TextSymbol::kerning
protected

◆ line_below

bool OpenOrienteering::TextSymbol::line_below
protected

◆ line_below_color

const MapColor* OpenOrienteering::TextSymbol::line_below_color
protected

◆ line_below_distance

int OpenOrienteering::TextSymbol::line_below_distance
protected

◆ line_below_width

int OpenOrienteering::TextSymbol::line_below_width
protected

◆ line_spacing

float OpenOrienteering::TextSymbol::line_spacing
protected

default tab interval length in text coordinates

◆ metrics

QFontMetricsF OpenOrienteering::TextSymbol::metrics
protected

◆ paragraph_spacing

int OpenOrienteering::TextSymbol::paragraph_spacing
protected

◆ qfont

QFont OpenOrienteering::TextSymbol::qfont
protected

◆ tab_interval

double OpenOrienteering::TextSymbol::tab_interval
protected

◆ underline

bool OpenOrienteering::TextSymbol::underline
protected

The documentation for this class was generated from the following files: