degate  0.1.2
Line.h
Go to the documentation of this file.
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  Copyright 2012 Robert Nitsch
00007 
00008  Degate is free software: you can redistribute it and/or modify
00009  it under the terms of the GNU General Public License as published by
00010  the Free Software Foundation, either version 3 of the License, or
00011  any later version.
00012 
00013  Degate is distributed in the hope that it will be useful,
00014  but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  GNU General Public License for more details.
00017 
00018  You should have received a copy of the GNU General Public License
00019  along with degate. If not, see <http://www.gnu.org/licenses/>.
00020 
00021  */
00022 
00023 #ifndef __LINE_H__
00024 #define __LINE_H__
00025 
00026 #include <BoundingBox.h>
00027 #include "DeepCopyable.h"
00028 #include <Shape.h>
00029 #include <Point.h>
00030 
00031 namespace degate {
00032 
00033   class Line : public AbstractShape, public DeepCopyableBase {
00034 
00035   private:
00036     int from_x, from_y, to_x, to_y;
00037     unsigned int diameter;
00038 
00039     double d_x, d_y;
00040 
00041     BoundingBox bounding_box;
00042 
00043   private:
00044 
00045     /**
00046      * Recalulate the bounding box of a line.
00047      * If the line is either horizontally nor vertically
00048      * aligned, the bounding box corresponds exactly to
00049      * the area, the line spans. If the line is horizontal
00050      * or vertical, the bounding box also depends on the
00051      * diameter.
00052      */
00053     void calculate_bounding_box();
00054 
00055   public:
00056 
00057     Line();
00058     Line(int from_x, int from_y, int to_x, int to_y, unsigned int diameter);
00059 
00060     virtual ~Line() {}
00061     
00062     void cloneDeepInto(DeepCopyable_shptr destination, oldnew_t *oldnew) const;
00063 
00064     virtual bool in_shape(int x, int y, int max_distance = 0) const;
00065     virtual bool in_bounding_box(BoundingBox const& bbox) const;
00066     virtual BoundingBox const& get_bounding_box() const;
00067 
00068 
00069     virtual int get_from_x() const;
00070     virtual int get_to_x() const;
00071     virtual int get_from_y() const;
00072     virtual int get_to_y() const;
00073 
00074     virtual void set_from_x(int min_x);
00075     virtual void set_from_y(int min_y);
00076     virtual void set_to_x(int max_x);
00077     virtual void set_to_y(int max_y);
00078 
00079     virtual void shift_x(int delta_x);
00080     virtual void shift_y(int delta_y);
00081 
00082     virtual unsigned int get_diameter() const;
00083     virtual void set_diameter(unsigned int diameter);
00084 
00085     virtual bool is_vertical() const;
00086     virtual bool is_horizontal() const;
00087 
00088     virtual unsigned int get_length() const;
00089 
00090     virtual Point get_p1() const;
00091     virtual Point get_p2() const;
00092 
00093     virtual void set_p1(Point const& p);
00094     virtual void set_p2(Point const& p);
00095 
00096   };
00097 
00098 }
00099 
00100 #endif