SUMO - Simulation of Urban MObility
polyfonts.c File Reference
#include <config.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <GL/gl.h>
#include "polyfonts.h"
#include "pfPSansBold16.h"

Go to the source code of this file.

Data Structures

struct  nameValue
 
struct  vertex
 

Macros

#define abs(a)   (((a)<0) ? -(a) : (a))
 
#define DtoR   (PI/180.0)
 
#define max(a, b)   (((a) > (b)) ? (a) : (b))
 
#define min(a, b)   (((a) < (b)) ? (a) : (b))
 
#define numWeights   (sizeof(weightOffset) / sizeof(vertex))
 
#define PI   (3.1415926535897932384626433)
 
#define RtoD   (180.0/PI)
 
#define sign(a)   (((a)<0) ? -1 : (a)>0 ? 1 : 0)
 
#define unfix(value)   ((SUMOReal)(value)) / ((SUMOReal)pfFixScale)
 

Functions

static int comp (const void *key, const void *target)
 
static int drawWideChar (wchar_t c)
 
static SUMOReal getCharAdvance (wchar_t c)
 
static int getCharBBox (wchar_t c, SUMOReal *minx, SUMOReal *miny, SUMOReal *maxx, SUMOReal *maxy)
 
static int getStringBox (char *c, SUMOReal *minx, SUMOReal *miny, SUMOReal *maxx, SUMOReal *maxy)
 
static int getStringBoxW (wchar_t *c, SUMOReal *minx, SUMOReal *miny, SUMOReal *maxx, SUMOReal *maxy)
 
static int lookupGlOp (char *op)
 
SUMOReal pfdkGetStringWidth (const char *c)
 
int pfDrawChar (wchar_t c)
 
int pfDrawString (const char *c)
 
int pfDrawStringW (wchar_t *c)
 
static pfglyphpfFindGlyph (pfglyph *glyphs, int numglyphs, pfglyph *find)
 
wchar_t pfGetChar (int g)
 
SUMOReal pfGetCharAdvance (wchar_t c)
 
SUMOReal pfGetCharAscent (wchar_t c)
 
int pfGetCharBBox (wchar_t c, SUMOReal *minx, SUMOReal *miny, SUMOReal *maxx, SUMOReal *maxy)
 
SUMOReal pfGetCharDescent (wchar_t c)
 
SUMOReal pfGetCharHeight (wchar_t c)
 
SUMOReal pfGetCharWidth (wchar_t c)
 
pffontpfGetCurrentFont ()
 
SUMOReal pfGetFontAscent ()
 
int pfGetFontBBox (SUMOReal *minx, SUMOReal *miny, SUMOReal *maxx, SUMOReal *maxy)
 
SUMOReal pfGetFontDescent ()
 
SUMOReal pfGetFontHeight ()
 
char * pfGetFontName ()
 
int pfGetFontNumGlyphs ()
 
SUMOReal pfGetFontWidth ()
 
static pfglyphpfGetGlyph (wchar_t c)
 
void pfGetPosition (SUMOReal *x, SUMOReal *y)
 
void pfSetAngleD (SUMOReal a)
 
void pfSetAngleR (SUMOReal a)
 
void pfSetCenter (int onOff)
 
int pfSetFont (pffont *f)
 
void pfSetPosition (SUMOReal x, SUMOReal y)
 
void pfSetScale (SUMOReal s)
 
int pfSetScaleBox (char *c, SUMOReal w, SUMOReal h)
 
int pfSetScaleBoxW (wchar_t *c, SUMOReal w, SUMOReal h)
 
void pfSetScaleXY (SUMOReal sx, SUMOReal sy)
 
void pfSetSkew (SUMOReal s)
 
void pfSetWeight (int w)
 
static SUMOReal pfSkew (SUMOReal x, SUMOReal y)
 
void pfUnloadFont (pffont *font)
 
static void validate (pffont *font)
 

Variables

static nameValue glPrims []
 
static int pfCenter = 0
 
static pffontpfCurrentFont = &pfPSansBold16
 
static pffontpfDefaultFont = &pfPSansBold16
 
static SUMOReal pfScaleX = 20.0
 
static SUMOReal pfScaleY = 20.0
 
static SUMOReal pfTextCos = 1.0
 
static SUMOReal pfTextSin = 0.0
 
static SUMOReal pfTextSkew = 0.0
 
static int pfTextWeight = 1
 
static SUMOReal pfTextX = 0.0
 
static SUMOReal pfTextY = 0.0
 
vertex weightOffset []
 

Macro Definition Documentation

#define DtoR   (PI/180.0)

Definition at line 63 of file polyfonts.c.

Referenced by pfSetAngleD().

#define max (   a,
 
)    (((a) > (b)) ? (a) : (b))

Definition at line 65 of file polyfonts.c.

Referenced by TplConvert::_2int(), TplConvert::_hex2int(), SUMOVehicleParserHelper::beginVTypeParsing(), CHRouter< E, V, PF >::buildContractionHierarchy(), TraCIServerAPI_Vehicle::commandDistanceRequest(), DijkstraRouterTT< MSEdge, SUMOVehicle, prohibited_withRestrictions< MSEdge, SUMOVehicle > >::compute(), DijkstraRouterEffort< MSEdge, SUMOVehicle, prohibited_withRestrictions< MSEdge, SUMOVehicle > >::compute(), AStarRouter< MSEdge, SUMOVehicle, prohibited_withRestrictions< MSEdge, SUMOVehicle > >::compute(), BulkStarRouter< E, V, PF >::compute(), CHRouter< E, V, PF >::compute(), computeRoutes(), TraCIServerAPI_Simulation::convertCartesianToRoadMap(), SPTree< CHRouter::CHInfo, CHRouter::CHConnection >::dijkstraTT(), PositionVector::distance(), MSLaneChanger::findCandidate(), NBEdge::firstIntersection(), MSActuatedTrafficLightLogic::gapControl(), GawronCalculator< R, E, V >::gawronF(), GawronCalculator< R, E, V >::gawronG(), LogitCalculator< R, E, V >::getBetaForCLogit(), MSLane::getCriticalLeader(), MSRoute::getDistanceBetween(), MSVehicle::getDistanceToPosition(), MSLane::getFollowerOnConsecutive(), MSEdge::getFreeLane(), RODFDetectorFlows::getMaxDetectorFlow(), GUITexturesHelper::getMaxTextureSize(), NBContHelper::same_connection_edge_sorter::getMinMaxRelAngles(), GUISUMOAbstractView::getObjectAtPosition(), getStringBox(), getStringBoxW(), LogitCalculator< R, E, V >::getThetaForCLogit(), PositionVector::indexOfClosest(), PositionVector::insertAtClosest(), NBContHelper::maxSpeed(), VectorHelper< T >::maxValue(), VectorHelper< T >::minValue(), NIImporter_OpenStreetMap::EdgesHandler::myStartElement(), PositionVector::nearest_offset_to_point2D(), GUIParameterTracker::onCmdSave(), MSPModel_Striping::PState::otherStripe(), pfSetSkew(), pfSetWeight(), BulkStarRouter< E, V, PF >::prepare(), TraCIServerAPI_Vehicle::processGet(), TraCIServerAPI_Vehicle::processSet(), SPTree< CHRouter::CHInfo, CHRouter::CHConnection >::rebuildFrom(), MSDevice_Routing::reroute(), DijkstraRouterEffort< E, V, PF >::EdgeInfo::reset(), DijkstraRouterTT< E, V, PF >::EdgeInfo::reset(), BulkStarRouter< E, V, PF >::EdgeInfo::reset(), CHRouter< E, V, PF >::EdgeInfo::reset(), AStarRouter< E, V, PF >::EdgeInfo::reset(), CHRouter< E, V, PF >::CHInfo::reset(), MSFrame::setMSGlobals(), MFXAddEditTypedTable::setNumberCellParams(), CHRouter< E, V, PF >::Unidirectional::step(), MSPModel_Striping::PState::stripe(), PositionVector::transformToVectorCoordinates(), MSActuatedTrafficLightLogic::trySwitch(), CHRouter< E, V, PF >::tryUpdateFront(), SUMOVTypeParameter::write(), and GeoConvHelper::x2cartesian_const().

#define numWeights   (sizeof(weightOffset) / sizeof(vertex))

Definition at line 129 of file polyfonts.c.

Referenced by pfSetWeight().

#define RtoD   (180.0/PI)

Definition at line 62 of file polyfonts.c.

#define sign (   a)    (((a)<0) ? -1 : (a)>0 ? 1 : 0)
#define unfix (   value)    ((SUMOReal)(value)) / ((SUMOReal)pfFixScale)

Definition at line 136 of file polyfonts.c.

Referenced by drawWideChar().

Function Documentation

static int comp ( const void *  key,
const void *  target 
)
static

Definition at line 820 of file polyfonts.c.

References pfglyph::glyph.

Referenced by pfFindGlyph().

static SUMOReal getCharAdvance ( wchar_t  c)
static

Definition at line 855 of file polyfonts.c.

References pfglyph::advance, and pfGetGlyph().

Referenced by getStringBox(), and getStringBoxW().

static int getCharBBox ( wchar_t  c,
SUMOReal minx,
SUMOReal miny,
SUMOReal maxx,
SUMOReal maxy 
)
static
static int getStringBox ( char *  c,
SUMOReal minx,
SUMOReal miny,
SUMOReal maxx,
SUMOReal maxy 
)
static

Definition at line 558 of file polyfonts.c.

References getCharAdvance(), getCharBBox(), max, min, and SUMOReal.

Referenced by pfSetScaleBox().

static int getStringBoxW ( wchar_t *  c,
SUMOReal minx,
SUMOReal miny,
SUMOReal maxx,
SUMOReal maxy 
)
static

Definition at line 598 of file polyfonts.c.

References getCharAdvance(), getCharBBox(), max, min, and SUMOReal.

Referenced by pfSetScaleBoxW().

static int lookupGlOp ( char *  op)
static

Definition at line 188 of file polyfonts.c.

References glPrims.

int pfDrawChar ( wchar_t  c)

Definition at line 1058 of file polyfonts.c.

References drawWideChar().

int pfDrawStringW ( wchar_t *  c)

Definition at line 1093 of file polyfonts.c.

References drawWideChar().

static pfglyph* pfFindGlyph ( pfglyph glyphs,
int  numglyphs,
pfglyph find 
)
static

Definition at line 830 of file polyfonts.c.

References comp().

Referenced by pfGetGlyph().

wchar_t pfGetChar ( int  g)

Definition at line 801 of file polyfonts.c.

References pfglyph::glyph, pffont::glyphs, and pffont::numglyphs.

SUMOReal pfGetCharAdvance ( wchar_t  c)

Definition at line 869 of file polyfonts.c.

References pfglyph::advance, pfGetGlyph(), and pfScaleX.

Referenced by pfdkGetStringWidth().

SUMOReal pfGetCharAscent ( wchar_t  c)

Definition at line 946 of file polyfonts.c.

References pfGetCharBBox(), and SUMOReal.

int pfGetCharBBox ( wchar_t  c,
SUMOReal minx,
SUMOReal miny,
SUMOReal maxx,
SUMOReal maxy 
)
SUMOReal pfGetCharDescent ( wchar_t  c)

Definition at line 960 of file polyfonts.c.

References pfGetCharBBox(), and SUMOReal.

SUMOReal pfGetCharHeight ( wchar_t  c)

Definition at line 918 of file polyfonts.c.

References pfGetCharBBox(), and SUMOReal.

SUMOReal pfGetCharWidth ( wchar_t  c)

Definition at line 932 of file polyfonts.c.

References pfGetCharBBox(), and SUMOReal.

pffont* pfGetCurrentFont ( )

Definition at line 692 of file polyfonts.c.

References pfCurrentFont.

SUMOReal pfGetFontAscent ( )

Definition at line 761 of file polyfonts.c.

References pfGetFontBBox(), and SUMOReal.

int pfGetFontBBox ( SUMOReal minx,
SUMOReal miny,
SUMOReal maxx,
SUMOReal maxy 
)
SUMOReal pfGetFontDescent ( )

Definition at line 775 of file polyfonts.c.

References pfGetFontBBox(), and SUMOReal.

SUMOReal pfGetFontHeight ( )

Definition at line 733 of file polyfonts.c.

References pfGetFontBBox(), and SUMOReal.

char* pfGetFontName ( )

Definition at line 678 of file polyfonts.c.

References pffont::name.

int pfGetFontNumGlyphs ( )

Definition at line 789 of file polyfonts.c.

References pffont::numglyphs.

SUMOReal pfGetFontWidth ( )

Definition at line 747 of file polyfonts.c.

References pfGetFontBBox(), and SUMOReal.

static pfglyph * pfGetGlyph ( wchar_t  c)
static
void pfGetPosition ( SUMOReal x,
SUMOReal y 
)

Definition at line 488 of file polyfonts.c.

References pfTextX, and pfTextY.

void pfSetAngleD ( SUMOReal  a)

Definition at line 518 of file polyfonts.c.

References DtoR, and pfSetAngleR().

void pfSetAngleR ( SUMOReal  a)

Definition at line 510 of file polyfonts.c.

References pfTextCos, and pfTextSin.

Referenced by pfSetAngleD().

void pfSetCenter ( int  onOff)

Definition at line 525 of file polyfonts.c.

References pfCenter.

int pfSetFont ( pffont f)

Definition at line 152 of file polyfonts.c.

int pfSetScaleBox ( char *  c,
SUMOReal  w,
SUMOReal  h 
)

Definition at line 638 of file polyfonts.c.

References getStringBox(), pfSetScaleXY(), and SUMOReal.

int pfSetScaleBoxW ( wchar_t *  c,
SUMOReal  w,
SUMOReal  h 
)

Definition at line 658 of file polyfonts.c.

References getStringBoxW(), pfSetScaleXY(), and SUMOReal.

void pfSetSkew ( SUMOReal  s)

Definition at line 496 of file polyfonts.c.

References max, min, and pfTextSkew.

void pfSetWeight ( int  w)

Definition at line 503 of file polyfonts.c.

References max, min, numWeights, and pfTextWeight.

static SUMOReal pfSkew ( SUMOReal  x,
SUMOReal  y 
)
static

Definition at line 145 of file polyfonts.c.

References pfTextSkew.

Referenced by drawWideChar(), pfGetCharBBox(), and pfGetFontBBox().

void pfUnloadFont ( pffont font)

Definition at line 256 of file polyfonts.c.

References pffont::glyphs, pffont::loaded, pffont::name, and pffont::numglyphs.

static void validate ( pffont font)
static

Variable Documentation

nameValue glPrims[]
static
Initial value:
=
{
{"GL_POINTS", GL_POINTS},
{"GL_LINES", GL_LINES},
{"GL_LINE_LOOP", GL_LINE_LOOP},
{"GL_LINE_STRIP", GL_LINE_STRIP},
{"GL_TRIANGLES", GL_TRIANGLES},
{"GL_TRIANGLE_STRIP", GL_TRIANGLE_STRIP},
{"GL_TRIANGLE_FAN", GL_TRIANGLE_FAN},
{"GL_QUADS", GL_QUADS},
{"GL_QUAD_STRIP", GL_QUAD_STRIP},
{"GL_POLYGON", GL_POLYGON},
}

Definition at line 172 of file polyfonts.c.

Referenced by lookupGlOp().

int pfCenter = 0
static

Definition at line 134 of file polyfonts.c.

Referenced by drawWideChar(), and pfSetCenter().

pffont* pfCurrentFont = &pfPSansBold16
static

Definition at line 83 of file polyfonts.c.

Referenced by pfGetCurrentFont().

pffont* pfDefaultFont = &pfPSansBold16
static

Definition at line 84 of file polyfonts.c.

SUMOReal pfScaleX = 20.0
static
SUMOReal pfScaleY = 20.0
static

Definition at line 103 of file polyfonts.c.

Referenced by drawWideChar(), pfGetCharBBox(), pfGetFontBBox(), pfSetScale(), and pfSetScaleXY().

SUMOReal pfTextCos = 1.0
static

Definition at line 132 of file polyfonts.c.

Referenced by drawWideChar(), and pfSetAngleR().

SUMOReal pfTextSin = 0.0
static

Definition at line 131 of file polyfonts.c.

Referenced by drawWideChar(), and pfSetAngleR().

SUMOReal pfTextSkew = 0.0
static

Definition at line 108 of file polyfonts.c.

Referenced by pfGetCharBBox(), pfGetFontBBox(), pfSetSkew(), and pfSkew().

int pfTextWeight = 1
static

Definition at line 109 of file polyfonts.c.

Referenced by drawWideChar(), and pfSetWeight().

SUMOReal pfTextX = 0.0
static

Definition at line 105 of file polyfonts.c.

Referenced by drawWideChar(), pfGetPosition(), and pfSetPosition().

SUMOReal pfTextY = 0.0
static

Definition at line 106 of file polyfonts.c.

Referenced by drawWideChar(), pfGetPosition(), and pfSetPosition().

vertex weightOffset[]
Initial value:
= {
{0.0, 0.0},
{0.0, 1.0},
{1.0, 1.0},
{1.0, 0.0},
{0.0, 2.0},
{1.0, 2.0},
{2.0, 2.0},
{1.0, 2.0},
{0.0, 2.0},
}

Definition at line 116 of file polyfonts.c.