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 LAYER_H
00027 #define LAYER_H
00028
00029 #include <QObject>
00030 #include <QDebug>
00031 #include <QPainter>
00032 #include <QMouseEvent>
00033
00034 #include "mapadapter.h"
00035 #include "layermanager.h"
00036 #include "geometry.h"
00037 #include "point.h"
00038
00039 #include "wmsmapadapter.h"
00040 #include "tilemapadapter.h"
00041
00042 namespace qmapcontrol
00043 {
00045
00059 class Layer : public QObject
00060 {
00061 Q_OBJECT
00062
00063 public:
00064 friend class LayerManager;
00065
00067 enum LayerType
00068 {
00069 MapLayer,
00070 GeometryLayer
00071 };
00072
00074
00083 Layer(QString layername, MapAdapter* mapadapter, enum LayerType layertype, bool takeevents=true);
00084 virtual ~Layer();
00085
00087
00090 QString layername() const;
00091
00093
00098 const MapAdapter* mapadapter() const;
00099
00101
00105 void addGeometry(Geometry* geometry);
00106
00108
00111 void removeGeometry(Geometry* geometry);
00112
00114
00117 void clearGeometries();
00118
00120
00123 bool isVisible() const;
00124
00126
00130 Layer::LayerType layertype() const;
00131
00132 void setMapAdapter(MapAdapter* mapadapter);
00133
00134 Layer& operator=(const Layer& rhs);
00135 Layer(const Layer& old);
00136
00137 private:
00138 void moveWidgets(const QPoint mapmiddle_px) const;
00139 void drawYourImage(QPainter* painter, const QPoint mapmiddle_px) const;
00140 void drawYourGeometries(QPainter* painter, const QPoint mapmiddle_px, QRect viewport) const;
00141 void setSize(QSize size);
00142 QRect offscreenViewport() const;
00143 bool takesMouseEvents() const;
00144 void mouseEvent(const QMouseEvent*, const QPoint mapmiddle_px);
00145 void zoomIn() const;
00146 void zoomOut() const;
00147 void _draw(QPainter* painter, const QPoint mapmiddle_px) const;
00148
00149 bool visible;
00150 QString mylayername;
00151 LayerType mylayertype;
00152 QSize size;
00153 QPoint screenmiddle;
00154
00155 QList<Geometry*> geometries;
00156 MapAdapter* mapAdapter;
00157 bool takeevents;
00158 mutable QRect myoffscreenViewport;
00159
00160 signals:
00162
00168 void geometryClicked(Geometry* geometry, QPoint point);
00169
00170 void updateRequest(QRectF rect);
00171 void updateRequest();
00172
00173 public slots:
00175
00178 void setVisible(bool visible);
00179
00180 };
00181 }
00182 #endif