Skip to content
This repository has been archived by the owner on Jul 1, 2022. It is now read-only.

Commit

Permalink
added save button to map view
Browse files Browse the repository at this point in the history
Signed-off-by: Benjamin Blacher <[email protected]>
  • Loading branch information
Benjamin Blacher committed Feb 20, 2022
1 parent 194f6cc commit 8c3fa96
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 7 deletions.
15 changes: 13 additions & 2 deletions GUI/win_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,14 @@
## WARNING! All changes made in this file will be lost when recompiling UI file!
################################################################################

from PySide6.QtCore import (QCoreApplication, QMetaObject, QRect, Qt)
from PySide6.QtCore import (QCoreApplication, QMetaObject, QRect,
Qt)
from PySide6.QtGui import (QAction, QFont)
from PySide6.QtWidgets import (QAbstractScrollArea, QGraphicsView, QHBoxLayout, QLabel, QMenu, QMenuBar, QPushButton, QSizePolicy, QSpacerItem, QStackedWidget, QTableWidget, QVBoxLayout, QWidget, QAbstractItemView)
from PySide6.QtWidgets import (QAbstractScrollArea, QGraphicsView, QHBoxLayout,
QLabel, QMenu,
QMenuBar, QPushButton, QSizePolicy, QSpacerItem,
QStackedWidget, QTableWidget, QVBoxLayout,
QWidget, QAbstractItemView)

from pyqtgraph import PlotWidget

Expand Down Expand Up @@ -153,6 +158,11 @@ def setupUi(self, win_main):
self.verticalLayout.setObjectName(u"verticalLayout")
self.horizontalLayout_3 = QHBoxLayout()
self.horizontalLayout_3.setObjectName(u"horizontalLayout_3")
self.saveImage = QPushButton(self.view_mapview)
self.saveImage.setObjectName(u"saveImage")

self.horizontalLayout_3.addWidget(self.saveImage)

self.horizontalSpacer_3 = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)

self.horizontalLayout_3.addItem(self.horizontalSpacer_3)
Expand Down Expand Up @@ -266,6 +276,7 @@ def retranslateUi(self, win_main):
self.lab_tableview.setText(QCoreApplication.translate("win_main", u"Table View", None))
self.lab_plotview.setText(QCoreApplication.translate("win_main", u"Plot View", None))
self.PlotSettings.setText(QCoreApplication.translate("win_main", u"Plot Settings", None))
self.saveImage.setText(QCoreApplication.translate("win_main", u"Save Image", None))
self.lab_mapview.setText(QCoreApplication.translate("win_main", u"Map View", None))
self.styleSatellite.setText(QCoreApplication.translate("win_main", u"Satellite ", None))
self.styleMap.setText(QCoreApplication.translate("win_main", u"OpenStreetMap", None))
Expand Down
7 changes: 7 additions & 0 deletions GUI/win_main.ui
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,13 @@
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QPushButton" name="saveImage">
<property name="text">
<string>Save Image</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
Expand Down
18 changes: 13 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
# TODO add "Save as" for map view
# TODO don't spawn a terminal window
# TODO check screen res for map view
# TODO allow zoom & pan on map view
# TODO fix plotsettings on "open file"
# TODO fix datatypes, plotcolor on "open file"
# TODO close all child windows on main window close
# TODO Dropdown position for disabled items

# TODO (feedback needed) resize graph on edit

from csv import reader
from datetime import datetime
Expand All @@ -21,6 +17,7 @@
import os
import numpy as np
import staticmaps
from shutil import copy

windowtitle = "RC-Car Viewer"
plotinitialized = False
Expand Down Expand Up @@ -90,8 +87,17 @@ def __init__(self):
self.MapLoadButton.clicked.connect(self.draw_map)
self.styleSatellite.clicked.connect(self.map_satellite)
self.styleMap.clicked.connect(self.map_map)
self.saveImage.clicked.connect(self.save_map)
self.PlotSettings.clicked.connect(lambda: win_plotsettings.show_window())

def save_map(self):
savepath = QFileDialog.getSaveFileName(self, "Save Location", QDir.homePath(), "*.svg")
path = savepath[0]
if not path[-4:] == ".svg":
path = path + ".svg"
copy(os.getcwd() + "/temp/map_tmp.svg", path)


def map_satellite(self):
context.set_tile_provider(staticmaps.tile_provider_ArcGISWorldImagery)
self.draw_map()
Expand Down Expand Up @@ -220,6 +226,7 @@ def draw_map(self):
map_scene.addItem(map_item)
self.MapLoadButton.setVisible(0)
self.mapdisplay.setVisible(1)
self.saveImage.setVisible(1)
self.styleSatellite.setVisible(1)
self.styleMap.setVisible(1)
self.mapdisplay.setScene(map_scene)
Expand All @@ -232,6 +239,7 @@ def toggle_fullscreen(self):

def openfile(self):
self.mapdisplay.setVisible(0)
self.saveImage.setVisible(0)
self.MapLoadButton.setVisible(1)
self.styleSatellite.setVisible(0)
self.styleMap.setVisible(0)
Expand Down

0 comments on commit 8c3fa96

Please sign in to comment.