1 /** \file
2  * \brief Splits and packs the components of a Graph.
3  *
4  * \author Gereon Bartel
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 <memory>
35 #include <ogdf/energybased/multilevel_mixer/MultilevelGraph.h>
36 #include <ogdf/packing/CCLayoutPackModule.h>
37 #include <ogdf/basic/LayoutModule.h>
38 #include <ogdf/basic/geometry.h>
39 #include <ogdf/basic/GraphAttributes.h>
40 #include <vector>
41 
42 namespace ogdf {
43 
44 class OGDF_EXPORT ComponentSplitterLayout : public LayoutModule
45 {
46 private:
47 	std::unique_ptr<LayoutModule> m_secondaryLayout;
48 	std::unique_ptr<CCLayoutPackModule> m_packer;
49 
50 	double m_targetRatio;
51 	int m_border;
52 
53 	//! Combines drawings of connected components to
54 	//! a single drawing by rotating components and packing
55 	//! the result (optimizes area of axis-parallel rectangle).
56 	void reassembleDrawings(GraphAttributes &GA, const Array<List<node> > &nodesInCC);
57 
58 public:
59 	ComponentSplitterLayout();
60 
61 	void call(GraphAttributes &GA) override;
62 
setLayoutModule(LayoutModule * layout)63 	void setLayoutModule(LayoutModule *layout) {
64 		m_secondaryLayout.reset(layout);
65 	}
66 
setPacker(CCLayoutPackModule * packer)67 	void setPacker(CCLayoutPackModule *packer) {
68 		m_packer.reset(packer);
69 	}
70 };
71 
72 }
73