Vidalia
0.2.15
|
00001 /* 00002 ** This file is part of Vidalia, and is subject to the license terms in the 00003 ** LICENSE file, found in the top level directory of this distribution. If you 00004 ** did not receive the LICENSE file with this file, you may obtain it from the 00005 ** Vidalia source package distributed by the Vidalia Project at 00006 ** http://www.torproject.org/projects/vidalia.html. No part of Vidalia, 00007 ** including this file, may be copied, modified, propagated, or distributed 00008 ** except according to the terms described in the LICENSE file. 00009 */ 00010 00011 /* 00012 ** \file TorMapImageView.h 00013 ** \brief Displays Tor servers and circuits on a map of the world 00014 */ 00015 00016 #ifndef _TORMAPIMAGEVIEW_H 00017 #define _TORMAPIMAGEVIEW_H 00018 00019 #include "ZImageView.h" 00020 #include "GeoIpRecord.h" 00021 00022 #include "RouterDescriptor.h" 00023 #include "Circuit.h" 00024 00025 #include <QHash> 00026 #include <QPair> 00027 #include <QPainter> 00028 #include <QPainterPath> 00029 00030 00031 class TorMapImageView : public ZImageView 00032 { 00033 Q_OBJECT 00034 00035 public: 00036 /** Default constructor. */ 00037 TorMapImageView(QWidget *parent = 0); 00038 /** Destructor. */ 00039 ~TorMapImageView(); 00040 00041 /** Plots the given router on the map using the given coordinates. */ 00042 void addRouter(const RouterDescriptor &desc, const GeoIpRecord &geoip); 00043 /** Plots the given circuit on the map. */ 00044 void addCircuit(const CircuitId &circid, const QStringList &path); 00045 /** Selects and hightlights a router on the map. */ 00046 void selectRouter(const QString &id); 00047 /** Selects and highlights a circuit on the map. */ 00048 void selectCircuit(const CircuitId &circid); 00049 /** Returns the minimum size of the widget */ 00050 QSize minimumSizeHint() const; 00051 00052 public slots: 00053 /** Removes a circuit from the map. */ 00054 void removeCircuit(const CircuitId &circid); 00055 /** Deselects all the highlighted circuits and routers */ 00056 void deselectAll(); 00057 /** Clears the known routers and removes all the data from the map */ 00058 void clear(); 00059 /** Zooms to fit all currently displayed circuits on the map. */ 00060 void zoomToFit(); 00061 /** Zoom to a particular router on the map. */ 00062 void zoomToRouter(const QString &id); 00063 /** Zoom to the circuit on the map with the given <b>circid</b>. */ 00064 void zoomToCircuit(const CircuitId &circid); 00065 00066 protected: 00067 /** Paints the current circuits and streams on the image. */ 00068 virtual void paintImage(QPainter *painter); 00069 00070 private: 00071 /** Converts world space coordinates into map space coordinates */ 00072 QPointF toMapSpace(float latitude, float longitude); 00073 /** Linearly interpolates using the values in the projection table */ 00074 float lerp(float input, float *table); 00075 /** Computes a bounding box around all currently displayed circuit paths on 00076 * the map. */ 00077 QRectF circuitBoundingBox(); 00078 00079 /** Stores map locations for tor routers */ 00080 QHash<QString, QPair<QPointF,bool>* > _routers; 00081 /** Stores circuit information */ 00082 QHash<CircuitId, QPair<QPainterPath *,bool>* > _circuits; 00083 }; 00084 00085 #endif 00086