Не отображается MapPolyLine после изменения размера окна приложения
Если размер окна приложения не изменяется, то перемещение по карте или скроллинг карты не вызвает бага, то есть все мои MapPolyLine с MapPolygon отображается корректно. Но если изменить размер окна, то пропадает MapPolyLine. Причём не отображается часть линии, которая связывает конечную точку с начальной. Возможно у кого-то была такая бага. Буду признателен за помощь.
delegate: MapItemGroup {
function zoneDir(dir) {
switch (dir) {
case DirectionType.InOut:
return 0
case DirectionType.In:
return 1
case DirectionType.Out:
return 2
default:
return 0
}
}
// v высота зон регулируется здесь v //
//z: model.layout
MapPolyline {
id: _polyline
property int frontier: model.direction
property var lineWidth: model.lineWidth
property var lineColor: model.color
smooth: true
antialiasing: true
path: model.path
visible: {
if (model.species === Species.Frontier)
return model.visible
return false;
}
enabled: visible
line.color: model.color
line.width: model.lineWidth
onPathChanged: {
console.log("Path changed")
dataModel.clear();
for (var i = 0; i < _polyline.path.length - 1; ++i)
dataModel.append({ "p1": i, "p2": i + 1});
//dataModel.append( {"p1": 0, "p2": 3} );
}
ListModel {
id: dataModel
}
Instantiator {
model: dataModel
delegate: MapItemGroup {
Anchor {
id: point1
coordinate: _polyline.path[p1]
}
Anchor {
id: point2
coordinate: _polyline.path[p2]
}
LineItem {
opacity: 1
color: _polyline.lineColor
lineWidth: _polyline.lineWidth
style: Qt.SolidLine
frontier: _polyline.frontier
visible: _polygon.visible
x1: point1.x
y1: point1.y
x2: point2.x
y2: point2.y
z: _polygon.z
MouseArea {
anchors.fill: parent
cursorShape: active ? Qt.PointingHandCursor : Qt.ArrowCursor
onClicked: {
console.log("Нажал ыы")
}
}
}
}
onObjectAdded: map.addMapItemGroup(object)
onObjectRemoved: map.removeMapItemGroup(object)
}
}
MapPolygon {
id: _polygon
property var valueOpacity: model.valueOpacity / 100
property var generalColor: model.color
property var generalLineWidth: model.lineWidth
smooth: true
path: model.path
visible: {
if (MenuManager.onscreen && MenuManager.currentMenuTitle === qsTr("zones"))
return true;
if(model.species === Species.Polygon)
return model.visible
return false
}
enabled: model.visible
border {
// Задаём цвет границы зоны
color: { return model.valid ? model.color : "red" }
// Задаём ширину границы зоны
width: model.lineWidth
}
color: {
var c = border.color
// Если выбрана зона (полигон), то делаем темнее, иначе наоборот светлее.
// Коэффициент затемнения alpha = 0.5
return Qt.rgba(c.r, c.g, c.b, model.locked ? _polygon.valueOpacity : 0.5)
}
}
MouseArea {
Component.onCompleted: {
Activator.tag = Qt.binding(function() {
return (model.ignore) ? "ignore zone" : "detection zone"}
)
}
enabled: Activator.isActive
property bool active: Activator.isActive && parent.contains(Qt.point(mouseX, mouseY))
parent: {
switch(model.species){
case Species.Frontier:
return _polyline;
case Species.Polygon:
return _polygon;
default:
return {};
}
}
anchors.fill: parent
cursorShape: active ? Qt.PointingHandCursor : Qt.ArrowCursor
acceptedButtons: Qt.LeftButton | Qt.RightButton
onClicked: {
console.log("Нажал")
console.log(_polyline.path.length)
var p = parent.mapToItem(map, mouse.x, mouse.y)
var coord = map.toCoordinate(p, false)
if (Activator.isActive && mouse.button === Qt.LeftButton) {
zoneView.zoneLeftBtnClicked(zoneView.delegatedModel.index(index, 0), coord)
} else if (mouse.button === Qt.RightButton) {
zoneView.zoneRightBtnClicked(zoneView.delegatedModel.index(index, 0), coord)
}
}
onDoubleClicked: {
var m = zoneView.delegatedModel
var p = parent.mapToItem(map, mouse.x, mouse.y)
var coord = map.toCoordinate(p, false)
m.add(m.index(index, 0), coord)
}
hoverEnabled: true
}
DelegatedInstantiator {
id: pointInstantiator
delegatedModel: zoneView.delegatedModel
rootIndex: zoneView.delegatedModel.index(index, 0)
delegate: MapHandle {
visible: !model.locked
z: model.layout + 10.5
Binding on coordinate {
when: !dragged
value: model.coordinate
}
Binding {
target: model
property: "coordinate"
when: dragged
value: coordinate
}
onDoubleClicked: {
var m = zoneView.delegatedModel
var pn = m.borderPointCount(m.index(index, 0, pointInstantiator.rootIndex))
if (pn > 3) {
m.remove(m.index(index, 0, pointInstantiator.rootIndex))
}
//} else {
//_dialog.open() //WARNING: нужно ли тут предупреждение
//}
}
}
onObjectAdded: map.addMapItem(object)
onObjectRemoved: map.removeMapItem(object)
}
}
onObjectAdded: map.addMapItemGroup(object)
onObjectRemoved: map.removeMapItemGroup(object)}

