tormapwidget.h

Go to the documentation of this file.
00001 /****************************************************************
00002  *  Vidalia is distributed under the following license:
00003  *
00004  *  Copyright (C) 2006,  Matt Edman, Justin Hipple
00005  *
00006  *  This program is free software; you can redistribute it and/or
00007  *  modify it under the terms of the GNU General Public License
00008  *  as published by the Free Software Foundation; either version 2
00009  *  of the License, or (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License
00017  *  along with this program; if not, write to the Free Software
00018  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, 
00019  *  Boston, MA  02110-1301, USA.
00020  ****************************************************************/
00021 
00022 /** 
00023  * \file tormapwidget.h
00024  * \version $Id: tormapwidget.h 1563 2006-12-26 06:06:04Z edmanm $
00025  * \brief Displays Tor servers and circuits on a map of the world
00026  */
00027 
00028 #ifndef _TORMAPWIDGET_H
00029 #define _TORMAPWIDGET_H
00030 
00031 #include <QHash>
00032 #include <QPair>
00033 #include <QPainter>
00034 #include <QPainterPath>
00035 
00036 #include "zimageview.h"
00037 
00038 
00039 class TorMapWidget : public ZImageView
00040 {
00041   Q_OBJECT
00042 
00043 public:
00044   /** Default constructor. */
00045   TorMapWidget(QWidget *parent = 0);
00046   /** Destructor. */
00047   ~TorMapWidget();
00048 
00049   /** Plots the given router on the map using the given coordinates. */
00050   void addRouter(QString id, float latitude, float longitude);
00051   /** Plots the given circuit on the map. */
00052   void addCircuit(quint64 circid, QStringList path);
00053   /** Selects and hightlights a router on the map. */
00054   void selectRouter(QString id);
00055   /** Selects and highlights a circuit on the map. */
00056   void selectCircuit(quint64 circid);
00057   /** Returns the minimum size of the widget */
00058   QSize minimumSizeHint() const;
00059 
00060 public slots:
00061   /** Removes a circuit from the map. */
00062   void removeCircuit(quint64 circid);
00063   /** Deselects all the highlighted circuits and routers */
00064   void deselectAll();
00065   /** Clears the known routers and removes all the data from the map */
00066   void clear();
00067   /** Zooms to fit all currently displayed circuits on the map. */
00068   void zoomToFit();
00069   /** Zoom to a particular router on the map. */
00070   void zoomToRouter(QString id);
00071   /** Zoom to the circuit on the map with the given <b>circid</b>. */
00072   void zoomToCircuit(quint64 circid);
00073 
00074 protected:
00075   /** Paints the current circuits and streams on the image. */
00076   virtual void paintImage(QPainter *painter);
00077 
00078 private:
00079   /** Converts world space coordinates into map space coordinates */
00080   QPointF toMapSpace(float latitude, float longitude);
00081   /** Linearly interpolates using the values in the projection table */
00082   float lerp(float input, float *table);
00083   /** Computes a bounding box around all currently displayed circuit paths on
00084    * the map. */
00085   QRectF circuitBoundingBox();
00086   
00087   /** Stores map locations for tor routers */
00088   QHash<QString, QPair<QPointF,bool>* > _routers;
00089   /** Stores circuit information */
00090   QHash<quint64, QPair<QPainterPath *,bool>* > _circuits;
00091 };
00092 
00093 #endif
00094 

Generated on Wed Sep 5 15:49:28 2007 for Vidalia by  doxygen 1.5.3