17 #if defined(DUMP_SYNC)
19 # define DUMP_SCROLL_DETECT
27 if (!clickable)
return NULp;
45 bool do_insert = species.find(gb_species) == species.end();
47 bool do_insert =
true;
53 species.insert(gb_species);
69 bool drawflag =
false;
70 if (filteri & filter) {
73 drawflag = clip(transLine, clippedLine);
74 if (drawflag) track();
79 bool drawflag =
false;
80 if (filteri & filter) {
81 if (!is_outside_clip(transform(pos))) track();
105 device.set_top_clip_border(rect.
t);
106 device.set_bottom_clip_border(rect.
b);
107 device.set_left_clip_border(rect.
l);
108 device.set_right_clip_border(rect.
r);
124 SpeciesPositions spos;
127 SpeciesPositions::iterator tracked = spos.find(gb_species);
128 if (tracked == spos.end()) {
129 spos[gb_species] = spec_area;
132 tracked->second =
bounding_box(tracked->second, spec_area);
136 trackPosition(gb_species,
Rectangle(spec_vec));
138 void trackPosition(
GBDATA *gb_species,
const Position& spec_pos) {
155 bool drawflag =
false;
156 if (filteri & filter) {
159 if (species->find(gb_species) != species->end()) {
160 trackPosition(gb_species, Line);
168 bool drawflag =
false;
169 if (filteri & filter) {
172 if (species->find(gb_species) != species->end()) {
173 trackPosition(gb_species, pos);
213 for (SpeciesPositions::const_iterator
s = spos.begin();
s != spos.end(); ++
s) {
214 pos.insert(
s->second);
219 viewport_size = viewport_size_;
222 void calc_best_area();
228 const int max_species =
int(pos.size());
229 int rest = max_species;
231 SortedPositions::const_iterator end = pos.end();
232 for (SortedPositions::const_iterator s1 = pos.begin(); rest>best_count && s1 != end; ++s1) {
240 SortedPositions::const_iterator s2 = s1;
242 for (; s2 != end; ++s2) {
252 if (count>best_count) {
254 best_area = contained_area;
256 #if defined(DUMP_SCROLL_DETECT)
257 fprintf(stderr,
"Found %i species fitting into area ", count);
258 AW_DUMP(contained_area);
268 if (best_area.valid()) {
276 void SlaveCanvas::track_display_positions() {
285 device.set_species(species);
286 device.forget_positions();
298 internal->store_positions_sorted(device.get_tracked_positions());
301 void SlaveCanvas::calc_scroll_zoom() {
306 internal->announce_viewport_size(viewport.
diagonal());
307 internal->calc_best_area();
310 void SlaveCanvas::refresh_scroll_zoom() {
311 #if defined(DUMP_SYNC)
312 fprintf(stderr,
"DEBUG: SlaveCanvas does refresh_scroll_zoom (idx=%i)\n", get_index());
318 Vector world_scroll(internal->calc_best_scroll_delta(viewport));
320 #if defined(DUMP_SCROLL_DETECT)
322 AW_DUMP(world_scroll);
325 if (world_scroll.has_length()) {
327 #if defined(DUMP_SCROLL_DETECT)
328 AW_DUMP(screen_scroll);
330 ntw->
scroll(screen_scroll);
338 last_master_change(0),
339 need_SetUpdate(
true),
340 need_PositionTrack(
true),
341 need_ScrollZoom(
true),
AW::Vector transform(const AW::Vector &vec) const
AW_trackSpecies_device(AW_common *common_, SpeciesSet &species_)
bool operator()(const Rectangle &r1, const Rectangle &r2) const
AW_device * get_device(AW_area area)
Vector calc_best_scroll_delta(const Rectangle &viewport)
bool text_impl(int, const SizedCstr &, const AW::Position &pos, AW_pos, AW_bitset filteri) OVERRIDE
AW_DEVICE_TYPE type() OVERRIDE
void specific_reset() OVERRIDE
Rectangle bounding_box(const Rectangle &r1, const Rectangle &r2)
void set_species(SpeciesSetPtr species_)
AW_trackPositions_device(AW_common *common_)
bool line_impl(int, const LineVector &Line, AW_bitset filteri) OVERRIDE
AW_common * get_common(AW_area area)
void specific_reset() OVERRIDE
bool invisible_impl(const Position &, AW_bitset) OVERRIDE
const SpeciesPositions & get_tracked_positions() const
AW_DEVICE_TYPE type() OVERRIDE
AW::Vector rtransform(const AW::Vector &vec) const
bool line_impl(int, const LineVector &Line, AW_bitset filteri) OVERRIDE
const Position & upper_left_corner() const
void store_positions_sorted(const SpeciesPositions &spos)
const Vector & diagonal() const
Rectangle bounding_box(const Rectangle &rect) const
bool text_impl(int, const SizedCstr &, const AW::Position &pos, AW_pos, AW_bitset filteri) OVERRIDE
void scroll(int delta_x, int delta_y, bool dont_update_scrollbars=false)
bool invisible_impl(const Position &, AW_bitset) OVERRIDE
bool overlaps_with(const Rectangle &rect) const
void init_device(AW_device *device)
void announce_viewport_size(const Vector &viewport_size_)
GB_transaction ta(gb_var)
GB_CSTR GBT_get_name_or_description(GBDATA *gb_item)
virtual void show(AW_device *device)=0
GB_write_int const char s