19 #include <QStringList>
21 #if defined(__sgi) && defined(_COMPILER_VERSION) && _COMPILER_VERSION >= 730
27 #define IMG_WORLD_MAP ":/images/map/world-map.png"
30 #define PEN_ROUTER QPen(QColor("#ff030d"), 1.0)
31 #define PEN_CIRCUIT QPen(Qt::yellow, 0.5)
32 #define PEN_SELECTED QPen(Qt::green, 2.0)
35 #define IMG_WIDTH 1000
36 #define IMG_HEIGHT 507
43 #define MAP_WIDTH (IMG_WIDTH-MAP_LEFT-MAP_RIGHT)
44 #define MAP_HEIGHT (IMG_HEIGHT-MAP_TOP-MAP_BOTTOM)
47 #define MAP_ORIGIN -10
50 #define MIN_SIZE QSize(512,256)
55 1.0000, 0.9986, 0.9954, 0.9900,
56 0.9822, 0.9730, 0.9600, 0.9427,
57 0.9216, 0.8962, 0.8679, 0.8350,
58 0.7986, 0.7597, 0.7186, 0.6732,
59 0.6213, 0.5722, 0.5322
64 0.0000, 0.0620, 0.1240, 0.1860,
65 0.2480, 0.3100, 0.3720, 0.4340,
66 0.4958, 0.5571, 0.6176, 0.6769,
67 0.7346, 0.7903, 0.8435, 0.8936,
68 0.9394, 0.9761, 1.0000
89 QString
id = desc.
id();
94 _routers.value(
id)->first = routerCoord;
96 _routers.insert(
id,
new QPair<QPointF,bool>(routerCoord,
false));
103 QPainterPath *circPainterPath =
new QPainterPath;
106 for (
int i = 0;
i < path.size()-1;
i++) {
107 QString fromNode = path.at(
i);
108 QString toNode = path.at(
i+1);
113 QPointF fromPos =
_routers.value(fromNode)->first;
114 QPointF endPos =
_routers.value(toNode)->first;
117 circPainterPath->moveTo(fromPos);
118 circPainterPath->lineTo(endPos);
119 circPainterPath->moveTo(endPos);
127 QPair<QPainterPath*,bool> *circuitPair =
_circuits.value(circid);
128 delete circuitPair->first;
129 circuitPair->first = circPainterPath;
132 _circuits.insert(circid,
new QPair<QPainterPath*,bool>(circPainterPath,
false));
140 QPair<QPainterPath*,bool> *circ =
_circuits.take(circid);
141 QPainterPath *circpath = circ->first;
153 QPair<QPointF, bool> *routerPair =
_routers.value(
id);
154 routerPair->second =
true;
165 QPair<QPainterPath*, bool> *circuitPair =
_circuits.value(circid);
166 circuitPair->second =
true;
176 foreach (QString router,
_routers.keys()) {
177 QPair<QPointF,bool> *routerPair =
_routers.value(router);
178 routerPair->second =
false;
182 QPair<QPainterPath*,bool> *circuitPair =
_circuits.value(circid);
183 circuitPair->second =
false;
192 foreach (QString router,
_routers.keys()) {
197 QPair<QPainterPath*,bool> *circuitPair =
_circuits.take(circid);
198 delete circuitPair->first;
207 painter->setRenderHint(QPainter::Antialiasing);
210 foreach(QString router,
_routers.keys()) {
211 QPair<QPointF,bool> *routerPair =
_routers.value(router);
213 painter->drawPoint(routerPair->first);
217 QPair<QPainterPath*,bool> *circuitPair =
_circuits.value(circid);
219 painter->drawPath(*(circuitPair->first));
229 float deg = width / 360.0;
235 lat = floor(longitude * (deg *
lerp(abs(
int(latitude)),
plen))
239 lon = floor((height/2) + (
lerp(abs(
int(latitude)),
pdfe) * (height/2))
242 lon = floor((height/2) - (
lerp(abs(
int(latitude)),
pdfe) * (height/2))
246 return QPointF(lat, lon);
253 int x = int(floor(input / 5));
255 return ((table[x+1] - table[x]) /
256 (((x+1)*5) - (x*5))) * (input - x*5) + table[x];
280 float zoomLevel = 1.0 - qMax(rect.height()/
float(
MAP_HEIGHT),
283 zoom(rect.center().toPoint(), zoomLevel+0.2);
292 QPair<QPainterPath*,bool> *pair =
_circuits.value(circid);
293 QRectF rect = ((QPainterPath *)pair->first)->boundingRect();
294 if (!rect.isNull()) {
295 float zoomLevel = 1.0 - qMax(rect.height()/
float(
MAP_HEIGHT),
298 zoom(rect.center().toPoint(), zoomLevel+0.2);
307 QPair<QPointF,bool> *routerPair;
312 routerPair->second =
true;
313 zoom(routerPair->first.toPoint(), 1.0);
326 QPair<QPainterPath*,bool> *pair =
_circuits.value(circid);
327 QPainterPath *circuit = pair->first;
328 rect = rect.unite(circuit->boundingRect());