|
degate 0.1.1
|
This class represents a grid type with non equidistant spacing between grid lines. More...
#include <IrregularGrid.h>

Public Member Functions | |
| IrregularGrid (Grid::ORIENTATION orientation) | |
| The ctor to construct a new irregular grid. | |
| virtual | ~IrregularGrid () |
| The destructor. | |
| virtual grid_iter | begin () const |
| Get an iterator to iterate over the offsets where the grid lines are. | |
| virtual grid_iter | end () const |
| Get an end marker for the iteration over grid line offsets. | |
| virtual void | clear () |
| Remove all grid lines. | |
| virtual void | add_offset (int offset) |
| Add a new grid line starting at an given offset. | |
| virtual void | remove_offset (int offset) |
| Remove a grid line that is placed at an offset. | |
| virtual int | snap_to_grid (int pos) const |
| Get the nearest offset where a grid line starts. | |
Private Attributes | |
| grid_set | grid_offsets |
This class represents a grid type with non equidistant spacing between grid lines.
Definition at line 35 of file IrregularGrid.h.
| degate::IrregularGrid::IrregularGrid | ( | Grid::ORIENTATION | orientation | ) | [inline] |
The ctor to construct a new irregular grid.
Definition at line 44 of file IrregularGrid.h.
: Grid(orientation) {}
| virtual degate::IrregularGrid::~IrregularGrid | ( | ) | [inline, virtual] |
| virtual void degate::IrregularGrid::add_offset | ( | int | offset | ) | [inline, virtual] |
Add a new grid line starting at an given offset.
Definition at line 69 of file IrregularGrid.h.
References grid_offsets.
{
grid_offsets.push_back(offset);
grid_offsets.sort();
}
| virtual grid_iter degate::IrregularGrid::begin | ( | ) | const [inline, virtual] |
Get an iterator to iterate over the offsets where the grid lines are.
Implements degate::Grid.
Definition at line 54 of file IrregularGrid.h.
References grid_offsets.
{ return grid_offsets.begin(); }
| virtual void degate::IrregularGrid::clear | ( | ) | [inline, virtual] |
Remove all grid lines.
Implements degate::Grid.
Definition at line 64 of file IrregularGrid.h.
References grid_offsets.
{ grid_offsets.clear(); }
| virtual grid_iter degate::IrregularGrid::end | ( | ) | const [inline, virtual] |
Get an end marker for the iteration over grid line offsets.
Implements degate::Grid.
Definition at line 59 of file IrregularGrid.h.
References grid_offsets.
{ return grid_offsets.end(); }
| virtual void degate::IrregularGrid::remove_offset | ( | int | offset | ) | [inline, virtual] |
Remove a grid line that is placed at an offset.
Definition at line 77 of file IrregularGrid.h.
References grid_offsets.
{
grid_offsets.remove(offset);
}
| int IrregularGrid::snap_to_grid | ( | int | pos | ) | const [virtual] |
Get the nearest offset where a grid line starts.
Implements degate::Grid.
Definition at line 29 of file IrregularGrid.cc.
References grid_offsets.
{
if(pos <= grid_offsets.front()) return grid_offsets.front();
else if(pos >= grid_offsets.back()) return grid_offsets.back();
else {
int last = grid_offsets.front();
for(grid_iter it = grid_offsets.begin(); it != grid_offsets.end(); ++it) {
int current = *it;
if(current < pos) last = current;
else if(current >= pos) {
int d1 = abs(pos - last);
int d2 = abs(current - pos);
return d1 < d2 ? last : current;
}
}
// should not reach this line
assert(1 == 0);
}
}
grid_set degate::IrregularGrid::grid_offsets [private] |
Definition at line 37 of file IrregularGrid.h.
Referenced by add_offset(), begin(), clear(), end(), remove_offset(), and snap_to_grid().
1.7.4