diff --git a/eotimeseriesviewer/mapcanvas.py b/eotimeseriesviewer/mapcanvas.py index 751beec2f4de36cba9b8e86c1168ed87eec9f775..4ab83c1ef110a0d7f8a2e2653cd28e57c24e9663 100644 --- a/eotimeseriesviewer/mapcanvas.py +++ b/eotimeseriesviewer/mapcanvas.py @@ -42,6 +42,8 @@ from .externals.qps.utils import * from .externals.qps.layerproperties import showLayerPropertiesDialog import eotimeseriesviewer.settings +PROGRESS_TIMER = QTimer() +PROGRESS_TIMER.start(100) def toQgsMimeDataUtilsUri(mapLayer:QgsMapLayer): @@ -57,6 +59,50 @@ def toQgsMimeDataUtilsUri(mapLayer:QgsMapLayer): raise NotImplementedError() return uri +class MapLoadingInfoItem(QgsMapCanvasItem): + + def __init__(self, mapCanvas): + assert isinstance(mapCanvas, QgsMapCanvas) + super(MapLoadingInfoItem, self).__init__(mapCanvas) + self.mCanvas = mapCanvas + self.mProgressConnection = None + + self.mCanvas.renderStarting.connect(lambda: self.showLoadingProgress(True)) + #self.mCanvas.renderComplete.connect(lambda: self.showLoadingProgress(False)) + + PROGRESS_TIMER.timeout.connect(self.onProgressTimeOut) + self.mShowProgress = False + self.mIsVisible = True + + def showLoadingProgress(self, showProgress: bool): + self.mShowProgress = showProgress + self.update() + + def onProgressTimeOut(self): + + if self.mShowProgress: + self.mCanvas.update() + + def paint(self, painter, QStyleOptionGraphicsItem=None, QWidget_widget=None): + """ + Paints the crosshair + :param painter: + :param QStyleOptionGraphicsItem: + :param QWidget_widget: + :return: + """ + if self.mShowProgress: + + if True: + options = QStyleOptionProgressBar() + options.rect = QRect(0, 0, painter.window().width(), 25) + options.textAlignment = Qt.AlignCenter + options.progress = 0 + options.maximum = 0 + options.minimum = 0 + QApplication.style().drawControl(QStyle.CE_ProgressBar, options, painter) + else: + class MapCanvasInfoItem(QgsMapCanvasItem): def __init__(self, mapCanvas): @@ -72,7 +118,7 @@ class MapCanvasInfoItem(QgsMapCanvasItem): def setVisibility(self, b:bool): """ - Sets the visibility of a Crosshair + Sets the visibility of the info item :param b: :return: """ @@ -83,7 +129,7 @@ class MapCanvasInfoItem(QgsMapCanvasItem): self.mCanvas.update() def visibility(self)->bool: - """Returns the Crosshair visibility""" + """Returns the info items's visibility""" return self.mVisibility def paintText(self, painter, text:str, position): @@ -115,6 +161,7 @@ class MapCanvasInfoItem(QgsMapCanvasItem): :param QWidget_widget: :return: """ + if self.mLRText: self.paintText(painter, self.mLRText, QPoint(0, 0)) @@ -212,9 +259,19 @@ class MapCanvas(QgsMapCanvas): self.mCrosshairItem = CrosshairMapCanvasItem(self) self.mInfoItem = MapCanvasInfoItem(self) + self.mProgressItem = MapLoadingInfoItem(self) self.mTSD = self.mMapView = None + self.mUserInputWidget = QgsUserInputWidget(self) + self.mUserInputWidget.setObjectName('UserInputDockWidget') + self.mUserInputWidget.setAnchorWidget(self) + self.mUserInputWidget.setAnchorWidgetPoint(QgsFloatingWidget.TopRight) + self.mUserInputWidget.setAnchorPoint(QgsFloatingWidget.TopRight) + + #self.mProgressBar = QProgressBar() + #self.mUserInputWidget.addUserInputWidget(self.mProgressBar) + self.mIsRefreshing = False self.mRenderingFinished = True self.mRefreshStartTime = time.time() @@ -239,6 +296,14 @@ class MapCanvas(QgsMapCanvas): self.extentsChanged.connect(lambda : self.sigSpatialExtentChanged.emit(self.spatialExtent())) + + def userInputWidget(self)->QgsUserInputWidget: + """ + Returns the mapcanvas QgsUserInputWidget + :return: QgsUserInputWidget + """ + return self.mUserInputWidget + def mapView(self): """ Returns the MapView this MapCanvas is linked to @@ -841,7 +906,7 @@ class MapCanvas(QgsMapCanvas): action.triggered.connect(self.onFocusToCurrentSpatialExtent) action = menu.addAction('Hide Date') - action.triggered.connect(lambda: self.mTSD.setVisibility(False)) + action.triggered.connect(lambda: self.mTSD.setIsVisible(False)) if isinstance(eotsv, TimeSeriesViewer): ts = eotsv.timeSeries() diff --git a/eotimeseriesviewer/mapvisualization.py b/eotimeseriesviewer/mapvisualization.py index 1f0ffcb1a10090f69f2896e8cb97368da7f03ce8..63a458adc8ec0a86ccde36b373e106ef233b2d2d 100644 --- a/eotimeseriesviewer/mapvisualization.py +++ b/eotimeseriesviewer/mapvisualization.py @@ -199,6 +199,7 @@ class MapViewLayerTreeModel(QgsLayerTreeModel): return f + class MapView(QFrame, loadUIFormClass(jp(DIR_UI, 'mapview.ui'))): """ A MapView defines how a single map canvas visualizes sensor specific EOTS data plus additional vector overlays @@ -656,6 +657,9 @@ class DatumViewUI(QFrame, loadUI('timeseriesdateview.ui')): super(DatumViewUI, self).__init__(parent) self.setupUi(self) + # do not show progress bar + self.progressBar.setVisible(False) + def sizeHint(self): m = self.layout().contentsMargins() @@ -812,8 +816,8 @@ class DatumView(QObject): mapCanvas.setTSD(self.TSD) mapView.registerMapCanvas(mapCanvas) self.STV.registerMapCanvas(mapCanvas) - mapCanvas.renderComplete.connect(lambda : self.onRenderingChange(False)) - mapCanvas.renderStarting.connect(lambda : self.onRenderingChange(True)) + mapCanvas.renderComplete.connect(lambda: self.onRenderingChange(False)) + mapCanvas.renderStarting.connect(lambda: self.onRenderingChange(True)) #mapCanvas.sigMapRefreshed[float, float].connect( # lambda dt: self.STV.TSV.ui.dockSystemInfo.addTimeDelta('Map {}'.format(self.mSensor.name()), dt)) @@ -1527,6 +1531,51 @@ class MapViewDock(QgsDockWidget, loadUI('mapviewdock.ui')): return None +class MapWidget(QWidget, loadUIFormClass(jp(DIR_UI, 'mapwidget.ui'))): + """ + This widget contains all maps + """ + + class ViewMode(enum.Enum): + + MapViewByRows = 1, + MapViewByCols = 2 + + + + + def __init__(self, *args, **kwds): + super(MapWidget, self).__init__(*args, **kwds) + self.setupUi(self) + + self.mGrid = self.layout() + self.mViewMode = MapWidget.ViewMode.MapViewByRows + self.nMpMV = 3 + + self.mCanvases = dict() + + def setMode(self, mode:ViewMode): + + self.mViewMode = mode + + def setMapsPerMapView(self, n:int): + assert n > 0 + + self.nMpMV = n + + def setCurrentDate(self, tsd:TimeSeriesDate): + pass + + def addMapView(self, mapView:MapView): + pass + + + def removeMapView(self, mapView:MapView): + pass + + def updateCanvasWidgets(self): + pass + class SpatialTemporalVisualization(QObject): """ diff --git a/eotimeseriesviewer/ui/mapviewrendersettings.ui b/eotimeseriesviewer/ui/mapviewrendersettings.ui deleted file mode 100644 index 5da10e3df3f71e2044a4f3ebe461089b3a53a2aa..0000000000000000000000000000000000000000 --- a/eotimeseriesviewer/ui/mapviewrendersettings.ui +++ /dev/null @@ -1,287 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>MapViewRenderSettings</class> - <widget class="QGroupBox" name="MapViewRenderSettings"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>335</width> - <height>487</height> - </rect> - </property> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>150</width> - <height>0</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>16777215</width> - <height>16777215</height> - </size> - </property> - <property name="font"> - <font> - <pointsize>8</pointsize> - </font> - </property> - <property name="windowTitle"> - <string>RenderSettings</string> - </property> - <property name="styleSheet"> - <string notr="true">QFrame::title{color: rgb(0, 0, 127);}</string> - </property> - <property name="title"> - <string><sensor/product></string> - </property> - <property name="flat"> - <bool>true</bool> - </property> - <property name="checkable"> - <bool>false</bool> - </property> - <layout class="QVBoxLayout" name="verticalLayout" stretch="0,0"> - <property name="spacing"> - <number>2</number> - </property> - <property name="sizeConstraint"> - <enum>QLayout::SetNoConstraint</enum> - </property> - <property name="leftMargin"> - <number>2</number> - </property> - <property name="topMargin"> - <number>6</number> - </property> - <property name="rightMargin"> - <number>2</number> - </property> - <property name="bottomMargin"> - <number>0</number> - </property> - <item> - <widget class="QFrame" name="frame"> - <layout class="QHBoxLayout" name="horizontalLayout_3"> - <property name="spacing"> - <number>2</number> - </property> - <property name="topMargin"> - <number>1</number> - </property> - <item> - <widget class="QLabel" name="labelRenderer"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="font"> - <font> - <pointsize>8</pointsize> - <weight>50</weight> - <italic>false</italic> - <bold>false</bold> - <kerning>true</kerning> - </font> - </property> - <property name="toolTip"> - <string>Sensor name</string> - </property> - <property name="text"> - <string>Style</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - </widget> - </item> - <item> - <widget class="QComboBox" name="cbRenderType"> - <property name="maximumSize"> - <size> - <width>16777215</width> - <height>16777215</height> - </size> - </property> - <property name="font"> - <font> - <pointsize>8</pointsize> - </font> - </property> - </widget> - </item> - <item> - <widget class="QToolButton" name="btnPasteStyle"> - <property name="text"> - <string>...</string> - </property> - <property name="icon"> - <iconset resource="resources.qrc"> - <normaloff>:/timeseriesviewer/icons/mActionEditPaste.svg</normaloff>:/timeseriesviewer/icons/mActionEditPaste.svg</iconset> - </property> - <property name="autoRaise"> - <bool>true</bool> - </property> - </widget> - </item> - <item> - <widget class="QToolButton" name="btnCopyStyle"> - <property name="text"> - <string>...</string> - </property> - <property name="icon"> - <iconset resource="resources.qrc"> - <normaloff>:/timeseriesviewer/icons/mActionEditCopy.svg</normaloff>:/timeseriesviewer/icons/mActionEditCopy.svg</iconset> - </property> - <property name="autoRaise"> - <bool>true</bool> - </property> - </widget> - </item> - <item> - <widget class="QToolButton" name="btnApplyStyle"> - <property name="text"> - <string>...</string> - </property> - <property name="icon"> - <iconset> - <normaloff>:/timeseriesviewer/icons/mActionRefresh.png</normaloff>:/timeseriesviewer/icons/mActionRefresh.png</iconset> - </property> - <property name="autoRaise"> - <bool>true</bool> - </property> - </widget> - </item> - <item> - <spacer name="horizontalSpacer_4"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>0</width> - <height>0</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - </item> - <item> - <layout class="QVBoxLayout" name="renderWidgetLayout"/> - </item> - </layout> - <action name="actionSetDefaultMB"> - <property name="text"> - <string>Def</string> - </property> - <property name="toolTip"> - <string>Set default band selection</string> - </property> - </action> - <action name="actionSetTrueColor"> - <property name="text"> - <string>True</string> - </property> - <property name="toolTip"> - <string>Set to true color (red-green-blue)</string> - </property> - </action> - <action name="actionSetCIR"> - <property name="text"> - <string>CIR1</string> - </property> - <property name="toolTip"> - <string>Set to coloured infra red (swIR-red-green)</string> - </property> - </action> - <action name="actionSet453"> - <property name="text"> - <string>CIR2</string> - </property> - <property name="toolTip"> - <string>Set to swIR-mwIR-red</string> - </property> - </action> - <action name="actionCopyStyle"> - <property name="icon"> - <iconset resource="resources.qrc"> - <normaloff>:/timeseriesviewer/icons/mActionEditCopy.svg</normaloff>:/timeseriesviewer/icons/mActionEditCopy.svg</iconset> - </property> - <property name="text"> - <string>Copy style</string> - </property> - <property name="toolTip"> - <string>Copy style to clipboard</string> - </property> - </action> - <action name="actionPasteStyle"> - <property name="icon"> - <iconset resource="resources.qrc"> - <normaloff>:/timeseriesviewer/icons/mActionEditPaste.svg</normaloff>:/timeseriesviewer/icons/mActionEditPaste.svg</iconset> - </property> - <property name="text"> - <string>Paste Style</string> - </property> - <property name="toolTip"> - <string>Paste style from clipboard</string> - </property> - </action> - <action name="actionApplyStyle"> - <property name="icon"> - <iconset resource="resources.qrc"> - <normaloff>:/timeseriesviewer/icons/mActionRefresh.svg</normaloff>:/timeseriesviewer/icons/mActionRefresh.svg</iconset> - </property> - <property name="text"> - <string>ApplySettings</string> - </property> - <property name="toolTip"> - <string>Apply Style</string> - </property> - </action> - <action name="actionSetR"> - <property name="text"> - <string>R</string> - </property> - </action> - <action name="actionSetG"> - <property name="text"> - <string>G</string> - </property> - </action> - <action name="actionSetB"> - <property name="text"> - <string>B</string> - </property> - </action> - <action name="actionSetNIR"> - <property name="text"> - <string>nIR</string> - </property> - </action> - <action name="actionSetSWIR"> - <property name="text"> - <string>swIR</string> - </property> - </action> - <action name="actionSetDefaultSB"> - <property name="text"> - <string>Def</string> - </property> - </action> - </widget> - <resources> - <include location="resources.qrc"/> - </resources> - <connections/> -</ui> diff --git a/eotimeseriesviewer/ui/mapwidget.ui b/eotimeseriesviewer/ui/mapwidget.ui new file mode 100644 index 0000000000000000000000000000000000000000..66336b6616b8f40936125441679363b9a5dd7faf --- /dev/null +++ b/eotimeseriesviewer/ui/mapwidget.ui @@ -0,0 +1,73 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>Form</class> + <widget class="QWidget" name="Form"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <action name="actionForward"> + <property name="icon"> + <iconset resource="../../../../QGIS/images/images.qrc"> + <normaloff>:/images/themes/default/mActionAtlasNext.svg</normaloff>:/images/themes/default/mActionAtlasNext.svg</iconset> + </property> + <property name="text"> + <string>Forward</string> + </property> + <property name="toolTip"> + <string>Moves to next date</string> + </property> + </action> + <action name="actionBackward"> + <property name="icon"> + <iconset resource="../../../../QGIS/images/images.qrc"> + <normaloff>:/images/themes/default/mActionAtlasPrev.svg</normaloff>:/images/themes/default/mActionAtlasPrev.svg</iconset> + </property> + <property name="text"> + <string>Backward</string> + </property> + <property name="toolTip"> + <string>Moves one date back.</string> + </property> + </action> + <action name="actionLastDate"> + <property name="icon"> + <iconset resource="../../../../QGIS/images/images.qrc"> + <normaloff>:/images/themes/default/mActionAtlasLast.svg</normaloff>:/images/themes/default/mActionAtlasLast.svg</iconset> + </property> + <property name="text"> + <string>Last Date</string> + </property> + </action> + <action name="actionFirstDate"> + <property name="icon"> + <iconset resource="../../../../QGIS/images/images.qrc"> + <normaloff>:/images/themes/default/mActionAtlasFirst.svg</normaloff>:/images/themes/default/mActionAtlasFirst.svg</iconset> + </property> + <property name="text"> + <string>First Date</string> + </property> + </action> + <action name="actionFastForward"> + <property name="text"> + <string>Fast Forward</string> + </property> + </action> + <action name="actionFastBackward"> + <property name="text"> + <string>Fast Backward</string> + </property> + </action> + </widget> + <resources> + <include location="../../../../QGIS/images/images.qrc"/> + </resources> + <connections/> +</ui>