source: source/ariba/utility/visual/OvlVis.h@ 10570

Last change on this file since 10570 was 6822, checked in by Christoph Mayer, 15 years ago

-ovlvis verschoben und 3dvis hinzu

File size: 8.6 KB
RevLine 
[6584]1// [License]
2// The Ariba-Underlay Copyright
3//
4// Copyright (c) 2008-2009, Institute of Telematics, UniversitÀt Karlsruhe (TH)
5//
6// Institute of Telematics
7// UniversitÀt Karlsruhe (TH)
8// Zirkel 2, 76128 Karlsruhe
9// Germany
10//
11// Redistribution and use in source and binary forms, with or without
12// modification, are permitted provided that the following conditions are
13// met:
14//
15// 1. Redistributions of source code must retain the above copyright
16// notice, this list of conditions and the following disclaimer.
17// 2. Redistributions in binary form must reproduce the above copyright
18// notice, this list of conditions and the following disclaimer in the
19// documentation and/or other materials provided with the distribution.
20//
21// THIS SOFTWARE IS PROVIDED BY THE INSTITUTE OF TELEMATICS ``AS IS'' AND
22// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ARIBA PROJECT OR
25// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
26// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
28// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32//
33// The views and conclusions contained in the software and documentation
34// are those of the authors and should not be interpreted as representing
35// official policies, either expressed or implied, of the Institute of
36// Telematics.
37// [License]
38
39#ifndef OVLVIS_H__
40#define OVLVIS_H__
41
42#include <sstream>
43#include <iostream>
44#include <string>
45#include <map>
46#include <boost/utility.hpp>
47#include "ariba/utility/system/Timer.h"
48#include "ariba/utility/misc/Helper.h"
49#include "ariba/utility/misc/KeyMapping.hpp"
[6822]50#include "ariba/utility/visual/ServerVis.h"
[6584]51
52using std::string;
53using std::map;
54using std::pair;
55using std::make_pair;
56using std::cout;
57using std::ostringstream;
58using ariba::utility::KeyMapping;
59using ariba::utility::Timer;
60
61namespace ariba {
62namespace utility {
63
[6822]64class OvlVis : public ServerVis, private boost::noncopyable {
[6584]65 use_logging_h(OvlVis);
66public:
67 static OvlVis& instance() { static OvlVis the_inst; return the_inst; }
68
69 //****************************************************************
70 // Node creation, node connections, status, node deletion, ...
71 //****************************************************************
72
73 /**
74 * Create a node in the network that is initially unconnected.
75 */
76 void visCreate (
77 NETWORK_ID network,
78 NodeID& node,
79 string nodename,
80 string info
81 );
82
83 /**
84 * Change the status of a node -> enable/disable a node.
85 */
86 void visChangeStatus(
87 NETWORK_ID network,
88 NodeID& node,
89 bool enable,
90 string info
91 );
92
93 /**
94 * Connect two nodes using a link.
95 */
96 void visConnect (
97 NETWORK_ID network,
98 NodeID& srcnode,
99 NodeID& destnode,
100 string info
101 );
102
103 /**
104 * Disconnect the link between two nodes.
105 */
106 void visDisconnect (
107 NETWORK_ID network,
108 NodeID& srcnode,
109 NodeID& destnode,
110 string info
111 );
112
113 /**
114 * Indicate that the connection procedure
115 * between two nodes failed.
116 */
117 void visFailedConnect (
118 NETWORK_ID network,
119 NodeID& srcnode,
120 NodeID& destnode,
121 string info
122 );
123
124 /**
125 * Delete a node from the network.
126 */
127 void visShutdown (
128 NETWORK_ID network,
129 NodeID& node,
130 string info
131 );
132
133 //****************************************************************
134 // Node manipulation: change color, change icon
135 //****************************************************************
136
137 /**
138 * Change the color of the node.
139 */
140 void visChangeNodeColor (
141 NETWORK_ID network,
142 NodeID& node,
143 unsigned char r,
144 unsigned char g,
145 unsigned char b
146 );
147
148 /**
149 * Change the color of the node.
150 */
151 void visChangeNodeColor (
152 NETWORK_ID network,
153 NodeID& node,
154 NODE_COLORS color
155 );
156
157 /**
158 * The available icons for changing the
159 * icon of a node, showing an icon besides
160 * a node and showing an icon at a link.
161 */
162 typedef enum _ICON_ID {
163 ICON_ID_DEFAULT_NODE = 0,
164 ICON_ID_PC = 1,
165 ICON_ID_PC_WORLD = 2,
166 ICON_ID_FAILURE = 3,
167 ICON_ID_RED_CROSS = 4,
168 ICON_ID_CHARACTER_A = 5,
169 ICON_ID_CHARACTER_W = 6,
170 ICON_ID_CAMERA = 7,
171 } ICON_ID;
172
173 /**
174 * Change the icon of a node.
175 */
176 void visChangeNodeIcon (
177 NETWORK_ID network,
178 NodeID& node,
179 ICON_ID icon
180 );
181
182 /**
183 * Show the label of the node.
184 */
185 void visShowNodeLabel (
186 NETWORK_ID network,
187 NodeID& node,
188 string label
189 );
190
191 /**
192 * Delete the label of the node.
193 */
194 void visDeleteNodeLabel (
195 NETWORK_ID network,
196 NodeID& node
197 );
198
199 /**
200 * Show a bubble at the node.
201 */
202 void visShowNodeBubble (
203 NETWORK_ID network,
204 NodeID& node,
205 string label
206 );
207
208 /**
209 * Delete a bubble at the node.
210 */
211 void visDeleteNodeBubble (
212 NETWORK_ID network,
213 NodeID& node
214 );
215
216 /**
217 * Show an icon besides the node.
218 */
219 void visShowShiftedNodeIcon (
220 NETWORK_ID network,
221 NodeID& node,
222 ICON_ID iconID,
223 unsigned int timeout = 0
224 );
225
226 /**
227 * Delete an icon besides the node
228 */
229 void visDeleteShiftedNodeIcon (
230 NETWORK_ID network,
231 NodeID& node
232 );
233
234 //****************************************************************
235 // Link manipulation: change width, color, show bubbles, icons, ...
236 //****************************************************************
237
238 /**
239 * Change the link width
240 */
241 void visChangeLinkWidth (
242 NETWORK_ID network,
243 NodeID& srcnode,
244 NodeID& destnode,
245 unsigned int width
246 );
247
248 /**
249 * Change the link color
250 */
251 void visChangeLinkColor (
252 NETWORK_ID network,
253 NodeID& srcnode,
254 NodeID& destnode,
255 unsigned char r,
256 unsigned char g,
257 unsigned char b
258 );
259
260 /**
261 * Change the link color
262 */
263 void visChangeLinkColor (
264 NETWORK_ID network,
265 NodeID& srcnode,
266 NodeID& destnode,
267 NODE_COLORS color
268 );
269
270 /**
271 * Show a link label
272 */
273 void visShowLinkLabel (
274 NETWORK_ID network,
275 NodeID& srcnode,
276 NodeID& destnode,
277 string label
278 );
279
280 /**
281 * Delete a link label
282 */
283 void visDeleteLinkLabel (
284 NETWORK_ID network,
285 NodeID& srcnode,
286 NodeID& destnode
287 );
288
289 /**
290 * Show an icon at the link
291 */
292 void visShowOnLinkIcon (
293 NETWORK_ID network,
294 NodeID& srcnode,
295 NodeID& destnode,
296 ICON_ID iconID
297 );
298
299 /**
300 * Delete an icon at the link
301 */
302 void visDeleteOnLinkIcon (
303 NETWORK_ID network,
304 NodeID& srcnode,
305 NodeID& destnode
306 );
307
308 /**
309 * Show a bubble besides the link
310 */
311 void visShowLinkBubble (
312 NETWORK_ID network,
313 NodeID& srcnode,
314 NodeID& destnode,
315 string label
316 );
317
318 /**
319 * Delete a bubble besides the link
320 */
321 void visDeleteLinkBubble (
322 NETWORK_ID network,
323 NodeID& srcnode,
324 NodeID& destnode
325 );
326
327 //****************************************************************
328 // Send message between two nodes
329 //****************************************************************
330
331 /**
332 * Animate the message sending between two nodes
333 */
334 void visSendMessage (
335 NETWORK_ID network,
336 NodeID& startnode,
337 NodeID& endnode
338 );
339
340 //*******************************************************
341 //*
342 void visCLIOInitMeasurement (
343 NETWORK_ID network,
344 unsigned long edgekey,
345 NodeID& srcnode,
346 NodeID& destnode,
347 string info
348 );
349
350 void visCLIOEndMeasurement (
351 NETWORK_ID network,
352 unsigned long edgekey,
353 NodeID& srcnode,
354 NodeID& destnode,
355 string info,
356 string value,
357 string unit
358 );
359 //*
360 //*******************************************************
361
362protected:
363 OvlVis();
[6822]364 virtual ~OvlVis();
[6584]365
366private:
367 void sendMessage( const string msg, NETWORK_ID nid );
368
369 typedef pair<NodeID, NodeID> NodePair;
370 typedef KeyMapping<NodePair> NetworkLinks;
371 typedef KeyMapping<NodePair> LinkBubbles;
372 typedef KeyMapping<NodeID> NodeBubbles;
373 typedef KeyMapping<NodeID> ShiftedNodeIcons;
374 typedef KeyMapping<NodePair> OnLinkIcons;
375
376 NetworkLinks networkLinks;
377 LinkBubbles linkBubbles;
378 NodeBubbles nodeBubbles;
379 ShiftedNodeIcons shiftedNodeIcons;
380 OnLinkIcons onLinkIcons;
381
382 class TimedoutIcon : public Timer {
383 private:
384 NETWORK_ID network;
385 NodeID node;
386 unsigned int timeout;
387 public:
388 TimedoutIcon(NETWORK_ID _network, NodeID _node, unsigned int _timeout) :
389 network(_network), node(_node), timeout(_timeout) {
390 }
391
392 virtual ~TimedoutIcon(){
393 Timer::stop();
394 }
395
396 void startIcon(){
397 Timer::setInterval( timeout, true );
398 Timer::start();
399 }
400
401 protected:
402 virtual void eventFunction(){
403 OvlVis::instance().visDeleteShiftedNodeIcon( network, node );
404 delete this;
405 }
406 };
407
408};
409
410}} // namespace ariba, common
411
412#endif // OVLVIS_H__
Note: See TracBrowser for help on using the repository browser.