Mapper  0.9.0
API documentation
Public Types | Public Member Functions | Static Public Member Functions | List of all members
OpenOrienteering::SymbolRuleSet Class Reference

An utility for assigning symbols to objects based on queries. More...

#include <symbol_rule_set.h>

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

Public Types

enum  Option { ImportAllSymbols = 0x01, PreserveSymbolState = 0x02, KeepUnusedSymbols = 0x04, KeepUnusedColors = 0x08 }
 Options for importing of new colors and symbols in to a map. More...
 

Public Member Functions

SymbolRuleSet squeezed () const
 Returns a copy which has all NoAssignment items removed. More...
 
void sortByQuerySymbol ()
 Sorts the items by original symbol number and name if possible. More...
 
void sortByQueryKeyAndValue ()
 Sorts the items by tag query key and value if possible. More...
 
void matchQuerySymbolName (const Map &other_map)
 Sets the assigned symbols to match the original symbol name if possible. More...
 
void matchQuerySymbolNumber (const Map &other_map)
 Sets the assigned symbols to match the original symbol number if possible. More...
 
void writeCrt (QTextStream &stream) const
 Writes rules to a cross reference table (CRT) stream. More...
 
void operator() (Object *object) const
 Applies the matching rules to the object. More...
 
void apply (Map &object_map, const Map &symbol_set, Options options=0)
 Adds colors and symbols from the symbol map to the object map, and applies the rules. More...
 

Static Public Member Functions

static SymbolRuleSet forOriginalSymbols (const Map &map)
 Creates a list of NoAssignment items for the map's symbols as originals. More...
 
static SymbolRuleSet loadCrt (QTextStream &stream, const Map &replacement_map)
 Loads rules from a cross reference table (CRT) stream. More...
 

Detailed Description

An utility for assigning symbols to objects based on queries.

Member Enumeration Documentation

◆ Option

Options for importing of new colors and symbols in to a map.

Enumerator
ImportAllSymbols 
PreserveSymbolState 
KeepUnusedSymbols 
KeepUnusedColors 

Member Function Documentation

◆ apply()

void OpenOrienteering::SymbolRuleSet::apply ( Map object_map,
const Map symbol_set,
Options  options = 0 
)

Adds colors and symbols from the symbol map to the object map, and applies the rules.

Note that for efficiency, this should be called on a squeezed() map.

◆ forOriginalSymbols()

SymbolRuleSet OpenOrienteering::SymbolRuleSet::forOriginalSymbols ( const Map map)
static

Creates a list of NoAssignment items for the map's symbols as originals.

This function can be used to easily initialize variables of type SymbolRuleSet despite the absence of specialized constructors. Each item is initialized with an object query for a symbol from the map.

The created list is sorted by formatted symbol number.

◆ loadCrt()

SymbolRuleSet OpenOrienteering::SymbolRuleSet::loadCrt ( QTextStream stream,
const Map replacement_map 
)
static

Loads rules from a cross reference table (CRT) stream.

Each line in a CRT file takes the form:

REPLACEMENT pattern

where REPLACEMENT is the formatted number of the replacement symbol.

If the replacement symbol number exists, the import creates a new entry of type DefinedReplacement with the given replacement symbol. Otherwise, the replacement symbool is set to nullptr, and the type is set to NoReplacement. No other validation is performed.

The query is set to operand ObjectQuery::OperatorSearch and the tag value is set to the given pattern.

◆ matchQuerySymbolName()

void OpenOrienteering::SymbolRuleSet::matchQuerySymbolName ( const Map other_map)

Sets the assigned symbols to match the original symbol name if possible.

The symbol name is only available for queries with operator ObjectQuery::OperatorSymbol.

The symbols' types must be compatible.

◆ matchQuerySymbolNumber()

void OpenOrienteering::SymbolRuleSet::matchQuerySymbolNumber ( const Map other_map)

Sets the assigned symbols to match the original symbol number if possible.

The symbol number is only available for queries with operator ObjectQuery::OperatorSymbol.

The symbols' types must be compatible.

◆ operator()()

void OpenOrienteering::SymbolRuleSet::operator() ( Object object) const

Applies the matching rules to the object.

This operator can be used with Map::applyOnAllObjects etc.

Normally, you don't want to call this unless the new symbols are already part of the object's map. Note that for efficiency, this should be called on a squeezed() map.

See also
apply

◆ sortByQueryKeyAndValue()

void OpenOrienteering::SymbolRuleSet::sortByQueryKeyAndValue ( )

Sorts the items by tag query key and value if possible.

The tag key and value are only available for queries with operator ObjectQuery::OperatorIs, ObjectQuery::OperatorIsNot, and ObjectQuery::OperatorIs. Other rules are moved to the end.

◆ sortByQuerySymbol()

void OpenOrienteering::SymbolRuleSet::sortByQuerySymbol ( )

Sorts the items by original symbol number and name if possible.

The symbol number and name are only available for queries with operator ObjectQuery::OperatorSymbol. Other rules are moved to the end.

◆ squeezed()

SymbolRuleSet OpenOrienteering::SymbolRuleSet::squeezed ( ) const

Returns a copy which has all NoAssignment items removed.

◆ writeCrt()

void OpenOrienteering::SymbolRuleSet::writeCrt ( QTextStream stream) const

Writes rules to a cross reference table (CRT) stream.

Entries of type NoAssignment are skipped.

See also
loadCrt

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