diff --git a/opmap/mapwidget/geoFencecircle.cpp b/opmap/mapwidget/geoFencecircle.cpp index 75d13fe..a959e6a 100644 --- a/opmap/mapwidget/geoFencecircle.cpp +++ b/opmap/mapwidget/geoFencecircle.cpp @@ -35,7 +35,7 @@ void geoFencecircle::paint(QPainter *painter, const QStyleOptionGraphicsItem *op Q_UNUSED(option); Q_UNUSED(widget); - painter->setOpacity(0.4); + painter->setOpacity(0.5); QPointF p1; QPointF p2; @@ -97,7 +97,7 @@ void geoFencecircle::refreshLocations() rectangle.setRect(-line.length(),-line.length(), 2 * line.length(), 2 * line.length()); - qDebug() << line << rectangle << C.Lat() << C.Lng() << m_radius; + //qDebug() << line << rectangle << C.Lat() << C.Lng() << m_radius; setPos(p); update(); diff --git a/opmap/mapwidget/geoFenceitem.cpp b/opmap/mapwidget/geoFenceitem.cpp index 6d6c6b3..62c1e52 100644 --- a/opmap/mapwidget/geoFenceitem.cpp +++ b/opmap/mapwidget/geoFenceitem.cpp @@ -27,7 +27,7 @@ void geoFenceitem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti Q_UNUSED(option); Q_UNUSED(widget); - painter->setOpacity(0.4); + painter->setOpacity(0.5); QPen myPen = painter->pen(); myPen.setWidth(lineWidth); diff --git a/opmap/mapwidget/opmapwidget.cpp b/opmap/mapwidget/opmapwidget.cpp index 3d33288..5ae076b 100644 --- a/opmap/mapwidget/opmapwidget.cpp +++ b/opmap/mapwidget/opmapwidget.cpp @@ -2332,15 +2332,59 @@ void OPMapWidget::WPSave(QString path)//带文件目录参数 QJsonArray circles; QJsonArray polygons; { - QJsonArray polygon; - QJsonObject polygonObj; + foreach(QGraphicsItem * i, map->childItems()) { + geoFenceitem *w = qgraphicsitem_cast(i); + if (w) { - polygonObj["inclusion"] = true; - polygonObj["polygon"] = polygon; - polygonObj["version"] = 1; + QJsonArray polygon; + QJsonObject polygonObj; - polygons.append(polygonObj); + QList points = w->points; + for(internals::PointLatLng ll:points) + { + + QJsonArray latlng; + latlng.append(ll.Lat()); + latlng.append(ll.Lng()); + + polygon.push_back(latlng); + } + + polygonObj["inclusion"] = w->Inclusion(); + polygonObj["polygon"] = polygon; + polygonObj["version"] = 1; + + + polygons.push_back(polygonObj); + } + } + + foreach(QGraphicsItem * i, map->childItems()) { + geoFencecircle *w = qgraphicsitem_cast(i); + if (w) { + QJsonObject circle; + QJsonObject circleObj; + + + QJsonArray center; + center.append(w->Latitude()); + center.append(w->Longitude()); + + double radius = w->Radius(); + + circle["center"] = center; + circle["radius"] = radius; + + + circleObj["inclusion"] = w->Inclusion(); + circleObj["circle"] = circle; + circleObj["version"] = 1; + + + circles.push_back(circleObj); + } + } } geoFence.insert("circles",circles); geoFence.insert("polygons",polygons);