mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-08 00:05:09 -04:00
Code cleanup
This commit is contained in:
parent
666479494b
commit
19fdf11976
@ -35,10 +35,6 @@ Constructor for QgsPointCloudAttributeByRampRenderer.
|
||||
|
||||
virtual QDomElement save( QDomDocument &doc, const QgsReadWriteContext &context ) const;
|
||||
|
||||
virtual void startRender( QgsPointCloudRenderContext &context );
|
||||
|
||||
virtual void stopRender( QgsPointCloudRenderContext &context );
|
||||
|
||||
virtual QSet< QString > usedAttributes( const QgsPointCloudRenderContext &context ) const;
|
||||
|
||||
virtual QList<QgsLayerTreeModelLegendNode *> createLegendNodes( QgsLayerTreeLayer *nodeLayer ) /Factory/;
|
||||
|
@ -127,10 +127,6 @@ Constructor for QgsPointCloudClassifiedRenderer.
|
||||
|
||||
virtual QDomElement save( QDomDocument &doc, const QgsReadWriteContext &context ) const;
|
||||
|
||||
virtual void startRender( QgsPointCloudRenderContext &context );
|
||||
|
||||
virtual void stopRender( QgsPointCloudRenderContext &context );
|
||||
|
||||
virtual QSet< QString > usedAttributes( const QgsPointCloudRenderContext &context ) const;
|
||||
|
||||
virtual QList<QgsLayerTreeModelLegendNode *> createLegendNodes( QgsLayerTreeLayer *nodeLayer ) /Factory/;
|
||||
|
@ -368,6 +368,11 @@ Retrieves the x and y coordinate for the point at index ``i``.
|
||||
static double pointZ( QgsPointCloudRenderContext &context, const char *ptr, int i );
|
||||
%Docstring
|
||||
Retrieves the z value for the point at index ``i``.
|
||||
%End
|
||||
|
||||
void drawPoint( double x, double y, const QColor &color, QgsPointCloudRenderContext &context ) const;
|
||||
%Docstring
|
||||
Draws a point using a ``color`` at the specified ``x`` and ``y`` (in map coordinates).
|
||||
%End
|
||||
|
||||
void copyCommonProperties( QgsPointCloudRenderer *destination ) const;
|
||||
|
@ -36,10 +36,6 @@ Constructor for QgsPointCloudRgbRenderer.
|
||||
|
||||
virtual QDomElement save( QDomDocument &doc, const QgsReadWriteContext &context ) const;
|
||||
|
||||
virtual void startRender( QgsPointCloudRenderContext &context );
|
||||
|
||||
virtual void stopRender( QgsPointCloudRenderContext &context );
|
||||
|
||||
virtual QSet< QString > usedAttributes( const QgsPointCloudRenderContext &context ) const;
|
||||
|
||||
|
||||
|
@ -51,11 +51,6 @@ void QgsPointCloudAttributeByRampRenderer::renderBlock( const QgsPointCloudBlock
|
||||
|
||||
const QgsRectangle visibleExtent = context.renderContext().extent();
|
||||
|
||||
QPen pen;
|
||||
pen.setWidth( mPainterPenWidth );
|
||||
pen.setCapStyle( Qt::FlatCap );
|
||||
//pen.setJoinStyle( Qt::MiterJoin );
|
||||
|
||||
const char *ptr = block->data();
|
||||
int count = block->pointCount();
|
||||
const QgsPointCloudAttributeCollection request = block->attributes();
|
||||
@ -120,19 +115,8 @@ void QgsPointCloudAttributeByRampRenderer::renderBlock( const QgsPointCloudBlock
|
||||
if ( applyZOffset )
|
||||
attributeValue = context.offset().z() + context.scale().z() * attributeValue;
|
||||
|
||||
mapToPixel.transformInPlace( x, y );
|
||||
|
||||
mColorRampShader.shade( attributeValue, &red, &green, &blue, &alpha );
|
||||
#if 0
|
||||
pen.setColor( QColor( red, green, blue ) );
|
||||
context.renderContext().painter()->setPen( pen );
|
||||
context.renderContext().painter()->drawPoint( QPointF( x, y ) );
|
||||
#else
|
||||
|
||||
context.renderContext().painter()->fillRect( QRectF( x - mPainterPenWidth * 0.5,
|
||||
y - mPainterPenWidth * 0.5,
|
||||
mPainterPenWidth, mPainterPenWidth ), QColor( red, green, blue, alpha ) );
|
||||
#endif
|
||||
drawPoint( x, y, QColor( red, green, blue, alpha ), context );
|
||||
|
||||
rendered++;
|
||||
}
|
||||
@ -176,18 +160,6 @@ QDomElement QgsPointCloudAttributeByRampRenderer::save( QDomDocument &doc, const
|
||||
return rendererElem;
|
||||
}
|
||||
|
||||
void QgsPointCloudAttributeByRampRenderer::startRender( QgsPointCloudRenderContext &context )
|
||||
{
|
||||
QgsPointCloudRenderer::startRender( context );
|
||||
|
||||
mPainterPenWidth = context.renderContext().convertToPainterUnits( pointSize(), pointSizeUnit(), pointSizeMapUnitScale() );
|
||||
}
|
||||
|
||||
void QgsPointCloudAttributeByRampRenderer::stopRender( QgsPointCloudRenderContext &context )
|
||||
{
|
||||
QgsPointCloudRenderer::stopRender( context );
|
||||
}
|
||||
|
||||
QSet<QString> QgsPointCloudAttributeByRampRenderer::usedAttributes( const QgsPointCloudRenderContext & ) const
|
||||
{
|
||||
QSet<QString> res;
|
||||
|
@ -42,8 +42,6 @@ class CORE_EXPORT QgsPointCloudAttributeByRampRenderer : public QgsPointCloudRen
|
||||
QgsPointCloudRenderer *clone() const override;
|
||||
void renderBlock( const QgsPointCloudBlock *block, QgsPointCloudRenderContext &context ) override;
|
||||
QDomElement save( QDomDocument &doc, const QgsReadWriteContext &context ) const override;
|
||||
void startRender( QgsPointCloudRenderContext &context ) override;
|
||||
void stopRender( QgsPointCloudRenderContext &context ) override;
|
||||
QSet< QString > usedAttributes( const QgsPointCloudRenderContext &context ) const override;
|
||||
QList<QgsLayerTreeModelLegendNode *> createLegendNodes( QgsLayerTreeLayer *nodeLayer ) override SIP_FACTORY;
|
||||
|
||||
@ -114,8 +112,6 @@ class CORE_EXPORT QgsPointCloudAttributeByRampRenderer : public QgsPointCloudRen
|
||||
|
||||
private:
|
||||
|
||||
int mPainterPenWidth = 1;
|
||||
|
||||
double mMin = 0;
|
||||
double mMax = 100;
|
||||
|
||||
|
@ -59,15 +59,8 @@ QgsPointCloudRenderer *QgsPointCloudClassifiedRenderer::clone() const
|
||||
|
||||
void QgsPointCloudClassifiedRenderer::renderBlock( const QgsPointCloudBlock *block, QgsPointCloudRenderContext &context )
|
||||
{
|
||||
const QgsMapToPixel mapToPixel = context.renderContext().mapToPixel();
|
||||
|
||||
const QgsRectangle visibleExtent = context.renderContext().extent();
|
||||
|
||||
QPen pen;
|
||||
pen.setWidth( mPainterPenWidth );
|
||||
pen.setCapStyle( Qt::FlatCap );
|
||||
//pen.setJoinStyle( Qt::MiterJoin );
|
||||
|
||||
const char *ptr = block->data();
|
||||
int count = block->pointCount();
|
||||
const QgsPointCloudAttributeCollection request = block->attributes();
|
||||
@ -129,19 +122,7 @@ void QgsPointCloudClassifiedRenderer::renderBlock( const QgsPointCloudBlock *blo
|
||||
}
|
||||
}
|
||||
|
||||
mapToPixel.transformInPlace( x, y );
|
||||
|
||||
#if 0
|
||||
pen.setColor( QColor( red, green, blue ) );
|
||||
context.renderContext().painter()->setPen( pen );
|
||||
context.renderContext().painter()->drawPoint( QPointF( x, y ) );
|
||||
#else
|
||||
|
||||
context.renderContext().painter()->fillRect( QRectF( x - mPainterPenWidth * 0.5,
|
||||
y - mPainterPenWidth * 0.5,
|
||||
mPainterPenWidth, mPainterPenWidth ), color );
|
||||
#endif
|
||||
|
||||
drawPoint( x, y, color, context );
|
||||
rendered++;
|
||||
}
|
||||
}
|
||||
@ -227,18 +208,6 @@ QDomElement QgsPointCloudClassifiedRenderer::save( QDomDocument &doc, const QgsR
|
||||
return rendererElem;
|
||||
}
|
||||
|
||||
void QgsPointCloudClassifiedRenderer::startRender( QgsPointCloudRenderContext &context )
|
||||
{
|
||||
QgsPointCloudRenderer::startRender( context );
|
||||
|
||||
mPainterPenWidth = context.renderContext().convertToPainterUnits( pointSize(), pointSizeUnit(), pointSizeMapUnitScale() );
|
||||
}
|
||||
|
||||
void QgsPointCloudClassifiedRenderer::stopRender( QgsPointCloudRenderContext &context )
|
||||
{
|
||||
QgsPointCloudRenderer::stopRender( context );
|
||||
}
|
||||
|
||||
QSet<QString> QgsPointCloudClassifiedRenderer::usedAttributes( const QgsPointCloudRenderContext & ) const
|
||||
{
|
||||
QSet<QString> res;
|
||||
|
@ -129,8 +129,6 @@ class CORE_EXPORT QgsPointCloudClassifiedRenderer : public QgsPointCloudRenderer
|
||||
QgsPointCloudRenderer *clone() const override;
|
||||
void renderBlock( const QgsPointCloudBlock *block, QgsPointCloudRenderContext &context ) override;
|
||||
QDomElement save( QDomDocument &doc, const QgsReadWriteContext &context ) const override;
|
||||
void startRender( QgsPointCloudRenderContext &context ) override;
|
||||
void stopRender( QgsPointCloudRenderContext &context ) override;
|
||||
QSet< QString > usedAttributes( const QgsPointCloudRenderContext &context ) const override;
|
||||
QList<QgsLayerTreeModelLegendNode *> createLegendNodes( QgsLayerTreeLayer *nodeLayer ) override SIP_FACTORY;
|
||||
QStringList legendRuleKeys() const override;
|
||||
@ -184,8 +182,6 @@ class CORE_EXPORT QgsPointCloudClassifiedRenderer : public QgsPointCloudRenderer
|
||||
|
||||
private:
|
||||
|
||||
int mPainterPenWidth = 1;
|
||||
|
||||
QString mAttribute = QStringLiteral( "Classification" );
|
||||
|
||||
QgsPointCloudCategoryList mCategories;
|
||||
|
@ -70,7 +70,7 @@ QSet<QString> QgsPointCloudRenderer::usedAttributes( const QgsPointCloudRenderCo
|
||||
return QSet< QString >();
|
||||
}
|
||||
|
||||
void QgsPointCloudRenderer::startRender( QgsPointCloudRenderContext & )
|
||||
void QgsPointCloudRenderer::startRender( QgsPointCloudRenderContext &context )
|
||||
{
|
||||
#ifdef QGISDEBUG
|
||||
if ( !mThread )
|
||||
@ -82,6 +82,8 @@ void QgsPointCloudRenderer::startRender( QgsPointCloudRenderContext & )
|
||||
Q_ASSERT_X( mThread == QThread::currentThread(), "QgsPointCloudRenderer::startRender", "startRender called in a different thread - use a cloned renderer instead" );
|
||||
}
|
||||
#endif
|
||||
|
||||
mPainterPenWidth = context.renderContext().convertToPainterUnits( pointSize(), pointSizeUnit(), pointSizeMapUnitScale() );
|
||||
}
|
||||
|
||||
void QgsPointCloudRenderer::stopRender( QgsPointCloudRenderContext & )
|
||||
@ -131,6 +133,8 @@ QStringList QgsPointCloudRenderer::legendRuleKeys() const
|
||||
return QStringList();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void QgsPointCloudRenderer::copyCommonProperties( QgsPointCloudRenderer *destination ) const
|
||||
{
|
||||
destination->setPointSize( mPointSize );
|
||||
|
@ -430,6 +430,23 @@ class CORE_EXPORT QgsPointCloudRenderer
|
||||
return context.offset().z() + context.scale().z() * iz;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws a point using a \a color at the specified \a x and \a y (in map coordinates).
|
||||
*/
|
||||
void drawPoint( double x, double y, const QColor &color, QgsPointCloudRenderContext &context ) const
|
||||
{
|
||||
context.renderContext().mapToPixel().transformInPlace( x, y );
|
||||
#if 0
|
||||
pen.setColor( QColor( red, green, blue ) );
|
||||
context.renderContext().painter()->setPen( pen );
|
||||
context.renderContext().painter()->drawPoint( QPointF( x, y ) );
|
||||
#else
|
||||
context.renderContext().painter()->fillRect( QRectF( x - mPainterPenWidth * 0.5,
|
||||
y - mPainterPenWidth * 0.5,
|
||||
mPainterPenWidth, mPainterPenWidth ), color );
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies common point cloud properties (such as point size and screen error) to the \a destination renderer.
|
||||
*/
|
||||
@ -468,6 +485,7 @@ class CORE_EXPORT QgsPointCloudRenderer
|
||||
QgsUnitTypes::RenderUnit mPointSizeUnit = QgsUnitTypes::RenderMillimeters;
|
||||
QgsMapUnitScale mPointSizeMapUnitScale;
|
||||
|
||||
int mPainterPenWidth = 1;
|
||||
};
|
||||
|
||||
#endif // QGSPOINTCLOUDRENDERER_H
|
||||
|
@ -60,11 +60,6 @@ void QgsPointCloudRgbRenderer::renderBlock( const QgsPointCloudBlock *block, Qgs
|
||||
|
||||
const QgsRectangle visibleExtent = context.renderContext().extent();
|
||||
|
||||
QPen pen;
|
||||
pen.setWidth( mPainterPenWidth );
|
||||
pen.setCapStyle( Qt::FlatCap );
|
||||
//pen.setJoinStyle( Qt::MiterJoin );
|
||||
|
||||
const char *ptr = block->data();
|
||||
int count = block->pointCount();
|
||||
const QgsPointCloudAttributeCollection request = block->attributes();
|
||||
@ -155,18 +150,7 @@ void QgsPointCloudRgbRenderer::renderBlock( const QgsPointCloudBlock *block, Qgs
|
||||
blue = mBlueContrastEnhancement->enhanceContrast( blue );
|
||||
}
|
||||
|
||||
mapToPixel.transformInPlace( x, y );
|
||||
|
||||
#if 0
|
||||
pen.setColor( QColor( red, green, blue ) );
|
||||
context.renderContext().painter()->setPen( pen );
|
||||
context.renderContext().painter()->drawPoint( QPointF( x, y ) );
|
||||
#else
|
||||
context.renderContext().painter()->fillRect( QRectF( x - mPainterPenWidth * 0.5,
|
||||
y - mPainterPenWidth * 0.5,
|
||||
mPainterPenWidth, mPainterPenWidth ), QColor( red, green, blue ) );
|
||||
#endif
|
||||
|
||||
drawPoint( x, y, QColor( red, green, blue ), context );
|
||||
rendered++;
|
||||
}
|
||||
}
|
||||
@ -250,18 +234,6 @@ QDomElement QgsPointCloudRgbRenderer::save( QDomDocument &doc, const QgsReadWrit
|
||||
return rendererElem;
|
||||
}
|
||||
|
||||
void QgsPointCloudRgbRenderer::startRender( QgsPointCloudRenderContext &context )
|
||||
{
|
||||
QgsPointCloudRenderer::startRender( context );
|
||||
|
||||
mPainterPenWidth = context.renderContext().convertToPainterUnits( pointSize(), pointSizeUnit(), pointSizeMapUnitScale() );
|
||||
}
|
||||
|
||||
void QgsPointCloudRgbRenderer::stopRender( QgsPointCloudRenderContext &context )
|
||||
{
|
||||
QgsPointCloudRenderer::stopRender( context );
|
||||
}
|
||||
|
||||
QSet<QString> QgsPointCloudRgbRenderer::usedAttributes( const QgsPointCloudRenderContext & ) const
|
||||
{
|
||||
QSet<QString> res;
|
||||
|
@ -43,8 +43,6 @@ class CORE_EXPORT QgsPointCloudRgbRenderer : public QgsPointCloudRenderer
|
||||
QgsPointCloudRenderer *clone() const override;
|
||||
void renderBlock( const QgsPointCloudBlock *block, QgsPointCloudRenderContext &context ) override;
|
||||
QDomElement save( QDomDocument &doc, const QgsReadWriteContext &context ) const override;
|
||||
void startRender( QgsPointCloudRenderContext &context ) override;
|
||||
void stopRender( QgsPointCloudRenderContext &context ) override;
|
||||
QSet< QString > usedAttributes( const QgsPointCloudRenderContext &context ) const override;
|
||||
|
||||
/**
|
||||
@ -168,8 +166,6 @@ class CORE_EXPORT QgsPointCloudRgbRenderer : public QgsPointCloudRenderer
|
||||
|
||||
private:
|
||||
|
||||
int mPainterPenWidth = 1;
|
||||
|
||||
QString mRedAttribute = QStringLiteral( "Red" );
|
||||
QString mGreenAttribute = QStringLiteral( "Green" );
|
||||
QString mBlueAttribute = QStringLiteral( "Blue" );
|
||||
|
Loading…
x
Reference in New Issue
Block a user