Skip to content
Permalink
Browse files

some cleanups:

- macros TRUE/FALSE to keywords true/false
- replace boolean comparison (x==true => x / x==false => !x)
- return(x); => return x;


git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@13380 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef
jef committed Apr 25, 2010
1 parent 9d835b3 commit 952cae5da65b5708a6667db3b86c28128c3ca00d
Showing with 341 additions and 399 deletions.
  1. +24 −24 src/analysis/interpolation/DualEdgeTriangulation.cc
  2. +4 −4 src/analysis/interpolation/MathUtils.cc
  3. +6 −6 src/analysis/interpolation/NormVecDecorator.cc
  4. +1 −1 src/analysis/raster/qgsninecellfilter.cpp
  5. +3 −11 src/app/composer/qgscomposerpicturewidget.cpp
  6. +9 −9 src/app/legend/qgslegendlayer.cpp
  7. +2 −2 src/app/legend/qgslegendlayer.h
  8. +1 −1 src/app/main.cpp
  9. +1 −1 src/app/ogr/qgsnewogrconnection.cpp
  10. +9 −9 src/app/qgisapp.cpp
  11. +1 −1 src/app/qgsgraduatedsymboldialog.cpp
  12. +1 −1 src/app/qgsmaptoolnodetool.cpp
  13. +2 −2 src/app/qgsmaptoolselect.cpp
  14. +5 −5 src/app/qgsmaptoolsimplify.cpp
  15. +2 −2 src/app/qgsmaptoolsimplify.h
  16. +6 −6 src/app/qgsrasterlayerproperties.cpp
  17. +1 −1 src/app/qgssinglesymboldialog.cpp
  18. +1 −1 src/app/qgsspatialitesourceselect.cpp
  19. +1 −1 src/app/qgswmssourceselect.h
  20. +1 −1 src/core/pal/simplemutex.h
  21. +4 −4 src/core/pal/util.h
  22. +1 −1 src/core/qgsapplication.h
  23. +1 −1 src/core/qgscoordinatereferencesystem.h
  24. +1 −1 src/core/qgsdistancearea.cpp
  25. +42 −42 src/core/qgsgeometry.cpp
  26. +7 −7 src/core/qgsgeometry.h
  27. +16 −16 src/core/qgshttptransaction.cpp
  28. +1 −1 src/core/qgshttptransaction.h
  29. +1 −1 src/core/qgsmaplayer.cpp
  30. +2 −2 src/core/qgsmaplayerregistry.h
  31. +1 −1 src/core/qgsmaprenderer.cpp
  32. +1 −1 src/core/qgsmaprenderer.h
  33. +10 −10 src/core/qgspluginlayerregistry.h
  34. +1 −1 src/core/qgsproject.h
  35. +4 −11 src/core/qgsrectangle.cpp
  36. +6 −6 src/core/qgsvectordataprovider.cpp
  37. +1 −1 src/core/qgsvectordataprovider.h
  38. +5 −5 src/core/qgsvectorfilewriter.cpp
  39. +3 −3 src/core/qgsvectorfilewriter.h
  40. +13 −13 src/core/qgsvectorlayer.cpp
  41. +7 −7 src/core/qgsvectorlayer.h
  42. +13 −20 src/core/raster/qgsrasterlayer.cpp
  43. +6 −6 src/core/spatialindex/rtree/RTree.cc
  44. +2 −2 src/core/spatialindex/storagemanager/Buffer.cc
  45. +3 −3 src/core/spatialindex/storagemanager/DiskStorageManager.cc
  46. +0 −1 src/core/symbology-ng/qgsmarkersymbollayerv2.cpp
  47. +3 −3 src/gui/qgsmapcanvas.cpp
  48. +2 −2 src/gui/qgsmapcanvas.h
  49. +2 −2 src/gui/qgsmaptoolpan.cpp
  50. +1 −6 src/plugins/diagram_overlay/qgssvgdiagramfactorywidget.cpp
  51. +6 −6 src/plugins/evis/eventbrowser/evisconfiguration.cpp
  52. +11 −11 src/plugins/georeferencer/qgsgeorefplugingui.cpp
  53. +14 −14 src/plugins/georeferencer/qgsgeoreftransform.cpp
  54. +7 −7 src/plugins/georeferencer/qgsimagewarper.cpp
  55. +4 −4 src/plugins/grass/qgsgrassattributes.cpp
  56. +2 −2 src/plugins/grass/qgsgrassbrowser.cpp
  57. +1 −5 src/plugins/grass/qgsgrassmapcalc.cpp
  58. +3 −10 src/plugins/grass/qgsgrassmodule.cpp
  59. +3 −3 src/plugins/labeling/pallabeling.cpp
  60. +2 −9 src/plugins/raster_terrain_analysis/qgsrasterterrainanalysisdialog.cpp
  61. +2 −2 src/plugins/spatialquery/qgsspatialquery.h
  62. +1 −1 src/plugins/spatialquery/qgsspatialquerydialog.cpp
  63. +2 −2 src/plugins/spit/qgsshapefile.cpp
  64. +0 −14 src/plugins/spit/qgsspit.cpp
  65. +6 −6 src/plugins/wfs/qgswfssourceselect.cpp
  66. +10 −8 src/providers/grass/qgsgrass.cpp
  67. +20 −20 src/providers/ogr/qgsogrprovider.cpp
  68. +6 −6 src/providers/wms/qgswmsprovider.h
@@ -767,7 +767,7 @@ void DualEdgeTriangulation::draw( QPainter* p, double xlowleft, double ylowleft,
{continue;}

//check, if the edge belongs to a flat triangle, remove this later
if ( control2[i] == false )
if ( !control2[i] )
{
double p1, p2, p3;
if ( mHalfEdge[i]->getPoint() != -1 && mHalfEdge[mHalfEdge[i]->getNext()]->getPoint() != -1 && mHalfEdge[mHalfEdge[mHalfEdge[i]->getNext()]->getNext()]->getPoint() != -1 )
@@ -792,7 +792,7 @@ void DualEdgeTriangulation::draw( QPainter* p, double xlowleft, double ylowleft,
control2[mHalfEdge[mHalfEdge[i]->getNext()]->getNext()] = true;
}//end of the section, which has to be removed later

if ( control[i] == true )//check, if edge has already been drawn
if ( control[i] )//check, if edge has already been drawn
{continue;}

//draw the edge;
@@ -830,7 +830,7 @@ void DualEdgeTriangulation::draw( QPainter* p, double xlowleft, double ylowleft,
{continue;}

//check, if the edge belongs to a flat triangle, remove this section later
if ( control2[i] == false )
if ( !control2[i] )
{
double p1, p2, p3;
if ( mHalfEdge[i]->getPoint() != -1 && mHalfEdge[mHalfEdge[i]->getNext()]->getPoint() != -1 && mHalfEdge[mHalfEdge[mHalfEdge[i]->getNext()]->getNext()]->getPoint() != -1 )
@@ -856,7 +856,7 @@ void DualEdgeTriangulation::draw( QPainter* p, double xlowleft, double ylowleft,
}//end of the section, which has to be removed later


if ( control[i] == true )//check, if edge has already been drawn
if ( control[i] )//check, if edge has already been drawn
{continue;}

//draw the edge
@@ -944,7 +944,7 @@ QList<int>* DualEdgeTriangulation::getSurroundingTriangles( int pointno )
vlist->append( mHalfEdge[nextedge]->getPoint() );//add the number of the endpoint of the second edge to the value list
nextnextedge = mHalfEdge[nextedge]->getNext();
vlist->append( mHalfEdge[nextnextedge]->getPoint() );//add the number of endpoint of the third edge to the value list
if ( mHalfEdge[nextnextedge]->getBreak() == true )//add, whether the third edge is a breakline or not
if ( mHalfEdge[nextnextedge]->getBreak() )//add, whether the third edge is a breakline or not
{
vlist->append( -10 );
}
@@ -1606,7 +1606,7 @@ void DualEdgeTriangulation::eliminateHorizontalTriangles()

for ( int i = 0; i <= mHalfEdge.count() - 1; i++ )
{
if ( control[i] == true )//edge has already been examined
if ( control[i] )//edge has already been examined
{
continue;
}
@@ -1666,7 +1666,7 @@ void DualEdgeTriangulation::eliminateHorizontalTriangles()
continue;
}
}
if ( swaped == false )
if ( !swaped )
{
delete[] control;
break;
@@ -1691,7 +1691,7 @@ void DualEdgeTriangulation::ruppertRefinement()
//first, go through all the forced edges and subdivide if they are encroached by a point
bool stop = false;//flag to ensure that the for-loop is repeated until no half edge is split any more

while ( stop == false )
while ( !stop )
{
stop = true;
int nhalfedges = mHalfEdge.count();
@@ -1736,7 +1736,7 @@ void DualEdgeTriangulation::ruppertRefinement()
bool twoforcededges;//flag to decide, if edges should be added to the maps. Do not add them if true


if (( mHalfEdge[i]->getForced() == true || edgeOnConvexHull( i ) ) && ( mHalfEdge[mHalfEdge[i]->getNext()]->getForced() == true || edgeOnConvexHull( mHalfEdge[i]->getNext() ) ) )
if (( mHalfEdge[i]->getForced() || edgeOnConvexHull( i ) ) && ( mHalfEdge[mHalfEdge[i]->getNext()]->getForced() || edgeOnConvexHull( mHalfEdge[i]->getNext() ) ) )
{
twoforcededges = true;
}
@@ -1853,7 +1853,7 @@ void DualEdgeTriangulation::ruppertRefinement()
//don't put the edges on the maps if two segments are forced or on a hull
bool twoforcededges1, twoforcededges2, twoforcededges3;//flag to indicate, if angle1, angle2 and angle3 are between forced edges or hull edges

if (( mHalfEdge[ed1]->getForced() == true || edgeOnConvexHull( ed1 ) ) && ( mHalfEdge[ed2]->getForced() == true || edgeOnConvexHull( ed2 ) ) )
if (( mHalfEdge[ed1]->getForced() || edgeOnConvexHull( ed1 ) ) && ( mHalfEdge[ed2]->getForced() || edgeOnConvexHull( ed2 ) ) )
{
twoforcededges1 = true;
}
@@ -1862,7 +1862,7 @@ void DualEdgeTriangulation::ruppertRefinement()
twoforcededges1 = false;
}

if (( mHalfEdge[ed2]->getForced() == true || edgeOnConvexHull( ed2 ) ) && ( mHalfEdge[ed3]->getForced() == true || edgeOnConvexHull( ed3 ) ) )
if (( mHalfEdge[ed2]->getForced() || edgeOnConvexHull( ed2 ) ) && ( mHalfEdge[ed3]->getForced() || edgeOnConvexHull( ed3 ) ) )
{
twoforcededges2 = true;
}
@@ -1871,7 +1871,7 @@ void DualEdgeTriangulation::ruppertRefinement()
twoforcededges2 = false;
}

if (( mHalfEdge[ed3]->getForced() == true || edgeOnConvexHull( ed3 ) ) && ( mHalfEdge[ed1]->getForced() == true || edgeOnConvexHull( ed1 ) ) )
if (( mHalfEdge[ed3]->getForced() || edgeOnConvexHull( ed3 ) ) && ( mHalfEdge[ed1]->getForced() || edgeOnConvexHull( ed1 ) ) )
{
twoforcededges3 = true;
}
@@ -2024,7 +2024,7 @@ void DualEdgeTriangulation::ruppertRefinement()

for ( std::set<int>::iterator it = influenceedges.begin(); it != influenceedges.end(); ++it )
{
if (( mHalfEdge[*it]->getForced() == true || edgeOnConvexHull( *it ) ) && MathUtils::inDiametral( mPointVector[mHalfEdge[*it]->getPoint()], mPointVector[mHalfEdge[mHalfEdge[*it]->getDual()]->getPoint()], &circumcenter ) )
if (( mHalfEdge[*it]->getForced() || edgeOnConvexHull( *it ) ) && MathUtils::inDiametral( mPointVector[mHalfEdge[*it]->getPoint()], mPointVector[mHalfEdge[mHalfEdge[*it]->getDual()]->getPoint()], &circumcenter ) )
{
//split segment
QgsDebugMsg( "segment split" );
@@ -2063,7 +2063,7 @@ void DualEdgeTriangulation::ruppertRefinement()



if (( mHalfEdge[ed1]->getForced() == true || edgeOnConvexHull( ed1 ) ) && ( mHalfEdge[ed2]->getForced() == true || edgeOnConvexHull( ed2 ) ) )
if (( mHalfEdge[ed1]->getForced() || edgeOnConvexHull( ed1 ) ) && ( mHalfEdge[ed2]->getForced() || edgeOnConvexHull( ed2 ) ) )
{
twoforcededges1 = true;
}
@@ -2072,7 +2072,7 @@ void DualEdgeTriangulation::ruppertRefinement()
twoforcededges1 = false;
}

if (( mHalfEdge[ed2]->getForced() == true || edgeOnConvexHull( ed2 ) ) && ( mHalfEdge[ed3]->getForced() == true || edgeOnConvexHull( ed3 ) ) )
if (( mHalfEdge[ed2]->getForced() || edgeOnConvexHull( ed2 ) ) && ( mHalfEdge[ed3]->getForced() || edgeOnConvexHull( ed3 ) ) )
{
twoforcededges2 = true;
}
@@ -2081,7 +2081,7 @@ void DualEdgeTriangulation::ruppertRefinement()
twoforcededges2 = false;
}

if (( mHalfEdge[ed3]->getForced() == true || edgeOnConvexHull( ed3 ) ) && ( mHalfEdge[ed1]->getForced() == true || edgeOnConvexHull( ed1 ) ) )
if (( mHalfEdge[ed3]->getForced() || edgeOnConvexHull( ed3 ) ) && ( mHalfEdge[ed1]->getForced() || edgeOnConvexHull( ed1 ) ) )
{
twoforcededges3 = true;
}
@@ -2197,7 +2197,7 @@ void DualEdgeTriangulation::ruppertRefinement()
} //end fast method


if ( encroached == true )
if ( encroached )
{
continue;
}
@@ -2228,7 +2228,7 @@ void DualEdgeTriangulation::ruppertRefinement()
flag = true;
}
}
if ( flag == false )
if ( !flag )
{
QgsDebugMsg( "point is not present in the triangulation" );
}
@@ -2279,7 +2279,7 @@ void DualEdgeTriangulation::ruppertRefinement()
//todo: put all three edges on the dontexamine list if two edges are forced or convex hull edges
bool twoforcededges1, twoforcededges2, twoforcededges3;

if (( mHalfEdge[ed1]->getForced() == true || edgeOnConvexHull( ed1 ) ) && ( mHalfEdge[ed2]->getForced() == true || edgeOnConvexHull( ed2 ) ) )
if (( mHalfEdge[ed1]->getForced() || edgeOnConvexHull( ed1 ) ) && ( mHalfEdge[ed2]->getForced() || edgeOnConvexHull( ed2 ) ) )
{
twoforcededges1 = true;
}
@@ -2288,7 +2288,7 @@ void DualEdgeTriangulation::ruppertRefinement()
twoforcededges1 = false;
}

if (( mHalfEdge[ed2]->getForced() == true || edgeOnConvexHull( ed2 ) ) && ( mHalfEdge[ed3]->getForced() == true || edgeOnConvexHull( ed3 ) ) )
if (( mHalfEdge[ed2]->getForced() || edgeOnConvexHull( ed2 ) ) && ( mHalfEdge[ed3]->getForced() || edgeOnConvexHull( ed3 ) ) )
{
twoforcededges2 = true;
}
@@ -2297,7 +2297,7 @@ void DualEdgeTriangulation::ruppertRefinement()
twoforcededges2 = false;
}

if (( mHalfEdge[ed3]->getForced() == true || edgeOnConvexHull( ed3 ) ) && ( mHalfEdge[ed1]->getForced() == true || edgeOnConvexHull( ed1 ) ) )
if (( mHalfEdge[ed3]->getForced() || edgeOnConvexHull( ed3 ) ) && ( mHalfEdge[ed1]->getForced() || edgeOnConvexHull( ed1 ) ) )
{
twoforcededges3 = true;
}
@@ -2424,7 +2424,7 @@ void DualEdgeTriangulation::ruppertRefinement()
bool DualEdgeTriangulation::swapPossible( unsigned int edge )
{
//test, if edge belongs to a forced edge
if ( mHalfEdge[edge]->getForced() == true )
if ( mHalfEdge[edge]->getForced() )
{
return false;
}
@@ -2926,7 +2926,7 @@ bool DualEdgeTriangulation::saveToTAFF( QString filename ) const

for ( unsigned int i = 0; i < mHalfEdge.count(); i++ )
{
if ( cont[i] == true )
if ( cont[i] )
{
continue;
}
@@ -3276,7 +3276,7 @@ void DualEdgeTriangulation::evaluateInfluenceRegion( Point3D* point, int edge, s
return;
}

if ( mHalfEdge[edge]->getForced() == false && !edgeOnConvexHull( edge ) )
if ( !mHalfEdge[edge]->getForced() && !edgeOnConvexHull( edge ) )
{
//test, if point is in the circle through both endpoints of edge and the endpoint of edge->dual->next->point
if ( MathUtils::inCircle( point, mPointVector[mHalfEdge[mHalfEdge[edge]->getDual()]->getPoint()], mPointVector[mHalfEdge[edge]->getPoint()], mPointVector[mHalfEdge[mHalfEdge[edge]->getNext()]->getPoint()] ) )
@@ -102,7 +102,7 @@ double MathUtils::calcBernsteinPoly( int n, int i, double t )
return 0;
}

return( lower( n, i )*power( t, i )*power(( 1 - t ), ( n - i ) ) );
return lower( n, i )*power( t, i )*power(( 1 - t ), ( n - i ) );
}

double MathUtils::cFDerBernsteinPoly( int n, int i, double t )
@@ -265,7 +265,7 @@ bool MathUtils::inCircle( Point3D* testp, Point3D* p1, Point3D* p2, Point3D* p3
aValue = aValue - (( bx * bx + by * by ) * triArea( p1, p3, testp ) );
aValue = aValue + (( cx * cx + cy * cy ) * triArea( p1, p2, testp ) );
aValue = aValue - (( px * px + py * py ) * triArea( p1, p2, p3 ) );
//return(aValue>0.0);
//return aValue>0.0;
if ( aValue > tolerance )
{
return true;
@@ -277,7 +277,7 @@ bool MathUtils::inCircle( Point3D* testp, Point3D* p1, Point3D* p2, Point3D* p3
else//point is approximately on the circle
{
//cout << "aValue " << aValue << endl << flush;
//return(aValue>0.0);
//return aValue>0.0;
return false;
}
}
@@ -324,7 +324,7 @@ double MathUtils::leftOf( Point3D* thepoint, Point3D* p1, Point3D* p2 )
double f3 = thepoint->getY() - p1->getY();
double f4 = p2->getX() - p1->getX();
return f1*f2 - f3*f4;
//return(thepoint->getX()-p1->getX())*(p2->getY()-p1->getY())-(thepoint->getY()-p1->getY())*(p2->getX()-p1->getX());//calculating the vectorproduct
//return thepoint->getX()-p1->getX())*(p2->getY()-p1->getY())-(thepoint->getY()-p1->getY())*(p2->getX()-p1->getX();//calculating the vectorproduct
}
else
{
@@ -82,7 +82,7 @@ int NormVecDecorator::addPoint( Point3D* p )

bool NormVecDecorator::calcNormal( double x, double y, Vector3D* result )
{
if ( alreadyestimated == false )
if ( !alreadyestimated )
{
estimateFirstDerivatives();
alreadyestimated = true;
@@ -102,7 +102,7 @@ bool NormVecDecorator::calcNormal( double x, double y, Vector3D* result )

bool NormVecDecorator::calcNormalForPoint( double x, double y, int point, Vector3D* result )
{
if ( alreadyestimated == false )
if ( !alreadyestimated )
{
estimateFirstDerivatives();
alreadyestimated = true;
@@ -186,9 +186,9 @@ bool NormVecDecorator::calcNormalForPoint( double x, double y, int point, Vector
lfirstbp = p3;
}

if ( p2 == ffirstbp && p3 == lfirstbp && firstrun == false )//we are back at the first breakline
if ( p2 == ffirstbp && p3 == lfirstbp && !firstrun )//we are back at the first breakline
{
if ( pointfound == false )//the point with coordinates x, y was in no triangle
if ( !pointfound )//the point with coordinates x, y was in no triangle
{
QgsDebugMsg( "warning: point (x,y) was in no triangle" );
return false;
@@ -197,7 +197,7 @@ bool NormVecDecorator::calcNormalForPoint( double x, double y, int point, Vector
break;
}

if ( numberofbreaks > 0 && pointfound == true )//we found the second break line and the point is between the first and the second
if ( numberofbreaks > 0 && pointfound )//we found the second break line and the point is between the first and the second
{
result->standardise();
numberofbreaks++;//to make the distinction between endpoints and points on a breakline easier
@@ -234,7 +234,7 @@ bool NormVecDecorator::calcNormalForPoint( double x, double y, int point, Vector
bool NormVecDecorator::calcPoint( double x, double y, Point3D* result )
{

if ( alreadyestimated == false )
if ( !alreadyestimated )
{
estimateFirstDerivatives();
alreadyestimated = true;
@@ -220,7 +220,7 @@ GDALDriverH QgsNineCellFilter::openOutputDriver()
}

driverMetadata = GDALGetMetadata( outputDriver, NULL );
if ( !CSLFetchBoolean( driverMetadata, GDAL_DCAP_CREATE, FALSE ) )
if ( !CSLFetchBoolean( driverMetadata, GDAL_DCAP_CREATE, false ) )
{
return NULL; //driver exist, but it does not support the create operation
}
@@ -447,7 +447,7 @@ void QgsComposerPictureWidget::addStandardDirectoriesToPreview()
{
continue;
}

//add directory itself
mSearchDirectoriesComboBox->addItem( svgDirectory.absolutePath() );
addDirectoryToPreview( svgDirectory.absolutePath() );
@@ -475,19 +475,11 @@ bool QgsComposerPictureWidget::testSvgFile( const QString& filename ) const
}

QSvgRenderer svgRenderer( filename );
if ( svgRenderer.isValid() )
{
return true;
}
return false;
return svgRenderer.isValid();
}

bool QgsComposerPictureWidget::testImageFile( const QString& filename ) const
{
QString formatName = QString( QImageReader::imageFormat( filename ) );
if ( !formatName.isEmpty() )
{
return true; //file is in a supported pixel format
}
return false;
return !formatName.isEmpty(); //file is in a supported pixel format
}

0 comments on commit 952cae5

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