gravatar
alpar (Alpar Juttner)
alpar@cs.elte.hu
Change the order of the Palette constructor parameters
0 2 0
default
2 files changed with 2 insertions and 2 deletions:
↑ Collapse diff ↑
Ignore white space 96 line context
1 1
/* -*- C++ -*-
2 2
 *
3 3
 * This file is a part of LEMON, a generic C++ optimization library
4 4
 *
5 5
 * Copyright (C) 2003-2008
6 6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
8 8
 *
9 9
 * Permission to use, modify and distribute this software is granted
10 10
 * provided that this copyright notice appears in all copies. For
11 11
 * precise terms see the accompanying LICENSE file.
12 12
 *
13 13
 * This software is provided "AS IS" with no warranty of any kind,
14 14
 * express or implied, and with no claim as to its suitability for any
15 15
 * purpose.
16 16
 *
17 17
 */
18 18

	
19 19
/// \ingroup demos
20 20
/// \file
21 21
/// \brief Demo of the graph grawing function \ref graphToEps()
22 22
///
23 23
/// This demo program shows examples how to  use the function \ref
24 24
/// graphToEps(). It takes no input but simply creates  six
25 25
/// <tt>.eps</tt> files demonstrating the capability of \ref
26 26
/// graphToEps(), and showing how to draw directed/graphs,
27 27
/// how to handle parallel egdes, how to change the properties (like
28 28
/// color, shape, size, title etc.) of nodes and arcs individually
29 29
/// using appropriate \ref maps-page "graph maps".
30 30
///
31 31
/// \include graph_to_eps_demo.cc
32 32

	
33 33
#include <lemon/math.h>
34 34

	
35 35
#include<lemon/graph_to_eps.h>
36 36
#include<lemon/list_graph.h>
37 37
#include<lemon/graph_utils.h>
38 38

	
39 39
using namespace std;
40 40
using namespace lemon;
41 41

	
42 42
int main()
43 43
{
44 44
  Palette palette;
45
  Palette paletteW(-1,true);
45
  Palette paletteW(true);
46 46

	
47 47
  ListDigraph g;
48 48
  typedef ListDigraph::Node Node;
49 49
  typedef ListDigraph::NodeIt NodeIt;
50 50
  typedef ListDigraph::Arc Arc;
51 51
  typedef dim2::Point<int> Point;
52 52
  
53 53
  Node n1=g.addNode();
54 54
  Node n2=g.addNode();
55 55
  Node n3=g.addNode();
56 56
  Node n4=g.addNode();
57 57
  Node n5=g.addNode();
58 58

	
59 59
  ListDigraph::NodeMap<Point> coords(g);
60 60
  ListDigraph::NodeMap<double> sizes(g);
61 61
  ListDigraph::NodeMap<int> colors(g);
62 62
  ListDigraph::NodeMap<int> shapes(g);
63 63
  ListDigraph::ArcMap<int> ecolors(g);
64 64
  ListDigraph::ArcMap<int> widths(g);
65 65
  
66 66
  coords[n1]=Point(50,50);  sizes[n1]=1; colors[n1]=1; shapes[n1]=0;
67 67
  coords[n2]=Point(50,70);  sizes[n2]=2; colors[n2]=2; shapes[n2]=2;
68 68
  coords[n3]=Point(70,70);  sizes[n3]=1; colors[n3]=3; shapes[n3]=0;
69 69
  coords[n4]=Point(70,50);  sizes[n4]=2; colors[n4]=4; shapes[n4]=1;
70 70
  coords[n5]=Point(85,60);  sizes[n5]=3; colors[n5]=5; shapes[n5]=2;
71 71
  
72 72
  Arc e;
73 73

	
74 74
  e=g.addArc(n1,n2); ecolors[e]=0; widths[e]=1;
75 75
  e=g.addArc(n2,n3); ecolors[e]=0; widths[e]=1;
76 76
  e=g.addArc(n3,n5); ecolors[e]=0; widths[e]=3;
77 77
  e=g.addArc(n5,n4); ecolors[e]=0; widths[e]=1;
78 78
  e=g.addArc(n4,n1); ecolors[e]=0; widths[e]=1;
79 79
  e=g.addArc(n2,n4); ecolors[e]=1; widths[e]=2;
80 80
  e=g.addArc(n3,n4); ecolors[e]=2; widths[e]=1;
81 81
  
82 82
  IdMap<ListDigraph,Node> id(g);
83 83

	
84 84
  cout << "Create 'graph_to_eps_demo_out_pure.eps'" << endl;
85 85
  graphToEps(g,"graph_to_eps_demo_out_pure.eps").
86 86
    //scale(10).
87 87
    coords(coords).
88 88
    title("Sample .eps figure").
89 89
    copyright("(C) 2003-2007 LEMON Project").
90 90
    run();
91 91

	
92 92
  cout << "Create 'graph_to_eps_demo_out.eps'" << endl;
93 93
  graphToEps(g,"graph_to_eps_demo_out.eps").
Ignore white space 96 line context
... ...
@@ -74,97 +74,97 @@
74 74
  /// Blue color constant
75 75
  extern const Color BLUE;
76 76
  /// Yellow color constant
77 77
  extern const Color YELLOW;
78 78
  /// Magenta color constant
79 79
  extern const Color MAGENTA;
80 80
  /// Cyan color constant
81 81
  extern const Color CYAN;
82 82
  /// Grey color constant
83 83
  extern const Color GREY;
84 84
  /// Dark red color constant
85 85
  extern const Color DARK_RED;
86 86
  /// Dark green color constant
87 87
  extern const Color DARK_GREEN;
88 88
  /// Drak blue color constant
89 89
  extern const Color DARK_BLUE;
90 90
  /// Dark yellow color constant
91 91
  extern const Color DARK_YELLOW;
92 92
  /// Dark magenta color constant
93 93
  extern const Color DARK_MAGENTA;
94 94
  /// Dark cyan color constant
95 95
  extern const Color DARK_CYAN;
96 96

	
97 97
  ///Map <tt>int</tt>s to different \ref Color "Color"s
98 98

	
99 99
  ///This map assigns one of the predefined \ref Color "Color"s to
100 100
  ///each <tt>int</tt>. It is possible to change the colors as well as
101 101
  ///their number. The integer range is cyclically mapped to the
102 102
  ///provided set of colors.
103 103
  ///
104 104
  ///This is a true \ref concepts::ReferenceMap "reference map", so
105 105
  ///you can also change the actual colors.
106 106

	
107 107
  class Palette : public MapBase<int,Color>
108 108
  {
109 109
    std::vector<Color> colors;
110 110
  public:
111 111
    ///Constructor
112 112

	
113 113
    ///Constructor 
114 114
    ///\param num the number of the allocated colors. If it is \c -1,
115 115
    ///the default color configuration is set up (26 color plus the
116 116
    ///white).  If \c num is less then 26/27 then the default color
117 117
    ///list is cut. Otherwise the color list is filled repeatedly with
118 118
    ///the default color list.  (The colors can be changed later on.)
119 119
    ///\param have_white indicates whether white is amongst the
120 120
    ///provided color (\c true) or not (\c false). If it is true,
121 121
    ///white will be assigned to \c 0.
122
    Palette(int num=-1,bool have_white=false)
122
    Palette(bool have_white=false,int num=-1)
123 123
    {
124 124
      if (num==0) return;
125 125
      do {
126 126
        if(have_white) colors.push_back(Color(1,1,1));
127 127

	
128 128
        colors.push_back(Color(0,0,0));
129 129
        colors.push_back(Color(1,0,0));
130 130
        colors.push_back(Color(0,1,0));
131 131
        colors.push_back(Color(0,0,1));
132 132
        colors.push_back(Color(1,1,0));
133 133
        colors.push_back(Color(1,0,1));
134 134
        colors.push_back(Color(0,1,1));
135 135
      
136 136
        colors.push_back(Color(.5,0,0));
137 137
        colors.push_back(Color(0,.5,0));
138 138
        colors.push_back(Color(0,0,.5));
139 139
        colors.push_back(Color(.5,.5,0));
140 140
        colors.push_back(Color(.5,0,.5));
141 141
        colors.push_back(Color(0,.5,.5));
142 142
      
143 143
        colors.push_back(Color(.5,.5,.5));
144 144
        colors.push_back(Color(1,.5,.5));
145 145
        colors.push_back(Color(.5,1,.5));
146 146
        colors.push_back(Color(.5,.5,1));
147 147
        colors.push_back(Color(1,1,.5));
148 148
        colors.push_back(Color(1,.5,1));
149 149
        colors.push_back(Color(.5,1,1));
150 150
      
151 151
        colors.push_back(Color(1,.5,0));
152 152
        colors.push_back(Color(.5,1,0));
153 153
        colors.push_back(Color(1,0,.5));
154 154
        colors.push_back(Color(0,1,.5));
155 155
        colors.push_back(Color(0,.5,1));
156 156
        colors.push_back(Color(.5,0,1));
157 157
      } while(int(colors.size())<num);
158 158
      //    colors.push_back(Color(1,1,1));
159 159
      if(num>=0) colors.resize(num);
160 160
    }
161 161
    ///\e
162 162
    Color &operator[](int i)
163 163
    {
164 164
      return colors[i%colors.size()];
165 165
    }
166 166
    ///\e
167 167
    const Color &operator[](int i) const
168 168
    {
169 169
      return colors[i%colors.size()];
170 170
    }
0 comments (0 inline)