Selection-class

Derived from: none

Declared in: Selection.h


Overview

Selections are used to determine which parts of the image should be affected by manipulators. While selection-class contains many functions, only three of them should be used by regular add-ons. The functions that should not be used are not documente here.

Constructor and Destructor

Selection()

  Selection()
  
  Selection(const Selection* selection)
The first version initializes the selection to be empty (i.e. it will have every point selected). The second version copies the selection.

~Selection()

  ~Selection()
Frees all the resources allocated by the selection and stops the thread that draws the selection.

Member Functions

ContainsPoint()

  inline  bool  ContainsPoint(BPoint point)

  inline  bool  ContainsPoint(int32 x,int32 y)
The first version returns true if the selection contains the pixel located at point. Otherwise the function returns false. The second version returns true if and only if the selection contains pixel located at x,y.

The BPoint-version checks first that the point is inside the image's bounds. The int32-version does not check whether the coordinate-pair actually is inside the image area. The int32-version is faster of the two, but you must be careful not to give it coordinates outside the image's bounds or it will crash.


GetBoundingRect()

  BRect  GetBoundingRect()
This function returns the smallest rectangle that surrounds the whole selection. If the rectangle has not yet been calculated, it will be calculated the first time this function is called.

IsEmpty()

  bool  IsEmpty()
This function returns true if the selection is empty. This means that selection does not have any non-selected areas, so everything is selected. If there are at least some non-selected areas it will return false. This function can be used to speed up manipulating in the case when everything is selected. This should be done with something resembling the following code:
  if (selection->IsEmpty()) {
    // manipulate all pixels
  }
  else {
    // manipulate only pixels at x,y for which
    // selection->ContainsPoint(x,y) == TRUE
  }