Adaptagrams
output_svg.h
1 /*
2  * vim: ts=4 sw=4 et tw=0 wm=0
3  *
4  * libcola - A library providing force-directed network layout using the
5  * stress-majorization method subject to separation constraints.
6  *
7  * Copyright (C) 2006-2008 Monash University
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  * See the file LICENSE.LGPL distributed with the library.
14  *
15  * This library is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18  *
19 */
20 
21 #ifndef _OUTPUT_SVG_H
22 #define _OUTPUT_SVG_H
23 
24 #include "libcola/config.h"
25 #include "libcola/cola.h"
26 
27 #ifdef HAVE_CAIROMM
28 #include <cairomm/context.h>
29 #include <cairomm/surface.h>
30 #endif
31 
32 class OutputFile {
33 public:
34  std::vector<vpsc::Rectangle*> const &rs;
35  std::vector<cola::Edge> const &es;
36  std::vector<straightener::Route*> *routes;
37  cola::RootCluster const * rc;
38  std::string const fname;
39  bool rects;
40  bool curvedEdges;
41  OutputFile(std::vector<vpsc::Rectangle*> const &rs,
42  std::vector<cola::Edge> const &es,
43  cola::RootCluster const * rc,
44  std::string const fname,
45  const bool rects=false,
46  const bool curvedEdges=false)
47  : rs(rs),
48  es(es),
49  routes(nullptr),
50  rc(rc),
51  fname(fname),
52  rects(rects),
53  curvedEdges(curvedEdges) {}
54  void generate();
55  void setLabels(std::vector<std::string> ls) {
56  labels.resize(ls.size());
57  std::copy(ls.begin(),ls.end(),labels.begin());
58  }
59  void setLabels(const unsigned n, const char **ls) {
60  labels.resize(n);
61  for(unsigned i=0;i<n;i++) {
62  labels[i]=ls[i];
63  }
64  }
65 private:
66 #ifdef HAVE_CAIROMM
67  void draw_cluster_boundary(Cairo::RefPtr<Cairo::Context> const &cr,
68  cola::Cluster &c, const double xmin, const double ymin);
69  void draw_edges(Cairo::RefPtr<Cairo::Context> &cr,
70  std::vector<straightener::Route*> const & es,
71  double const xmin, double const ymin);
72  void draw_curved_edges(Cairo::RefPtr<Cairo::Context> &cr,
73  std::vector<cola::Edge> const & es,
74  const double xmin,
75  const double ymin);
76  void openCairo(Cairo::RefPtr<Cairo::Context> &cr, double width, double height);
77 #endif // HAVE_CAIROMM
78  std::vector<std::string> labels;
79 };
80 #endif // _OUTPUT_SVG_H
Holds the cluster hierarchy specification for a diagram.
Definition: cluster.h:172
A cluster defines a hierarchical partitioning over the nodes which should be kept disjoint by the lay...
Definition: cluster.h:50