Skip to content

Commit

Permalink
Reduce warning noise and fix some doxymentation issues
Browse files Browse the repository at this point in the history
Some warnings are wrapped in Q_NOWARN_DEPRECATED_*, these are warnings for
issues which are not critical and therefore of limited importance.

The general idea is to leave the space for compiler warnings to the one that
really need to be addressed.

Also removes a no longer required header file of dxflib.

Exposes some ready-to use doxymentation by wrapping it in appropriate comment
structure.

And some more cleanup
  • Loading branch information
m-kuhn committed Jun 15, 2015
1 parent f1eb380 commit 038f99b
Show file tree
Hide file tree
Showing 16 changed files with 178 additions and 178 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -16,7 +16,7 @@ notifications:
urls:
- https://webhooks.gitter.im/e/467e3aff72e344d1dae3
on_success: change # options: [always|never|change] default: always
on_failure: change # options: [always|never|change] default: always
on_failure: always # options: [always|never|change] default: always
on_start: never # default: never

addons:
Expand Down
4 changes: 4 additions & 0 deletions src/analysis/vector/qgstransectsample.cpp
Expand Up @@ -288,7 +288,9 @@ int QgsTransectSample::createSample( QProgressDialog* pd )
outputPointWriter.addFeature( samplePointFeature );

sIndex.insertFeature( sampleLineFeature );
Q_NOWARN_DEPRECATED_PUSH
lineFeatureMap.insert( fid, sampleLineFeature.geometryAndOwnership() );
Q_NOWARN_DEPRECATED_POP

delete lineFarAwayGeom;
++nTotalTransects;
Expand Down Expand Up @@ -336,7 +338,9 @@ QgsGeometry* QgsTransectSample::findBaselineGeometry( QVariant strataId )
{
if ( strataId == fet.attribute( mBaselineStrataId ) || mShareBaseline )
{
Q_NOWARN_DEPRECATED_PUSH
return fet.geometryAndOwnership();
Q_NOWARN_DEPRECATED_POP
}
}
return 0;
Expand Down
42 changes: 16 additions & 26 deletions src/app/qgslabelpreview.cpp
Expand Up @@ -22,19 +22,9 @@
QgsLabelPreview::QgsLabelPreview( QWidget* parent )
: QLabel( parent )
{
mTmpLyr = new QgsPalLayerSettings();

// construct a device-based render context
QgsMapToPixel newCoordXForm;
newCoordXForm.setParameters( 1, 0, 0, 0 );
mContext = new QgsRenderContext();
mContext->setMapToPixel( newCoordXForm );
}

QgsLabelPreview::~QgsLabelPreview()
{
delete mTmpLyr;
delete mContext;
QgsMapToPixel newCoordXForm( 1 );
mContext.setMapToPixel( newCoordXForm );
}

void QgsLabelPreview::setTextColor( QColor color )
Expand All @@ -45,13 +35,13 @@ void QgsLabelPreview::setTextColor( QColor color )

void QgsLabelPreview::setBuffer( double size, QColor color, Qt::PenJoinStyle joinStyle, bool noFill )
{
mTmpLyr->bufferSize = size * 88 / 25.4; //assume standard dpi for preview;
mTmpLyr->bufferSizeInMapUnits = false;
mTmpLyr->bufferColor = color;
mTmpLyr->bufferJoinStyle = joinStyle;
mTmpLyr->bufferNoFill = noFill;
mTmpLyr.bufferSize = size * 88 / 25.4; //assume standard dpi for preview;
mTmpLyr.bufferSizeInMapUnits = false;
mTmpLyr.bufferColor = color;
mTmpLyr.bufferJoinStyle = joinStyle;
mTmpLyr.bufferNoFill = noFill;

mTmpLyr->textFont = font();
mTmpLyr.textFont = font();
update();
}

Expand All @@ -62,28 +52,28 @@ void QgsLabelPreview::paintEvent( QPaintEvent *e )

// TODO: draw all label components when this preview is an actual map canvas
// for now, only preview label's text and buffer
mTmpLyr->shadowDraw = false;
mTmpLyr.shadowDraw = false;

p.setRenderHint( QPainter::Antialiasing );
p.setFont( font() );
QFontMetrics fm( font() );

// otherwise thin buffers don't look like those on canvas
if ( mTmpLyr->bufferSize != 0 && mTmpLyr->bufferSize < 1 )
mTmpLyr->bufferSize = 1;
if ( mTmpLyr.bufferSize != 0 && mTmpLyr.bufferSize < 1 )
mTmpLyr.bufferSize = 1;

double xtrans = 0;
if ( mTmpLyr->bufferSize != 0 )
xtrans = mTmpLyr->bufferSize / 4;
if ( mTmpLyr.bufferSize != 0 )
xtrans = mTmpLyr.bufferSize / 4;

p.translate( xtrans, fm.ascent() + 4 );

if ( mTmpLyr->bufferSize != 0 )
if ( mTmpLyr.bufferSize != 0 )
{
mContext->setPainter( &p );
mContext.setPainter( &p );
QgsLabelComponent component;
component.setText( text() );
QgsPalLabeling::drawLabelBuffer( *mContext, component, *mTmpLyr );
QgsPalLabeling::drawLabelBuffer( mContext, component, mTmpLyr );
}

QPainterPath path;
Expand Down
5 changes: 2 additions & 3 deletions src/app/qgslabelpreview.h
Expand Up @@ -25,7 +25,6 @@ class APP_EXPORT QgsLabelPreview : public QLabel
{
public:
QgsLabelPreview( QWidget* parent = NULL );
~QgsLabelPreview();

void setTextColor( QColor color );

Expand All @@ -37,12 +36,12 @@ class APP_EXPORT QgsLabelPreview : public QLabel
void paintEvent( QPaintEvent* e ) override;

private:
QgsPalLayerSettings* mTmpLyr;
QgsPalLayerSettings mTmpLyr;
QColor mTextColor;
QFont mFont;

// device-based render context
QgsRenderContext* mContext;
QgsRenderContext mContext;
};

#endif // LABELPREVIEW_H
8 changes: 8 additions & 0 deletions src/app/qgsmaptooloffsetcurve.cpp
Expand Up @@ -278,8 +278,10 @@ QgsGeometry* QgsMapToolOffsetCurve::createOriginGeometry( QgsVectorLayer* vl, co

if ( vl == currentVectorLayer() && !mForceCopy )
{
Q_NOWARN_DEPRECATED_PUSH
//don't consider selected geometries, only the snap result
return convertToSingleLine( snappedFeature.geometryAndOwnership(), partVertexNr, mMultiPartGeometry );
Q_NOWARN_DEPRECATED_POP
}
else //snapped to a background layer
{
Expand All @@ -294,14 +296,18 @@ QgsGeometry* QgsMapToolOffsetCurve::createOriginGeometry( QgsVectorLayer* vl, co
const QgsFeatureIds& selection = vl->selectedFeaturesIds();
if ( selection.size() < 1 || !selection.contains( match.featureId() ) )
{
Q_NOWARN_DEPRECATED_PUSH
return convertToSingleLine( snappedFeature.geometryAndOwnership(), partVertexNr, mMultiPartGeometry );
Q_NOWARN_DEPRECATED_POP
}
else
{
//merge together if several features
QgsFeatureList selectedFeatures = vl->selectedFeatures();
QgsFeatureList::iterator selIt = selectedFeatures.begin();
Q_NOWARN_DEPRECATED_PUSH
QgsGeometry* geom = selIt->geometryAndOwnership();
Q_NOWARN_DEPRECATED_POP
++selIt;
for ( ; selIt != selectedFeatures.end(); ++selIt )
{
Expand All @@ -314,7 +320,9 @@ QgsGeometry* QgsMapToolOffsetCurve::createOriginGeometry( QgsVectorLayer* vl, co
if ( geom->isMultipart() )
{
delete geom;
Q_NOWARN_DEPRECATED_PUSH
return convertToSingleLine( snappedFeature.geometryAndOwnership(), match.vertexIndex(), mMultiPartGeometry );
Q_NOWARN_DEPRECATED_POP
}

return geom;
Expand Down
2 changes: 2 additions & 0 deletions src/core/dxf/qgsdxfpallabeling.cpp
Expand Up @@ -50,7 +50,9 @@ QgsDxfPalLabeling::QgsDxfPalLabeling( QgsDxfExport* dxf, const QgsRectangle& bbo
mRenderContext.setRendererScale( scale );
mRenderContext.setExtent( bbox );
mRenderContext.setScaleFactor( 96.0 / 25.4 );
Q_NOWARN_DEPRECATED_PUSH
mRenderContext.setMapToPixel( QgsMapToPixel( 1.0 / factor, bbox.xMinimum(), bbox.yMinimum(), bbox.height() * factor ) );
Q_NOWARN_DEPRECATED_POP
}

QgsDxfPalLabeling::~QgsDxfPalLabeling()
Expand Down
4 changes: 2 additions & 2 deletions src/core/layertree/qgslayertreemodellegendnode.cpp
Expand Up @@ -202,7 +202,7 @@ QgsRenderContext * QgsSymbolV2LegendNode::createTemporaryRenderContext() const
QScopedPointer<QgsRenderContext> context( new QgsRenderContext );
context->setScaleFactor( dpi / 25.4 );
context->setRendererScale( scale );
context->setMapToPixel( QgsMapToPixel( mupp ) ); // hope it's ok to leave out other params
context->setMapToPixel( QgsMapToPixel( mupp ) );
return validData ? context.take() : 0;
}

Expand Down Expand Up @@ -309,7 +309,7 @@ QSizeF QgsSymbolV2LegendNode::drawSymbol( const QgsLegendSettings& settings, Ite
QgsRenderContext context;
context.setScaleFactor( settings.dpi() / 25.4 );
context.setRendererScale( settings.mapScale() );
context.setMapToPixel( QgsMapToPixel( 1 / ( settings.mmPerMapUnit() * context.scaleFactor() ) ) ); // hope it's ok to leave out other params
context.setMapToPixel( QgsMapToPixel( 1 / ( settings.mmPerMapUnit() * context.scaleFactor() ) ) );
context.setForceVectorOutput( true );
context.setPainter( ctx ? ctx->painter : 0 );

Expand Down
2 changes: 1 addition & 1 deletion src/core/pal/feature.h
Expand Up @@ -84,7 +84,7 @@ namespace pal
friend class FeaturePart;

public:
Feature( Layer* l, const char* id, PalGeometry* userG, double lx, double ly );
Feature( Layer* l, const char* geom_id, PalGeometry* userG, double lx, double ly );
~Feature();

void setLabelInfo( LabelInfo* info ) { labelInfo = info; }
Expand Down
5 changes: 2 additions & 3 deletions src/core/qgis.h
Expand Up @@ -451,9 +451,9 @@ typedef unsigned long long qgssize;
#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) || defined(__clang__)
#define Q_NOWARN_DEPRECATED_PUSH \
_Pragma("GCC diagnostic push") \
_Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
_Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"");
#define Q_NOWARN_DEPRECATED_POP \
_Pragma("GCC diagnostic pop")
_Pragma("GCC diagnostic pop");
#elif defined(_MSC_VER)
#define Q_NOWARN_DEPRECATED_PUSH \
__pragma(warning(push)) \
Expand All @@ -465,7 +465,6 @@ typedef unsigned long long qgssize;
#define Q_NOWARN_DEPRECATED_POP
#endif

// FIXME: also in qgisinterface.h
#ifndef QGISEXTERN
#ifdef WIN32
# define QGISEXTERN extern "C" __declspec( dllexport )
Expand Down
6 changes: 5 additions & 1 deletion src/core/qgsmaprenderer.cpp
Expand Up @@ -175,7 +175,7 @@ void QgsMapRenderer::adjustExtentToSize()
if ( !myWidth || !myHeight )
{
mScale = 1.0;
newCoordXForm.setParameters( 1, 0, 0, 0 );
newCoordXForm.setParameters( 1, 0, 0, 0, 0, 0 );
return;
}

Expand Down Expand Up @@ -225,7 +225,9 @@ void QgsMapRenderer::adjustExtentToSize()

QgsDebugMsg( QString( "Scale (assuming meters as map units) = 1:%1" ).arg( qgsDoubleToString( mScale ) ) );

Q_NOWARN_DEPRECATED_PUSH
newCoordXForm.setParameters( mMapUnitsPerPixel, dxmin, dymin, myHeight );
Q_NOWARN_DEPRECATED_POP
mRenderContext.setMapToPixel( newCoordXForm );
mRenderContext.setExtent( mExtent );
}
Expand Down Expand Up @@ -485,7 +487,9 @@ void QgsMapRenderer::render( QPainter* painter, double* forceWidthScale )
bk_mapToPixel = mRenderContext.mapToPixel();
rasterMapToPixel = mRenderContext.mapToPixel();
rasterMapToPixel.setMapUnitsPerPixel( mRenderContext.mapToPixel().mapUnitsPerPixel() / rasterScaleFactor );
Q_NOWARN_DEPRECATED_PUSH
rasterMapToPixel.setYMaximum( mSize.height() * rasterScaleFactor );
Q_NOWARN_DEPRECATED_POP
mRenderContext.setMapToPixel( rasterMapToPixel );
mRenderContext.painter()->save();
mRenderContext.painter()->scale( 1.0 / rasterScaleFactor, 1.0 / rasterScaleFactor );
Expand Down
14 changes: 14 additions & 0 deletions src/core/qgsmaptopixel.cpp
Expand Up @@ -42,6 +42,20 @@ QgsMapToPixel::QgsMapToPixel( double mapUnitsPerPixel,
updateMatrix();
}

QgsMapToPixel::QgsMapToPixel( double mapUnitsPerPixel )
: mMapUnitsPerPixel( mapUnitsPerPixel )
, mWidth( 0 )
, mHeight( 0 )
, mRotation( 0 )
, xCenter( 0 )
, yCenter( 0 )
, xMin( 0 )
, yMin( 0 )
{
Q_ASSERT( mapUnitsPerPixel > 0 );
updateMatrix();
}

QgsMapToPixel::QgsMapToPixel()
: mMapUnitsPerPixel( 1 )
, mWidth( 1 )
Expand Down

0 comments on commit 038f99b

Please sign in to comment.