Skip to content

Commit

Permalink
Solved issue #644 (#709)
Browse files Browse the repository at this point in the history
* 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

Co-authored-by: ReimarBauer <rb.proj@gmail.com>
  • Loading branch information
risehr and ReimarBauer authored Mar 26, 2021
1 parent 33868cc commit 81a62a3
Show file tree
Hide file tree
Showing 6 changed files with 256 additions and 116 deletions.
31 changes: 11 additions & 20 deletions mslib/msui/_tests/test_kmloverlay_dockwidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,41 +161,32 @@ def test_merge_file(self, mocksave, mockbox):
assert os.path.exists(save_kml)

@mock.patch("PyQt5.QtWidgets.QColorDialog.getColor", return_value=QtGui.QColor())
def test_customize_kml(self, mock_colour_dialog):
def test_customize_kml(self, mock_colour_button):
"""
Test opening Customize KML Dialogue and checking specific file gets
desired linewidth and colour
Test the pushbutton for color and double spin box for linewidth and checking specific
file gets desired linewidth and colour
"""
path = self.select_file("line.kml") # selects file and returns path
assert self.window.listWidget.count() == 1
item = self.window.listWidget.item(0)
rect = self.window.listWidget.visualItemRect(item)
# in testing, need to add mouseclick before double click
# in testing, need to add mouseclick and click the listWidget item
QtTest.QTest.mouseClick(self.window.listWidget.viewport(),
QtCore.Qt.LeftButton,
pos=rect.center())
QtWidgets.QApplication.processEvents()
# Double click feature
QtTest.QTest.mouseDClick(self.window.listWidget.viewport(),
QtCore.Qt.LeftButton,
pos=rect.center())
QtWidgets.QApplication.processEvents()

# Clicking on Push Button Colour
QtTest.QTest.mouseClick(self.window.dialog.pushButton_colour, QtCore.Qt.LeftButton)
QtTest.QTest.mouseClick(self.window.pushButton_color, QtCore.Qt.LeftButton)
QtWidgets.QApplication.processEvents()
assert mock_colour_dialog.call_count == 1

# Testing the Double Spin Box
self.window.dialog.dsb_linewidth.setValue(3)
assert self.window.dialog.dsb_linewidth.value() == 3
assert mock_colour_button.call_count == 1

# clicking on OK Button
okWidget = self.window.dialog.buttonBox.button(self.window.dialog.buttonBox.Ok)
QtTest.QTest.mouseClick(okWidget, QtCore.Qt.LeftButton)
QtWidgets.QApplication.processEvents()
# Testing the Double Spin Box for linewidth
self.window.dsbx_linewidth.setValue(3)
assert self.window.dsbx_linewidth.value() == 3

assert self.window.dict_files[path]["color"] == self.window.get_color()
# Testing the dictionary of files for color and linewidth
assert self.window.dict_files[path]["color"] == (0, 0, 0, 1)
assert self.window.dict_files[path]["linewidth"] == 3

self.window.remove_file()
Expand Down
15 changes: 10 additions & 5 deletions mslib/msui/_tests/test_wms_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,8 @@ def test_multilayer_handling(self, mockbox):
assert that multilayers get created, handled and drawn properly
"""
self.query_server(f"http://127.0.0.1:{self.port}")
server = self.window.multilayers.listLayers.findItems(f"http://127.0.0.1:{self.port}/", QtCore.Qt.MatchFixedString)[0]
server = self.window.multilayers.listLayers.findItems(f"http://127.0.0.1:{self.port}/",
QtCore.Qt.MatchFixedString)[0]
assert server is not None
assert "header" in self.window.multilayers.layers[f"http://127.0.0.1:{self.port}/"]
assert "wms" in self.window.multilayers.layers[f"http://127.0.0.1:{self.port}/"]
Expand Down Expand Up @@ -307,7 +308,8 @@ def test_singlelayer_handling(self, mockbox):
assert that singlelayer mode behaves as expected
"""
self.query_server(f"http://127.0.0.1:{self.port}")
server = self.window.multilayers.listLayers.findItems(f"http://127.0.0.1:{self.port}/", QtCore.Qt.MatchFixedString)[0]
server = self.window.multilayers.listLayers.findItems(f"http://127.0.0.1:{self.port}/",
QtCore.Qt.MatchFixedString)[0]
assert server is not None
assert "header" in self.window.multilayers.layers[f"http://127.0.0.1:{self.port}/"]
assert "wms" in self.window.multilayers.layers[f"http://127.0.0.1:{self.port}/"]
Expand All @@ -317,7 +319,8 @@ def test_singlelayer_handling(self, mockbox):
# Check using singlelayer mode contains no checkboxes
for i in range(0, server.childCount()):
layer = server.child(i)
assert layer.data(0, QtCore.Qt.CheckStateRole) is None or not layer.data(0, QtCore.Qt.CheckStateRole).isValid()
assert layer.data(0, QtCore.Qt.CheckStateRole) is None or not layer.data(0,
QtCore.Qt.CheckStateRole).isValid()

# Check clicking on layers updates the UI
self.window.multilayers.multilayer_clicked(server.child(0))
Expand All @@ -341,7 +344,8 @@ def test_multilayer_syncing(self, mockbox):
assert that synced layers share their options
"""
self.query_server(f"http://127.0.0.1:{self.port}")
server = self.window.multilayers.listLayers.findItems(f"http://127.0.0.1:{self.port}/", QtCore.Qt.MatchFixedString)[0]
server = self.window.multilayers.listLayers.findItems(f"http://127.0.0.1:{self.port}/",
QtCore.Qt.MatchFixedString)[0]
server.setExpanded(True)
self.window.multilayers.cbMultilayering.setChecked(True)
layer_a = server.child(0)
Expand Down Expand Up @@ -394,7 +398,8 @@ def test_multilayer_drawing(self, mockbox):
assert that drawing a layer through code doesn't fail for vsec
"""
self.query_server(f"http://127.0.0.1:{self.port}")
server = self.window.multilayers.listLayers.findItems(f"http://127.0.0.1:{self.port}/", QtCore.Qt.MatchFixedString)[0]
server = self.window.multilayers.listLayers.findItems(f"http://127.0.0.1:{self.port}/",
QtCore.Qt.MatchFixedString)[0]
server.child(0).draw()

assert mockbox.critical.call_count == 0
Expand Down
Loading

0 comments on commit 81a62a3

Please sign in to comment.