Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Merge pull request #7105 from PeterPetrik/quick-3-identity
[qgsquick] [feature] Identify and highlight
- Loading branch information
Showing
24 changed files
with
1,461 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/core/qgstessellator.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ | ||
|
||
|
||
|
||
|
||
|
||
class QgsTessellator | ||
{ | ||
%Docstring | ||
Class that takes care of tessellation of polygons into triangles. | ||
|
||
It is expected that client code will create the tessellator object, then repeatedly call | ||
addPolygon() method that will generate triangles, and finally call data() to get final vertex data. | ||
|
||
Optionally provides extrusion by adding triangles that serve as walls when extrusion height is non-zero. | ||
|
||
.. versionadded:: 3.4 | ||
%End | ||
|
||
%TypeHeaderCode | ||
#include "qgstessellator.h" | ||
%End | ||
public: | ||
QgsTessellator( double originX, double originY, bool addNormals, bool invertNormals = false, bool addBackFaces = false ); | ||
%Docstring | ||
Creates tessellator with a specified origin point of the world (in map coordinates) | ||
%End | ||
|
||
void addPolygon( const QgsPolygon &polygon, float extrusionHeight ); | ||
%Docstring | ||
Tessellates a triangle and adds its vertex entries to the output data array | ||
%End | ||
|
||
QVector<float> data() const; | ||
%Docstring | ||
Returns array of triangle vertex data | ||
|
||
Vertice coordinates are stored as (x, z, -y) | ||
%End | ||
|
||
int dataVerticesCount() const; | ||
%Docstring | ||
Returns the number of vertices stored in the output data array | ||
%End | ||
|
||
int stride() const; | ||
%Docstring | ||
Returns size of one vertex entry in bytes | ||
%End | ||
|
||
|
||
}; | ||
|
||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/core/qgstessellator.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/*************************************************************************** | ||
qgsqguickfeaturehighlight.cpp | ||
-------------------------------------- | ||
Date : May 2018 | ||
Copyright : (C) 2018 by Peter Petrik | ||
Email : zilolv at gmail dot com | ||
*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#include <memory> | ||
|
||
#include "qgsvectorlayer.h" | ||
|
||
#include "qgsquickfeaturehighlight.h" | ||
#include "qgsquickmapsettings.h" | ||
#include "qgsquickhighlightsgnode.h" | ||
|
||
|
||
QgsQuickFeatureHighlight::QgsQuickFeatureHighlight( QQuickItem *parent ) | ||
: QQuickItem( parent ) | ||
{ | ||
setFlags( QQuickItem::ItemHasContents ); | ||
setAntialiasing( true ); | ||
|
||
// transform to device coords | ||
mTransform.appendToItem( this ); | ||
|
||
connect( this, &QgsQuickFeatureHighlight::mapSettingsChanged, this, &QgsQuickFeatureHighlight::onMapSettingsChanged ); | ||
connect( this, &QgsQuickFeatureHighlight::featureLayerPairChanged, this, &QgsQuickFeatureHighlight::markDirty ); | ||
connect( this, &QgsQuickFeatureHighlight::colorChanged, this, &QgsQuickFeatureHighlight::markDirty ); | ||
connect( this, &QgsQuickFeatureHighlight::widthChanged, this, &QgsQuickFeatureHighlight::markDirty ); | ||
} | ||
|
||
void QgsQuickFeatureHighlight::markDirty() | ||
{ | ||
mDirty = true; | ||
update(); | ||
} | ||
|
||
void QgsQuickFeatureHighlight::onMapSettingsChanged() | ||
{ | ||
mTransform.setMapSettings( mMapSettings ); | ||
markDirty(); | ||
} | ||
|
||
QSGNode *QgsQuickFeatureHighlight::updatePaintNode( QSGNode *n, QQuickItem::UpdatePaintNodeData * ) | ||
{ | ||
if ( !mDirty || !mMapSettings || !mFeatureLayerPair.isValid() ) | ||
return n; | ||
|
||
delete n; | ||
n = new QSGNode; | ||
|
||
QgsVectorLayer *layer = mFeatureLayerPair.layer(); | ||
Q_ASSERT( layer ); // we checked the validity of feature-layer pair | ||
QgsCoordinateTransform transf( layer->crs(), mMapSettings->destinationCrs(), mMapSettings->transformContext() ); | ||
|
||
QgsFeature feature = mFeatureLayerPair.feature(); | ||
if ( feature.hasGeometry() ) | ||
{ | ||
QgsGeometry geom( feature.geometry() ); | ||
try | ||
{ | ||
geom.transform( transf ); | ||
std::unique_ptr<QgsQuickHighlightSGNode> rb( new QgsQuickHighlightSGNode( geom, mColor, mWidth ) ); | ||
rb->setFlag( QSGNode::OwnedByParent ); | ||
n->appendChildNode( rb.release() ); | ||
} | ||
catch ( QgsCsException &e ) | ||
{ | ||
Q_UNUSED( e ); | ||
// Caught an error in transform | ||
} | ||
} | ||
mDirty = false; | ||
|
||
return n; | ||
} |
Oops, something went wrong.