提交 3c83a95a 编写于 作者: 丁劲犇's avatar 丁劲犇 💬

1.ActiveX need export DllRegisitServer.

2.Pixmap Items' coordinates should be recaled when level changed.
上级 51d26373
......@@ -18,7 +18,7 @@ QMutex osm_frame_widget::m_mutex_proteced;
/*!
\brief osm_frame_widget is the main widget of this control.
in this constructor, 2 OUTER message will be fired.
in this constructor, 2 OUTER message will be fired.
\fn osm_frame_widget::osm_frame_widget
\param parent
......
......@@ -5,3 +5,4 @@ DllGetClassObject @2
DllRegisterServer @3
DllUnregisterServer @4
DumpIDL @5
DllInstall @6
......@@ -43,36 +43,6 @@ namespace QTVP_GEOMARKER{
QGraphicsPixmapItem::setTransformOriginPoint(oldlefttop_x*ratio, oldlefttop_y*ratio );
}
}
void geoGraphicsPixmapItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget /*= nullptr*/)
{
if (vi())
{
const int cv = vi()->level();
if (cv!=level())
{
adjust_coords(cv);
setLevel(cv);
}
}
QGraphicsPixmapItem::paint(painter,option,widget);
}
QRectF geoGraphicsPixmapItem::boundingRect() const
{
QRectF rect = QGraphicsPixmapItem::boundingRect();
auto v = vi();
if (v && v->level()!=level())
{
double ratio = pow(2.0,(v->level() - level()));
QPointF center = rect.center();
rect.setRect(center.x() * ratio - rect.width()/2,
center.y() * ratio - rect.height()/2,
rect.width(),
rect.height());
}
return rect;
}
void geoGraphicsPixmapItem::setPixmap(const tag_icon &icon)
{
this->m_pIcon = &icon;
......
......@@ -30,8 +30,6 @@ namespace QTVP_GEOMARKER{
,const tag_icon * pIcon,
qreal cent_lat = 90,
qreal cent_lon = 0);
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr) override;
QRectF boundingRect() const override;
public:
const tag_icon * icon(){return m_pIcon;}
qreal lat() const {return m_lat;}
......
......@@ -19,6 +19,27 @@ namespace QTVP_GEOMARKER{
:QGraphicsScene(x,y,width,height,parent)
{
}
/**
* @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)
{
currentNewLevel = newLevel;
for (QSet<geoItemBase * >::iterator p = m_set_iconitems.begin();p!=m_set_iconitems.end();++p)
{
geoItemBase * base = *p;
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);
}
}
bool geoGraphicsScene::addItem(geoItemBase * item,int /*reserved*/)
{
......@@ -35,12 +56,16 @@ namespace QTVP_GEOMARKER{
this->removeItem(oldItem,0);
this->m_map_items[namec] = item;
this->addItem(pg);
if (item->item_type()==ITEAMTYPE_PIXMAP)
m_set_iconitems.insert(item);
}
}
else
{
this->addItem(pg);
this->m_map_items[namec] = item;
if (item->item_type()==ITEAMTYPE_PIXMAP)
m_set_iconitems.insert(item);
}
res = true;
}
......@@ -58,6 +83,8 @@ namespace QTVP_GEOMARKER{
{
this->removeItem(pg);
m_map_items.remove(c_name);
if (item->item_type()==ITEAMTYPE_PIXMAP)
m_set_iconitems.remove(item);
delete item;
}
}
......
......@@ -3,6 +3,7 @@
#include <QGraphicsScene>
#include <QMap>
#include <QSet>
namespace QTVP_GEOMARKER{
class geoItemBase;
/**
......@@ -27,8 +28,10 @@ namespace QTVP_GEOMARKER{
geoGraphicsScene(const QRectF &sceneRect, QObject *parent = 0);
geoGraphicsScene(qreal x, qreal y, qreal width, qreal height, QObject *parent = 0);
int currentLevel() const {return currentNewLevel;}
void adjust_item_coords(int currentLevel);
private:
QMap<QString, geoItemBase * > m_map_items;
QSet<geoItemBase * > m_set_iconitems;
int currentNewLevel;
//Overload public functions to provate.
QGraphicsEllipseItem * addEllipse(const QRectF & rect, const QPen & pen = QPen(), const QBrush & brush = QBrush())
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册