Since QGIS 2.12, with the introduction of data-defined properties on the "lock layers for map" option, in the map item properties, you can do what you seek. You just need to create the right coverage layer, with the information of the extents, but also of the layers to "print".
Create the layer presets
You can "save" the current state (visible or not visible) of your layers as presets. Just create the desired combination and press the eye icon on the layers panel, and choose "add preset".
Basically, you will have to create a preset for each contour, with that layer visible (paired with other layers if you like). This will be your "set of layers".
Give your preset memorable names, or else just opt for some kind of a sequence.
Creating the coverage layer.
Now you will have to create a polygon layer with all the possible combinations between the extents polygons, and all the presets. That means you will end up with some redundancy. You will have to replicate each extent polygon for each preset. Something like this:
polygon 1, preset a
polygon 1, preset b
...
polygon 50, preset a
polygon 50, preset b
You can do this manually with copy paste, or else create some kind of script, but I would say your best and easier way would be using Spatialite or Postgis database. Just import you polygons extents there, and create a new non-spatial table with all presets names. Then, create a view that returns all the combinations.
SELECT f.*, g.preset_name
FROM polygons_extent as f, presets as g
Making it work
Add the new layer or view to QGIS, use it as coverage layer in atlas settings, and use the preset_name attribute in data-defined properties on the "lock layers for map" option.
I have found the solution.
Atlas generation TAB
Layers B, C and D
They need to be rule based (style) and need to contain the following rules (in Style):
"Feature ID" = attribute( $atlasfeature , 'Feature ID') - for visible records
"Feature ID" <> attribute( $atlasfeature , 'Feature ID') - for all records we don't want to see ( I styled it as transparent)
.....................................................................................................................................................................
Settings for the layer A, which works with ATLAS:
Configuration section:
Coverage layer: A
Hidden coverage layer: - TICKED
Filter with - NOT TICKED - this is important as the automation won't work otherwise
Output section:
Output filename expression: attribute($currentfeature, 'Feature ID') - this is not mandatory but will produce single files with the name = to the values from Feature ID column
Single file export when possible - NOT TICKED - this can be ticked in order to create a booklet, but not in my case
Sort by: Feature ID
.....................................................................................................................................................................
Item properties TAB
Below are my settings for the Map in the Item properties panel
.....................................................................................................................................................................
Thanks Jesse again. I hope this will help the others as well at some point.
Regards,
Maciek Drozda
Best Answer
I think you can solve this using a single coverage layer (the plots) and then use an expression to set the extent of the map to the bounds of the enclosing block based on the location of the plot.