Skip to content

Commit

Permalink
Merge pull request #42 from Samweli/time_slider_update
Browse files Browse the repository at this point in the history
Updates to the time slider
  • Loading branch information
Samweli committed Jul 31, 2024
2 parents 9bb6bb7 + ac7f3b1 commit aa150b1
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 39 deletions.
2 changes: 1 addition & 1 deletion config.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"author": "Kartoza",
"email": "[email protected]",
"description": "View, browse and navigate through imagery.",
"version": "0.0.1",
"version": "0.0.13dev",
"changelog": ""
}
}
21 changes: 14 additions & 7 deletions src/qgis_gea_plugin/gui/qgis_gea.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ def __init__(self, iface, parent=None):
QgsInterval(1, QgsUnitTypes.TemporalIrregularStep)
)

self.frame_rate_box.valueChanged.connect(self.frame_rate_changed)

self.current_imagery_type = IMAGERY.HISTORICAL

icon_pixmap = QtGui.QPixmap(PLUGIN_ICON)
Expand Down Expand Up @@ -143,6 +145,11 @@ def __init__(self, iface, parent=None):

self.iface.projectRead.connect(self.prepare_time_slider)

def frame_rate_changed(self, value):
self.navigation_object.setFramesPerSecond(
value
)

def save_settings(self):

settings_manager.set_value(Settings.SITE_REFERENCE, self.site_reference_le.text())
Expand Down Expand Up @@ -241,8 +248,7 @@ def temporal_range_changed(self, temporal_range):
self.temporal_range_la.setText(
tr(
f'Current time range: '
f'<b>{temporal_range.begin().toString("yyyy-MM-ddTHH:mm:ss")} to '
f'{temporal_range.end().toString("yyyy-MM-ddTHH:mm:ss")} </b>'
f'<b>{temporal_range.begin().toString("yyyy-MM-ddTHH:mm:ss")}'
))
self.time_slider.setValue(
self.navigation_object.currentFrameNumber()
Expand Down Expand Up @@ -294,18 +300,19 @@ def prepare_time_slider(self):
self.update_layer_group(set_layer)
self.update_layer_group(active_layer, True)

self.time_slider.setRange(0, len(values) - 1)
self.navigation_object.setAvailableTemporalRanges(values)
sorted_date_time_ranges = sorted(values, key=lambda x: x.begin())

self.time_slider.setRange(0, len(sorted_date_time_ranges) - 1)
self.navigation_object.setAvailableTemporalRanges(sorted_date_time_ranges)

temporal_range = values[0] if len(values) > 0 else None
temporal_range = sorted_date_time_ranges[0] if len(sorted_date_time_ranges) > 0 else None

if temporal_range:
self.iface.mapCanvas().setTemporalRange(temporal_range)
self.temporal_range_la.setText(
tr(
f'Current time range: '
f'<b>{temporal_range.begin().toString("yyyy-MM-ddTHH:mm:ss")} to '
f'{temporal_range.end().toString("yyyy-MM-ddTHH:mm:ss")} </b>'
f'<b>{temporal_range.begin().toString("yyyy-MM-ddTHH:mm:ss")}'
))

def update_layer_group(self, layer, show=False):
Expand Down
76 changes: 45 additions & 31 deletions src/qgis_gea_plugin/ui/main_dockwidget.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>741</width>
<height>712</height>
<height>716</height>
</rect>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -117,29 +117,6 @@
<string>Time Slider</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="0" colspan="2">
<widget class="QSlider" name="time_slider">
<property name="maximum">
<number>10</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="tickPosition">
<enum>QSlider::TicksBelow</enum>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="nicfi_imagery">
<property name="text">
<string>Current Imagery (NICIFI)</string>
</property>
<attribute name="buttonGroup">
<string notr="true">buttonGroup</string>
</attribute>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="historical_imagery">
<property name="text">
Expand All @@ -153,14 +130,14 @@
</attribute>
</widget>
</item>
<item row="2" column="2">
<widget class="QToolButton" name="play_btn">
<property name="toolTip">
<string>Play animation</string>
</property>
<item row="0" column="1">
<widget class="QCheckBox" name="nicfi_imagery">
<property name="text">
<string>...</string>
<string>Current Imagery (NICIFI)</string>
</property>
<attribute name="buttonGroup">
<string notr="true">buttonGroup</string>
</attribute>
</widget>
</item>
<item row="1" column="0">
Expand All @@ -170,6 +147,43 @@
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QSlider" name="time_slider">
<property name="maximum">
<number>10</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="tickPosition">
<enum>QSlider::TicksBelow</enum>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="frame_rate_box">
<property name="toolTip">
<string>Sets the animation frame rate.</string>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="play_btn">
<property name="toolTip">
<string>Play animation</string>
</property>
<property name="text">
<string>...</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
Expand Down Expand Up @@ -234,7 +248,7 @@
<item row="0" column="1">
<widget class="QgsDateTimeEdit" name="project_inception_date">
<property name="displayFormat">
<string>yyyy MM</string>
<string>MMyy</string>
</property>
</widget>
</item>
Expand Down

0 comments on commit aa150b1

Please sign in to comment.