source: source/ariba/utility/visual/OvlVis.cpp@ 7041

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

-ovlvis verschoben und 3dvis hinzu

File size: 15.5 KB
Line 
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#include "OvlVis.h"
40
41namespace ariba {
42namespace utility {
43
44use_logging_cpp(OvlVis);
45
46OvlVis::OvlVis() {
47}
48
49OvlVis::~OvlVis(){
50}
51
52void OvlVis::sendMessage( const string msg, NETWORK_ID nid ) {
53
54 sendSocket( msg );
55
56// {
57// // auto layout
58// ostringstream out;
59//
60// out << "VisMsgOptimizeView" << ";"
61// << Helper::ultos(nid) << ";" // network id is ignored in the message renderer, just renders the current viewed network
62// << "0" << std::endl;
63//
64// sendSocket( out.str() );
65// }
66
67// { // auto zoom
68// ostringstream out;
69//
70// out << "VisMsgOptimizeView" << ";"
71// << Helper::ultos(nid) << ";" // network id is ignored in the message renderer, just renders the current viewed network
72// << "1" << std::endl;
73//
74// sendSocket( out.str() );
75// }
76
77}
78
79//*****************************************************
80//*****************************************************
81//*****************************************************
82
83void OvlVis::visCreate(
84 NETWORK_ID network,
85 NodeID& node,
86 string nodename,
87 string info
88 ){
89
90 ostringstream out;
91
92 out << "VisMsgCreate" << ";"
93 << Helper::ultos(network) << ";"
94 << node.toString() << ";"
95 << nodename << ";"
96 << "" /*netName*/ << ";"
97 << "" /*ip*/ << ";"
98 << "" /*port*/ << ";"
99 << "0" << ";"
100 << info << std::endl;
101
102 sendMessage( out.str(), network );
103}
104
105void OvlVis::visChangeStatus(
106 NETWORK_ID network,
107 NodeID& node,
108 bool enable,
109 string info
110 ){
111
112 ostringstream out;
113
114 out << "VisMsgChangeStatus" << ";"
115 << Helper::ultos(network) << ";"
116 << node.toString() << ";"
117 << (enable ? "1" : "0") << ";"
118 << info << std::endl;
119
120 sendMessage( out.str(), network );
121}
122
123void OvlVis::visConnect(
124 NETWORK_ID network,
125 NodeID& srcnode,
126 NodeID& destnode,
127 string info
128 ){
129
130 // if we already have a link between the two nodes
131 // we just ignore the call and leave the old link
132
133 if( networkLinks.exists( network, NodePair(srcnode,destnode) )) return;
134
135 ostringstream out;
136 unsigned long edgekey = networkLinks.insert( network, NodePair(srcnode,destnode) );
137
138 out << "VisMsgConnect" << ";"
139 << Helper::ultos(network) << ";"
140 << edgekey << ";"
141 << srcnode.toString() << ";"
142 << destnode.toString() << ";"
143 << "0" << ";"
144 << info << std::endl;
145
146 sendMessage( out.str(), network );
147}
148
149void OvlVis::visDisconnect(
150 NETWORK_ID network,
151 NodeID& srcnode,
152 NodeID& destnode,
153 string info
154 ){
155
156 if( !networkLinks.exists(network, NodePair(srcnode, destnode)) ) return;
157
158 unsigned long edgekey = networkLinks.get( network, NodePair(srcnode, destnode) );
159 networkLinks.remove( network, NodePair(srcnode, destnode) );
160
161 ostringstream out;
162 out << "VisMsgDisconnect" << ";"
163 << Helper::ultos(network) << ";"
164 << Helper::ultos(edgekey) << ";"
165 << info << std::endl;
166
167 sendMessage( out.str(), network );
168}
169
170void OvlVis::visFailedConnect(
171 NETWORK_ID network,
172 NodeID& srcnode,
173 NodeID& destnode,
174 string info
175 ){
176
177 ostringstream out;
178
179 out << "VisMsgFailedConnect" << ";"
180 << Helper::ultos(network) << ";"
181 << srcnode.toString() << ";"
182 << destnode.toString() << ";"
183 << info << std::endl;
184
185 sendMessage( out.str(), network );
186}
187
188void OvlVis::visShutdown(
189 NETWORK_ID network,
190 NodeID& node,
191 string info
192 ){
193
194 ostringstream out;
195
196 out << "VisMsgShutdown" << ";"
197 << Helper::ultos(network) << ";"
198 << node.toString() << ";"
199 << info << std::endl;
200
201 sendMessage( out.str(), network );
202}
203
204//*****************************************************
205//*****************************************************
206//*****************************************************
207
208void OvlVis::visChangeNodeColor (
209 NETWORK_ID network,
210 NodeID& node,
211 unsigned char r,
212 unsigned char g,
213 unsigned char b
214 ){
215
216 ostringstream out;
217
218 out << "VisMsgChangeNodeColor" << ";"
219 << Helper::ultos(network) << ";"
220 << node.toString() << ";"
221 << ariba::utility::Helper::ultos(r) << ";"
222 << ariba::utility::Helper::ultos(g) << ";"
223 << ariba::utility::Helper::ultos(b) << std::endl;
224
225 sendMessage( out.str(), network );
226}
227
228void OvlVis::visChangeNodeColor (
229 NETWORK_ID network,
230 NodeID& node,
231 NODE_COLORS color
232 ){
233
234 unsigned char r = 0;
235 unsigned char g = 0;
236 unsigned char b = 0;
237
238 switch( color ) {
239 case NODE_COLORS_GREY: r = 128; g = 128; b = 128; break;
240 case NODE_COLORS_GREEN: r = 0; g = 200; b = 0; break;
241 case NODE_COLORS_RED: r = 255; g = 0; b = 0; break;
242 }
243
244 visChangeNodeColor( network, node, r, g, b );
245}
246
247void OvlVis::visChangeNodeIcon (
248 NETWORK_ID network,
249 NodeID& node,
250 ICON_ID icon
251 ){
252
253 ostringstream out;
254
255 out << "VisMsgChangeNodeIcon" << ";"
256 << Helper::ultos(network) << ";"
257 << node.toString() << ";"
258 << Helper::ultos((unsigned int)icon) << std::endl;
259
260 sendMessage( out.str(), network );
261}
262
263void OvlVis::visShowNodeLabel (
264 NETWORK_ID network,
265 NodeID& node,
266 string label
267 ){
268
269 ostringstream out;
270
271 out << "VisMsgShowNodeLabel" << ";"
272 << Helper::ultos(network) << ";"
273 << node.toString() << ";"
274 << label << std::endl;
275
276 sendMessage( out.str(), network );
277}
278
279void OvlVis::visDeleteNodeLabel (
280 NETWORK_ID network,
281 NodeID& node
282 ){
283
284 ostringstream out;
285
286 out << "VisMsgDeleteNodeLable" << ";"
287 << Helper::ultos(network) << ";"
288 << node.toString() << std::endl;
289
290 sendMessage( out.str(), network );
291}
292
293void OvlVis::visShowNodeBubble (
294 NETWORK_ID network,
295 NodeID& node,
296 string label
297 ){
298
299 unsigned long bubbleKey = nodeBubbles.insert( network, node );
300 ostringstream out;
301
302 out << "VisMsgShowNodeBubble" << ";"
303 << Helper::ultos(network) << ";"
304 << Helper::ultos(bubbleKey) << ";"
305 << node.toString() << ";"
306 << label << std::endl;
307
308 sendMessage( out.str(), network );
309}
310
311
312void OvlVis::visDeleteNodeBubble (
313 NETWORK_ID network,
314 NodeID& node
315 ){
316
317 if( !nodeBubbles.exists(network, node)) return;
318
319 unsigned long bubbleID = nodeBubbles.get( network, node );
320 nodeBubbles.remove( network, node );
321
322 ostringstream out;
323
324 out << "VisMsgDeleteBubble" << ";"
325 << Helper::ultos(network) << ";"
326 << Helper::ultos(bubbleID) << std::endl;
327
328 sendMessage( out.str(), network );
329}
330
331void OvlVis::visShowShiftedNodeIcon (
332 NETWORK_ID network,
333 NodeID& node,
334 ICON_ID iconID,
335 unsigned int timeout
336 ){
337
338 unsigned long iconKey = shiftedNodeIcons.insert( network, node );
339
340 ostringstream out;
341
342 out << "VisMsgShowNodeIcon" << ";"
343 << Helper::ultos(network) << ";"
344 << Helper::ultos(iconKey) << ";"
345 << node.toString() << ";"
346 << Helper::ultos(iconID) << std::endl;
347
348 sendMessage( out.str(), network );
349
350 if( timeout > 0 ){
351 TimedoutIcon* obj = new TimedoutIcon( network, node, timeout );
352 obj->startIcon();
353 }
354}
355
356void OvlVis::visDeleteShiftedNodeIcon (
357 NETWORK_ID network,
358 NodeID& node
359 ){
360
361 if( !shiftedNodeIcons.exists(network, node) )return;
362
363 unsigned long iconKey = shiftedNodeIcons.get( network, node );
364 shiftedNodeIcons.remove( network, node );
365
366 ostringstream out;
367
368 out << "VisMsgDeleteIcon" << ";"
369 << Helper::ultos(network) << ";"
370 << Helper::ultos(iconKey) << std::endl;
371
372 sendMessage( out.str(), network );
373}
374
375//*****************************************************
376//*****************************************************
377//*****************************************************
378
379void OvlVis::visChangeLinkWidth (
380 NETWORK_ID network,
381 NodeID& srcnode,
382 NodeID& destnode,
383 unsigned int width
384 ){
385
386 unsigned long edgekey = networkLinks.get( network, NodePair(srcnode, destnode) );
387
388 ostringstream out;
389 out << "VisMsgChangeLinkWidth" << ";"
390 << Helper::ultos(network) << ";"
391 << Helper::ultos(edgekey) << ";"
392 << Helper::ultos(width) << std::endl;
393
394 sendMessage( out.str(), network );
395}
396
397void OvlVis::visChangeLinkColor (
398 NETWORK_ID network,
399 NodeID& srcnode,
400 NodeID& destnode,
401 unsigned char r,
402 unsigned char g,
403 unsigned char b
404 ){
405
406 ostringstream out;
407 unsigned long edgekey = networkLinks.get( network, NodePair(srcnode, destnode) );
408
409 out << "VisMsgChangeLinkColor" << ";"
410 << Helper::ultos(network) << ";"
411 << Helper::ultos(edgekey) << ";"
412 << Helper::ultos(r) << ";"
413 << Helper::ultos(g) << ";"
414 << Helper::ultos(b) << std::endl;
415
416 sendMessage( out.str(), network );
417}
418
419void OvlVis::visChangeLinkColor (
420 NETWORK_ID network,
421 NodeID& srcnode,
422 NodeID& destnode,
423 NODE_COLORS color
424 ){
425
426 unsigned char r = 0;
427 unsigned char g = 0;
428 unsigned char b = 0;
429
430 switch( color ) {
431 case NODE_COLORS_GREY: r = 128; g = 128; b = 128; break;
432 case NODE_COLORS_GREEN: r = 0; g = 200; b = 0; break;
433 case NODE_COLORS_RED: r = 255; g = 0; b = 0; break;
434 }
435
436 visChangeLinkColor( network, srcnode, destnode, r, g, b );
437}
438
439void OvlVis::visShowLinkLabel (
440 NETWORK_ID network,
441 NodeID& srcnode,
442 NodeID& destnode,
443 string label
444 ){
445
446 ostringstream out;
447 unsigned long edgekey = networkLinks.get( network, NodePair(srcnode, destnode) );
448
449 out << "VisMsgShowLinkLabel" << ";"
450 << Helper::ultos(network) << ";"
451 << Helper::ultos(edgekey) << ";"
452 << label << std::endl;
453
454 sendMessage( out.str(), network );
455}
456
457void OvlVis::visDeleteLinkLabel (
458 NETWORK_ID network,
459 NodeID& srcnode,
460 NodeID& destnode
461 ){
462
463 if( !networkLinks.exists(network, NodePair(srcnode, destnode))) return;
464
465 unsigned long edgekey = networkLinks.get( network, NodePair(srcnode, destnode) );
466 ostringstream out;
467
468 out << "VisMsgDeleteLinkLabel" << ";"
469 << Helper::ultos(network) << ";"
470 << Helper::ultos(edgekey) << std::endl;
471
472 sendMessage( out.str(), network );
473}
474
475void OvlVis::visShowOnLinkIcon (
476 NETWORK_ID network,
477 NodeID& srcnode,
478 NodeID& destnode,
479 ICON_ID iconID
480 ){
481
482 unsigned long iconKey = onLinkIcons.insert(network, NodePair(srcnode, destnode));
483 ostringstream out;
484
485 out << "VisMsgShowLinkIcon" << ";"
486 << Helper::ultos(network) << ";"
487 << Helper::ultos(iconKey) << ";"
488 << srcnode.toString() << ";"
489 << destnode.toString() << ";"
490 << Helper::ultos(iconID) << std::endl;
491
492 sendMessage( out.str(), network );
493}
494
495void OvlVis::visDeleteOnLinkIcon (
496 NETWORK_ID network,
497 NodeID& srcnode,
498 NodeID& destnode
499 ){
500
501 if( !onLinkIcons.exists(network, NodePair(srcnode, destnode))) return;
502
503 unsigned long iconKey = onLinkIcons.get( network, NodePair(srcnode, destnode) );
504 onLinkIcons.remove( network, NodePair(srcnode, destnode) );
505
506 ostringstream out;
507
508 out << "VisMsgDeleteIcon" << ";"
509 << Helper::ultos(network) << ";"
510 << Helper::ultos(iconKey) << std::endl;
511
512 sendMessage( out.str(), network );
513}
514
515void OvlVis::visShowLinkBubble (
516 NETWORK_ID network,
517 NodeID& srcnode,
518 NodeID& destnode,
519 string label
520 ){
521
522 ostringstream out;
523 unsigned long bubble = linkBubbles.insert( network, NodePair(srcnode, destnode) );
524
525 out << "VisMsgShowLinkBubble" << ";"
526 << Helper::ultos(network) << ";"
527 << Helper::ultos(bubble) << ";"
528 << srcnode.toString() << ";"
529 << destnode.toString() << ";"
530 << label << std::endl;
531
532 sendMessage( out.str(), network );
533}
534
535void OvlVis::visDeleteLinkBubble (
536 NETWORK_ID network,
537 NodeID& srcnode,
538 NodeID& destnode
539 ){
540
541 if( !linkBubbles.exists(network, NodePair(srcnode, destnode))) return;
542
543 ostringstream out;
544 unsigned long bubble = linkBubbles.get( network, NodePair(srcnode, destnode) );
545 linkBubbles.remove( network, NodePair(srcnode, destnode) );
546
547 out << "VisMsgDeleteBubble" << ";"
548 << Helper::ultos(network) << ";"
549 << Helper::ultos(bubble) << std::endl;
550
551 sendMessage( out.str(), network );
552}
553
554//*****************************************************
555//*****************************************************
556//*****************************************************
557
558void OvlVis::visSendMessage (
559 NETWORK_ID network,
560 NodeID& startnode,
561 NodeID& endnode
562 ){
563
564 ostringstream out;
565
566 out << "VisMsgSendMessage" << ";"
567 << Helper::ultos(network) << ";"
568 << startnode.toString() << ";"
569 << endnode.toString() << std::endl;
570
571 sendMessage( out.str(), network );
572}
573
574//*****************************************************
575//*****************************************************
576//*****************************************************
577
578void OvlVis::visCLIOInitMeasurement(
579 NETWORK_ID network,
580 unsigned long edgekey,
581 NodeID& srcnode,
582 NodeID& destnode,
583 string info
584 ){
585
586 ostringstream out;
587
588 out << "VisMsgCLIOInitMeasurement" << ";"
589 << Helper::ultos(network) << ";"
590 << Helper::ultos(edgekey) << ";"
591 << srcnode.toString() << ";"
592 << destnode.toString() << ";"
593 << info << std::endl;
594
595 sendMessage( out.str(), network );
596}
597
598void OvlVis::visCLIOEndMeasurement(
599 NETWORK_ID network,
600 unsigned long edgekey,
601 NodeID& srcnode,
602 NodeID& destnode,
603 string info,
604 string value,
605 string unit
606 ){
607
608 ostringstream out;
609
610 out << "VisMsgCLIOEndMeasurement" << ";"
611 << Helper::ultos(network) << ";"
612 << Helper::ultos(edgekey) << ";"
613 << srcnode.toString() << ";"
614 << destnode.toString() << ";"
615 << info << ";"
616 << value << ";"
617 << unit << std::endl;
618
619 sendMessage( out.str(), network );
620}
621
622}} // namespace ariba, common
Note: See TracBrowser for help on using the repository browser.