|
degate 0.1.1
|
00001 /* 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 #include "globals.h" 00023 00024 #include "Point.h" 00025 #include <boost/format.hpp> 00026 00027 using namespace degate; 00028 00029 Point::Point() { 00030 x = y = 0; 00031 } 00032 00033 Point::Point(int x, int y) { 00034 this->x = x; 00035 this->y = y; 00036 } 00037 00038 bool Point::operator==(const Point& other) const { 00039 return (x == other.x && y == other.y); 00040 } 00041 00042 bool Point::operator!=(const Point& other) const { 00043 return !(*this == other); 00044 } 00045 00046 int Point::get_x() const { 00047 return x; 00048 } 00049 00050 int Point::get_y() const { 00051 return y; 00052 } 00053 00054 void Point::set_x(int x) { 00055 this->x = x; 00056 } 00057 00058 void Point::set_y(int y) { 00059 this->y = y; 00060 } 00061 00062 00063 void Point::shift_y(int delta_y) { 00064 y += delta_y; 00065 } 00066 00067 void Point::shift_x(int delta_x) { 00068 x += delta_x; 00069 } 00070 00071 00072 unsigned int Point::get_distance(Point const& p) const { 00073 return ((labs(x - p.get_x()) << 1) + (labs(y - p.get_y()) << 1)) >> 1; 00074 } 00075 00076 std::string Point::to_string() const { 00077 boost::format f("point(%1%, %2%)"); 00078 f % x % y; 00079 return f.str(); 00080 }
1.7.4