Skip to content

Commit

Permalink
renamed doubleNear to qgsDoubleNear, QgsMalloc to qgsMalloc, QgsCallo…
Browse files Browse the repository at this point in the history
…c to qgsCalloc, QgsFree to qgsFree
  • Loading branch information
blazek committed Apr 12, 2013
1 parent 19377fb commit f40e3a6
Show file tree
Hide file tree
Showing 43 changed files with 150 additions and 150 deletions.
2 changes: 1 addition & 1 deletion src/analysis/raster/qgsrastercalculator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ bool QgsRasterCalculator::transformationsEqual( double* t1, double* t2 ) const
{
for ( int i = 0; i < 6; ++i )
{
if ( !doubleNear( t1[i], t2[i], 0.00001 ) )
if ( !qgsDoubleNear( t1[i], t2[i], 0.00001 ) )
{
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/analysis/raster/qgsrelief.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@ void QgsRelief::optimiseClassBreaks( QList<int>& breaks, double* frequencies )
continue;
}

if ( doubleNear( a[i - 1 ], a[i] ) )
if ( qgsDoubleNear( a[i - 1 ], a[i] ) )
{
continue;
}
Expand Down
6 changes: 3 additions & 3 deletions src/analysis/vector/qgsgeometryanalyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1471,7 +1471,7 @@ void QgsGeometryAnalyzer::locateAlongSegment( double x1, double y1, double m1, d
}

//match with vertex1
if ( doubleNear( m1, measure, tolerance ) )
if ( qgsDoubleNear( m1, measure, tolerance ) )
{
if ( reversed )
{
Expand All @@ -1486,7 +1486,7 @@ void QgsGeometryAnalyzer::locateAlongSegment( double x1, double y1, double m1, d
}

//match with vertex2
if ( doubleNear( m2, measure, tolerance ) )
if ( qgsDoubleNear( m2, measure, tolerance ) )
{
if ( reversed )
{
Expand All @@ -1507,7 +1507,7 @@ void QgsGeometryAnalyzer::locateAlongSegment( double x1, double y1, double m1, d
}

//match between the vertices
if ( doubleNear( m1, m2 ) )
if ( qgsDoubleNear( m1, m2 ) )
{
pt1.setX( x1 );
pt1.setY( y1 );
Expand Down
4 changes: 2 additions & 2 deletions src/app/composer/qgscompositionwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,8 @@ void QgsCompositionWidget::displayCompositionWidthHeight()
QgsCompositionPaper currentPaper = paper_it.value();

//consider width and height values may be exchanged
if (( doubleNear( currentPaper.mWidth, paperWidth ) && doubleNear( currentPaper.mHeight, paperHeight ) )
|| ( doubleNear( currentPaper.mWidth, paperHeight ) && doubleNear( currentPaper.mHeight, paperWidth ) ) )
if (( qgsDoubleNear( currentPaper.mWidth, paperWidth ) && qgsDoubleNear( currentPaper.mHeight, paperHeight ) )
|| ( qgsDoubleNear( currentPaper.mWidth, paperHeight ) && qgsDoubleNear( currentPaper.mHeight, paperWidth ) ) )
{
mPaperSizeComboBox->setCurrentIndex( mPaperSizeComboBox->findText( paper_it.key() ) );
found = true;
Expand Down
4 changes: 2 additions & 2 deletions src/app/qgsdecorationgrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ int QgsDecorationGrid::xGridLines( QList< QPair< double, QLineF > >& lines, QPai
double roundCorrection = mapBoundingRect.top() > 0 ? 1.0 : 0.0;
double currentLevel = ( int )(( mapBoundingRect.top() - mGridOffsetY ) / mGridIntervalY + roundCorrection ) * mGridIntervalY + mGridOffsetY;

// if ( doubleNear( mRotation, 0.0 ) )
// if ( qgsDoubleNear( mRotation, 0.0 ) )
// {
//no rotation. Do it 'the easy way'

Expand Down Expand Up @@ -610,7 +610,7 @@ int QgsDecorationGrid::yGridLines( QList< QPair< double, QLineF > >& lines, QPai
double roundCorrection = mapBoundingRect.left() > 0 ? 1.0 : 0.0;
double currentLevel = ( int )(( mapBoundingRect.left() - mGridOffsetX ) / mGridIntervalX + roundCorrection ) * mGridIntervalX + mGridOffsetX;

// if ( doubleNear( mRotation, 0.0 ) )
// if ( qgsDoubleNear( mRotation, 0.0 ) )
// {
// //no rotation. Do it 'the easy way'
double xCanvasCoord;
Expand Down
4 changes: 2 additions & 2 deletions src/app/qgsmaptoolsimplify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ bool QgsMapToolSimplify::calculateSliderBoudaries()
bottomFound = true;
highTol = tol;
tol = ( highTol + lowTol ) / 2;
if ( doubleNear( highTol, lowTol, 0.0001 ) ) // without 0.0001 tolerance sometimes an endless loop in epsg:4326
if ( qgsDoubleNear( highTol, lowTol, 0.0001 ) ) // without 0.0001 tolerance sometimes an endless loop in epsg:4326
{ //solving problem that two points are in same distance from line, so they will be both excluded at same time
//so some time more than required count of vertices can stay
found = true;
Expand All @@ -230,7 +230,7 @@ bool QgsMapToolSimplify::calculateSliderBoudaries()
{
lowTol = tol;
tol = ( highTol + lowTol ) / 2;
if ( doubleNear( highTol, lowTol, 0.0001 ) ) // without 0.0001 tolerance sometimes an endless loop in epsg:4326
if ( qgsDoubleNear( highTol, lowTol, 0.0001 ) ) // without 0.0001 tolerance sometimes an endless loop in epsg:4326
{ //solving problem that two points are in same distance from line, so they will be both excluded at same time
//so some time more than required count of vertices can stay
found = true;
Expand Down
2 changes: 1 addition & 1 deletion src/core/composer/qgscomposeritem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1110,7 +1110,7 @@ bool QgsComposerItem::imageSizeConsideringRotation( double& width, double& heigh
return true;
}

if ( doubleNear( qAbs( mRotation ), 90 ) || doubleNear( qAbs( mRotation ), 270 ) )
if ( qgsDoubleNear( qAbs( mRotation ), 90 ) || qgsDoubleNear( qAbs( mRotation ), 270 ) )
{
double tmp = width;
width = height;
Expand Down
4 changes: 2 additions & 2 deletions src/core/composer/qgscomposermap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1344,7 +1344,7 @@ int QgsComposerMap::xGridLines( QList< QPair< double, QLineF > >& lines ) const
double roundCorrection = mapBoundingRect.top() > 0 ? 1.0 : 0.0;
double currentLevel = ( int )(( mapBoundingRect.top() - mGridOffsetY ) / mGridIntervalY + roundCorrection ) * mGridIntervalY + mGridOffsetY;

if ( doubleNear( mRotation, 0.0 ) )
if ( qgsDoubleNear( mRotation, 0.0 ) )
{
//no rotation. Do it 'the easy way'

Expand Down Expand Up @@ -1412,7 +1412,7 @@ int QgsComposerMap::yGridLines( QList< QPair< double, QLineF > >& lines ) const
double roundCorrection = mapBoundingRect.left() > 0 ? 1.0 : 0.0;
double currentLevel = ( int )(( mapBoundingRect.left() - mGridOffsetX ) / mGridIntervalX + roundCorrection ) * mGridIntervalX + mGridOffsetX;

if ( doubleNear( mRotation, 0.0 ) )
if ( qgsDoubleNear( mRotation, 0.0 ) )
{
//no rotation. Do it 'the easy way'
double xCanvasCoord;
Expand Down
16 changes: 8 additions & 8 deletions src/core/composer/qgscomposition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1277,7 +1277,7 @@ QGraphicsLineItem* QgsComposition::nearestSnapLine( bool horizontal, double x, d
QList< QGraphicsLineItem* >::const_iterator it = mSnapLines.constBegin();
for ( ; it != mSnapLines.constEnd(); ++it )
{
bool itemHorizontal = doubleNear(( *it )->line().y2() - ( *it )->line().y1(), 0 );
bool itemHorizontal = qgsDoubleNear(( *it )->line().y2() - ( *it )->line().y1(), 0 );
if ( horizontal && itemHorizontal )
{
currentYCoord = ( *it )->line().y1();
Expand Down Expand Up @@ -1312,30 +1312,30 @@ QGraphicsLineItem* QgsComposition::nearestSnapLine( bool horizontal, double x, d

if ( horizontal )
{
if ( doubleNear( currentYCoord, currentItem->transform().dy() + currentItem->rect().top(), itemTolerance ) )
if ( qgsDoubleNear( currentYCoord, currentItem->transform().dy() + currentItem->rect().top(), itemTolerance ) )
{
snappedItems.append( qMakePair( currentItem, QgsComposerItem::UpperMiddle ) );
}
else if ( doubleNear( currentYCoord, currentItem->transform().dy() + currentItem->rect().center().y(), itemTolerance ) )
else if ( qgsDoubleNear( currentYCoord, currentItem->transform().dy() + currentItem->rect().center().y(), itemTolerance ) )
{
snappedItems.append( qMakePair( currentItem, QgsComposerItem::Middle ) );
}
else if ( doubleNear( currentYCoord, currentItem->transform().dy() + currentItem->rect().bottom(), itemTolerance ) )
else if ( qgsDoubleNear( currentYCoord, currentItem->transform().dy() + currentItem->rect().bottom(), itemTolerance ) )
{
snappedItems.append( qMakePair( currentItem, QgsComposerItem::LowerMiddle ) );
}
}
else
{
if ( doubleNear( currentXCoord, currentItem->transform().dx(), itemTolerance ) )
if ( qgsDoubleNear( currentXCoord, currentItem->transform().dx(), itemTolerance ) )
{
snappedItems.append( qMakePair( currentItem, QgsComposerItem::MiddleLeft ) );
}
else if ( doubleNear( currentXCoord, currentItem->transform().dx() + currentItem->rect().center().x(), itemTolerance ) )
else if ( qgsDoubleNear( currentXCoord, currentItem->transform().dx() + currentItem->rect().center().x(), itemTolerance ) )
{
snappedItems.append( qMakePair( currentItem, QgsComposerItem::Middle ) );
}
else if ( doubleNear( currentXCoord, currentItem->transform().dx() + currentItem->rect().width(), itemTolerance ) )
else if ( qgsDoubleNear( currentXCoord, currentItem->transform().dx() + currentItem->rect().width(), itemTolerance ) )
{
snappedItems.append( qMakePair( currentItem, QgsComposerItem::MiddleRight ) );
}
Expand Down Expand Up @@ -2038,7 +2038,7 @@ void QgsComposition::collectAlignCoordinates( QMap< double, const QgsComposerIte
{
double x = ( *sIt )->line().x1();
double y = ( *sIt )->line().y1();
if ( doubleNear( y, 0.0 ) )
if ( qgsDoubleNear( y, 0.0 ) )
{
alignCoordsX.insert( x, 0 );
}
Expand Down
8 changes: 4 additions & 4 deletions src/core/qgis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ QString QGis::tr( QGis::UnitType unit )
return QCoreApplication::translate( "QGis::UnitType", qPrintable( toLiteral( unit ) ) );
}

void *QgsMalloc( size_t size )
void *qgsMalloc( size_t size )
{
if ( size == 0 || long( size ) < 0 )
{
Expand All @@ -123,22 +123,22 @@ void *QgsMalloc( size_t size )
return p;
}

void *QgsCalloc( size_t nmemb, size_t size )
void *qgsCalloc( size_t nmemb, size_t size )
{
if ( nmemb == 0 || long( nmemb ) < 0 || size == 0 || long( size ) < 0 )
{
QgsDebugMsg( QString( "Negative or zero nmemb %1 or size %2." ).arg( nmemb ).arg( size ) );
return NULL;
}
void *p = QgsMalloc( nmemb * size );
void *p = qgsMalloc( nmemb * size );
if ( p != NULL )
{
memset( p, 0, nmemb * size );
}
return p;
}

void QgsFree( void *ptr )
void qgsFree( void *ptr )
{
free( ptr );
}
Expand Down
10 changes: 5 additions & 5 deletions src/core/qgis.h
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ inline void ( *cast_to_fptr( void *p ) )()
//
// compare two doubles (but allow some difference)
//
inline bool doubleNear( double a, double b, double epsilon = 4 * DBL_EPSILON )
inline bool qgsDoubleNear( double a, double b, double epsilon = 4 * DBL_EPSILON )
{
const double diff = a - b;
return diff > -epsilon && diff <= epsilon;
Expand All @@ -255,7 +255,7 @@ inline bool doubleNear( double a, double b, double epsilon = 4 * DBL_EPSILON )
//
// compare two doubles using specified number of significant digits
//
inline bool doubleNearSig( double a, double b, int significantDigits = 10 )
inline bool qgsDoubleNearSig( double a, double b, int significantDigits = 10 )
{
// The most simple would be to print numbers as %.xe and compare as strings
// but that is probably too costly
Expand All @@ -278,20 +278,20 @@ bool qgsVariantGreaterThan( const QVariant& lhs, const QVariant& rhs );
Works like C malloc() but prints debug message by QgsLogger if allocation fails.
@param size size in bytes
*/
void CORE_EXPORT *QgsMalloc( size_t size );
void CORE_EXPORT *qgsMalloc( size_t size );

/** Allocates memory for an array of nmemb elements of size bytes each and returns
a pointer to the allocated memory. Works like C calloc() but prints debug message
by QgsLogger if allocation fails.
@param nmemb number of elements
@param size size of element in bytes
*/
void CORE_EXPORT *QgsCalloc( size_t nmemb, size_t size );
void CORE_EXPORT *qgsCalloc( size_t nmemb, size_t size );

/** Frees the memory space pointed to by ptr. Works like C free().
@param ptr pointer to memory space
*/
void CORE_EXPORT QgsFree( void *ptr );
void CORE_EXPORT qgsFree( void *ptr );

/** Wkt string that represents a geographic coord sys
* @note added in 1.8 to replace GEOWkt
Expand Down
40 changes: 20 additions & 20 deletions src/core/qgsclipper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,93 +109,93 @@ void QgsClipper::connectSeparatedLines( double x0, double y0, double x1, double
const QgsRectangle& clipRect, QPolygonF& pts )
{
//test the different edge combinations...
if ( doubleNear( x0, clipRect.xMinimum() ) )
if ( qgsDoubleNear( x0, clipRect.xMinimum() ) )
{
if ( doubleNear( x1, clipRect.xMinimum() ) )
if ( qgsDoubleNear( x1, clipRect.xMinimum() ) )
{
return;
}
else if ( doubleNear( y1, clipRect.yMaximum() ) )
else if ( qgsDoubleNear( y1, clipRect.yMaximum() ) )
{
pts << QPointF( clipRect.xMinimum(), clipRect.yMaximum() );
return;
}
else if ( doubleNear( x1, clipRect.xMaximum() ) )
else if ( qgsDoubleNear( x1, clipRect.xMaximum() ) )
{
pts << QPointF( clipRect.xMinimum(), clipRect.yMaximum() );
pts << QPointF( clipRect.xMaximum(), clipRect.yMaximum() );
return;
}
else if ( doubleNear( y1, clipRect.yMinimum() ) )
else if ( qgsDoubleNear( y1, clipRect.yMinimum() ) )
{
pts << QPointF( clipRect.xMinimum(), clipRect.yMinimum() );
return;
}
}
else if ( doubleNear( y0, clipRect.yMaximum() ) )
else if ( qgsDoubleNear( y0, clipRect.yMaximum() ) )
{
if ( doubleNear( y1, clipRect.yMaximum() ) )
if ( qgsDoubleNear( y1, clipRect.yMaximum() ) )
{
return;
}
else if ( doubleNear( x1, clipRect.xMaximum() ) )
else if ( qgsDoubleNear( x1, clipRect.xMaximum() ) )
{
pts << QPointF( clipRect.xMaximum(), clipRect.yMaximum() );
return;
}
else if ( doubleNear( y1, clipRect.yMinimum() ) )
else if ( qgsDoubleNear( y1, clipRect.yMinimum() ) )
{
pts << QPointF( clipRect.xMaximum(), clipRect.yMaximum() );
pts << QPointF( clipRect.xMaximum(), clipRect.yMinimum() );
return;
}
else if ( doubleNear( x1, clipRect.xMinimum() ) )
else if ( qgsDoubleNear( x1, clipRect.xMinimum() ) )
{
pts << QPointF( clipRect.xMinimum(), clipRect.yMaximum() );
return;
}
}
else if ( doubleNear( x0, clipRect.xMaximum() ) )
else if ( qgsDoubleNear( x0, clipRect.xMaximum() ) )
{
if ( doubleNear( x1, clipRect.xMaximum() ) )
if ( qgsDoubleNear( x1, clipRect.xMaximum() ) )
{
return;
}
else if ( doubleNear( y1, clipRect.yMinimum() ) )
else if ( qgsDoubleNear( y1, clipRect.yMinimum() ) )
{
pts << QPointF( clipRect.xMaximum(), clipRect.yMinimum() );
return;
}
else if ( doubleNear( x1, clipRect.xMinimum() ) )
else if ( qgsDoubleNear( x1, clipRect.xMinimum() ) )
{
pts << QPointF( clipRect.xMaximum(), clipRect.yMinimum() );
pts << QPointF( clipRect.xMinimum(), clipRect.yMinimum() );
return;
}
else if ( doubleNear( y1, clipRect.yMaximum() ) )
else if ( qgsDoubleNear( y1, clipRect.yMaximum() ) )
{
pts << QPointF( clipRect.xMaximum(), clipRect.yMaximum() );
return;
}
}
else if ( doubleNear( y0, clipRect.yMinimum() ) )
else if ( qgsDoubleNear( y0, clipRect.yMinimum() ) )
{
if ( doubleNear( y1, clipRect.yMinimum() ) )
if ( qgsDoubleNear( y1, clipRect.yMinimum() ) )
{
return;
}
else if ( doubleNear( x1, clipRect.xMinimum() ) )
else if ( qgsDoubleNear( x1, clipRect.xMinimum() ) )
{
pts << QPointF( clipRect.xMinimum(), clipRect.yMinimum() );
return;
}
else if ( doubleNear( y1, clipRect.yMaximum() ) )
else if ( qgsDoubleNear( y1, clipRect.yMaximum() ) )
{
pts << QPointF( clipRect.xMinimum(), clipRect.yMinimum() );
pts << QPointF( clipRect.xMinimum(), clipRect.yMaximum() );
return;
}
else if ( doubleNear( x1, clipRect.xMaximum() ) )
else if ( qgsDoubleNear( x1, clipRect.xMaximum() ) )
{
pts << QPointF( clipRect.xMaximum(), clipRect.yMinimum() );
return;
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsclipper.h
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ inline QPointF QgsClipper::intersectRect( const QPointF& pt1,
}

double r = 0;
if ( !doubleNear( r_d, 0.0 ) )
if ( !qgsDoubleNear( r_d, 0.0 ) )
{
r = r_n / r_d;
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgscoordinatereferencesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -972,7 +972,7 @@ void QgsCoordinateReferenceSystem::setMapUnits()

QgsDebugMsg( "Projection has linear units of " + unit );

if ( doubleNear( toMeter, 1.0 ) ) //Unit name for meters would be "metre"
if ( qgsDoubleNear( toMeter, 1.0 ) ) //Unit name for meters would be "metre"
mMapUnits = QGis::Meters;
else if ( unit == "Foot" )
mMapUnits = QGis::Feet;
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgspoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ double QgsPoint::sqrDistToSegment( double x1, double y1, double x2, double y2, Q

double dist = sqrDist( minDistPoint );
//prevent rounding errors if the point is directly on the segment
if ( doubleNear( dist, 0.0, epsilon ) )
if ( qgsDoubleNear( dist, 0.0, epsilon ) )
{
minDistPoint.setX( m_x );
minDistPoint.setY( m_y );
Expand Down
Loading

0 comments on commit f40e3a6

Please sign in to comment.