diff --git a/qtviewer_planetosm/osmtiles/tilesviewer.cpp b/qtviewer_planetosm/osmtiles/tilesviewer.cpp index 536b54b9d3d91691ac471e07e9de328923002cb8..c5e696a89b0d330b827f1489c8fc63b78945c0f0 100644 --- a/qtviewer_planetosm/osmtiles/tilesviewer.cpp +++ b/qtviewer_planetosm/osmtiles/tilesviewer.cpp @@ -655,13 +655,13 @@ namespace QTVOSM{ double dperx = dMx/(cProjectionMercator::pi*cProjectionMercator::R*2); double dpery = -dMy/(cProjectionMercator::pi*cProjectionMercator::R*2); - double dCurrImgSize = pow(2.0,m_nLevel)*256; + int nCurrImgSize = (1<rect(); QPointF center = rect.center(); diff --git a/qtvplugin_geomarker/geographicslineitem.cpp b/qtvplugin_geomarker/geographicslineitem.cpp index ecf4d42e8d749f8584849e66e0cdf0b96ad6a5a0..4479346eed4bd47fba7ca26e10576dea4028e76e 100644 --- a/qtvplugin_geomarker/geographicslineitem.cpp +++ b/qtvplugin_geomarker/geographicslineitem.cpp @@ -51,6 +51,10 @@ namespace QTVP_GEOMARKER{ { if (vi() && nNewLevel != level()) { + /** Since the map is zooming from level() to current level, + * the map size zoom ratio can be calculated using pow below. + * We can get new coord for current zoom level by multiplicative. + */ double ratio = pow(2.0,(nNewLevel - level())); QLineF l1 = this->line(); setLine(l1.x1() * ratio,l1.y1() * ratio,l1.x2() * ratio,l1.y2() * ratio); diff --git a/qtvplugin_geomarker/geographicspolygonitem.cpp b/qtvplugin_geomarker/geographicspolygonitem.cpp index 672d9ee1defedc7f94de7badd4f60b92e6e41641..3c638e33afd04a81de907d28bb3d7209370fe380 100644 --- a/qtvplugin_geomarker/geographicspolygonitem.cpp +++ b/qtvplugin_geomarker/geographicspolygonitem.cpp @@ -51,6 +51,10 @@ namespace QTVP_GEOMARKER{ { if (vi() && nNewLevel != level()) { + /** Since the map is zooming from level() to current level, + * the map size zoom ratio can be calculated using pow below. + * We can get new coord for current zoom level by multiplicative. + */ double ratio = pow(2.0,(nNewLevel - level())); QPolygonF p = this->polygon(); int sz = p.size(); diff --git a/qtvplugin_geomarker/geographicsrectitem.cpp b/qtvplugin_geomarker/geographicsrectitem.cpp index eb6d2b601e17bdf81b3f6e51766ce7f6b47bfe90..006003c7c928656990e611a9bf66a834221f169e 100644 --- a/qtvplugin_geomarker/geographicsrectitem.cpp +++ b/qtvplugin_geomarker/geographicsrectitem.cpp @@ -31,6 +31,10 @@ namespace QTVP_GEOMARKER{ { if (vi() && ncurrLevel != level()) { + /** Since the map is zooming from level() to current level, + * the map size zoom ratio can be calculated using pow below. + * We can get new coord for current zoom level by multiplicative. + */ double ratio = pow(2.0,(ncurrLevel - level())); QRectF rect = this->rect(); QPointF center = rect.center(); diff --git a/qtvplugin_geomarker/geographicsscene.cpp b/qtvplugin_geomarker/geographicsscene.cpp index 579e6dd2ef4e3756432b96e5e087a500dbfcb013..8e6aa80eb88b603aaf33fb0d2eecce1ba19c45e9 100644 --- a/qtvplugin_geomarker/geographicsscene.cpp +++ b/qtvplugin_geomarker/geographicsscene.cpp @@ -61,6 +61,13 @@ namespace QTVP_GEOMARKER{ } + /** + * @brief sequentially call virtual function geoItemBase::adjust_coords for every geoItemBase object. + * + * Since the scene coord will be zoomed in / out together with level change, all graphics items' coords should + * be recalculated in time. the method adjust_item_coords will do this automatically, + * @param newLevel the level to which current map is zoomed. + */ void geoGraphicsScene::adjust_item_coords(int newLevel) { QList it = this->items(); @@ -69,7 +76,11 @@ namespace QTVP_GEOMARKER{ geoItemBase * base = dynamic_cast(t); if (base) { + //when this function is called, base->level() is the old level from which + // current map is zoomed. base->adjust_coords(newLevel); + //After adjust_coords above, the item "base" is considered to + // have a valid coord corresponds to current newLevel base->setLevel(newLevel); } } diff --git a/qtvplugin_geomarker/geographicsscene.h b/qtvplugin_geomarker/geographicsscene.h index 4f5e16156d2f6f9626e3a7e0076de7cb1ef7e02d..b7849bcece8edfa2aa46442fbd841e8da6972c0c 100644 --- a/qtvplugin_geomarker/geographicsscene.h +++ b/qtvplugin_geomarker/geographicsscene.h @@ -5,6 +5,20 @@ #include namespace QTVP_GEOMARKER{ class geoItemBase; + /** + * @brief geoGraphicsScene shield the common item operations, such as addEllipse + * addPolygon, and so on. It provide user several new polymorphism method, + * for special geoItemBase classes. Item name will be indexed using a QMap object m_map_items + * so that user can get item pointers as soon as possible. + * + * The scene uses World Pixel Coordinate system, which has a commection between zoom level. + * You can learn more principle about coordinates in the comments of class viewer_interface. in zoom level 0, + * world pixel size is 256x256, level 1 is 512x512, level 18 is 67108864 x 67108864 + * Since the scene coord will be zoomed in / out together with level change, all graphics items' coords should + * be recalculated in time. the method adjust_item_coords will do this automatically, + * and in this function, virtual function geoItemBase::adjust_coords will be called sequentially. + * + */ class geoGraphicsScene : public QGraphicsScene { Q_OBJECT diff --git a/qtvplugin_geomarker/geoitembase.h b/qtvplugin_geomarker/geoitembase.h index 56b49e18a5a78b6aa262d1fa567f9b458fe1170f..5cc774524fee869e3f45a0a2dba23aa5494fbff9 100644 --- a/qtvplugin_geomarker/geoitembase.h +++ b/qtvplugin_geomarker/geoitembase.h @@ -32,6 +32,13 @@ namespace QTVP_GEOMARKER{ } class geoGraphicsScene; + /** + * @brief class geoItemBase is the root base class for all geoGraphicsItems. + * this class has several function, include: + * 1.provide properties system, include name, font, color, user-defined props using key-value mapping. + * 2.provide a LABEL mechanism, which is tooking use of by geoGraphicsScene to display props on map. + * 3.defines 2 interface, for Inheritance classes, give them optunities to maintain coordinates change when zooming. + */ class geoItemBase { friend class geoGraphicsScene;