| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
#ifndef MAPPING_CONTAINER_HH |
|---|
| 24 |
#define MAPPING_CONTAINER_HH |
|---|
| 25 |
|
|---|
| 26 |
#include <vector> |
|---|
| 27 |
#include <FL/Fl_Widget.H> |
|---|
| 28 |
#include "_Canvas.hh" |
|---|
| 29 |
#include "ColorPatch.hh" |
|---|
| 30 |
#include "FeaturesContainer.hh" |
|---|
| 31 |
|
|---|
| 32 |
namespace gui { |
|---|
| 33 |
|
|---|
| 34 |
|
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 |
class MappingContainerChanged_ { |
|---|
| 38 |
friend class MappingContainer; |
|---|
| 39 |
protected: |
|---|
| 40 |
virtual void notify() = 0; |
|---|
| 41 |
virtual ~MappingContainerChanged_() { } |
|---|
| 42 |
}; |
|---|
| 43 |
|
|---|
| 44 |
|
|---|
| 45 |
|
|---|
| 46 |
|
|---|
| 47 |
|
|---|
| 48 |
class _FeaturesToMapChangeNotify; |
|---|
| 49 |
class MappingContainer { |
|---|
| 50 |
friend class _FeaturesToMapChangeNotify; |
|---|
| 51 |
protected: |
|---|
| 52 |
Fl_Color _color; |
|---|
| 53 |
bool _visible; |
|---|
| 54 |
|
|---|
| 55 |
std::vector<MappingContainerChanged_*> _to_notify_list; |
|---|
| 56 |
|
|---|
| 57 |
|
|---|
| 58 |
void notify_changed() { |
|---|
| 59 |
for (unsigned int i = 0; i < _to_notify_list.size(); i++) { |
|---|
| 60 |
_to_notify_list[i]->notify(); |
|---|
| 61 |
} |
|---|
| 62 |
} |
|---|
| 63 |
|
|---|
| 64 |
MappingContainer() : _color(FL_BLACK), _visible(true) { }; |
|---|
| 65 |
public: |
|---|
| 66 |
|
|---|
| 67 |
void add_change_listener(MappingContainerChanged_* l) { |
|---|
| 68 |
_to_notify_list.push_back(l); |
|---|
| 69 |
} |
|---|
| 70 |
|
|---|
| 71 |
bool visible() { return _visible; } |
|---|
| 72 |
void visible(bool t) { _visible = t; notify_changed(); } |
|---|
| 73 |
|
|---|
| 74 |
Fl_Color color() const { return _color; } |
|---|
| 75 |
void color(Fl_Color c) { _color = c; notify_changed(); } |
|---|
| 76 |
|
|---|
| 77 |
|
|---|
| 78 |
|
|---|
| 79 |
|
|---|
| 80 |
|
|---|
| 81 |
virtual void draw_on_canvas(_Canvas * canvas, bool is_closeup = false) = 0; |
|---|
| 82 |
virtual ~MappingContainer() { |
|---|
| 83 |
for (unsigned int i = 0; i < _to_notify_list.size(); i++) { |
|---|
| 84 |
delete _to_notify_list[i]; |
|---|
| 85 |
} |
|---|
| 86 |
} |
|---|
| 87 |
}; |
|---|
| 88 |
|
|---|
| 89 |
|
|---|
| 90 |
|
|---|
| 91 |
|
|---|
| 92 |
|
|---|
| 93 |
class MappingContainerChanged_Redrawer : public MappingContainerChanged_ { |
|---|
| 94 |
private: |
|---|
| 95 |
Fl_Widget * to_redraw; |
|---|
| 96 |
public: |
|---|
| 97 |
MappingContainerChanged_Redrawer(Fl_Widget * r) : to_redraw(r) { } |
|---|
| 98 |
void notify() { to_redraw->redraw(); } |
|---|
| 99 |
~MappingContainerChanged_Redrawer() { } |
|---|
| 100 |
}; |
|---|
| 101 |
|
|---|
| 102 |
|
|---|
| 103 |
|
|---|
| 104 |
|
|---|
| 105 |
|
|---|
| 106 |
class ColorChangeListener_MappingContainer : public ColorChangeListener_ { |
|---|
| 107 |
protected: |
|---|
| 108 |
MappingContainer * _map; |
|---|
| 109 |
public: |
|---|
| 110 |
ColorChangeListener_MappingContainer(MappingContainer * m) { |
|---|
| 111 |
_map = m; |
|---|
| 112 |
} |
|---|
| 113 |
|
|---|
| 114 |
void notify(Fl_Color c) { _map->color(c); } |
|---|
| 115 |
}; |
|---|
| 116 |
|
|---|
| 117 |
|
|---|
| 118 |
|
|---|
| 119 |
|
|---|
| 120 |
|
|---|
| 121 |
|
|---|
| 122 |
class _FeaturesToMapChangeNotify : public FeaturesContainerChanged_ { |
|---|
| 123 |
private: |
|---|
| 124 |
MappingContainer * map; |
|---|
| 125 |
public: |
|---|
| 126 |
|
|---|
| 127 |
_FeaturesToMapChangeNotify(MappingContainer* m) { map = m; } |
|---|
| 128 |
|
|---|
| 129 |
|
|---|
| 130 |
void notify() { map->notify_changed(); } |
|---|
| 131 |
}; |
|---|
| 132 |
} |
|---|
| 133 |
|
|---|
| 134 |
#endif |
|---|
| 135 |
|
|---|