<div dir="ltr"><div>Hi,</div><div><br></div><div>if you want to change the rendering settings use : <a href="https://qgis.org/api/classQgsMeshRendererSettings.html#details" target="_blank">https://qgis.org/api/classQgsMeshRendererSettings.html#details</a></div><div>and <a href="https://qgis.org/api/classQgsMeshLayer.html#ada9c8d32c90c0a7030f1a20de6435066">https://qgis.org/api/classQgsMeshLayer.html#ada9c8d32c90c0a7030f1a20de6435066</a></div><div><br></div><div>Use this QgsMeshRendererSettings class to set your active dataset group.</div><div><br></div><div>Regards.<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le lun. 24 janv. 2022 à 15:18, Brian Haynes <<a href="mailto:bhaynes@herricktechlabs.com" target="_blank">bhaynes@herricktechlabs.com</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">




<div dir="ltr">
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Good afternoon,</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
I am developing a QGIS application in C++ and am looking to overlay weather data stored in NetCDF files as mesh layers.  Each file has several variables that can be displayed; however it only displays one variable or dataset (always the first one in alphabetical
 order) and I'm not sure how to make it so I can choose which variable I want displayed.  For an entire layer I know I can call the layer tree node like this:</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<pre><code>QString layerName = <span>"Temperature"</span>;
QgsLayerTree *tree = project->instance()->layerTreeRoot(); //project <span>is</span> QgsProject <span>object</span>

<span>for</span> ( QgsMapLayer *layer: qmc->layers() ) // qmc <span>is</span> QgsMapCanvas <span>object</span>
    
    QgsLayerTreeNode *node = tree->findLayer(layer-><span>id</span>());
    
    <span>if</span> ( layer->name() == layerName )
    {
       node->setItemVisibilityChecked(true);

    } <span>else</span>
    {
       node->setItemVisibilityChecked(false);
    }

}</code></pre>
but its parallel for Mesh Layer subsets doesn't work:</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<pre><code>QgsMeshLayer *mesh = new QgsMeshLayer(<span>"/path/to/<a href="http://file.nc" target="_blank">file.nc</a>"</span>,<span>"MyData"</span>,<span>"mdal"</span>);
QString dataName = <span>"Temperature"</span>;

<span>for</span> ( <span>int</span> &i: mesh->datasetGroupsIndexes() )
{
   QgsMeshDatasetIndex did = i;
   QgsMeshDatasetGroupTreeItem *child = tree->childFromDatasetGroupIndex(i);
   
   <span>if</span> ( child->name() == dataName )
   {
      child->setIsEnabled(true);

   } <span>else</span>
   {
      child->setIsEnabled(false);
   }
}</code></pre>
I've also tried to set the layer rendering for datasets, but it seems to pertain to the entire file (mesh->datasetGroupCount > mesh->datasetCount; the renderer only pertains to the dataset (count = 1).  This would be helpful to figure out as setting the renderer
 for different types of data (vectors for wind, contours for pressure, etc) is the end goal of this application, and would be an upgrade from having to create multiple shapefiles/rasters for this data.  There doesn't seem to be many examples out there for mesh
 layer use outside of the QGIS console, not even for PyQGIS developers.</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Brian</div>
</div>

_______________________________________________<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>