1 | /* -*- C++ -*- |
---|

2 | * |
---|

3 | * This file is a part of LEMON, a generic C++ optimization library |
---|

4 | * |
---|

5 | * Copyright (C) 2003-2006 |
---|

6 | * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport |
---|

7 | * (Egervary Research Group on Combinatorial Optimization, EGRES). |
---|

8 | * |
---|

9 | * Permission to use, modify and distribute this software is granted |
---|

10 | * provided that this copyright notice appears in all copies. For |
---|

11 | * precise terms see the accompanying LICENSE file. |
---|

12 | * |
---|

13 | * This software is provided "AS IS" with no warranty of any kind, |
---|

14 | * express or implied, and with no claim as to its suitability for any |
---|

15 | * purpose. |
---|

16 | * |
---|

17 | */ |
---|

18 | |
---|

19 | #include "gui_reader.h" |
---|

20 | #include "xml.h" |
---|

21 | #include "mapstorage.h" |
---|

22 | #include <lemon/dim2.h> |
---|

23 | #include <vector> |
---|

24 | |
---|

25 | bool GuiReader::header(const std::string& line) |
---|

26 | { |
---|

27 | std::istringstream ls(line); |
---|

28 | std::string head; |
---|

29 | ls >> head; |
---|

30 | return head == "@gui"; |
---|

31 | } |
---|

32 | |
---|

33 | void GuiReader::read(std::istream& is) |
---|

34 | { |
---|

35 | XmlIo x(is); |
---|

36 | std::map<int, XY > m; |
---|

37 | x("arrow_pos", m); |
---|

38 | |
---|

39 | if ((int)m.size() == countEdges(mapstorage->graph)) |
---|

40 | { |
---|

41 | for (EdgeIt e(mapstorage->graph); e != INVALID; ++e) |
---|

42 | { |
---|

43 | int edgeid = (int)(*mapstorage->edgemap_storage["label"])[e]; |
---|

44 | mapstorage->arrow_pos.set(e, m[edgeid]); |
---|

45 | } |
---|

46 | mapstorage->ArrowPosReadOK(); |
---|

47 | } |
---|

48 | |
---|

49 | std::map<int, std::string> nm; |
---|

50 | x("active_nodemaps", nm); |
---|

51 | |
---|

52 | for(int i=0;i<NODE_PROPERTY_NUM;i++) |
---|

53 | { |
---|

54 | mapstorage->changeActiveMap(false, i, nm[i]); |
---|

55 | } |
---|

56 | |
---|

57 | std::map<int, std::string> em; |
---|

58 | x("active_edgemaps", em); |
---|

59 | for(int i=0;i<EDGE_PROPERTY_NUM;i++) |
---|

60 | { |
---|

61 | mapstorage->changeActiveMap(true, i, em[i]); |
---|

62 | } |
---|

63 | |
---|

64 | double attraction; |
---|

65 | double propulsation; |
---|

66 | int iteration; |
---|

67 | |
---|

68 | x("redesign-attraction", attraction); |
---|

69 | x("redesign-propulsation", propulsation); |
---|

70 | x("redesign-iteration", iteration); |
---|

71 | |
---|

72 | mapstorage->set_attraction(attraction); |
---|

73 | mapstorage->set_propulsation(propulsation); |
---|

74 | mapstorage->set_iteration(iteration); |
---|

75 | |
---|

76 | mapstorage->redesign_data_changed(); |
---|

77 | } |
---|

78 | |
---|

79 | GuiReader::GuiReader(LemonReader& reader, MapStorage* ms) : Parent(reader), mapstorage(ms) |
---|

80 | { |
---|

81 | } |
---|