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 2977 2008-08-17 01:28:25Z 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 #include <circuit.h> 00025 #include <stream.h> 00026 00027 #include "zimageview.h" 00028 00029 00030 class TorMapWidget : public ZImageView 00031 { 00032 Q_OBJECT 00033 00034 public: 00035 /** Default constructor. */ 00036 TorMapWidget(QWidget *parent = 0); 00037 /** Destructor. */ 00038 ~TorMapWidget(); 00039 00040 /** Plots the given router on the map using the given coordinates. */ 00041 void addRouter(const QString &id, float latitude, float longitude); 00042 /** Plots the given circuit on the map. */ 00043 void addCircuit(const CircuitId &circid, const QStringList &path); 00044 /** Selects and hightlights a router on the map. */ 00045 void selectRouter(const QString &id); 00046 /** Selects and highlights a circuit on the map. */ 00047 void selectCircuit(const CircuitId &circid); 00048 /** Returns the minimum size of the widget */ 00049 QSize minimumSizeHint() const; 00050 00051 public slots: 00052 /** Removes a circuit from the map. */ 00053 void removeCircuit(const CircuitId &circid); 00054 /** Deselects all the highlighted circuits and routers */ 00055 void deselectAll(); 00056 /** Clears the known routers and removes all the data from the map */ 00057 void clear(); 00058 /** Zooms to fit all currently displayed circuits on the map. */ 00059 void zoomToFit(); 00060 /** Zoom to a particular router on the map. */ 00061 void zoomToRouter(const QString &id); 00062 /** Zoom to the circuit on the map with the given <b>circid</b>. */ 00063 void zoomToCircuit(const CircuitId &circid); 00064 00065 protected: 00066 /** Paints the current circuits and streams on the image. */ 00067 virtual void paintImage(QPainter *painter); 00068 00069 private: 00070 /** Converts world space coordinates into map space coordinates */ 00071 QPointF toMapSpace(float latitude, float longitude); 00072 /** Linearly interpolates using the values in the projection table */ 00073 float lerp(float input, float *table); 00074 /** Computes a bounding box around all currently displayed circuit paths on 00075 * the map. */ 00076 QRectF circuitBoundingBox(); 00077 00078 /** Stores map locations for tor routers */ 00079 QHash<QString, QPair<QPointF,bool>* > _routers; 00080 /** Stores circuit information */ 00081 QHash<CircuitId, QPair<QPainterPath *,bool>* > _circuits; 00082 }; 00083 00084 #endif 00085