00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef MAPCONTROL_H
00027 #define MAPCONTROL_H
00028
00029 #include <QtGui>
00030
00031 #include "layermanager.h"
00032 #include "layer.h"
00033 #include "mapadapter.h"
00034 #include "geometry.h"
00035 #include "imagemanager.h"
00036
00038 namespace qmapcontrol
00039 {
00040 class LayerManager;
00041 class MapAdapter;
00042 class Layer;
00043
00045
00053 class MapControl : public QWidget
00054 {
00055 Q_OBJECT
00056
00057 public:
00059 enum MouseMode
00060 {
00061 Panning,
00062 Dragging,
00063 None,
00064 };
00065
00067
00077 MapControl ( QSize size, MouseMode mousemode = Panning );
00078
00079 ~MapControl();
00080
00082
00086 void addLayer ( Layer* layer );
00087
00089
00093 Layer* layer ( const QString& layername ) const;
00094
00096
00099 QList<QString> layers() const;
00100
00102
00105 int numberOfLayers() const;
00106
00108
00111 QPointF currentCoordinate() const;
00112
00114
00117 int currentZoom() const;
00118
00120
00123 void setView ( const QPointF& coordinate ) const;
00124
00126
00129 void setView ( const QList<QPointF> coordinates ) const;
00130
00132
00137 void setViewAndZoomIn ( const QList<QPointF> coordinates ) const;
00138
00140
00144 void setView ( const Point* point ) const;
00145
00147
00151 void followGeometry ( const Geometry* geometry ) const;
00152
00153
00154
00155
00157
00162 void stopFollowing ( Geometry* geometry );
00163
00165
00168 void moveTo ( QPointF coordinate );
00169
00171
00179 void setMouseMode ( MouseMode mousemode );
00180
00182
00186 MapControl::MouseMode mouseMode();
00187
00188
00189
00191
00198 void enablePersistentCache ( const QDir& path=QDir::homePath() + "/QMapControl.cache" );
00199
00200
00202
00208 void setProxy ( QString host, int port );
00209
00211
00215 void showScale ( bool show );
00216
00217 private:
00218 LayerManager* layermanager;
00219 QPoint screen_middle;
00220
00221 QPoint pre_click_px;
00222 QPoint current_mouse_pos;
00223
00224 QSize size;
00225
00226 bool mousepressed;
00227 MouseMode mymousemode;
00228 bool scaleVisible;
00229
00230 bool m_loadingFlag;
00231
00232 QMutex moveMutex;
00233 QPointF target;
00234 int steps;
00235
00236 QPointF clickToWorldCoordinate ( QPoint click );
00237 MapControl& operator= ( const MapControl& rhs );
00238 MapControl ( const MapControl& old );
00239
00240 protected:
00241 void paintEvent ( QPaintEvent* evnt );
00242 void mousePressEvent ( QMouseEvent* evnt );
00243 void mouseReleaseEvent ( QMouseEvent* evnt );
00244 void mouseMoveEvent ( QMouseEvent* evnt );
00245
00246 signals:
00247
00248
00250
00257 void mouseEventCoordinate ( const QMouseEvent* evnt, const QPointF coordinate );
00258
00260
00265 void boxDragged ( const QRectF );
00266
00268
00272 void geometryClicked ( Geometry* geometry, QPoint coord_px );
00273
00275
00279 void viewChanged ( const QPointF &coordinate, int zoom );
00280
00281 public slots:
00283 void zoomIn();
00284
00286 void zoomOut();
00287
00289
00292 void setZoom ( int zoomlevel );
00293
00295 void scrollLeft ( int pixel=10 );
00296
00298 void scrollRight ( int pixel=10 );
00299
00301 void scrollUp ( int pixel=10 );
00302
00304 void scrollDown ( int pixel=10 );
00305
00307 void scroll ( const QPoint scroll );
00308
00310
00313 void updateRequest ( QRect rect );
00314
00316
00319 void updateRequestNew();
00320
00322
00325 void resize(const QSize newSize);
00326
00327 private slots:
00328 void tick();
00329 void loadingFinished();
00330 void positionChanged ( Geometry* geom );
00331 };
00332 }
00333 #endif