mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
Update commit boundaries after moving waypoints.
Fixes https://github.com/dcs-liberation/dcs_liberation/issues/1084
This commit is contained in:
parent
53cb68f82c
commit
5d9563304f
@ -1,3 +1,5 @@
|
|||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
from typing import List, Optional, Tuple
|
from typing import List, Optional, Tuple
|
||||||
@ -323,17 +325,21 @@ class WaypointJs(QObject):
|
|||||||
self,
|
self,
|
||||||
waypoint: FlightWaypoint,
|
waypoint: FlightWaypoint,
|
||||||
number: int,
|
number: int,
|
||||||
flight: Flight,
|
flight_model: FlightJs,
|
||||||
theater: ConflictTheater,
|
theater: ConflictTheater,
|
||||||
ato_model: AtoModel,
|
ato_model: AtoModel,
|
||||||
) -> None:
|
) -> None:
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.waypoint = waypoint
|
self.waypoint = waypoint
|
||||||
self._number = number
|
self._number = number
|
||||||
self.flight = flight
|
self.flight_model = flight_model
|
||||||
self.theater = theater
|
self.theater = theater
|
||||||
self.ato_model = ato_model
|
self.ato_model = ato_model
|
||||||
|
|
||||||
|
@property
|
||||||
|
def flight(self) -> Flight:
|
||||||
|
return self.flight_model.flight
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def flight_plan(self) -> FlightPlan:
|
def flight_plan(self) -> FlightPlan:
|
||||||
return self.flight.flight_plan
|
return self.flight.flight_plan
|
||||||
@ -388,6 +394,7 @@ class WaypointJs(QObject):
|
|||||||
return "Could not find package model containing modified flight"
|
return "Could not find package model containing modified flight"
|
||||||
package.update_tot()
|
package.update_tot()
|
||||||
self.positionChanged.emit()
|
self.positionChanged.emit()
|
||||||
|
self.flight_model.commitBoundaryChanged.emit()
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
|
||||||
@ -412,7 +419,6 @@ class FlightJs(QObject):
|
|||||||
self.faction = faction
|
self.faction = faction
|
||||||
self.ato_model = ato_model
|
self.ato_model = ato_model
|
||||||
self._waypoints = self.make_waypoints()
|
self._waypoints = self.make_waypoints()
|
||||||
self._commit_boundary = self.make_commit_boundary()
|
|
||||||
|
|
||||||
def update_waypoints(self) -> None:
|
def update_waypoints(self) -> None:
|
||||||
for waypoint in self._waypoints:
|
for waypoint in self._waypoints:
|
||||||
@ -428,26 +434,11 @@ class FlightJs(QObject):
|
|||||||
departure.alt_type = "RADIO"
|
departure.alt_type = "RADIO"
|
||||||
waypoints = []
|
waypoints = []
|
||||||
for idx, point in enumerate([departure] + self.flight.points):
|
for idx, point in enumerate([departure] + self.flight.points):
|
||||||
waypoint = WaypointJs(point, idx, self.flight, self.theater, self.ato_model)
|
waypoint = WaypointJs(point, idx, self, self.theater, self.ato_model)
|
||||||
waypoint.positionChanged.connect(self.update_waypoints)
|
waypoint.positionChanged.connect(self.update_waypoints)
|
||||||
waypoints.append(waypoint)
|
waypoints.append(waypoint)
|
||||||
return waypoints
|
return waypoints
|
||||||
|
|
||||||
def make_commit_boundary(self) -> Optional[List[LeafletLatLon]]:
|
|
||||||
if not isinstance(self.flight.flight_plan, PatrollingFlightPlan):
|
|
||||||
return []
|
|
||||||
start = self.flight.flight_plan.patrol_start
|
|
||||||
end = self.flight.flight_plan.patrol_end
|
|
||||||
line = LineString(
|
|
||||||
[
|
|
||||||
ShapelyPoint(start.x, start.y),
|
|
||||||
ShapelyPoint(end.x, end.y),
|
|
||||||
]
|
|
||||||
)
|
|
||||||
doctrine = self.faction.doctrine
|
|
||||||
bubble = line.buffer(doctrine.cap_engagement_range.meters)
|
|
||||||
return shapely_poly_to_leaflet_points(bubble, self.theater)
|
|
||||||
|
|
||||||
@Property(list, notify=flightPlanChanged)
|
@Property(list, notify=flightPlanChanged)
|
||||||
def flightPlan(self) -> List[WaypointJs]:
|
def flightPlan(self) -> List[WaypointJs]:
|
||||||
return self._waypoints
|
return self._waypoints
|
||||||
@ -460,9 +451,21 @@ class FlightJs(QObject):
|
|||||||
def selected(self) -> bool:
|
def selected(self) -> bool:
|
||||||
return self._selected
|
return self._selected
|
||||||
|
|
||||||
@Property(list)
|
@Property(list, notify=commitBoundaryChanged)
|
||||||
def commitBoundary(self) -> Optional[List[LeafletLatLon]]:
|
def commitBoundary(self) -> Optional[List[LeafletLatLon]]:
|
||||||
return self._commit_boundary
|
if not isinstance(self.flight.flight_plan, PatrollingFlightPlan):
|
||||||
|
return []
|
||||||
|
start = self.flight.flight_plan.patrol_start
|
||||||
|
end = self.flight.flight_plan.patrol_end
|
||||||
|
line = LineString(
|
||||||
|
[
|
||||||
|
ShapelyPoint(start.x, start.y),
|
||||||
|
ShapelyPoint(end.x, end.y),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
doctrine = self.faction.doctrine
|
||||||
|
bubble = line.buffer(doctrine.cap_engagement_range.meters)
|
||||||
|
return shapely_poly_to_leaflet_points(bubble, self.theater)
|
||||||
|
|
||||||
|
|
||||||
class MapModel(QObject):
|
class MapModel(QObject):
|
||||||
|
|||||||
@ -479,7 +479,9 @@ class Flight {
|
|||||||
this.flight = flight;
|
this.flight = flight;
|
||||||
this.flightPlan = this.flight.flightPlan.map((p) => new Waypoint(p, this));
|
this.flightPlan = this.flight.flightPlan.map((p) => new Waypoint(p, this));
|
||||||
this.path = null;
|
this.path = null;
|
||||||
|
this.commitBoundary = null;
|
||||||
this.flight.flightPlanChanged.connect(() => this.draw());
|
this.flight.flightPlanChanged.connect(() => this.draw());
|
||||||
|
this.flight.commitBoundaryChanged.connect(() => this.drawCommitBoundary());
|
||||||
}
|
}
|
||||||
|
|
||||||
shouldMark(waypoint) {
|
shouldMark(waypoint) {
|
||||||
@ -509,9 +511,14 @@ class Flight {
|
|||||||
}
|
}
|
||||||
|
|
||||||
drawCommitBoundary() {
|
drawCommitBoundary() {
|
||||||
|
if (this.commitBoundary != null) {
|
||||||
|
this.commitBoundary
|
||||||
|
.removeFrom(this.flightPlanLayer())
|
||||||
|
.removeFrom(selectedFlightPlansLayer);
|
||||||
|
}
|
||||||
if (this.flight.selected) {
|
if (this.flight.selected) {
|
||||||
if (this.flight.commitBoundary) {
|
if (this.flight.commitBoundary) {
|
||||||
L.polyline(this.flight.commitBoundary, {
|
this.commitBoundary = L.polyline(this.flight.commitBoundary, {
|
||||||
color: Colors.Highlight,
|
color: Colors.Highlight,
|
||||||
weight: 1,
|
weight: 1,
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user