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.vidalia-project.net/. No part of Vidalia, including this file, 00007 ** may be copied, modified, propagated, or distributed except according to the 00008 ** terms described in the LICENSE file. 00009 */ 00010 00011 /* 00012 ** \file tormapwidget.h 00013 ** \version $Id: tormapwidget.h 2362 2008-02-29 04:30:11Z edmanm $ 00014 ** \brief Displays Tor servers and circuits on a map of the world 00015 */ 00016 00017 #ifndef _TORMAPWIDGET_H 00018 #define _TORMAPWIDGET_H 00019 00020 #include <QHash> 00021 #include <QPair> 00022 #include <QPainter> 00023 #include <QPainterPath> 00024 00025 #include "zimageview.h" 00026 00027 00028 class TorMapWidget : public ZImageView 00029 { 00030 Q_OBJECT 00031 00032 public: 00033 /** Default constructor. */ 00034 TorMapWidget(QWidget *parent = 0); 00035 /** Destructor. */ 00036 ~TorMapWidget(); 00037 00038 /** Plots the given router on the map using the given coordinates. */ 00039 void addRouter(QString id, float latitude, float longitude); 00040 /** Plots the given circuit on the map. */ 00041 void addCircuit(quint64 circid, QStringList path); 00042 /** Selects and hightlights a router on the map. */ 00043 void selectRouter(QString id); 00044 /** Selects and highlights a circuit on the map. */ 00045 void selectCircuit(quint64 circid); 00046 /** Returns the minimum size of the widget */ 00047 QSize minimumSizeHint() const; 00048 00049 public slots: 00050 /** Removes a circuit from the map. */ 00051 void removeCircuit(quint64 circid); 00052 /** Deselects all the highlighted circuits and routers */ 00053 void deselectAll(); 00054 /** Clears the known routers and removes all the data from the map */ 00055 void clear(); 00056 /** Zooms to fit all currently displayed circuits on the map. */ 00057 void zoomToFit(); 00058 /** Zoom to a particular router on the map. */ 00059 void zoomToRouter(QString id); 00060 /** Zoom to the circuit on the map with the given <b>circid</b>. */ 00061 void zoomToCircuit(quint64 circid); 00062 00063 protected: 00064 /** Paints the current circuits and streams on the image. */ 00065 virtual void paintImage(QPainter *painter); 00066 00067 private: 00068 /** Converts world space coordinates into map space coordinates */ 00069 QPointF toMapSpace(float latitude, float longitude); 00070 /** Linearly interpolates using the values in the projection table */ 00071 float lerp(float input, float *table); 00072 /** Computes a bounding box around all currently displayed circuit paths on 00073 * the map. */ 00074 QRectF circuitBoundingBox(); 00075 00076 /** Stores map locations for tor routers */ 00077 QHash<QString, QPair<QPointF,bool>* > _routers; 00078 /** Stores circuit information */ 00079 QHash<quint64, QPair<QPainterPath *,bool>* > _circuits; 00080 }; 00081 00082 #endif 00083