Don't import ogdf namespace
[TortoiseGit.git] / ext / OGDF / src / planarity / LayoutPlanRepModule.cpp
blob13a842355eff89d2ecaf3c3ce40500ea7fb549df
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 implementation of class LayoutPlanRepModule
12 * \author Carsten Gutwenger
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 ***************************************************************/
44 #include <ogdf/module/LayoutPlanRepModule.h>
47 namespace ogdf {
50 void LayoutPlanRepModule::setBoundingBox(PlanRepUML &PG, Layout &drawing)
52 double maxWidth = 0;
53 double maxHeight = 0;
55 // check rightmost and uppermost extension of all (original) nodes
56 const List<node> &origInCC = PG.nodesInCC(PG.currentCC());
57 ListConstIterator<node> itV;
59 for(itV = origInCC.begin(); itV.valid(); ++itV) {
60 node vG = *itV;
62 double maxX = drawing.x(PG.copy(vG)) + PG.widthOrig(vG)/2;
63 if (maxX > maxWidth ) maxWidth = maxX;
65 double maxY = drawing.y(PG.copy(vG)) + PG.heightOrig(vG)/2;
66 if (maxY > maxHeight) maxHeight = maxY;
68 // check polylines of all (original) edges
69 adjEntry adj;
70 forall_adj(adj,vG) {
71 if ((adj->index() & 1) == 0) continue;
72 edge eG = adj->theEdge();
74 const List<edge> &path = PG.chain(eG);
76 ListConstIterator<edge> itPath;
77 for(itPath = path.begin(); itPath.valid(); ++itPath)
79 edge e = *itPath;
81 // we have to check (only) all interior points, i.e., we can
82 // omitt the first and last point since it lies in the box of
83 // the source or target node.
84 // This version checks also the first for simplicity of the loop.
85 node v = e->source();
86 if (drawing.x(v) > maxWidth ) maxWidth = drawing.x(v);
87 if (drawing.y(v) > maxHeight) maxHeight = drawing.y(v);
89 const DPolyline &dpl = drawing.bends(e);
91 ListConstIterator<DPoint> it;
92 for(it = dpl.begin(); it.valid(); ++it)
94 const DPoint &dp = *it;
95 if (dp.m_x > maxWidth ) maxWidth = dp.m_x;
96 if (dp.m_y > maxHeight) maxHeight = dp.m_y;
103 m_boundingBox = DPoint(maxWidth,maxHeight);
106 } // end namespace ogdf