<div dir="ltr"><div>Thank you Nyall.</div><div><br></div><div>With your Python code I got the slider - and it works fine - Thank you!</div><div><br></div><div>Regarding the discussion around such a slider: next to slicing different attributes there is also the question if this should be per layer or global per project for all layers. Plenty of options and use cases here.</div><div><br></div><div>Thanks,</div><div>Andreas<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, 9 Dec 2020 at 02:42, Nyall Dawson <<a href="mailto:nyall.dawson@gmail.com">nyall.dawson@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Wed, 9 Dec 2020 at 00:10, Andreas Neumann <<a href="mailto:andreas@qgis.org" target="_blank">andreas@qgis.org</a>> wrote:<br>
><br>
> Hi,<br>
><br>
> I wonder how I can achieve the elevation slicing / filtering shown here:<br>
><br>
> <a href="https://twitter.com/nyalldawson/status/1331092360818614274?s=20" rel="noreferrer" target="_blank">https://twitter.com/nyalldawson/status/1331092360818614274?s=20</a><br>
><br>
> Is there Python code involved to do that? No GUI yet?<br>
<br>
No GUI yet (see below). Try the following Python code:<br>
<br>
<br>
w=QgsFloatingWidget(iface.mainWindow())<br>
l=QVBoxLayout()<br>
slider = QgsRangeSlider(Qt.Vertical)<br>
slider.setFlippedDirection(True)<br>
<br>
range = QgsElevationUtils.calculateZRangeForProject(QgsProject.instance())<br>
slider.setRangeLimits(range.lower() * 100,range.upper()*100)<br>
l.addWidget(slider)<br>
w.setSizePolicy( QSizePolicy.Fixed, QSizePolicy.Preferred)<br>
w.setFixedSize(500,200)<br>
w.setLayout(l)<br>
w.setAnchorWidget(iface.mapCanvas())<br>
w.setAnchorPoint(QgsFloatingWidget.TopLeft)<br>
w.setAnchorWidgetPoint(QgsFloatingWidget.TopLeft)<br>
w.show()<br>
w.raise_()<br>
<br>
def range_changed(lower,upper):<br>
iface.mapCanvas().setZRange(QgsDoubleRange(lower/100,upper/100))<br>
<br>
slider.rangeChanged.connect(range_changed)<br>
<br>
> That slicing looks incredibly useful to me.<br>
<br>
I've been struggling with how to expose this to users, which is why<br>
it's all just python code for now. I'm also starting to think I need<br>
to make the api a bit more generic and potentially allow for slicing<br>
based on any kind of attribute, not just elevation/z based slicing.<br>
There's potentially many different variables which users may want to<br>
interactively slice using and I'm leaning toward reworking the api to<br>
allow for more flexibility, including allowing multiple different<br>
range definition for layers. E.g. you could have a vector point layer<br>
with both a "z" attribute and a "concentration" attribute, and we<br>
could expose sliders for filtering on both the z AND concentration<br>
ranges...<br>
<br>
Something to think more about :)<br>
<br>
Nyall<br>
<br>
<br>
><br>
> I know I could change the min/max values and clip them in the symbology settings, but that isn't very interactive.<br>
><br>
> Thanks,<br>
> Andreas<br>
> htIs there Python<br>
> --<br>
> Andreas Neumann<br>
> <a href="http://QGIS.ORG" rel="noreferrer" target="_blank">QGIS.ORG</a> board member (treasurer)<br>
> _______________________________________________<br>
> QGIS-Developer mailing list<br>
> <a href="mailto:QGIS-Developer@lists.osgeo.org" target="_blank">QGIS-Developer@lists.osgeo.org</a><br>
> List info: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
> Unsubscribe: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
</blockquote></div><br clear="all"><br>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><br>--<br>Andreas Neumann<br></div><a href="http://QGIS.ORG" target="_blank">QGIS.ORG</a> board member (treasurer)<br></div></div>