mirror of
https://github.com/qgis/QGIS.git
synced 2025-12-15 00:07:25 -05:00
rollback the existing implementation and use QgsHighlight
This commit is contained in:
parent
6de83cd662
commit
bec8fe5f2e
@ -130,16 +130,6 @@ Sets the 2D ``renderer`` for the point cloud.
|
||||
Ownership of ``renderer`` is transferred to the layer.
|
||||
|
||||
.. seealso:: :py:func:`renderer`
|
||||
%End
|
||||
|
||||
void setHighlightedPoints( const QVector<QPointF> &points );
|
||||
%Docstring
|
||||
Sets the points that will be highlighted when the layer is rendered
|
||||
%End
|
||||
|
||||
QVector<QPointF> highlightedPoints() const;
|
||||
%Docstring
|
||||
Returns the list of the points that need to be highlighted when the layer is rendered
|
||||
%End
|
||||
|
||||
private:
|
||||
|
||||
@ -26,7 +26,7 @@ Encapsulates the render context for a 2D point cloud rendering operation.
|
||||
public:
|
||||
|
||||
QgsPointCloudRenderContext( QgsRenderContext &context, const QgsVector3D &scale, const QgsVector3D &offset,
|
||||
double zValueScale, double zValueFixedOffset, const QVector<QPointF> &highlightedPoints );
|
||||
double zValueScale, double zValueFixedOffset );
|
||||
%Docstring
|
||||
Constructor for QgsPointCloudRenderContext.
|
||||
|
||||
@ -137,11 +137,6 @@ Returns any constant offset which must be applied to z values taken from the poi
|
||||
Scaling of z values via :py:func:`~QgsPointCloudRenderContext.zValueScale` should be applied before the :py:func:`~QgsPointCloudRenderContext.zValueFixedOffset`.
|
||||
%End
|
||||
|
||||
bool isPointHighlighted( const QPointF &p ) const;
|
||||
%Docstring
|
||||
Returns whether the point cloud point ``p`` should be highlighted
|
||||
%End
|
||||
|
||||
|
||||
private:
|
||||
QgsPointCloudRenderContext( const QgsPointCloudRenderContext &rh );
|
||||
|
||||
@ -1287,8 +1287,12 @@ void QgsIdentifyResultsDialog::addFeature( QgsPointCloudLayer *layer,
|
||||
connect( layer, &QgsMapLayer::crsChanged, this, &QgsIdentifyResultsDialog::layerDestroyed );
|
||||
}
|
||||
|
||||
QgsFeature feature;
|
||||
QgsPointXY point( attributes[ QStringLiteral( "X" ) ].toDouble(), attributes[ QStringLiteral( "Y" ) ].toDouble() );
|
||||
feature.setGeometry( QgsGeometry::fromPointXY( point ) );
|
||||
|
||||
QgsIdentifyResultsFeatureItem *featItem = new QgsIdentifyResultsFeatureItem( QgsFields(),
|
||||
QgsFeature(),
|
||||
feature,
|
||||
layer->crs(),
|
||||
QStringList() << label << QString() );
|
||||
layItem->addChild( featItem );
|
||||
@ -1304,6 +1308,8 @@ void QgsIdentifyResultsDialog::addFeature( QgsPointCloudLayer *layer,
|
||||
{
|
||||
featItem->addChild( new QTreeWidgetItem( QStringList() << it.key() << it.value() ) );
|
||||
}
|
||||
|
||||
highlightFeature( featItem );
|
||||
}
|
||||
|
||||
|
||||
@ -1825,6 +1831,14 @@ QgsVectorTileLayer *QgsIdentifyResultsDialog::vectorTileLayer( QTreeWidgetItem *
|
||||
return qobject_cast<QgsVectorTileLayer *>( item->data( 0, Qt::UserRole ).value<QObject *>() );
|
||||
}
|
||||
|
||||
QgsPointCloudLayer *QgsIdentifyResultsDialog::pointCloudLayer( QTreeWidgetItem *item )
|
||||
{
|
||||
item = layerItem( item );
|
||||
if ( !item )
|
||||
return nullptr;
|
||||
return qobject_cast<QgsPointCloudLayer *>( item->data( 0, Qt::UserRole ).value<QObject *>() );
|
||||
}
|
||||
|
||||
QTreeWidgetItem *QgsIdentifyResultsDialog::retrieveAttributes( QTreeWidgetItem *item, QgsAttributeMap &attributes, int &idx )
|
||||
{
|
||||
QTreeWidgetItem *featItem = featureItem( item );
|
||||
@ -2054,9 +2068,11 @@ void QgsIdentifyResultsDialog::highlightFeature( QTreeWidgetItem *item )
|
||||
QgsVectorLayer *vlayer = vectorLayer( item );
|
||||
QgsRasterLayer *rlayer = rasterLayer( item );
|
||||
QgsVectorTileLayer *vtlayer = vectorTileLayer( item );
|
||||
QgsPointCloudLayer *pcLayer = pointCloudLayer( item );
|
||||
|
||||
layer = vlayer ? static_cast<QgsMapLayer *>( vlayer ) : static_cast<QgsMapLayer *>( rlayer );
|
||||
layer = layer ? layer : vtlayer;
|
||||
layer = layer ? layer : pcLayer;
|
||||
|
||||
if ( !layer ) return;
|
||||
|
||||
@ -2075,6 +2091,11 @@ void QgsIdentifyResultsDialog::highlightFeature( QTreeWidgetItem *item )
|
||||
{
|
||||
highlight = new QgsHighlight( mCanvas, featItem->feature(), vlayer );
|
||||
}
|
||||
else if ( pcLayer )
|
||||
{
|
||||
highlight = new QgsHighlight( mCanvas, featItem->feature().geometry(), layer );
|
||||
highlight->setWidth( 2 );
|
||||
}
|
||||
else
|
||||
{
|
||||
highlight = new QgsHighlight( mCanvas, featItem->feature().geometry(), layer );
|
||||
|
||||
@ -301,6 +301,7 @@ class APP_EXPORT QgsIdentifyResultsDialog: public QDialog, private Ui::QgsIdenti
|
||||
QgsRasterLayer *rasterLayer( QTreeWidgetItem *item );
|
||||
QgsMeshLayer *meshLayer( QTreeWidgetItem *item );
|
||||
QgsVectorTileLayer *vectorTileLayer( QTreeWidgetItem *item );
|
||||
QgsPointCloudLayer *pointCloudLayer( QTreeWidgetItem *item );
|
||||
QTreeWidgetItem *featureItem( QTreeWidgetItem *item );
|
||||
QTreeWidgetItem *layerItem( QTreeWidgetItem *item );
|
||||
QTreeWidgetItem *layerItem( QObject *layer );
|
||||
|
||||
@ -621,8 +621,3 @@ void QgsPointCloudLayer::setRenderer( QgsPointCloudRenderer *renderer )
|
||||
emit rendererChanged();
|
||||
emit styleChanged();
|
||||
}
|
||||
|
||||
void QgsPointCloudLayer::setHighlightedPoints( const QVector<QPointF> &points )
|
||||
{
|
||||
mHighlightedPoints = points;
|
||||
}
|
||||
|
||||
@ -167,16 +167,6 @@ class CORE_EXPORT QgsPointCloudLayer : public QgsMapLayer
|
||||
*/
|
||||
void setRenderer( QgsPointCloudRenderer *renderer SIP_TRANSFER );
|
||||
|
||||
/**
|
||||
* Sets the points that will be highlighted when the layer is rendered
|
||||
*/
|
||||
void setHighlightedPoints( const QVector<QPointF> &points );
|
||||
|
||||
/**
|
||||
* Returns the list of the points that need to be highlighted when the layer is rendered
|
||||
*/
|
||||
QVector<QPointF> highlightedPoints() const { return mHighlightedPoints; }
|
||||
|
||||
private slots:
|
||||
void onPointCloudIndexGenerationStateChanged( QgsPointCloudDataProvider::PointCloudIndexGenerationState state );
|
||||
|
||||
@ -193,8 +183,6 @@ class CORE_EXPORT QgsPointCloudLayer : public QgsMapLayer
|
||||
std::unique_ptr<QgsPointCloudRenderer> mRenderer;
|
||||
|
||||
QgsPointCloudLayerElevationProperties *mElevationProperties = nullptr;
|
||||
|
||||
QVector<QPointF> mHighlightedPoints;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -64,7 +64,7 @@ QgsPointCloudLayerRenderer::QgsPointCloudLayerRenderer( QgsPointCloudLayer *laye
|
||||
|
||||
bool QgsPointCloudLayerRenderer::render()
|
||||
{
|
||||
QgsPointCloudRenderContext context( *renderContext(), mScale, mOffset, mZScale, mZOffset, mLayer->highlightedPoints() );
|
||||
QgsPointCloudRenderContext context( *renderContext(), mScale, mOffset, mZScale, mZOffset );
|
||||
|
||||
// Set up the render configuration options
|
||||
QPainter *painter = context.renderContext().painter();
|
||||
|
||||
@ -25,13 +25,12 @@
|
||||
#include "qgslogger.h"
|
||||
#include "qgscircle.h"
|
||||
|
||||
QgsPointCloudRenderContext::QgsPointCloudRenderContext( QgsRenderContext &context, const QgsVector3D &scale, const QgsVector3D &offset, double zValueScale, double zValueFixedOffset, const QVector<QPointF> &highlightedPoints )
|
||||
QgsPointCloudRenderContext::QgsPointCloudRenderContext( QgsRenderContext &context, const QgsVector3D &scale, const QgsVector3D &offset, double zValueScale, double zValueFixedOffset )
|
||||
: mRenderContext( context )
|
||||
, mScale( scale )
|
||||
, mOffset( offset )
|
||||
, mZValueScale( zValueScale )
|
||||
, mZValueFixedOffset( zValueFixedOffset )
|
||||
, mHighlightedPoints( highlightedPoints )
|
||||
{
|
||||
|
||||
}
|
||||
@ -152,8 +151,6 @@ QStringList QgsPointCloudRenderer::legendRuleKeys() const
|
||||
return QStringList();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void QgsPointCloudRenderer::copyCommonProperties( QgsPointCloudRenderer *destination ) const
|
||||
{
|
||||
destination->setPointSize( mPointSize );
|
||||
@ -196,8 +193,6 @@ void QgsPointCloudRenderer::setPointSymbol( PointSymbol symbol )
|
||||
mPointSymbol = symbol;
|
||||
}
|
||||
|
||||
|
||||
|
||||
QVector<QVariantMap> QgsPointCloudRenderer::identify( QgsPointCloudLayer *layer, const QgsRenderContext &renderContext, const QgsGeometry &geometry, double toleranceForPointIdentification )
|
||||
{
|
||||
QVector<QVariantMap> selectedPoints;
|
||||
@ -286,4 +281,3 @@ QVector<QVariantMap> QgsPointCloudRenderer::identify( QgsPointCloudLayer *layer,
|
||||
|
||||
return selectedPoints;
|
||||
}
|
||||
|
||||
|
||||
@ -57,7 +57,7 @@ class CORE_EXPORT QgsPointCloudRenderContext
|
||||
* The \a highlightedPoints argument specifies highlighted points during rendering
|
||||
*/
|
||||
QgsPointCloudRenderContext( QgsRenderContext &context, const QgsVector3D &scale, const QgsVector3D &offset,
|
||||
double zValueScale, double zValueFixedOffset, const QVector<QPointF> &highlightedPoints );
|
||||
double zValueScale, double zValueFixedOffset );
|
||||
|
||||
//! QgsPointCloudRenderContext cannot be copied.
|
||||
QgsPointCloudRenderContext( const QgsPointCloudRenderContext &rh ) = delete;
|
||||
@ -156,11 +156,6 @@ class CORE_EXPORT QgsPointCloudRenderContext
|
||||
*/
|
||||
double zValueFixedOffset() const { return mZValueFixedOffset; }
|
||||
|
||||
/**
|
||||
* Returns whether the point cloud point \a p should be highlighted
|
||||
*/
|
||||
bool isPointHighlighted( const QPointF &p ) const { return mHighlightedPoints.contains( p ); }
|
||||
|
||||
#ifndef SIP_RUN
|
||||
|
||||
/**
|
||||
@ -215,8 +210,6 @@ class CORE_EXPORT QgsPointCloudRenderContext
|
||||
int mZOffset = 0;
|
||||
double mZValueScale = 1.0;
|
||||
double mZValueFixedOffset = 0;
|
||||
|
||||
QVector<QPointF> mHighlightedPoints;
|
||||
};
|
||||
|
||||
|
||||
@ -538,22 +531,6 @@ class CORE_EXPORT QgsPointCloudRenderer
|
||||
mPainterPenWidth, mPainterPenWidth ) );
|
||||
break;
|
||||
};
|
||||
if ( context.isPointHighlighted( originalXY ) )
|
||||
{
|
||||
QPen highlightPen( QColor( 255 - color.red(), 255 - color.green(), 255 - color.blue() ), 0.3 * mPainterPenWidth );
|
||||
painter->setPen( highlightPen );
|
||||
switch ( mPointSymbol )
|
||||
{
|
||||
case Square:
|
||||
painter->drawRect( QRectF( x - mPainterPenWidth * 0.65, y - mPainterPenWidth * 0.65,
|
||||
mPainterPenWidth * 1.3, mPainterPenWidth * 1.3 ) );
|
||||
break;
|
||||
case Circle:
|
||||
painter->drawEllipse( QRectF( x - mPainterPenWidth * 0.65, y - mPainterPenWidth * 0.65,
|
||||
mPainterPenWidth * 1.3, mPainterPenWidth * 1.3 ) );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -517,16 +517,8 @@ bool QgsMapToolIdentify::identifyPointCloudLayer( QList<QgsMapToolIdentify::Iden
|
||||
|
||||
const QVector<QVariantMap> points = renderer->identify( layer, context, geometry, searchRadiusMapUnits );
|
||||
|
||||
QVector<QPointF> highlightedPoints;
|
||||
for ( const QVariantMap &point : points )
|
||||
{
|
||||
highlightedPoints.push_back( QPointF( point[QStringLiteral( "X" ) ].toDouble(), point[QStringLiteral( "Y" ) ].toDouble() ) );
|
||||
}
|
||||
layer->setHighlightedPoints( highlightedPoints );
|
||||
|
||||
fromPointCloudIdentificationToIdentifyResults( layer, points, *results );
|
||||
|
||||
layer->triggerRepaint();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user