Commit ab9e1010 authored by Margaux Mouchene's avatar Margaux Mouchene
Browse files

Merge branch 'feature_orbit-LOS-symbol' into 'develop'

feature Orbit/LOS symbol on Minimap

See merge request !46
parents 3a5a5450 044fa149
......@@ -5,7 +5,12 @@
from .AbstractMapView import *
from PyQt5.QtCore import QSize
from PyQt5.QtCore import QSize, QPoint
from PyQt5.QtGui import (
QPolygon, QPainter, QPen,
QColor
)
import math
# mini map ##################################################################
......@@ -132,14 +137,64 @@ class MinimapView(AbstractMapView):
# glBindTexture(GL_TEXTURE_2D, 0)
# overlay using QPainter
# painter = QPainter(self)
# for dx, dy, color in [
# (1, 1, QColor('black')),
# (0, 0, QColor('white')),
# ]:
# painter.setPen(color)
# painter.drawText(10+dx, 20+dy, 'Minimap')
# overlay orbit+LOS symbol using QPainter
# if info available from metadata file
try:
assert(self.model.loader.metadata['Antenna_side'] in (
'LEFT', 'RIGHT'))
painter = QPainter(self)
painter.setRenderHint(QPainter.Antialiasing) # does not work...
# symbol is made of two perpendicular arrows, orbit arrow and LOS
# arrow (which starts at orbit arrow's mid-point)
# drawn twice, in black and in white to improve readability
for dx, dy, color in [
(1, 1, QColor('black')),
(0, 0, QColor('white'))]:
painter.setPen(QPen(color, 2))
painter.setBrush(color)
painter.pen().setWidth(10)
center_pt = QPoint(self.width()-25+dx, self.height()-25+dy)
# drawing points
(orb_start,
orb_end,
los_end) = self.make_orbit_LOS_symbol(center_pt)
los_start = center_pt
# orbit arrow:
painter.drawLine(orb_start, orb_end)
rotation = math.degrees(
math.atan2(orb_start.y()-orb_end.y(),
orb_end.x()-orb_start.x())) + 90
arrowhead_poly = [
QPoint(orb_end.x()+5*math.sin(math.radians(rotation)),
orb_end.y()+5*math.cos(math.radians(rotation))),
QPoint(orb_end.x()+5*math.sin(math.radians(rotation-120)),
orb_end.y()+5*math.cos(math.radians(rotation-120))),
QPoint(orb_end.x()+5*math.sin(math.radians(rotation+120)),
orb_end.y()+5*math.cos(math.radians(rotation+120)))]
painter.drawPolygon(QPolygon(arrowhead_poly))
# LOS arrow:
painter.drawLine(los_start, los_end)
rotation = math.degrees(
math.atan2(los_start.y()-los_end.y(),
los_end.x()-los_start.x())) + 90
arrowhead_poly = [
QPoint(los_end.x()+4*math.sin(math.radians(rotation)),
los_end.y()+4*math.cos(math.radians(rotation))),
QPoint(los_end.x()+4*math.sin(math.radians(rotation-120)),
los_end.y()+4*math.cos(math.radians(rotation-120))),
QPoint(los_end.x()+4*math.sin(math.radians(rotation+120)),
los_end.y()+4*math.cos(math.radians(rotation+120)))]
painter.drawPolygon(QPolygon(arrowhead_poly))
except (AssertionError, AttributeError, KeyError):
# no metadata or wrong format
pass
# interaction
......@@ -243,3 +298,55 @@ class MinimapView(AbstractMapView):
elif self.interaction == ZOOM:
if e.button() == Qt.RightButton:
self.interaction = IDLE
def make_orbit_LOS_symbol(self, center_pt):
"""
determine the coordinates or the points for the symbol representing
the satellite's orbit direction and LOS in the Minimap
Symbol for ASCENDING RIGHT:
Orbit direction
^
|
|
|-> LOS
|
|
Parameters
----------
center_pt : QPoint
center point for the symbol (near bottom-right corner of Minimap)
Returns
-------
orb_start : QPoint
starting point of the orbit arrow.
orb_end : QPoint
end point of the orbit arrow.
los_end : QPoint
end point of the LOS arrow.
"""
# ASCENDING:
if self.model.loader.metadata['Orbit_direction'] == 'ASCENDING':
orb_start = QPoint(center_pt.x() + 4, center_pt.y() + 15)
orb_end = QPoint(center_pt.x() - 4, center_pt.y() - 15)
if self.model.loader.metadata['Antenna_side'] == 'RIGHT':
los_end = QPoint(center_pt.x() + 3, center_pt.y() - 1)
elif self.model.loader.metadata['Antenna_side'] == 'LEFT':
los_end = QPoint(center_pt.x() - 3, center_pt.y() + 1)
elif self.model.loader.metadata['Orbit_direction'] == 'DESCENDING':
orb_start = QPoint(center_pt.x() + 4, center_pt.y() - 15)
orb_end = QPoint(center_pt.x() - 4, center_pt.y() + 15)
if self.model.loader.metadata['Antenna_side'] == 'RIGHT':
los_end = QPoint(center_pt.x() - 3, center_pt.y() - 1)
elif self.model.loader.metadata['Antenna_side'] == 'LEFT':
los_end = QPoint(center_pt.x() + 3, center_pt.y() + 1)
else:
print('unrecognized orbit/LOS parameters')
return (orb_start, orb_end, los_end)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment