Whiteboard
An interface and tools for visualizing large and complex datasets
Compounds.h
Go to the documentation of this file.
1 #ifndef COMPOUNDS_H
2 #define COMPOUNDS_H
3 
4 #include "visual/Whiteboard.h"
5 #include <math.h>
6 
10 class Box
11 {
12  public:
13  Box(double width = 1.,
14  const color & color = color(0, 0, 0) ) {
15  m_width = width;
16  m_col = color;
17  }
18 
23  const ns_whiteboard::xy_coords & from,
24  const ns_whiteboard::xy_coords & to ) {
25 
26  board.Add( new ns_whiteboard::line( ns_whiteboard::xy_coords(from.first, from.second),
27  ns_whiteboard::xy_coords(from.first, to.second),
28  m_width,
29  m_col) );
30  board.Add( new ns_whiteboard::line( ns_whiteboard::xy_coords(from.first, to.second),
31  ns_whiteboard::xy_coords(to.first, to.second),
32  m_width,
33  m_col) );
34  board.Add( new ns_whiteboard::line( ns_whiteboard::xy_coords(to.first, to.second),
35  ns_whiteboard::xy_coords(to.first, from.second),
36  m_width,
37  m_col) );
38  board.Add( new ns_whiteboard::line( ns_whiteboard::xy_coords(to.first, from.second),
39  ns_whiteboard::xy_coords(from.first, from.second),
40  m_width,
41  m_col) );
42 
43  }
44 
49  const ns_whiteboard::xy_coords & a,
50  const ns_whiteboard::xy_coords & b,
51  const ns_whiteboard::xy_coords & c,
52  const ns_whiteboard::xy_coords & d ) {
53 
54  board.Add( new ns_whiteboard::line( ns_whiteboard::xy_coords(a.first, a.second),
55  ns_whiteboard::xy_coords(b.first, b.second),
56  m_width,
57  m_col) );
58  board.Add( new ns_whiteboard::line( ns_whiteboard::xy_coords(b.first, b.second),
59  ns_whiteboard::xy_coords(c.first, c.second),
60  m_width,
61  m_col) );
62  board.Add( new ns_whiteboard::line( ns_whiteboard::xy_coords(c.first, c.second),
63  ns_whiteboard::xy_coords(d.first, d.second),
64  m_width,
65  m_col) );
66  board.Add( new ns_whiteboard::line( ns_whiteboard::xy_coords(d.first, d.second),
67  ns_whiteboard::xy_coords(a.first, a.second),
68  m_width,
69  m_col) );
70  }
71 
72 
73 
74  private:
75  double m_width;
77 };
78 
82 class Arrow
83 {
84  public:
85  Arrow(double size_off = 8.,
86  double size_back = 10.,
87  double width = 1.,
88  const color & color = color(0, 0, 0) ) {
89  m_width = width;
90  m_col = color;
91  m_size_off = size_off;
92  m_size_back = size_back;
93  }
94 
99  const ns_whiteboard::xy_coords & from,
100  const ns_whiteboard::xy_coords & to ) {
101 
102  board.Add( new ns_whiteboard::line( from,
103  to,
104  m_width,
105  m_col) );
106  double x = to.first - from.first;
107  double y = to.second - from.second;
108 
109  //double phi = 0.;
110  //if (x != 0.)
111  //phi = atan(y/x);
112  double phi = acos(x/sqrt(x*x+y*y));
113  //cout << phi << endl;
114 
115  double size = 10 * m_width;
116  double r = sqrt(x*x+y*y);
117 
118  double x1 = r - m_size_back;
119  double y1 = m_size_off;
120  double x2 = r - m_size_back;
121  double y2 = -m_size_off;
122  //cout << "x1=" << x1 << " y1=" << y1 << endl;
123 
124  double rx1 = from.first + x1 * cos(phi) - y1 * sin(phi);
125  double ry1 = from.second + x1 * sin(phi) + y1 * cos(phi);
126 
127  double rx2 = from.first + x2 * cos(phi) - y2 * sin(phi);
128  double ry2 = from.second + x2 * sin(phi) + y2 * cos(phi);
129 
130  board.Add( new ns_whiteboard::line( to,
131  ns_whiteboard::xy_coords(rx1, ry1),
132  m_width,
133  m_col) );
134 
135  board.Add( new ns_whiteboard::line( to,
136  ns_whiteboard::xy_coords(rx2, ry2),
137  m_width,
138  m_col) );
139  }
140 
141 
142  private:
143  double m_width;
144  double m_size_off;
145  double m_size_back;
146 
148 };
149 
150 
151 
152 
153 #endif
154 
155 
Definition: Whiteboard.h:276
double m_width
Definition: Compounds.h:75
Arrow(double size_off=8., double size_back=10., double width=1., const color &color=color(0, 0, 0))
Definition: Compounds.h:85
color m_col
Definition: Compounds.h:147
void Draw(ns_whiteboard::whiteboard &board, const ns_whiteboard::xy_coords &from, const ns_whiteboard::xy_coords &to)
Definition: Compounds.h:22
Definition: Whiteboard.h:154
void Draw(ns_whiteboard::whiteboard &board, const ns_whiteboard::xy_coords &a, const ns_whiteboard::xy_coords &b, const ns_whiteboard::xy_coords &c, const ns_whiteboard::xy_coords &d)
Definition: Compounds.h:48
void Add(graphic *g)
Definition: Whiteboard.h:162
pair< double, double > xy_coords
Definition: Whiteboard.h:30
double m_size_back
Definition: Compounds.h:145
File holding the base drawing classes of the whiteboard.
void Draw(ns_whiteboard::whiteboard &board, const ns_whiteboard::xy_coords &from, const ns_whiteboard::xy_coords &to)
Definition: Compounds.h:98
Box(double width=1., const color &color=color(0, 0, 0))
Definition: Compounds.h:13
double m_width
Definition: Compounds.h:143
color m_col
Definition: Compounds.h:76
Definition: Compounds.h:10
Definition: Color.h:12
Definition: Compounds.h:82
double m_size_off
Definition: Compounds.h:144