Mapping color points with text workinggit add .git add .

This commit is contained in:
2018-07-28 18:51:12 -07:00
parent ba07b6da02
commit 6cd95b59cb
4 changed files with 299 additions and 200 deletions

View File

@@ -440,14 +440,15 @@ class OverlayImage(object):
for element in navigation_list:
x, y = self._get_cartesian(float(element[1]), float(element[2]))
draw.ellipse((x - size, y - size, x + size, y + size), fill="red")
draw.text((x + 10, y - 5), str(element[0]))
draw.ellipse((x - size, y - size, x + size, y + size), fill=(element[3].red(), element[3].green(), element[3].blue()))
for element in landmark_list:
x, y = self._get_cartesian(element[1], element[2])
draw.ellipse((x - size, y - size, x + size, y + size), fill="blue")
draw.text((x + 10, y - 5), str(element[0]))
draw.ellipse((x - size, y - size, x + size, y + size), fill=(element[3].red(), element[3].green(), element[3].blue()))
self._draw_rover(latitude, longitude, compass)
# self._draw_coordinate_text(latitude, longitude)
self.update(latitude, longitude)
return self.display_image
@@ -455,8 +456,6 @@ class OverlayImage(object):
def load_rover_icon(self):
self.indicator = PIL.Image.open("Resources/Images/rover.png").resize((40, 40))
def _draw_rover(self, lat, lon, angle=0):
x, y = self._get_cartesian(lat, lon)

View File

@@ -68,8 +68,8 @@ class RoverMapCoordinator(QtCore.QThread):
self.map_pixmap = QtGui.QPixmap.fromImage(ImageQt(Image.open("Resources/Images/maps_loading.png").resize((1280, 720), Image.BICUBIC)))
self.last_map_pixmap_cache_key = None
self.longitude = None
self.latitude = None
self.longitude = 0
self.latitude = 0
self.last_heading = 0
self.imu_data = None
@@ -168,6 +168,10 @@ class RoverMapCoordinator(QtCore.QThread):
self.pixmap_ready_signal.emit()
def _draw_coordinate_text(self, latitude, longitude):
if latitude == 0 and longitude == 0:
location_text = "LAT: NO FIX\nLON: NO FIX"
else:
location_text = "LAT: %+014.9f\nLON: %+014.9f" % (latitude, longitude)
font = PIL.ImageFont.truetype("UbuntuMono-R", size=20)
@@ -204,15 +208,15 @@ class RoverMapCoordinator(QtCore.QThread):
temp_list = []
count = UI_element.rowCount()
for row in range(0, count):
num = UI_element.item(row, 0).text()
name = UI_element.item(row, 0).text()
lat = float(UI_element.item(row, 1).text())
lng = float(UI_element.item(row, 2).text())
temp_tuple = (num, lat, lng)
color = UI_element.item(row, 3).background().color()
temp_tuple = (name, lat, lng, color)
temp_list.append(temp_tuple)
return temp_list
def update_overlay(self):
if self.latitude and self.longitude:
if not numpy.isnan(self.latitude) and not numpy.isnan(self.longitude):
latitude = float(self.latitude)
longitude = float(self.longitude)

View File

@@ -44,6 +44,13 @@ class WaypointsCoordinator(QtCore.QThread):
self.longitude_card_label = self.left_screen.manual_waypoint_cardinal_longitude_combo_box
# Color Labels and Buttons
self.nav_color_label = self.left_screen.manual_waypoint_navigation_color_label
self.nav_color_set_button = self.left_screen.manual_waypoint_navigation_color_set_button
self.landmark_color_label = self.left_screen.manual_waypoint_landmark_color_label
self.landmark_color_set_button = self.left_screen.manual_waypoint_landmark_color_set_button
# Nav Table Buttons
self.nav_set_button_label = (self.left_screen.
navigation_waypoints_set_button)
@@ -77,6 +84,17 @@ class WaypointsCoordinator(QtCore.QThread):
self.longitude = None
self.latitude = None
self.nav_color = QtCore.Qt.yellow
self.landmark_color = QtCore.Qt.blue
self.nav_color_dialog = QtWidgets.QColorDialog()
self.nav_color_dialog.setWindowFlags(
QtCore.Qt.WindowStaysOnTopHint | QtCore.Qt.X11BypassWindowManagerHint | QtCore.Qt.WindowTitleHint | QtCore.Qt.WindowCloseButtonHint)
self.landmark_color_dialog = QtWidgets.QColorDialog()
self.landmark_color_dialog.setWindowFlags(
QtCore.Qt.WindowStaysOnTopHint | QtCore.Qt.X11BypassWindowManagerHint | QtCore.Qt.WindowTitleHint | QtCore.Qt.WindowCloseButtonHint)
def run(self):
while self.run_thread_flag:
self.msleep(3)
@@ -100,13 +118,22 @@ class WaypointsCoordinator(QtCore.QThread):
self.navigation_label.cellClicked.connect(self._on_nav_clicked)
self.landmark_label.cellClicked.connect(self._on_land_clicked)
def _add_to_table(self, name, lat, lng, dist, table):
self.nav_color_set_button.clicked.connect(self.nav_color_dialog.show)
self.landmark_color_set_button.clicked.connect(self.landmark_color_dialog.show)
self.nav_color_dialog.currentColorChanged.connect(self.__on_new_nav_color_selected)
self.landmark_color_dialog.currentColorChanged.connect(self.__on_new_landmark_color_selected)
def _add_to_table(self, name, lat, lng, color, table):
color_table_item = QtWidgets.QTableWidgetItem()
color_table_item.setBackground(color)
count = table.rowCount()
table.insertRow(count)
table.setItem(count, 0, QtWidgets.QTableWidgetItem(name))
table.setItem(count, 1, QtWidgets.QTableWidgetItem(lat))
table.setItem(count, 2, QtWidgets.QTableWidgetItem(lng))
table.setItem(count, 3, QtWidgets.QTableWidgetItem(dist))
table.setItem(count, 3, color_table_item)
def _clear_inputs(self):
self.name_edit_label.clear()
@@ -125,9 +152,8 @@ class WaypointsCoordinator(QtCore.QThread):
def _nav_add_gps(self):
if self.longitude and self.latitude:
name = self.navigation_label.rowCount()
distance = 0 # FIXME: this should be calculated from current to enterred position
self._add_to_table(str(name + 1), str(self.latitude),
str(self.longitude), str(distance),
str(self.longitude), self.nav_color,
self.navigation_label)
self._clear_inputs()
@@ -143,6 +169,14 @@ class WaypointsCoordinator(QtCore.QThread):
self.navigation_table_cur_click,
2,
QtWidgets.QTableWidgetItem(lng))
color_table_item = QtWidgets.QTableWidgetItem()
color_table_item.setBackground(self.nav_color)
self.navigation_label.setItem(
self.navigation_table_cur_click,
3,
color_table_item)
self._clear_inputs()
def _nav_add_manual(self):
@@ -151,9 +185,8 @@ class WaypointsCoordinator(QtCore.QThread):
name = self.navigation_label.rowCount()
lat = self.latitude_label.text()
lng = self.longitude_label.text()
distance = 200
self._add_to_table(str(name + 1), lat,
lng, str(distance),
lng, self.nav_color,
self.navigation_label)
self._clear_inputs()
@@ -171,10 +204,7 @@ class WaypointsCoordinator(QtCore.QThread):
def _land_add_gps(self):
if self.longitude and self.latitude:
name = self.name_edit_label.text()
distance = 200 # FIXME: this should be calculated from current to enterred position
self._add_to_table(name, str(self.latitude),
str(self.longitude), str(distance),
self.landmark_label)
self._add_to_table(name, str(self.latitude), str(self.longitude), self.landmark_color, self.landmark_label)
self._clear_inputs()
def _land_add_manual(self):
@@ -182,9 +212,8 @@ class WaypointsCoordinator(QtCore.QThread):
name = self.name_edit_label.text()
lat = self.latitude_label.text()
lng = self.longitude_label.text()
distance = 200
self._add_to_table(name, lat,
lng, str(distance),
lng, self.landmark_color,
self.landmark_label)
self._clear_inputs()
@@ -213,6 +242,12 @@ class WaypointsCoordinator(QtCore.QThread):
self.landmark_label.setItem(self.landmark_table_cur_click, 2,
QtWidgets.QTableWidgetItem(lng))
color_table_item = QtWidgets.QTableWidgetItem()
color_table_item.setBackground(self.landmark_color)
self.landmark_label.setItem(self.landmark_table_cur_click, 3,
color_table_item)
self._clear_inputs()
def setup_signals(self, start_signal,
@@ -272,6 +307,18 @@ class WaypointsCoordinator(QtCore.QThread):
1
)
def __on_new_nav_color_selected(self, color):
self.nav_color_label.setStyleSheet(
"background-color: rgb(%s, %s, %s)" % (color.red(), color.green(), color.blue()))
self.nav_color = color
def __on_new_landmark_color_selected(self, color):
self.landmark_color_label.setStyleSheet(
"background-color: rgb(%s, %s, %s)" % (color.red(), color.green(), color.blue()))
self.landmark_color = color
def gps_position_updated_callback(self, data):
self.latitude = data.latitude
self.longitude = data.longitude

View File

@@ -1892,6 +1892,125 @@ N/A</string>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<property name="spacing">
<number>6</number>
</property>
<item>
<widget class="QLabel" name="label_11">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Color</string>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>Navigation</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="manual_waypoint_navigation_color_label">
<property name="minimumSize">
<size>
<width>25</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>25</width>
<height>25</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background-color:yellow;</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="manual_waypoint_navigation_color_set_button">
<property name="text">
<string>Set</string>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line_7">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_12">
<property name="text">
<string>Landmark</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="manual_waypoint_landmark_color_label">
<property name="minimumSize">
<size>
<width>25</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>25</width>
<height>25</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background-color:blue;</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="manual_waypoint_landmark_color_set_button">
<property name="text">
<string>Set</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="Line" name="line_2">
<property name="orientation">
@@ -2063,22 +2182,26 @@ N/A</string>
</item>
<item>
<widget class="QTableWidget" name="navigation_waypoints_table_widget">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>9999999</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">QTableView{
selection-background-color: #DE8D47;
}
QTableView QHeaderView{
background-color: #201F1D;
}
QTableView QHeaderView::section{
background-color: #201F1D;
}
QTableView QTableCornerButton::section{
background-color: #201F1D;
}</string>
<string notr="true"/>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
@@ -2116,16 +2239,6 @@ QTableView QTableCornerButton::section{
<attribute name="verticalHeaderDefaultSectionSize">
<number>30</number>
</attribute>
<row>
<property name="text">
<string>1</string>
</property>
</row>
<row>
<property name="text">
<string>2</string>
</property>
</row>
<column>
<property name="text">
<string>#</string>
@@ -2143,49 +2256,9 @@ QTableView QTableCornerButton::section{
</column>
<column>
<property name="text">
<string>Dist</string>
<string>Color</string>
</property>
</column>
<item row="0" column="0">
<property name="text">
<string>1</string>
</property>
</item>
<item row="0" column="1">
<property name="text">
<string>44.5674</string>
</property>
</item>
<item row="0" column="2">
<property name="text">
<string>-123.2756</string>
</property>
</item>
<item row="0" column="3">
<property name="text">
<string>2.4 KM</string>
</property>
</item>
<item row="1" column="0">
<property name="text">
<string>2</string>
</property>
</item>
<item row="1" column="1">
<property name="text">
<string>44.5677</string>
</property>
</item>
<item row="1" column="2">
<property name="text">
<string>-123.2748</string>
</property>
</item>
<item row="1" column="3">
<property name="text">
<string>5.7 KM</string>
</property>
</item>
</widget>
</item>
<item>
@@ -2193,6 +2266,9 @@ QTableView QTableCornerButton::section{
<property name="spacing">
<number>2</number>
</property>
<property name="bottomMargin">
<number>4</number>
</property>
<item>
<widget class="QPushButton" name="navigation_waypoints_set_button">
<property name="sizePolicy">
@@ -2207,11 +2283,13 @@ QTableView QTableCornerButton::section{
<height>35</height>
</size>
</property>
<property name="font">
<font>
<pointsize>8</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">QPushButton{
color: #201F1D;
background-color: #868685;
}</string>
<string notr="true"/>
</property>
<property name="text">
<string>Set</string>
@@ -2232,11 +2310,13 @@ QTableView QTableCornerButton::section{
<height>35</height>
</size>
</property>
<property name="font">
<font>
<pointsize>8</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">QPushButton{
color: #201F1D;
background-color: #868685;
}</string>
<string notr="true"/>
</property>
<property name="text">
<string>Add
@@ -2258,11 +2338,13 @@ Manual</string>
<height>35</height>
</size>
</property>
<property name="font">
<font>
<pointsize>8</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">QPushButton{
color: #201F1D;
background-color: #868685;
}</string>
<string notr="true"/>
</property>
<property name="text">
<string>Add
@@ -2284,11 +2366,13 @@ GPS</string>
<height>35</height>
</size>
</property>
<property name="font">
<font>
<pointsize>8</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">QPushButton{
color: #201F1D;
background-color: #868685;
}</string>
<string notr="true"/>
</property>
<property name="text">
<string>Delete</string>
@@ -2359,22 +2443,26 @@ GPS</string>
</item>
<item>
<widget class="QTableWidget" name="landmark_waypoints_table_widget">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>9999999</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">QTableView{
selection-background-color: #DE8D47;
}
QTableView QHeaderView{
background-color: #201F1D;
}
QTableView QHeaderView::section{
background-color: #201F1D;
}
QTableView QTableCornerButton::section{
background-color: #201F1D;
}</string>
<string notr="true"/>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
@@ -2415,16 +2503,6 @@ QTableView QTableCornerButton::section{
<attribute name="verticalHeaderDefaultSectionSize">
<number>30</number>
</attribute>
<row>
<property name="text">
<string>1</string>
</property>
</row>
<row>
<property name="text">
<string>2</string>
</property>
</row>
<column>
<property name="text">
<string>Name</string>
@@ -2442,49 +2520,9 @@ QTableView QTableCornerButton::section{
</column>
<column>
<property name="text">
<string>Dist</string>
<string>Color</string>
</property>
</column>
<item row="0" column="0">
<property name="text">
<string>Astronaut</string>
</property>
</item>
<item row="0" column="1">
<property name="text">
<string>44.56745</string>
</property>
</item>
<item row="0" column="2">
<property name="text">
<string>-123.2756</string>
</property>
</item>
<item row="0" column="3">
<property name="text">
<string>2.4 KM</string>
</property>
</item>
<item row="1" column="0">
<property name="text">
<string>Water</string>
</property>
</item>
<item row="1" column="1">
<property name="text">
<string>44.56775</string>
</property>
</item>
<item row="1" column="2">
<property name="text">
<string>-123.2748</string>
</property>
</item>
<item row="1" column="3">
<property name="text">
<string>5.7 KM</string>
</property>
</item>
</widget>
</item>
<item>
@@ -2492,6 +2530,9 @@ QTableView QTableCornerButton::section{
<property name="spacing">
<number>2</number>
</property>
<property name="bottomMargin">
<number>4</number>
</property>
<item>
<widget class="QPushButton" name="landmark_waypoints_set_button">
<property name="sizePolicy">
@@ -2506,11 +2547,13 @@ QTableView QTableCornerButton::section{
<height>35</height>
</size>
</property>
<property name="font">
<font>
<pointsize>8</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">QPushButton{
color: #201F1D;
background-color: #868685;
}</string>
<string notr="true"/>
</property>
<property name="text">
<string>Set</string>
@@ -2531,11 +2574,13 @@ QTableView QTableCornerButton::section{
<height>35</height>
</size>
</property>
<property name="font">
<font>
<pointsize>8</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">QPushButton{
color: #201F1D;
background-color: #868685;
}</string>
<string notr="true"/>
</property>
<property name="text">
<string>Add
@@ -2557,11 +2602,13 @@ Manual</string>
<height>35</height>
</size>
</property>
<property name="font">
<font>
<pointsize>8</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">QPushButton{
color: #201F1D;
background-color: #868685;
}</string>
<string notr="true"/>
</property>
<property name="text">
<string>Add
@@ -2583,11 +2630,13 @@ GPS</string>
<height>35</height>
</size>
</property>
<property name="font">
<font>
<pointsize>8</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">QPushButton{
color: #201F1D;
background-color: #868685;
}</string>
<string notr="true"/>
</property>
<property name="text">
<string>Delete</string>