Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes and enhancements for GDALTools VRT, GDAL sublayer dialog and browser dock #101

Closed
wants to merge 4 commits into from

Conversation

etiennesky
Copy link
Contributor

  1. 3c1eb0a

GDALTools Build Virtual Raster - allow to use loaded layers as input files (instead of file selector)
I have enhanced the GDAL Tools VRT dialog to optionally use the active layers as input, instead of manually adding the files.

This is more convenient and also allows to use rasters within subdatasets (e.g. HDF files). I have created this to add (and extend) the functionality of the deprecated RGB composition plugin.

see thread "plugin bug and patch - RGB composition plugin broken in 1.7.4 and master" on the mailing list.

  1. c73e04e

askUserForGDALSublayers dialog:

  • fix order that items are added in the layers panel
  • add option to load all sublayers from a raster with subdatasets

Jürgen graciously applied my patches for bug #5041 that are related to this.

  1. aedb7de

fixes for browser panel:

  • skip *.aux.xml files (PAM auxiliary files) to avoid unnecessary warnings from GDAL

( ERROR 4: `/data/research/work/modis/mod13/MOD13Q1.A2009353.h13v10.005.2010009131529.250m 16 days relative azimuth angle.tif.aux.xml' not recognised as a supported file format. )

  • show HDF4 files: add HDF4 file suffix (.hdf) in buildSupportedRasterFileFilterAndExtensions()
  1. 7d61147

Add selected layers via context menu and tool button. This is handy when you want to load many layers.

I have added a button with the text "Add Selection" (maybe the text is not necessary) and 2 context menu items ("Add Layer" and "Add Selected Layers")

Thanks, Etienne

…ers dock ; add an option to load all sublayers of a GDAL raster with subdatasets
…to raster file names in browser ; add HDF4 file suffix (.hdf) in buildSupportedRasterFileFilterAndExtensions()
@brushtyler
Copy link
Contributor

I'm adding comments to commit 3c1eb0a (GdalTools) with changes I'm going to do on your patch before applying it.

@jef-n
Copy link
Member

jef-n commented Mar 9, 2012

everything except 3c1eb0a applied. Thanks.
Please run scripts/prepare-commit.sh before commiting.

@etiennesky
Copy link
Contributor Author

Great! thanks a bunch for such a quick response!

I missed that recommendation in the guideline in http://hub.qgis.org/wiki/quantum-gis/Developers_Manual
Reading scripts/prepare-commit.sh, I imagine that it makes sure indentation is ok?

Are there emacs macros out there that are compatible with qgis indentation rules?

In the dev guidelines, there is a mention of a .indent.pro but I can't find it in the source.

regards

@brushtyler
Copy link
Contributor

uhm... using both your iface.mapCanvas().layers() and mine Utils.LayerRegistry.instance().getRasterLayers() we get all the layers (raster only in my case), so we have to add a further check for getting selected raster layers only.

About your question, the GdalTools dialogs are not modal (you can open more dialogs at one time and continue to work on QGis while tools are running). To make things easy I added that method onLayersChanged(), so overriding it you can refresh the text command in the dialog. Have a look at the other tools (e.g. doNearBlack.py).

@etiennesky
Copy link
Contributor Author

when you mean selected, do you mean the ones that are checked or the ones that are highlighted? My initial goal was to use the ones that were highlighted (regardless of being active/checked), but I didn't see anything to get that).

When I tested, only the checked layers were considered.

@brushtyler
Copy link
Contributor

I meant highlighted but getting checked layers is also good changing the checkbox label to something like "Use visible raster layers for input". I think it's better to use visible layers instead of selected ones because it's more intuitive.

Anyway, to get highlighted layers in the legend you have to use the QgsLegendInterface available through the self.iface.legendInterface(). Instead `self.iface.mapCanvas().layers() get the list of layers visible in canvas (checked in legend).

@etiennesky
Copy link
Contributor Author

Looking at QgsLegendInterface I only see functions to get visible layers, nothing to get selected/highlighted ones.

My idea was that using selected/highlighted layers is faster, because you don't have to render them all, but if you think that it is more intuitive to use the visible/checked layers than that is fine by me.

@brushtyler
Copy link
Contributor

Oops, no methods to get selected layers, you're right and now I'm not even sure there's a way to do it (except that using QT methods to get the legend widget from QGis mainWindow).

BTW the user does his actions on what he's seeing in that moment IMHO: how could he decide which layers to add to the VRT and which ones keep out without seeing them?

@brushtyler
Copy link
Contributor

patch for 3c1eb0a applied!
I applied your patch as it is (to keep credits), then I made a cleanup commit.

Here's a summary: I removed the import qgis.utils.*, added a line in setParamsStatus() to refresh GUI when the checkbox is checked by user, kept your function code to retrieve visible layers but executed only when needed (when visible layers changes). I didn't use the onLayersChanged() because it is called when a layer is added or deleted to canvas, but not when layer visibility changes.

@brushtyler brushtyler closed this Mar 10, 2012
@etiennesky
Copy link
Contributor Author

Giuseppe - thanks a lot! It is great, except for a detail... visible layers are added to self.visibleRasterLayers only when they change, but not when you open the dialog.

The following one-liner patch makes sure that visible layers are loaded when the widget is loaded ( add self.onVisibleLayersChanged() to initialize(self) )

diff --git a/python/plugins/GdalTools/tools/doBuildVRT.py b/python/plugins/GdalTools/tools/doBuildVRT.py
index 66db659..b922efe 100644
--- a/python/plugins/GdalTools/tools/doBuildVRT.py
+++ b/python/plugins/GdalTools/tools/doBuildVRT.py
@@ -49,6 +49,7 @@ class GdalToolsDialog(QWidget, Ui_Widget, BasePluginWidget):
# connect to mapCanvas.layerChanged() signal
self.connect(self.iface.mapCanvas(), SIGNAL("layersChanged()"), self.onVisibleLayersChanged)
BasePluginWidget.initialize(self)

  •  self.onVisibleLayersChanged()
    

    def onClosing(self):

    disconnect from mapCanvas.layerChanged() signal

@brushtyler
Copy link
Contributor

Applied in 213138e, thanks.

yjacolin pushed a commit to yjacolin/QGIS that referenced this pull request Oct 4, 2014
2.0 Manual Update : Print Composer / Composition Tab
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants