From 64617204bbd50785577261986787bdb5d9712c8f Mon Sep 17 00:00:00 2001 From: jrand Date: Mon, 28 Oct 2002 02:50:08 +0000 Subject: [PATCH] Adding use cases for the BPolygon class git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1727 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../interface/usecases/BPolygonUseCases.html | 89 +++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 docs/develop/interface/usecases/BPolygonUseCases.html diff --git a/docs/develop/interface/usecases/BPolygonUseCases.html b/docs/develop/interface/usecases/BPolygonUseCases.html new file mode 100644 index 0000000000..2474e2871a --- /dev/null +++ b/docs/develop/interface/usecases/BPolygonUseCases.html @@ -0,0 +1,89 @@ + + + +BPolygon Use Cases and Implementation Details + + + + + + +

BPolygon Use Cases and Implementation Details:

+ +

This document describes the BPolygon interface and some basics of how it is implemented. +The document has the following sections:

+ +
    +
  1. BPolygon Interface
  2. +
  3. BPolygon Use Cases
  4. +
  5. BPolygon Implementation
  6. +
+ +

BPolygon Interface:

+ +

The BPolygon class is used to hold information about a shape composed of a series of straight +lines (ie a polygon). On its own, it just describes the shape and can only be drawn by passing +it to a BView. The best source of source of information for the BPolygon interface can be found +here in the Be Book. +

+ +

BPolygon Use Cases:

+ +

The following use cases cover the BPolygon functionality:

+ +
    +
  1. Construction 1: A BPolygon can be constructed without passing it any arguments. When +this is done, the polygon will have no points in it (ie no shape) until they are added through +AddPoints().

  2. + +
  3. Construction 2: A BPolygon can be constructed by passing it a pointer to an existing +BPolygon (ie a copy constructor). The resulting copy will have the exact same state as the +one passed in. That means it will have the same number of points in the same locations resulting +in the same shape.

  4. + +
  5. Construction 3: A BPolygon can be constructed by passing it a pointer to an array of +BPoints and an integer which describes the number of points in that array. The BPolygon will be +constructed such that it holds the shape described by that array of points.

  6. + +
  7. Destruction: When a BPolygon is deconstructed any memory allocated in order to hold +the state of the BPolygon is freed and the state of the polygon is lost.

  8. + +
  9. Add Points: The AddPoints() member function appends a number of passed in points to +the existing set of points already in the polygon. It takes a pointer to an array of BPoints and +an integer count of the number of points to append. This is similar to the "Construction 3" use +case except in that case there is no existing points so the passed in points describe the entire +polygon.

  10. + +
  11. Count Points: The CountPoints() member function returns the number of points which +describe the polygon. The result is an integer.

  12. + +
  13. Frame: The Frame() member function returns the smallest BRect which contains all of +the points which describes the BPolygon.

  14. + +
  15. Map To: The MapTo() member function applies a translation (ie move) and a scale (ie +grow/shrink) operation to the existing polygon, adjusting all points according to the passed in +rule. The operation to apply depends on two passed in BRect's. The translation and scale +adjustment which turns the first BRect into the second BRect is applied to all points in the +BPolygon.

  16. + +
  17. Print To Stream: The PrintToStream() member function sends the set of points which +make up the BPolygon to standard output. It does so by performing a PrintToStream() on the +individual BPoint's which make up the polygon. This member is generally used for debugging and +the output is primarily human readable and not sensitive to changes which could risk backward +compatibility.

  18. + +
  19. Assignment Operator The operator=() operator is defined for BPolygon's. It takes +a source BPolygon and assigns it to another existing BPolygon target. The state of the target +BPolygon is lost and replaced with that of the source. The source retains its state so the outcome +is two BPolygons with the same state (ie set of points).

  20. + +
+ +

BPolygon Implementation:

+ +

Internally, the BPolygon contains an array of BPoint's which it uses to track the shape it +holds. The implementation of BPolygon is fairly simple since it is a fairly basic container +class for a set of points.

+ + +