|
degate 0.1.1
|
00001 /* -*-c++-*- 00002 00003 This file is part of the IC reverse engineering tool degate. 00004 00005 Copyright 2008, 2009, 2010 by Martin Schobert 00006 00007 Degate is free software: you can redistribute it and/or modify 00008 it under the terms of the GNU General Public License as published by 00009 the Free Software Foundation, either version 3 of the License, or 00010 any later version. 00011 00012 Degate is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 GNU General Public License for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with degate. If not, see <http://www.gnu.org/licenses/>. 00019 00020 */ 00021 00022 #ifndef __IRREGULARGRID_H__ 00023 #define __IRREGULARGRID_H__ 00024 00025 #include "Grid.h" 00026 00027 #include <tr1/memory> 00028 00029 namespace degate { 00030 00031 /** 00032 * This class represents a grid type with non equidistant spacing between grid lines. 00033 */ 00034 00035 class IrregularGrid : public Grid { 00036 private: 00037 grid_set grid_offsets; 00038 00039 public: 00040 00041 /** 00042 * The ctor to construct a new irregular grid. 00043 */ 00044 IrregularGrid(Grid::ORIENTATION orientation) : Grid(orientation) {} 00045 00046 /** 00047 * The destructor. 00048 */ 00049 virtual ~IrregularGrid() {} 00050 00051 /** 00052 * Get an iterator to iterate over the offsets where the grid lines are. 00053 */ 00054 virtual grid_iter begin() const { return grid_offsets.begin(); } 00055 00056 /** 00057 * Get an end marker for the iteration over grid line offsets. 00058 */ 00059 virtual grid_iter end() const { return grid_offsets.end(); } 00060 00061 /** 00062 * Remove all grid lines. 00063 */ 00064 virtual void clear() { grid_offsets.clear(); } 00065 00066 /** 00067 * Add a new grid line starting at an given offset. 00068 */ 00069 virtual void add_offset(int offset) { 00070 grid_offsets.push_back(offset); 00071 grid_offsets.sort(); 00072 } 00073 00074 /** 00075 * Remove a grid line that is placed at an offset. 00076 */ 00077 virtual void remove_offset(int offset) { 00078 grid_offsets.remove(offset); 00079 } 00080 00081 /** 00082 * Get the nearest offset where a grid line starts. 00083 */ 00084 virtual int snap_to_grid(int pos) const; 00085 00086 }; 00087 00088 typedef std::tr1::shared_ptr<IrregularGrid> IrregularGrid_shptr; 00089 } 00090 00091 #endif
1.7.4