Class Selection
source code
Data selection base class
Selection
is an abstract class representing data
selections. Particular selection types are defined by vector layer
modules.
Selections behave as flat arrays of coordinates. They are however
logically split into selection objects (points, lines, rectangles),
characteristic for each selection type. For example, to describe a
horizontal line one needs only one coordinate, for a point two
coordinates are needed, rectangle or arbitrary line need four. Selection.get_object_size() can be used to generically
determine the number of coordinates used to describe a one selection
object.
The number of selection objects in a selection can vary, Selection.set_max_objects() sets the maximum possible
number. Functions for getting and setting individual selection objects
(Selection.get_object(), Selection.set_object()) or complete selection (Selection.get_data(), Selection.set_data()) are available. The method Selection.set_data() with None
second argument is also used to determine the number of selected
object.
|
|
|
|
|
|
|
|
|
|
|
|
|
crop(xmin,
ymin,
xmax,
ymax)
Limits objects in a selection to a rectangle. |
source code
|
|
|
|
|
filter(filter,
data)
Removes selection objects matching certain criteria. |
source code
|
|
|
|
|
finished()
Emits "finished" signal on a selection. |
source code
|
|
|
|
|
|
|
|
|
|
|
|
Gets the number of coordinates that make up a one selection
object.
- Returns:
- The number of coordinates in one selection object. (int)
|
Deletes a one selection object.
Since there cannot be holes in the object list, the rest of selection
objects is moved to close the gap.
- Parameters:
i - Index of object to delete. (int)
|
Gets the maximum number of selected objects.
- Returns:
- The maximum number of selected objects; (int)
|
Sets the maximum number of objects allowed to select.
When selection reaches this number of selected objects, it emits
"finished" signal.
- Parameters:
max_objects - The maximum number of objects allowed to select. Note particular
selection types may allow only specific values. (int)
|
Checks whether the maximum number of objects is selected.
- Returns:
True when the maximum possible number of
objects is selected, False otherwise.
(bool)
|
Limits objects in a selection to a rectangle.
Objects that are fully outside specified rectangle are removed.
Objects partially outside may be removed or cut, depending on what makes
sense for the specific selection type. If the selection class does not
implement this method then all objects are removed.
- Parameters:
xmin - Minimum x-coordinate. (float)
ymin - Minimum y-coordinate. (float)
xmax - Maximum x-coordinate. (float)
ymax - Maximum y-coordinate. (float)
|
Moves entire selection in plane by given vector.
If a selection class does not implement this operation the selection
remains unchanged. Bult-in selection classes generally implement this
operation if it is meaningful. For some, such as SelectionLattice, it is
not meaningful and moving SelectionLattice thus does not do anything.
- Parameters:
vx - Value to add to all x-coordinates. (float)
vy - Value to add to all y-coordinates. (float)
|
Removes selection objects matching certain criteria.
- Parameters:
filter - Function returning True for objects that
should be kept, False for objects that should
be removed. (SelectionFilterFunc)
data - User data passed to filter . (gpointer)
|
Emits "changed" signal on a selection.
- Parameters:
i - Index of object that changed. Use -1 when not applicable, e.g.,
when complete selection was changed, cleared, or truncated.
(int)
|
Get selection coordinates as single flat list.
- Returns:
- a list of selected data (list)
|
Gets one selection object.
- Parameters:
i - Index of object to get. (int)
- Returns:
True if there was such an object and
data was filled. (list)
|
Sets selection data.
- Parameters:
data - Selection data, that is an array nselected *
Selection.get_object_size() long with selected
object coordinates. (list)
|
Sets one selection object.
This method can be also used to append objects (if the maximum number
is not exceeded). Since there cannot be holes in the object list,
i must be then equal to either the number of selected
objects or special value -1 meaning append to end.
- Parameters:
i - Index of object to set. (int)
data - Object selection data. It's an array of coordinates whose
precise meaning is defined by particular selection types.
(list)
|