Skip to content

Commit

Permalink
Solved issue Open-MSS#573 (Configuration of label sizes for x,y axes …
Browse files Browse the repository at this point in the history
…and plot title) (Open-MSS#994)

* ui_kmloverlay_dockwidget.ui file changed for showing color and linewidth of individual kml files

* Changed the ui_kmloverlay_dockwidget.py added features of showing color and linewidth to this dockwidget (.py extension) file

* Added functionality and connected slots to show the respective color and respective linewidth of individual kml files in the listwwidget( added changes to kmloverlay_dockwidget.py)

* Modified 'remove_file(self)' function in kmloverlay_dockwidget.py ; added functionality for not showing color or linewidth when there are no kml files present in the listwidget

* Instant changes/reflection to the color label and linewidth label when the color and linewidth is changed. And also previous code's optimization

* Change color option added to main kmloverlay gui, editing of linewidth is direct in the main kmloverlay gui, display selected color of kml file right next to the file and the height of the colour block is in correspondence with the linewidth of that specific kml file

* Discarded obsolete color label display and linewidth label. The icons were made to appear directly upon startup of kmloverlaywidget. On clicking kml files it shows linewidth and you can edit from there directly.

* Optimized the code by setting flag to prevent the same icon being set twice because select_linewidth is called when item is clicked and also when valueChanged of spin box. Therefore, a flag is set to call select linewidth only when the value really changes.

* flake8 test run successfuly without any errors

* Improved functionality for setting color icons while adding files and tried the tests again

* Modified test_kmloverlay_dockwidget.py test file and removed brackets from if() in kmloverlay_dockwidget.py

* changes in test_wms_control/py for flake8 test to pass

* Added features for hiding of linewidth & color options until a file is selected. Made linewidth editor box faster which was slowing down significantly. Made color change much faster. Modified the tests also.

* Installed qt==5.9.7 and changed ui_kmloverlay_dockwidget.py and ui_kmloverlay_dockwidget.ui and removed the attribute setSteptype

* Made Change Color button transparent. Added the current color of the KML file to the QColorDialog selected color. Shortened range of linewidth from 0.1 to 10

* Added .coverage to gitignore

* Solved the issue Open-MSS#736 [Dock-widgets in TableView prevent TableView from closing upon application exit] - closing of tableview window when main MSS window is closed. Previously it used to stick around. But now it closes with MSS main window.

* Made the code more understandable for solved issue Open-MSS#736

* Updating Merge Conflict

* Synced with OpenMSS:develop

* Added options in sideview to change the fontsize of x and y(both y) axes ticklabels and labels along with the plot title.

* Rectified previous mistakes in gitignore file

* Added fontsize configuration options for topview and added datasets for default size in MSSdefaultConfig so that user can put his default value.

* Added plot options for LinearView, SideView, Topview and added default settings for users for those plot options.

* Modified code to pass the tests.

Co-authored-by: ReimarBauer <rb.proj@gmail.com>
  • Loading branch information
2 people authored and Marilyth committed Jun 17, 2021
1 parent bcb413e commit 7fbee8f
Show file tree
Hide file tree
Showing 16 changed files with 1,319 additions and 63 deletions.
11 changes: 11 additions & 0 deletions mslib/msui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,3 +192,14 @@ class MissionSupportSystemDefaultConfig(object):

# dictionary for import plugins, e.g. { "FliteStar": ["txt", "mslib.plugins.io.flitestar", "load_from_flitestar"] }
import_plugins = {}

# dictionary to make title, label and ticklabel sizes for topview and sideview configurable.
# You can put your default value here, whatever you want to give,it should be a number.
topview = {"plot_title_size": 10,
"axes_label_size": 10}

sideview = {"plot_title_size": 10,
"axes_label_size": 10}

linearview = {"plot_title_size": 10,
"axes_label_size": 10}
1 change: 1 addition & 0 deletions mslib/msui/_tests/test_mpl_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def test_no_coastsegs(self):
# On land
self.map.ax.set_xlim([2, 3])
self.map.ax.set_ylim([48, 49])
self.map._draw_auto_graticule()
self.map.update_with_coordinate_change()

# On water
Expand Down
77 changes: 75 additions & 2 deletions mslib/msui/linearview.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@
limitations under the License.
"""

from mslib.utils import config_loader
from PyQt5 import QtGui
from mslib.utils import config_loader, save_settings_qsettings, load_settings_qsettings
from PyQt5 import QtGui, QtWidgets
from mslib.msui.mss_qt import ui_linearview_window as ui
from mslib.msui.mss_qt import ui_linearview_options as ui_opt
from mslib.msui.viewwindows import MSSMplViewWindow
from mslib.msui import wms_control as wms
from mslib.msui.icons import icons
Expand All @@ -36,6 +37,49 @@
WMS = 0


class MSS_LV_Options_Dialog(QtWidgets.QDialog, ui_opt.Ui_LinearViewOptionsDialog):
"""
Dialog class to specify Linear View Options.
"""

def __init__(self, parent=None, settings_dict=None):
"""
Arguments:
parent -- Qt widget that is parent to this widget.
settings_dict -- dictionary containing sideview options.
"""
super(MSS_LV_Options_Dialog, self).__init__(parent)
self.setupUi(self)

default_settings_dict = {
"plot_title_size": "default",
"axes_label_size": "default"
}

if settings_dict is not None:
default_settings_dict.update(settings_dict)
settings_dict = default_settings_dict

for i in range(self.lv_cbtitlesize.count()):
if self.lv_cbtitlesize.itemText(i) == settings_dict["plot_title_size"]:
self.lv_cbtitlesize.setCurrentIndex(i)

for i in range(self.lv_cbaxessize.count()):
if self.lv_cbaxessize.itemText(i) == settings_dict["axes_label_size"]:
self.lv_cbaxessize.setCurrentIndex(i)

def get_settings(self):
"""
Returns the specified settings from the GUI elements.
"""
settings_dict = {
"plot_title_size": self.lv_cbtitlesize.currentText(),
"axes_label_size": self.lv_cbaxessize.currentText()
}

return settings_dict


class MSSLinearViewWindow(MSSMplViewWindow, ui.Ui_LinearWindow):
"""
PyQt window implementing a matplotlib canvas as linear flight track view.
Expand All @@ -57,12 +101,17 @@ def __init__(self, parent=None, model=None, _id=None):

self.setFlightTrackModel(model)

self.settings_tag = "linearview"
self.load_settings()

# Connect slots and signals.
# ==========================

# Tool opener.
self.cbTools.currentIndexChanged.connect(self.openTool)

self.lvoptionbtn.clicked.connect(self.set_options)

def __del__(self):
del self.mpl.canvas.waypoints_interactor

Expand Down Expand Up @@ -96,3 +145,27 @@ def setFlightTrackModel(self, model):
super(MSSLinearViewWindow, self).setFlightTrackModel(model)
if self.docks[WMS] is not None:
self.docks[WMS].widget().setFlightTrackModel(model)

def set_options(self):
settings = self.getView().get_settings()
dlg = MSS_LV_Options_Dialog(parent=self, settings_dict=settings)
dlg.setModal(True)
if dlg.exec_() == QtWidgets.QDialog.Accepted:
settings = dlg.get_settings()
self.getView().set_settings(settings)
self.save_settings()
dlg.destroy()

def save_settings(self):
"""
Save the current settings of plot options to the file self.settingsfile.
"""
settings = self.getView().get_settings()
save_settings_qsettings(self.settings_tag, settings)

def load_settings(self):
"""
Load settings from the file self.settingsfile.
"""
settings = load_settings_qsettings(self.settings_tag)
self.getView().set_settings(settings)
17 changes: 7 additions & 10 deletions mslib/msui/mpl_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ def __init__(self, identifier=None, CRS=None, BBOX_UNITS=None, PROJECT_NAME=None
"colour_land": ((204 / 255.), (153 / 255.), (102 / 255.), (255 / 255.))}
default_appearance.update(param_appearance)
self.appearance = default_appearance

# Identifier of this map canvas (used to query data structures that
# are observed by different views).
if identifier is not None:
Expand Down Expand Up @@ -145,10 +144,8 @@ def __init__(self, identifier=None, CRS=None, BBOX_UNITS=None, PROJECT_NAME=None
self.crs_text = self.ax.figure.text(0, 0, self.crs)

if self.appearance["draw_graticule"]:
try:
self._draw_auto_graticule()
except Exception as ex:
logging.error("ERROR: cannot plot graticule (message: %s - '%s')", type(ex), ex)
pass
# self._draw_auto_graticule() ; It's already called in mpl_qtwidget.py in MplTopviewCanvas init_map().
else:
self.map_parallels = None
self.map_meridians = None
Expand Down Expand Up @@ -177,7 +174,7 @@ def set_axes_limits(self, ax=None):
super(MapCanvas, self).set_axes_limits(ax=ax)
matplotlib.interactive(intact)

def _draw_auto_graticule(self):
def _draw_auto_graticule(self, font_size=None):
"""
Draw an automatically spaced graticule on the map.
"""
Expand Down Expand Up @@ -281,14 +278,14 @@ def _draw_auto_graticule(self):
latStart = np.floor((mapLatStart / spacingLat)) * spacingLat
latStop = np.ceil((mapLatStop / spacingLat)) * spacingLat

# d) call the basemap methods to draw the lines in the determined
# range.
# d) call the basemap methods to draw the lines in the determined
# range.
self.map_parallels = self.drawparallels(np.arange(latStart, latStop,
spacingLat),
labels=[1, 1, 0, 0], zorder=3)
labels=[1, 1, 0, 0], fontsize=font_size, zorder=3)
self.map_meridians = self.drawmeridians(np.arange(lonStart, lonStop,
spacingLon),
labels=[0, 0, 0, 1], zorder=3)
labels=[0, 0, 0, 1], fontsize=font_size, zorder=3)

def set_graticule_visible(self, visible=True):
"""
Expand Down
Loading

0 comments on commit 7fbee8f

Please sign in to comment.