QGIS API Documentation
3.14.0-Pi (9f7028fd23)
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:993
QgsExpressionContext
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Definition:
qgsexpressioncontext.h:369
Qgs3DMapSettings::crs
QgsCoordinateReferenceSystem crs() const
Returns coordinate reference system used in the 3D scene.
Definition:
qgs3dmapsettings.h:94
qgsfeature3dhandler_p.h
qgsfeaturerequest.h
QgsFeatureRequest::setSubsetOfAttributes
QgsFeatureRequest & setSubsetOfAttributes(const QgsAttributeList &attrs)
Set a subset of attributes that will be fetched.
Definition:
qgsfeaturerequest.cpp:190
Qgs3DMapSettings::transformContext
QgsCoordinateTransformContext transformContext() const
Returns the coordinate transform context, which stores various information regarding which datum tran...
Definition:
qgs3dmapsettings.cpp:329
Qgs3DUtils::globalProjectLayerExpressionContext
static QgsExpressionContext globalProjectLayerExpressionContext(QgsVectorLayer *layer)
Returns expression context for use in preparation of 3D data of a layer.
Definition:
qgs3dutils.cpp:566
QgsVectorLayer::fields
QgsFields fields() const FINAL
Returns the list of fields of this layer.
Definition:
qgsvectorlayer.cpp:3280
QgsFeatureRequest
Definition:
qgsfeaturerequest.h:75
qgs3dutils.h
Qgs3DMapSettings
Definition:
qgs3dmapsettings.h:51
qgsvectorlayer.h
qgs3dmapsettings.h
QgsFeatureIterator::nextFeature
bool nextFeature(QgsFeature &f)
Definition:
qgsfeatureiterator.h:373
QgsVectorLayer
Definition:
qgsvectorlayer.h:385
QgsFeature
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:263
QgsFeatureIterator
Definition:
qgsfeatureiterator.h:263
Generated on Mon Jun 22 2020 05:14:09 for QGIS API Documentation by
1.8.17