Skip to content
Permalink
Browse files

fix for different vector rendering types

  • Loading branch information
PeterPetrik committed Oct 25, 2018
1 parent b0bd629 commit 20a205d88144bcbb7155fd82f113c384d84f87d2
Showing with 41 additions and 8 deletions.
  1. +34 −1 src/core/mesh/qgsmeshvectorrenderer.cpp
  2. +7 −7 src/core/mesh/qgsmeshvectorrenderer.h
@@ -74,7 +74,7 @@ QgsMeshVectorRenderer::QgsMeshVectorRenderer( const QgsTriangularMesh &m,
// we need to expand out the extent so that it includes
// arrows which start or end up outside of the
// actual visible extent
double extension = context.convertToMapUnits( mMaxMag, QgsUnitTypes::RenderPixels );
double extension = context.convertToMapUnits( calcExtentBufferSize(), QgsUnitTypes::RenderPixels );
mBufferedExtent.setXMinimum( mBufferedExtent.xMinimum() - extension );
mBufferedExtent.setXMaximum( mBufferedExtent.xMaximum() + extension );
mBufferedExtent.setYMinimum( mBufferedExtent.yMinimum() - extension );
@@ -200,6 +200,39 @@ bool QgsMeshVectorRenderer::calcVectorLineEnd(
return false; //success
}

double QgsMeshVectorRenderer::calcExtentBufferSize() const
{
double buffer;
switch ( mCfg.shaftLengthMethod() )
{
case QgsMeshRendererVectorSettings::ArrowScalingMethod::MinMax:
{
buffer = mContext.convertToPainterUnits( mCfg.maxShaftLength(),
QgsUnitTypes::RenderUnit::RenderMillimeters );
break;
}
case QgsMeshRendererVectorSettings::ArrowScalingMethod::Scaled:
{
buffer = mCfg.scaleFactor() * mMaxMag;
break;
}
case QgsMeshRendererVectorSettings::ArrowScalingMethod::Fixed:
{
buffer = mContext.convertToPainterUnits( mCfg.fixedShaftLength(),
QgsUnitTypes::RenderUnit::RenderMillimeters );
break;
}
}

if ( mCfg.filterMax() >= 0 && buffer > mCfg.filterMax() )
buffer = mCfg.filterMax();

if ( buffer < 0.0 )
buffer = 0.0;

return buffer;
}


void QgsMeshVectorRenderer::drawVectorDataOnVertices( const QList<int> &trianglesInExtent )
{
@@ -83,6 +83,13 @@ class QgsMeshVectorRenderer
double magnitude //in
);

/**
* Calculates the buffer size
* needed to draw arrows which have
* start or end point outside the
* visible canvas extent (in pixels)
*/
double calcExtentBufferSize() const;

const QgsTriangularMesh &mTriangularMesh;
const QVector<double> &mDatasetValuesX;
@@ -94,13 +101,6 @@ class QgsMeshVectorRenderer
const QgsMeshRendererVectorSettings &mCfg;
bool mDataOnVertices = true;
QSize mOutputSize;

/**
* Canvas extent buffered by vector maximum magnitude
* Needed to draw arrows which have
* start or end point outside the
* visible canvas extent
*/
QgsRectangle mBufferedExtent;
};

0 comments on commit 20a205d

Please sign in to comment.
You can’t perform that action at this time.