Commit 3db8e607 authored by Benjamin Jakimow's avatar Benjamin Jakimow
Browse files

TimeSeriesDock: added option to focus on current visualized date range


added TimeSeriesFilterModel (for future filter options)
modified CHANGELOG.rst
Signed-off-by: Benjamin Jakimow's avatarBenjamin Jakimow benjamin.jakimow@geo.hu-berlin.de <benjamin.jakimow@geo.hu-berlin.de>
parent bf305b9f
==============
Changelog
==============
2020-11-16 (version 1.15):
* quick labels: CTRL + right mouse button opens map menu even when the feature modify map tool is activates
* source visibility update can be run on entire time series or (new and faster) for the next time steps only
* time series table can keep focus on the date range that is visualized in the map windows
* smaller bug fixes and improvements of workflow
2020-11-06 (version 1.14):
* this version focuses on stability updates and improvements of the "quick label" system
* map canvas menu now available with standard map tool (like zoom tool)
......
......@@ -754,7 +754,7 @@ class LabelWidget(AttributeTableWidget):
o.setCheckable(True)
o.triggered.connect(self.onSelectBehaviourOptionTriggered)
self.mOptionSelectionAddToSelection.trigger()
self.mOptionSelectionSetSelection.trigger()
# show selected feature on top by default
# self.mActionSelectedToTop.setChecked(True)
......
......@@ -404,6 +404,7 @@ class EOTimeSeriesViewer(QgisInterface, QObject):
"""
return EOTimeSeriesViewer._instance
sigCurrentDateChanged = pyqtSignal(TimeSeriesDate)
sigCurrentLocationChanged = pyqtSignal([QgsCoordinateReferenceSystem, QgsPointXY],
[QgsCoordinateReferenceSystem, QgsPointXY, QgsMapCanvas])
......@@ -515,6 +516,8 @@ class EOTimeSeriesViewer(QgisInterface, QObject):
lambda crs, pt, canvas=mw: self.setCurrentLocation(SpatialPoint(crs, pt),
mapCanvas=mw.currentMapCanvas()))
mw.sigCurrentLayerChanged.connect(self.updateCurrentLayerActions)
mw.sigCurrentDateChanged.connect(self.sigCurrentDateChanged)
mw.sigCurrentDateChanged.connect(dts.setCurrentDate)
self.ui.optionSyncMapCenter.toggled.connect(self.mapWidget().setSyncWithQGISMapCanvas)
tb = self.ui.toolBarTimeControl
......@@ -526,7 +529,7 @@ class EOTimeSeriesViewer(QgisInterface, QObject):
tb.addAction(mw.actionForwardFast)
tb.addAction(mw.actionLastDate)
tstv = self.ui.dockTimeSeries.timeSeriesTreeView
tstv = self.ui.dockTimeSeries.timeSeriesTreeView()
assert isinstance(tstv, TimeSeriesTreeView)
tstv.sigMoveToDate.connect(self.setCurrentDate)
tstv.sigMoveToSource.connect(self.setCurrentSource)
......
......@@ -2846,6 +2846,12 @@ def extractWavelengths(ds):
return None, None
class TimeSeriesFilterModel(QSortFilterProxyModel):
def __init__(self, *args, **kwds):
super().__init__(*args, **kwds)
class TimeSeriesDock(QgsDockWidget):
"""
QgsDockWidget that shows the TimeSeries
......@@ -2856,35 +2862,55 @@ class TimeSeriesDock(QgsDockWidget):
loadUi(DIR_UI / 'timeseriesdock.ui', self)
self.frameFilters.setVisible(False)
self.timeSeriesTreeView: TimeSeriesTreeView
assert isinstance(self.timeSeriesTreeView, TimeSeriesTreeView)
self.mTimeSeriesTreeView: TimeSeriesTreeView
assert isinstance(self.mTimeSeriesTreeView, TimeSeriesTreeView)
self.mTimeSeries: TimeSeries = None
self.mSelectionModel = None
self.mLastDate: TimeSeriesDate = None
self.optionFollowCurrentDate: QAction
self.optionFollowCurrentDate.toggled.connect(lambda : self.setCurrentDate(self.mLastDate))
def timeSeriesTreeView(self) -> TimeSeriesTreeView:
return self.mTimeSeriesTreeView
def setCurrentDate(self, tsd: TimeSeriesDate):
"""
Checks if optionFollowCurrentDate is checked. If True, will call setTSD to focus on the TimeSeriesDate
:param tsd: TimeSeriesDate
:type tsd:
:return:
:rtype:
"""
self.mLastDate = tsd
if not isinstance(tsd, TimeSeriesDate):
return
if self.optionFollowCurrentDate.isChecked():
self.moveToDate(tsd)
def initActions(self, parent):
from eotimeseriesviewer.main import EOTimeSeriesViewerUI
assert isinstance(parent, EOTimeSeriesViewerUI)
self.btnFollowCurrentDate.setDefaultAction(self.optionFollowCurrentDate)
self.btnAddTSD.setDefaultAction(parent.actionAddTSD)
self.btnRemoveTSD.setDefaultAction(parent.actionRemoveTSD)
self.btnLoadTS.setDefaultAction(parent.actionLoadTS)
self.btnSaveTS.setDefaultAction(parent.actionSaveTS)
self.btnClearTS.setDefaultAction(parent.actionClearTS)
def showTSD(self, tsd: TimeSeriesDate):
assert isinstance(self.timeSeriesTreeView, TimeSeriesTreeView)
def moveToDate(self, tsd: TimeSeriesDate):
tstv = self.timeSeriesTreeView()
assert isinstance(tstv, TimeSeriesTreeView)
assert isinstance(self.mTSProxyModel, QSortFilterProxyModel)
tsd.setVisibility(True)
assert isinstance(self.mTimeSeries, TimeSeries)
idxSrc = self.mTimeSeries.tsdToIdx(tsd)
if isinstance(idxSrc, QModelIndex):
idx2 = self.mTSProxyModel.mapFromSource(idxSrc)
if isinstance(idx2, QModelIndex):
self.timeSeriesTreeView.setCurrentIndex(idx2)
self.timeSeriesTreeView.scrollTo(idx2, QAbstractItemView.PositionAtCenter)
tstv.setCurrentIndex(idx2)
tstv.scrollTo(idx2, QAbstractItemView.PositionAtCenter)
def updateSummary(self):
......@@ -2941,18 +2967,18 @@ class TimeSeriesDock(QgsDockWidget):
if isinstance(TS, TimeSeries):
self.mTimeSeries = TS
self.mTSProxyModel = QSortFilterProxyModel(self)
self.mTSProxyModel = TimeSeriesFilterModel(self)
self.mTSProxyModel.setSourceModel(self.mTimeSeries)
self.mSelectionModel = QItemSelectionModel(self.mTSProxyModel)
self.mSelectionModel.selectionChanged.connect(self.onSelectionChanged)
self.timeSeriesTreeView.setModel(self.mTSProxyModel)
self.timeSeriesTreeView.setSelectionModel(self.mSelectionModel)
self.timeSeriesTreeView.sortByColumn(0, Qt.AscendingOrder)
tstv = self.timeSeriesTreeView()
tstv.setModel(self.mTSProxyModel)
tstv.setSelectionModel(self.mSelectionModel)
tstv.sortByColumn(0, Qt.AscendingOrder)
for c in range(self.mTSProxyModel.columnCount()):
self.timeSeriesTreeView.header().setSectionResizeMode(c, QHeaderView.ResizeToContents)
self.timeSeriesTreeView().header().setSectionResizeMode(c, QHeaderView.ResizeToContents)
self.mTimeSeries.rowsInserted.connect(self.updateSummary)
# self.mTimeSeries.dataChanged.connect(self.updateSummary)
self.mTimeSeries.rowsRemoved.connect(self.updateSummary)
......
......@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>640</width>
<height>261</height>
<height>266</height>
</rect>
</property>
<property name="sizePolicy">
......@@ -95,6 +95,16 @@
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QToolButton" name="btnFollowCurrentDate">
<property name="text">
<string>...</string>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="btnAddTSD">
<property name="text">
......@@ -214,7 +224,7 @@
</widget>
</item>
<item>
<widget class="TimeSeriesTreeView" name="timeSeriesTreeView">
<widget class="TimeSeriesTreeView" name="mTimeSeriesTreeView">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
......@@ -314,6 +324,24 @@
</item>
</layout>
</widget>
<action name="optionFollowCurrentDate">
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="icon">
<iconset resource="eotsv_resources.qrc">
<normaloff>:/eotimeseriesviewer/icons/mapview.svg</normaloff>:/eotimeseriesviewer/icons/mapview.svg</iconset>
</property>
<property name="text">
<string>Follow Current Date</string>
</property>
<property name="toolTip">
<string>Activate to focus the view on the current date</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>
......@@ -324,6 +352,7 @@
</customwidgets>
<resources>
<include location="eotsv_resources.qrc"/>
<include location="../../../QGIS_Images/images/images.qrc"/>
</resources>
<connections/>
</ui>
Markdown is supported
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