Fix warning
[TortoiseGit.git] / ext / OGDF / src / energybased / Rectangle.h
blobb0a310b8808a86ce64d1f01fa226c9e9ce7cb484
1 /*
2 * $Revision: 2559 $
4 * last checkin:
5 * $Author: gutwenger $
6 * $Date: 2012-07-06 15:04:28 +0200 (Fr, 06. Jul 2012) $
7 ***************************************************************/
9 /** \file
10 * \brief Declaration of class Rectangle.
12 * \author Stefan Hachul
14 * \par License:
15 * This file is part of the Open Graph Drawing Framework (OGDF).
17 * \par
18 * Copyright (C)<br>
19 * See README.txt in the root directory of the OGDF installation for details.
21 * \par
22 * This program is free software; you can redistribute it and/or
23 * modify it under the terms of the GNU General Public License
24 * Version 2 or 3 as published by the Free Software Foundation;
25 * see the file LICENSE.txt included in the packaging of this file
26 * for details.
28 * \par
29 * This program is distributed in the hope that it will be useful,
30 * but WITHOUT ANY WARRANTY; without even the implied warranty of
31 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32 * GNU General Public License for more details.
34 * \par
35 * You should have received a copy of the GNU General Public
36 * License along with this program; if not, write to the Free
37 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
38 * Boston, MA 02110-1301, USA.
40 * \see http://www.gnu.org/copyleft/gpl.html
41 ***************************************************************/
43 #ifdef _MSC_VER
44 #pragma once
45 #endif
47 #ifndef OGDF_RECTANGLE_H
48 #define OGDF_RECTANGLE_H
50 #include <ogdf/basic/geometry.h>
51 #include <iostream>
53 namespace ogdf {
55 class Rectangle
57 //Helping data structure for packing rectangles; The width, height and the position
58 //of the down left corner of the tight surroundig rectangle is represented for each
59 //connected component of the graph.
61 //Outputstream for Rectangle.
62 friend ostream &operator<< (ostream & output, const Rectangle & A)
64 output <<"width: "<< A.width<<" height: "<<A.height<<" old dlc_position: "
65 <<A.old_down_left_corner_position<<" new dlc_position: "
66 <<A.new_down_left_corner_position<<" coponenet_index: "<<A.component_index;
67 if(A.tipped_over == true)
68 output<<" is tipped_over";
69 return output;
72 //Inputstream for Rectangle.
73 friend istream &operator>> (istream & input, Rectangle & A)
75 input >>A.width;
76 return input;
79 public:
81 Rectangle() //constructor
83 old_down_left_corner_position.m_x = 0;
84 old_down_left_corner_position.m_y = 0;
85 new_down_left_corner_position.m_x = 0;
86 new_down_left_corner_position.m_y = 0;
87 width = 0;
88 height = 0;
89 component_index = -1;
90 tipped_over = false;
93 ~Rectangle() { } //destructor
95 void set_rectangle (double w, double h, double old_dlc_x_pos,double
96 old_dlc_y_pos,int comp_index)
98 width = w;
99 height = h;
100 old_down_left_corner_position.m_x = old_dlc_x_pos;
101 old_down_left_corner_position.m_y = old_dlc_y_pos;
102 component_index = comp_index;
103 tipped_over = false;
106 void set_old_dlc_position(DPoint dlc_pos){old_down_left_corner_position = dlc_pos;}
107 void set_new_dlc_position(DPoint dlc_pos){new_down_left_corner_position = dlc_pos;}
108 void set_width(double w) {width = w;}
109 void set_height(double h) {height = h;}
110 void set_component_index (int comp_index) {component_index = comp_index;}
111 void tipp_over()
113 if(tipped_over == false)
114 tipped_over = true;
115 else
116 tipped_over = false;
119 DPoint get_old_dlc_position() const { return old_down_left_corner_position; }
120 DPoint get_new_dlc_position() const { return new_down_left_corner_position; }
121 double get_width() const {return width;}
122 double get_height() const {return height;}
123 int get_component_index() const {return component_index;}
124 bool is_tipped_over() const {return tipped_over;}
126 private:
127 DPoint old_down_left_corner_position;//down left corner of the tight surround. rect.
128 DPoint new_down_left_corner_position;//new calculated down left corner of ...
129 double width; //width of the surround. rect.
130 double height; //height of the surround. rect.
131 int component_index; //the index of the related connected component
132 bool tipped_over; //indicates if this rectangle has been tipped over in the
133 //packing step
138 //Needed for sorting algorithms in ogdf/List and ogdf/Array.
139 class RectangleComparerHeight
141 public:
142 RectangleComparerHeight() { }
143 ~RectangleComparerHeight() { }
145 bool less(const Rectangle& A,const Rectangle & B) const
147 if(A.get_height() > B.get_height() )
148 return true;
149 else
150 return false;
153 bool leq(const Rectangle& A,const Rectangle & B) const
155 if(A.get_height() >= B.get_height() )
156 return true;
157 else
158 return false;
161 bool equal(const Rectangle& A,const Rectangle & B) const
163 if(A.get_height() == B.get_height() )
164 return true;
165 else
166 return false;
171 class RectangleComparerWidth
173 public:
174 RectangleComparerWidth() { }
175 ~RectangleComparerWidth() { }
177 bool less(const Rectangle& A,const Rectangle & B) const
179 if(A.get_width() > B.get_width() )
180 return true;
181 else
182 return false;
185 bool leq(const Rectangle& A,const Rectangle & B) const
187 if(A.get_width() >= B.get_width() )
188 return true;
189 else
190 return false;
193 bool equal(const Rectangle& A,const Rectangle & B) const
195 if(A.get_width() == B.get_width() )
196 return true;
197 else
198 return false;
202 }//namespace ogdf
203 #endif