1 /** \file
2  * \brief Declaration of class TileToRowsCCPacker.
3  *
4  * \author Carsten Gutwenger
5  *
6  * \par License:
7  * This file is part of the Open Graph Drawing Framework (OGDF).
8  *
9  * \par
10  * Copyright (C)<br>
11  * See README.md in the OGDF root directory for details.
12  *
13  * \par
14  * This program is free software; you can redistribute it and/or
15  * modify it under the terms of the GNU General Public License
16  * Version 2 or 3 as published by the Free Software Foundation;
17  * see the file LICENSE.txt included in the packaging of this file
18  * for details.
19  *
20  * \par
21  * This program is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24  * GNU General Public License for more details.
25  *
26  * \par
27  * You should have received a copy of the GNU General Public
28  * License along with this program; if not, see
29  * http://www.gnu.org/copyleft/gpl.html
30  */
31 
32 #pragma once
33 
34 #include <ogdf/packing/CCLayoutPackModule.h>
35 
36 namespace ogdf {
37 
38 
39 //! The tile-to-rows algorithm for packing drawings of connected components.
40 class OGDF_EXPORT TileToRowsCCPacker : public CCLayoutPackModule
41 {
42 	template<class POINT> struct RowInfo;
43 
44 public:
45 	//! Creates an instance of tile-to-rows packer.
TileToRowsCCPacker()46 	TileToRowsCCPacker() { }
47 
~TileToRowsCCPacker()48 	virtual ~TileToRowsCCPacker() { }
49 
50 	/**
51 	 * \brief Arranges the rectangles given by \p box.
52 	 *
53 	 * The algorithm call takes an input an array \p box of rectangles with
54 	 * real coordinates and computes in \p offset the offset to (0,0) of each
55 	 * rectangle in the layout.
56 	 * @param box is the array of input rectangles.
57 	 * @param offset is assigned the offset of each rectangle to the origin (0,0).
58 	 *        The offset of a rectangle is its lower left point in the layout.
59 	 * @param pageRatio is the desired page ratio (width / height) of the
60 	 *        resulting layout.
61 	 */
62 	virtual void call(Array<DPoint> &box,
63 		Array<DPoint> &offset,
64 		double pageRatio = 1.0) override;
65 
66 	/**
67 	 * \brief Arranges the rectangles given by \p box.
68 	 *
69 	 * The algorithm call takes an input an array \p box of rectangles with
70 	 * real coordinates and computes in \p offset the offset to (0,0) of each
71 	 * rectangle in the layout.
72 	 * @param box is the array of input rectangles.
73 	 * @param offset is assigned the offset of each rectangle to the origin (0,0).
74 	 *        The offset of a rectangle is its lower left point in the layout.
75 	 * @param pageRatio is the desired page ratio (width / height) of the
76 	 *        resulting layout.
77 	 */
78 	virtual void call(Array<IPoint> &box,
79 		Array<IPoint> &offset,
80 		double pageRatio = 1.0) override;
81 
82 private:
83 	template<class POINT>
84 	static void callGeneric(Array<POINT> &box,
85 		Array<POINT> &offset,
86 		double pageRatio);
87 
88 	template<class POINT>
89 	static int findBestRow(Array<RowInfo<POINT> > &row,
90 		int nRows,
91 		double pageRatio,
92 		const POINT &rect);
93 };
94 
95 }
96