QGIS API Documentation
3.26.3-Buenos Aires (65e4edfdad)
src
3d
qgsfeature3dhandler_p.cpp
Go to the documentation of this file.
1
/***************************************************************************
2
qgsfeature3dhandler_p.cpp
3
--------------------------------------
4
Date : January 2019
5
Copyright : (C) 2019 by Martin Dobias
6
Email : wonder dot sk at gmail dot com
7
***************************************************************************
8
* *
9
* This program is free software; you can redistribute it and/or modify *
10
* it under the terms of the GNU General Public License as published by *
11
* the Free Software Foundation; either version 2 of the License, or *
12
* (at your option) any later version. *
13
* *
14
***************************************************************************/
15
16
17
#include "
qgsfeature3dhandler_p.h
"
18
19
#include "
qgsfeaturerequest.h
"
20
#include "
qgsvectorlayer.h
"
21
22
#include "
qgs3dmapsettings.h
"
23
#include "
qgs3dutils.h
"
24
26
27
28
namespace
Qgs3DSymbolImpl
29
{
30
31
Qt3DCore::QEntity *entityFromHandler( QgsFeature3DHandler *handler,
const
Qgs3DMapSettings
&map,
QgsVectorLayer
*layer )
32
{
33
Qgs3DRenderContext context( map );
34
35
QgsExpressionContext
exprContext(
Qgs3DUtils::globalProjectLayerExpressionContext
( layer ) );
36
exprContext.setFields( layer->
fields
() );
37
context.setExpressionContext( exprContext );
38
39
QSet<QString> attributeNames;
40
if
( !handler->prepare( context, attributeNames ) )
41
return
nullptr
;
42
43
// build the feature request
44
QgsFeatureRequest
req;
45
req.
setDestinationCrs
( map.
crs
(), map.
transformContext
() );
46
req.
setSubsetOfAttributes
( attributeNames, layer->
fields
() );
47
48
QgsFeature
f;
49
QgsFeatureIterator
fi = layer->
getFeatures
( req );
50
while
( fi.
nextFeature
( f ) )
51
{
52
context.expressionContext().setFeature( f );
53
handler->processFeature( f, context );
54
}
55
56
Qt3DCore::QEntity *entity =
new
Qt3DCore::QEntity;
57
handler->finalize( entity, context );
58
return
entity;
59
}
60
61
}
62
63
void
QgsFeature3DHandler::updateZRangeFromPositions(
const
QVector<QVector3D> &positions )
64
{
65
for
(
const
QVector3D &pos : positions )
66
{
67
if
( pos.y() < mZMin )
68
mZMin = pos.y();
69
if
( pos.y() > mZMax )
70
mZMax = pos.y();
71
}
72
}
73
QgsVectorLayer::getFeatures
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) const FINAL
Queries the layer for features specified in request.
Definition:
qgsvectorlayer.cpp:1052
QgsExpressionContext
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Definition:
qgsexpressioncontext.h:406
Qgs3DMapSettings::crs
QgsCoordinateReferenceSystem crs() const
Returns coordinate reference system used in the 3D scene.
Definition:
qgs3dmapsettings.h:99
qgsfeature3dhandler_p.h
qgsfeaturerequest.h
QgsFeatureRequest::setSubsetOfAttributes
QgsFeatureRequest & setSubsetOfAttributes(const QgsAttributeList &attrs)
Set a subset of attributes that will be fetched.
Definition:
qgsfeaturerequest.cpp:228
Qgs3DMapSettings::transformContext
QgsCoordinateTransformContext transformContext() const
Returns the coordinate transform context, which stores various information regarding which datum tran...
Definition:
qgs3dmapsettings.cpp:494
Qgs3DUtils::globalProjectLayerExpressionContext
static QgsExpressionContext globalProjectLayerExpressionContext(QgsVectorLayer *layer)
Returns expression context for use in preparation of 3D data of a layer.
Definition:
qgs3dutils.cpp:662
QgsVectorLayer::fields
QgsFields fields() const FINAL
Returns the list of fields of this layer.
Definition:
qgsvectorlayer.cpp:3436
QgsFeatureRequest
This class wraps a request for features to a vector layer (or directly its vector data provider).
Definition:
qgsfeaturerequest.h:83
qgs3dutils.h
Qgs3DMapSettings
Definition of the world.
Definition:
qgs3dmapsettings.h:57
qgsvectorlayer.h
qgs3dmapsettings.h
QgsFeatureIterator::nextFeature
bool nextFeature(QgsFeature &f)
Definition:
qgsfeatureiterator.h:399
QgsVectorLayer
Represents a vector layer which manages a vector based data sets.
Definition:
qgsvectorlayer.h:391
QgsFeature
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition:
qgsfeature.h:55
QgsFeatureRequest::setDestinationCrs
QgsFeatureRequest & setDestinationCrs(const QgsCoordinateReferenceSystem &crs, const QgsCoordinateTransformContext &context)
Sets the destination crs for feature's geometries.
Definition:
qgsfeaturerequest.cpp:301
QgsFeatureIterator
Wrapper for iterator of features from vector data provider or vector layer.
Definition:
qgsfeatureiterator.h:289
Generated on Sun Sep 11 2022 00:03:17 for QGIS API Documentation by
1.8.17