Skip to content
View on GitHubSample viewer app

Explore details of a building scene by using filters and sublayer visibility.

screenshot

Use case

Buildings and their component parts (in this example, structural, electrical, or architectural) can be difficult to explain and visualize. An architectural firm might share a 3D building model visualization with clients and contractors to let them explore these components by floor and component type.

How to use the sample

Once the scene is loaded, click the "Building Filter Settings" button to view the filtering options.

  • Select a floor from the "Floor" menu to view the internal details of each floor or "All" to view the entire model. Selecting a floor applies a filter that hides all floors above the selected floor and gives the floors below a transparent, X-ray renderer.
  • Expand the categories under the top-level disciplines to show or hide individual categories in the building model. The entire discipline may be shown or hidden as well.
  • Click on any features in the building to view the attributes of the feature.

How it works

  1. Create a Scene with the URL to a Building Scene Layer service.
  2. Create a LocalSceneView and add the scene.
  3. Retrieve the BuildingSceneLayer from the scene's operational layers.
  4. When a floor is selected:
    1. A new BuildingFilter is created with two BuildingFilterBlock items.
    2. One block defines the solid renderer for features on the selected floor.
    3. The second block defines the X-ray filter for features on the floors below the selected floor.
    4. Features that exist on floors above the selected floor are not rendered.
    5. If “All” is selected, the activeFilter property on the building scene layer is set to null so all features are rendered according to their default settings.
  5. Architectural disciplines and categories are represented by BuildingGroupSublayer and BuildingSublayer objects containing features within a building scene layer. When checked or unchecked, the visibility of the group or sublayer is set to true (visible) or false (hidden).
  6. When a building feature is clicked on:
    1. A call to identifyLayer on the LocalSceneView is initiated based on the screen offset of the click.
    2. The sublayerResults property of the returned IdentifyLayerResult will contain the identified features. Note that the building scene layer features are NOT returned in the geoElements property of the results.
    3. The details of the first identified feature are shown in a popup.

Relevant API

  • BuildingComponentSublayer
  • BuildingFilter
  • BuildingFilterBlock
  • BuildingSceneLayer
  • LocalSceneView
  • Scene

About the data

This sample uses the Esri Building E Local Scene web scene, which contains a Building Scene Layer representing Building E on the Esri Campus in Redlands, CA. The Revit BIM model was brought into ArcGIS using the BIM capabilities in ArcGIS Pro and published to the web as a Building Scene Layer.

Additional information

Buildings in a Building Scene Layer can be very complex models composed of sublayers containing internal and external features of the structure. Sublayers may include structural components like columns, architectural components like floors and windows, and electrical components.

Applying filters to the Building Scene Layer can highlight features of interest in the model. Filters are made up of filter blocks, which contain several properties that allow control over the filter's function. Setting the filter mode to X-Ray, for instance, will render features with a semi-transparent white color so other interior features can be seen. In addition, toggling the visibility of sublayers can show or hide all the features of a sublayer.

Tags

3D, building scene layer, layers

Sample Code

FilterBuildingSceneLayer.cppFilterBuildingSceneLayer.cppFilterBuildingSceneLayer.hFilterBuildingSceneLayer.qml
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
// [WriteFile Name=FilterBuildingSceneLayer, Category=Layers]
// [Legal]
// Copyright 2025 Esri.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// [Legal]

#ifdef PCH_BUILD
#include "pch.hpp"
#endif // PCH_BUILD

// sample headers
#include "FilterBuildingSceneLayer.h"

// ArcGIS Maps SDK headers
#include "AttributeListModel.h"
#include "BuildingComponentSublayer.h"
#include "BuildingFilter.h"
#include "BuildingFilterBlock.h"
#include "BuildingGroupSublayer.h"
#include "BuildingSceneLayer.h"
#include "BuildingSceneLayerAttributeStatistics.h"
#include "BuildingSolidFilterMode.h"
#include "BuildingSublayer.h"
#include "BuildingSublayerListModel.h"
#include "BuildingXrayFilterMode.h"
#include "Feature.h"
#include "FeatureLayer.h"
#include "GeoElement.h"
#include "IdentifyLayerResult.h"
#include "LayerListModel.h"
#include "LocalSceneQuickView.h"
#include "MapTypes.h"
#include "PopupDefinition.h"
#include "Scene.h"
#include "SceneQuickView.h"
#include "Surface.h"

// Qt headers
#include <QFuture>
#include <QUrl>

using namespace Esri::ArcGISRuntime;

FilterBuildingSceneLayer::FilterBuildingSceneLayer(QObject* parent /* = nullptr */) :
  QObject(parent),
  m_scene(new Scene(QUrl("https://arcgisruntime.maps.arcgis.com/home/item.html?id=b7c387d599a84a50aafaece5ca139d44"), this))
{
  connect(m_scene, &Scene::doneLoading, this, [this]()
  {
    getFloorList();
    getCategoriesList();
  });
}

FilterBuildingSceneLayer::~FilterBuildingSceneLayer() = default;

void FilterBuildingSceneLayer::init()
{
  // Register classes for QML
  qmlRegisterType<LocalSceneQuickView>("Esri.Samples", 1, 0, "LocalSceneView");
  qmlRegisterType<FilterBuildingSceneLayer>("Esri.Samples", 1, 0, "FilterBuildingSceneLayerSample");
  qmlRegisterUncreatableType<BuildingSublayerListModel>("Esri.Samples", 1, 0, "AbstractListModel", "AbstractListModel is uncreateable");
}

LocalSceneQuickView* FilterBuildingSceneLayer::localSceneView() const
{
  return m_localSceneView;
}

// Set the view (created in QML)
void FilterBuildingSceneLayer::setLocalSceneView(LocalSceneQuickView* localSceneView)
{
  if (!localSceneView || localSceneView == m_localSceneView)
  {
    return;
  }

  m_localSceneView = localSceneView;
  m_localSceneView->setArcGISScene(m_scene);

  m_scene->load();

  connect(m_localSceneView, &LocalSceneQuickView::mouseClicked, this, &FilterBuildingSceneLayer::onMouseClicked);

  emit localSceneViewChanged();
}

void FilterBuildingSceneLayer::onMouseClicked(QMouseEvent& mouseEvent)
{
  if (!m_buildingSceneLayer || m_buildingSceneLayer->loadStatus() != LoadStatus::Loaded)
  {
    return;
  }

  // Clear previous selection if any
  if (m_selectedSublayer)
  {
    m_selectedSublayer->clearSelection();
    m_selectedSublayer = nullptr;
  }

  constexpr double tolerance = 5.0;

  // Identify on the building scene layer.
  QFuture future = m_localSceneView->identifyLayerAsync(m_buildingSceneLayer, mouseEvent.position(), tolerance, false, this);

  future.then(this, [this](IdentifyLayerResult* result)
  {
    if (!result || result->sublayerResults().empty())
    {
      return;
    }

    // Select the first identified feature and show the feature details in a popup.
    IdentifyLayerResult* sublayerResult = result->sublayerResults().first();
    GeoElement* geoElement = sublayerResult->geoElements().first();
    Feature* identifiedFeature = static_cast<Feature*>(geoElement);

    m_selectedSublayer = static_cast<BuildingComponentSublayer*>(sublayerResult->layerContent());
    if (m_selectedSublayer)
    {
      m_selectedSublayer->selectFeature(identifiedFeature);
    }

    m_popup = new Popup(geoElement, this);
    emit popupChanged();
  });
}

void FilterBuildingSceneLayer::getFloorList()
{
  if (!m_scene || !m_scene->operationalLayers() || m_scene->operationalLayers()->isEmpty())
  {
    return;
  }

  m_buildingSceneLayer = dynamic_cast<BuildingSceneLayer*>(m_scene->operationalLayers()->first());

  // Get the floor listing from the statistics.
  m_buildingSceneLayer->fetchStatisticsAsync(this).then(this, [this](QMap<QString, BuildingSceneLayerAttributeStatistics*> statistics)
  {
    if (statistics.value("BldgLevel"))
    {
      m_floorList = statistics.value("BldgLevel")->mostFrequentValues();
      std::sort(m_floorList.begin(), m_floorList.end());
      m_floorList.prepend("All");
      emit floorListChanged();
    }
  });
}

void FilterBuildingSceneLayer::getCategoriesList()
{
  if (!m_buildingSceneLayer)
  {
    return;
  }

  connect(m_buildingSceneLayer, &BuildingSceneLayer::loadStatusChanged, this, [this]()
  {
    if (m_buildingSceneLayer->loadStatus() != LoadStatus::Loaded)
    {
      return;
    }
    for (BuildingSublayer* sublayer : *m_buildingSceneLayer->sublayers())
    {
      if (sublayer->name() == "Full Model")
      {
        // Get the sublayer group for the full building model.
        m_fullModelSublayer = qobject_cast<BuildingGroupSublayer*>(sublayer);
        break;
      }
    }
    if (m_fullModelSublayer)
    {
      // The top-level sublayer groups will be the categories.
      m_sublayerListModel = m_fullModelSublayer->sublayers();
      emit sublayerListModelChanged();
    }
  });
  m_buildingSceneLayer->load();
}

// To update the building filters based on the selected floor.
void FilterBuildingSceneLayer::updateFloorFilter(const QString& selectedFloor)
{
  if (!m_buildingSceneLayer)
  {
    return;
  }

  // No filtering applied if 'All' floors are selected.
  if (selectedFloor == "All")
  {
    m_buildingSceneLayer->setActiveFilter(nullptr);
    return;
  }

  // Build a building filter to show the selected floor and an xray view of the floors below.
  // Floors above the selected floor are not shown at all.
  BuildingFilterBlock* solidBlock =
    new BuildingFilterBlock("solid block", QString("BldgLevel = '%1'").arg(selectedFloor), new BuildingSolidFilterMode(this), this);

  m_blocks.append(solidBlock);

  BuildingFilterBlock* xrayBlock =
    new BuildingFilterBlock("xray block", QString("BldgLevel < '%1'").arg(selectedFloor), new BuildingXrayFilterMode(this), this);

  m_blocks.append(xrayBlock);

  m_buildingFilter = new BuildingFilter("Floor filter", "Show selected floor and xray filter for lower floors.", m_blocks, this);

  // Apply the filter to the building scene layer.
  m_buildingSceneLayer->setActiveFilter(m_buildingFilter);
  m_blocks.clear();
}

// Get the component sublayers for each category.
BuildingSublayerListModel* FilterBuildingSceneLayer::getComponentSubLayerListModel(int layerId) const
{
  if (!m_scene)
  {
    return nullptr;
  }

  BuildingGroupSublayer* categorySublayer = static_cast<BuildingGroupSublayer*>(m_fullModelSublayer->sublayers()->at(layerId));

  if (categorySublayer)
  {
    return categorySublayer->sublayers();
  }

  return nullptr;
}

QStringList FilterBuildingSceneLayer::floorList() const
{
  return m_floorList;
}

void FilterBuildingSceneLayer::clearSelection()
{
  if (m_selectedSublayer)
  {
    m_selectedSublayer->clearSelection();
  }
}

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.