BPolygon: Style fixes for documentation.

This commit is contained in:
John Scipione
2014-05-21 16:12:47 -04:00
parent 82d885a82b
commit b955a4ca6b
2 changed files with 29 additions and 24 deletions
+7 -8
View File
@@ -9,10 +9,10 @@
#include <InterfaceDefs.h> #include <InterfaceDefs.h>
#include <Rect.h> #include <Rect.h>
//namespace BPrivate { class BAffineTransform; } //namespace BPrivate { class BAffineTransform; }
//using namespace BPrivate; //using namespace BPrivate;
class BPolygon { class BPolygon {
public: public:
BPolygon(const BPoint* points, int32 count); BPolygon(const BPoint* points, int32 count);
@@ -26,7 +26,7 @@ public:
BRect Frame() const; BRect Frame() const;
void AddPoints(const BPoint* points, int32 count); void AddPoints(const BPoint* points, int32 count);
int32 CountPoints() const; int32 CountPoints() const;
void MapTo(BRect srcRect, BRect dstRect); void MapTo(BRect source, BRect destination);
void PrintToStream() const; void PrintToStream() const;
// void TransformBy(const BAffineTransform& transform); // void TransformBy(const BAffineTransform& transform);
@@ -41,11 +41,10 @@ private:
bool _AddPoints(const BPoint* points, int32 count, bool _AddPoints(const BPoint* points, int32 count,
bool computeBounds); bool computeBounds);
void _ComputeBounds(); void _ComputeBounds();
void _MapPoint(BPoint* point, const BRect& srcRect, void _MapPoint(BPoint* point, const BRect& source,
const BRect& dstRect); const BRect& destination);
void _MapRectangle(BRect* rect, void _MapRectangle(BRect* rect, const BRect& source,
const BRect& srcRect, const BRect& destination);
const BRect& dstRect);
private: private:
BRect fBounds; BRect fBounds;
@@ -53,4 +52,4 @@ private:
BPoint* fPoints; BPoint* fPoints;
}; };
#endif // _POLYGON_H_ #endif // _POLYGON_H
+22 -16
View File
@@ -3,15 +3,16 @@
* Distributed under the terms of the MIT license. * Distributed under the terms of the MIT license.
* *
* Authors: * Authors:
* Stephan Aßmus, [email protected]
* Marc Flerackers, [email protected] * Marc Flerackers, [email protected]
* Marcus Overhagen * Marcus Overhagen
* Stephan Aßmus <[email protected]>
*/ */
#include <Polygon.h> #include <Polygon.h>
#include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <string.h> #include <string.h>
#include <AffineTransform.h> #include <AffineTransform.h>
@@ -107,16 +108,17 @@ BPolygon::CountPoints() const
void void
BPolygon::MapTo(BRect srcRect, BRect dstRect) BPolygon::MapTo(BRect source, BRect destination)
{ {
for (uint32 i = 0; i < fCount; i++) for (uint32 i = 0; i < fCount; i++)
_MapPoint(fPoints + i, srcRect, dstRect); _MapPoint(fPoints + i, source, destination);
_MapRectangle(&fBounds, srcRect, dstRect);
_MapRectangle(&fBounds, source, destination);
} }
void void
BPolygon::PrintToStream () const BPolygon::PrintToStream() const
{ {
for (uint32 i = 0; i < fCount; i++) for (uint32 i = 0; i < fCount; i++)
fPoints[i].PrintToStream(); fPoints[i].PrintToStream();
@@ -148,7 +150,7 @@ BPolygon::PrintToStream () const
//} //}
// #pragma mark - // #pragma mark - BPolygon private methods
bool bool
@@ -194,10 +196,13 @@ BPolygon::_ComputeBounds()
for (uint32 i = 1; i < fCount; i++) { for (uint32 i = 1; i < fCount; i++) {
if (fPoints[i].x < fBounds.left) if (fPoints[i].x < fBounds.left)
fBounds.left = fPoints[i].x; fBounds.left = fPoints[i].x;
if (fPoints[i].y < fBounds.top) if (fPoints[i].y < fBounds.top)
fBounds.top = fPoints[i].y; fBounds.top = fPoints[i].y;
if (fPoints[i].x > fBounds.right) if (fPoints[i].x > fBounds.right)
fBounds.right = fPoints[i].x; fBounds.right = fPoints[i].x;
if (fPoints[i].y > fBounds.bottom) if (fPoints[i].y > fBounds.bottom)
fBounds.bottom = fPoints[i].y; fBounds.bottom = fPoints[i].y;
} }
@@ -205,24 +210,25 @@ BPolygon::_ComputeBounds()
void void
BPolygon::_MapPoint(BPoint* point, const BRect& srcRect, const BRect& dstRect) BPolygon::_MapPoint(BPoint* point, const BRect& source,
const BRect& destination)
{ {
point->x = (point->x - srcRect.left) * dstRect.Width() / srcRect.Width() point->x = (point->x - source.left) * destination.Width() / source.Width()
+ dstRect.left; + destination.left;
point->y = (point->y - srcRect.top) * dstRect.Height() / srcRect.Height() point->y = (point->y - source.top) * destination.Height() / source.Height()
+ dstRect.top; + destination.top;
} }
void void
BPolygon::_MapRectangle(BRect* rect, const BRect& srcRect, BPolygon::_MapRectangle(BRect* rect, const BRect& source,
const BRect& dstRect) const BRect& destination)
{ {
BPoint leftTop = rect->LeftTop(); BPoint leftTop = rect->LeftTop();
BPoint bottomRight = rect->RightBottom(); BPoint bottomRight = rect->RightBottom();
_MapPoint(&leftTop, srcRect, dstRect); _MapPoint(&leftTop, source, destination);
_MapPoint(&bottomRight, srcRect, dstRect); _MapPoint(&bottomRight, source, destination);
*rect = BRect(leftTop, bottomRight); *rect = BRect(leftTop, bottomRight);
} }