Merge lp:~widelands-dev/widelands/bug-1573057-graph-relative-plotmode into lp:widelands

Proposed by GunChleoc
Status: Merged
Merged at revision: 8022
Proposed branch: lp:~widelands-dev/widelands/bug-1573057-graph-relative-plotmode
Merge into: lp:widelands
Diff against target: 918 lines (+231/-248)
6 files modified
src/logic/cmd_calculate_statistics.cc (+1/-1)
src/logic/constants.h (+4/-2)
src/wui/general_statistics_menu.cc (+3/-3)
src/wui/plot_area.cc (+176/-203)
src/wui/plot_area.h (+35/-27)
src/wui/ware_statistics_menu.cc (+12/-12)
To merge this branch: bzr merge lp:~widelands-dev/widelands/bug-1573057-graph-relative-plotmode
Reviewer Review Type Date Requested Status
TiborB Approve
kaputtnik (community) testing Approve
Review via email: mp+295198@code.launchpad.net

Commit message

Fixed relative plot mode and flickering graphs on button click. Only draw active statistics tab. Some refactoring.

To post a comment you must log in.
Revision history for this message
GunChleoc (gunchleoc) wrote :

Good savegames for testing are attached to bug https://bugs.launchpad.net/widelands/+bug/1573057

Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 1139. State: failed. Details: https://travis-ci.org/widelands/widelands/builds/131399247.
Appveyor build 976. State: failed. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bug_1573057_graph_relative_plotmode-976.

Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 1143. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/131622951.
Appveyor build 980. State: failed. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bug_1573057_graph_relative_plotmode-980.

Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 1143. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/131622951.
Appveyor build 980. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bug_1573057_graph_relative_plotmode-980.

Revision history for this message
kaputtnik (franku) wrote :

Works as expected :-)

review: Approve (testing)
Revision history for this message
bunnybot (widelandsofficial) wrote :

Bunnybot encountered an error while working on this merge proposal:

<urlopen error _ssl.c:495: The handshake operation timed out>

Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 1143. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/131622951.
Appveyor build 980. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bug_1573057_graph_relative_plotmode-980.

Revision history for this message
bunnybot (widelandsofficial) wrote :

Bunnybot encountered an error while working on this merge proposal:

The read operation timed out

Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 1143. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/131622951.
Appveyor build 980. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bug_1573057_graph_relative_plotmode-980.

Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 1156. State: failed. Details: https://travis-ci.org/widelands/widelands/builds/136762248.
Appveyor build 994. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bug_1573057_graph_relative_plotmode-994.

Revision history for this message
bunnybot (widelandsofficial) wrote :

Bunnybot encountered an error while working on this merge proposal:

<urlopen error _ssl.c:495: The handshake operation timed out>

Revision history for this message
bunnybot (widelandsofficial) wrote :

Bunnybot encountered an error while working on this merge proposal:

<urlopen error _ssl.c:495: The handshake operation timed out>

Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 1156. State: failed. Details: https://travis-ci.org/widelands/widelands/builds/136762248.
Appveyor build 994. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bug_1573057_graph_relative_plotmode-994.

Revision history for this message
GunChleoc (gunchleoc) wrote :

Ping?

It would be good to get this branch in so that we can go into official feature freeze.

Revision history for this message
TiborB (tiborb95) wrote :

oh, too complicated for me, but it at least LOOKS good to me :)

review: Approve
Revision history for this message
GunChleoc (gunchleoc) wrote :

Now you know how I feel when I review your AI code *lol* Thanks!

@bunnybot merge

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/logic/cmd_calculate_statistics.cc'
--- src/logic/cmd_calculate_statistics.cc 2015-10-24 15:42:37 +0000
+++ src/logic/cmd_calculate_statistics.cc 2016-06-10 17:28:35 +0000
@@ -31,7 +31,7 @@
31 game.sample_statistics();31 game.sample_statistics();
32 game.enqueue_command32 game.enqueue_command
33 (new CmdCalculateStatistics33 (new CmdCalculateStatistics
34 (game.get_gametime() + STATISTICS_SAMPLE_TIME));34 (game.get_gametime() + kStatisticsSampleTime));
35}35}
3636
37constexpr uint16_t kCurrentPacketVersion = 1;37constexpr uint16_t kCurrentPacketVersion = 1;
3838
=== modified file 'src/logic/constants.h'
--- src/logic/constants.h 2015-03-01 09:21:20 +0000
+++ src/logic/constants.h 2016-06-10 17:28:35 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright (C) 2006-2015 by the Widelands Development Team2 * Copyright (C) 2006-2016 by the Widelands Development Team
3 *3 *
4 * This program is free software; you can redistribute it and/or4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License5 * modify it under the terms of the GNU General Public License
@@ -20,6 +20,8 @@
20#ifndef WL_LOGIC_CONSTANTS_H20#ifndef WL_LOGIC_CONSTANTS_H
21#define WL_LOGIC_CONSTANTS_H21#define WL_LOGIC_CONSTANTS_H
2222
23#include <cstdint>
24
23/// Maximum numbers of players in a game. The game logic code reserves 5 bits25/// Maximum numbers of players in a game. The game logic code reserves 5 bits
24/// for player numbers, so it can keep track of 32 different player numbers, of26/// for player numbers, so it can keep track of 32 different player numbers, of
25/// which the value 0 means neutral and the values 1 .. 31 can be used as the27/// which the value 0 means neutral and the values 1 .. 31 can be used as the
@@ -27,6 +29,6 @@
27#define MAX_PLAYERS 829#define MAX_PLAYERS 8
2830
29/// How often are statistics to be sampled.31/// How often are statistics to be sampled.
30#define STATISTICS_SAMPLE_TIME 3000032constexpr uint32_t kStatisticsSampleTime = 30000;
3133
32#endif // end of include guard: WL_LOGIC_CONSTANTS_H34#endif // end of include guard: WL_LOGIC_CONSTANTS_H
3335
=== modified file 'src/wui/general_statistics_menu.cc'
--- src/wui/general_statistics_menu.cc 2016-01-29 08:37:22 +0000
+++ src/wui/general_statistics_menu.cc 2016-06-10 17:28:35 +0000
@@ -67,7 +67,9 @@
67 440, 400, _("General Statistics")),67 440, 400, _("General Statistics")),
68 my_registry_ (&registry),68 my_registry_ (&registry),
69 box_ (this, 0, 0, UI::Box::Vertical, 0, 0, 5),69 box_ (this, 0, 0, UI::Box::Vertical, 0, 0, 5),
70 plot_ (&box_, 0, 0, 430, PLOT_HEIGHT),70 plot_ (&box_, 0, 0, 430, PLOT_HEIGHT,
71 kStatisticsSampleTime,
72 WuiPlotArea::Plotmode::kAbsolute),
71 selected_information_(0)73 selected_information_(0)
72{74{
73 assert (my_registry_);75 assert (my_registry_);
@@ -78,8 +80,6 @@
78 box_.set_border(5, 5, 5, 5);80 box_.set_border(5, 5, 5, 5);
7981
80 // Setup plot data82 // Setup plot data
81 plot_.set_sample_rate(STATISTICS_SAMPLE_TIME);
82 plot_.set_plotmode(WuiPlotArea::PLOTMODE_ABSOLUTE);
83 Game & game = *parent.get_game();83 Game & game = *parent.get_game();
84 const Game::GeneralStatsVector & genstats =84 const Game::GeneralStatsVector & genstats =
85 game.get_general_statistics();85 game.get_general_statistics();
8686
=== modified file 'src/wui/plot_area.cc'
--- src/wui/plot_area.cc 2016-03-29 17:28:15 +0000
+++ src/wui/plot_area.cc 2016-06-10 17:28:35 +0000
@@ -39,24 +39,24 @@
3939
40constexpr int32_t kUpdateTimeInGametimeMs = 1000; // 1 second, gametime40constexpr int32_t kUpdateTimeInGametimeMs = 1000; // 1 second, gametime
4141
42const uint32_t minutes = 60 * 1000;42constexpr uint32_t kMinutes = 60 * 1000;
43const uint32_t hours = 60 * 60 * 1000;43constexpr uint32_t kHours = 60 * 60 * 1000;
44const uint32_t days = 24 * 60 * 60 * 1000;44constexpr uint32_t kDays = 24 * 60 * 60 * 1000;
4545
46const int32_t spacing = 5;46constexpr int32_t kSpacing = 5;
47const int32_t space_at_bottom = 20;47constexpr int32_t kSpaceBottom = 20;
48const int32_t space_at_right = 10;48constexpr int32_t kSpaceRight = 10;
49const int32_t space_left_of_label = 15;49constexpr int32_t kSpaceLeftOfLabel = 15;
50const uint32_t nr_samples = 30; // How many samples per diagramm when relative plotting50constexpr uint32_t KNoSamples = 30; // How many samples per diagramm when relative plotting
5151
52const uint32_t time_in_ms[] = {52const uint32_t time_in_ms[] = {
53 15 * minutes,53 15 * kMinutes,
54 30 * minutes,54 30 * kMinutes,
55 1 * hours,55 1 * kHours,
56 2 * hours,56 2 * kHours,
57 5 * hours,57 5 * kHours,
58 10 * hours,58 10 * kHours,
59 30 * hours59 30 * kHours
60};60};
6161
62const char BG_PIC[] = "images/wui/plot_area_bg.png";62const char BG_PIC[] = "images/wui/plot_area_bg.png";
@@ -99,18 +99,18 @@
99Units get_suggested_unit(uint32_t game_time, bool is_generic = false) {99Units get_suggested_unit(uint32_t game_time, bool is_generic = false) {
100 // Find a nice unit for max_x100 // Find a nice unit for max_x
101 if (is_generic) {101 if (is_generic) {
102 if (game_time > 4 * days) {102 if (game_time > 4 * kDays) {
103 return Units::kDayGeneric;103 return Units::kDayGeneric;
104 } else if (game_time > 4 * hours) {104 } else if (game_time > 4 * kHours) {
105 return Units::kHourGeneric;105 return Units::kHourGeneric;
106 } else {106 } else {
107 return Units::kMinutesGeneric;107 return Units::kMinutesGeneric;
108 }108 }
109 }109 }
110 else {110 else {
111 if (game_time > 4 * days) {111 if (game_time > 4 * kDays) {
112 return Units::kDayNarrow;112 return Units::kDayNarrow;
113 } else if (game_time > 4 * hours) {113 } else if (game_time > 4 * kHours) {
114 return Units::kHourNarrow;114 return Units::kHourNarrow;
115 } else {115 } else {
116 return Units::kMinutesNarrow;116 return Units::kMinutesNarrow;
@@ -153,13 +153,13 @@
153 switch (unit) {153 switch (unit) {
154 case Units::kDayGeneric:154 case Units::kDayGeneric:
155 case Units::kDayNarrow:155 case Units::kDayNarrow:
156 return ms / days;156 return ms / kDays;
157 case Units::kHourGeneric:157 case Units::kHourGeneric:
158 case Units::kHourNarrow:158 case Units::kHourNarrow:
159 return ms / hours;159 return ms / kHours;
160 case Units::kMinutesGeneric:160 case Units::kMinutesGeneric:
161 case Units::kMinutesNarrow:161 case Units::kMinutesNarrow:
162 return ms / minutes;162 return ms / kMinutes;
163 }163 }
164 NEVER_HERE();164 NEVER_HERE();
165}165}
@@ -167,11 +167,11 @@
167/**167/**
168 * calculate how many values are taken together when plot mode is relative168 * calculate how many values are taken together when plot mode is relative
169 */169 */
170int32_t calc_how_many(uint32_t time_ms, int32_t sample_rate) {170int32_t calc_how_many(uint32_t time_ms, uint32_t sample_rate) {
171 int32_t how_many = static_cast<int32_t>171 int32_t how_many = static_cast<int32_t>
172 ((static_cast<float>(time_ms)172 ((static_cast<float>(time_ms)
173 /173 /
174 static_cast<float>(nr_samples))174 static_cast<float>(KNoSamples))
175 /175 /
176 static_cast<float>(sample_rate));176 static_cast<float>(sample_rate));
177177
@@ -230,28 +230,28 @@
230 // Draw coordinate system230 // Draw coordinate system
231 // X Axis231 // X Axis
232 dst.draw_line_strip({232 dst.draw_line_strip({
233 FloatPoint(spacing, inner_h - space_at_bottom),233 FloatPoint(kSpacing, inner_h - kSpaceBottom),
234 FloatPoint(inner_w - space_at_right, inner_h - space_at_bottom)},234 FloatPoint(inner_w - kSpaceRight, inner_h - kSpaceBottom)},
235 kAxisLineColor, kAxisLinesWidth);235 kAxisLineColor, kAxisLinesWidth);
236 // Arrow236 // Arrow
237 dst.draw_line_strip({237 dst.draw_line_strip({
238 FloatPoint(spacing + 5, inner_h - space_at_bottom - 3),238 FloatPoint(kSpacing + 5, inner_h - kSpaceBottom - 3),
239 FloatPoint(spacing, inner_h - space_at_bottom),239 FloatPoint(kSpacing, inner_h - kSpaceBottom),
240 FloatPoint(spacing + 5, inner_h - space_at_bottom + 3),240 FloatPoint(kSpacing + 5, inner_h - kSpaceBottom + 3),
241 }, kAxisLineColor, kAxisLinesWidth);241 }, kAxisLineColor, kAxisLinesWidth);
242242
243 // Y Axis243 // Y Axis
244 dst.draw_line_strip({FloatPoint(inner_w - space_at_right, spacing),244 dst.draw_line_strip({FloatPoint(inner_w - kSpaceRight, kSpacing),
245 FloatPoint(inner_w - space_at_right, inner_h - space_at_bottom)},245 FloatPoint(inner_w - kSpaceRight, inner_h - kSpaceBottom)},
246 kAxisLineColor, kAxisLinesWidth);246 kAxisLineColor, kAxisLinesWidth);
247 // No Arrow here, since this doesn't continue.247 // No Arrow here, since this doesn't continue.
248248
249 float sub = (xline_length - space_left_of_label) / how_many_ticks;249 float sub = (xline_length - kSpaceLeftOfLabel) / how_many_ticks;
250 float posx = inner_w - space_at_right;250 float posx = inner_w - kSpaceRight;
251251
252 for (uint32_t i = 0; i <= how_many_ticks; ++i) {252 for (uint32_t i = 0; i <= how_many_ticks; ++i) {
253 dst.draw_line_strip({FloatPoint(static_cast<int32_t>(posx), inner_h - space_at_bottom),253 dst.draw_line_strip({FloatPoint(static_cast<int32_t>(posx), inner_h - kSpaceBottom),
254 FloatPoint(static_cast<int32_t>(posx), inner_h - space_at_bottom + 3)},254 FloatPoint(static_cast<int32_t>(posx), inner_h - kSpaceBottom + 3)},
255 kAxisLineColor, kAxisLinesWidth);255 kAxisLineColor, kAxisLinesWidth);
256256
257 // The space at the end is intentional to have the tick centered257 // The space at the end is intentional to have the tick centered
@@ -259,7 +259,7 @@
259 const Image* xtick = UI::g_fh1->render259 const Image* xtick = UI::g_fh1->render
260 (xtick_text_style((boost::format("-%u ") % (max_x / how_many_ticks * i)).str()));260 (xtick_text_style((boost::format("-%u ") % (max_x / how_many_ticks * i)).str()));
261 dst.blit261 dst.blit
262 (Point(static_cast<int32_t>(posx), inner_h - space_at_bottom + 10),262 (Point(static_cast<int32_t>(posx), inner_h - kSpaceBottom + 10),
263 xtick, BlendMode::UseAlpha, UI::Align::kCenter);263 xtick, BlendMode::UseAlpha, UI::Align::kCenter);
264264
265 posx -= sub;265 posx -= sub;
@@ -267,29 +267,32 @@
267267
268 // draw yticks, one at full, one at half268 // draw yticks, one at full, one at half
269 dst.draw_line_strip({269 dst.draw_line_strip({
270 FloatPoint(inner_w - space_at_right, spacing), FloatPoint(inner_w - space_at_right - 3, spacing)},270 FloatPoint(inner_w - kSpaceRight, kSpacing), FloatPoint(inner_w - kSpaceRight - 3, kSpacing)},
271 kAxisLineColor, kAxisLinesWidth);271 kAxisLineColor, kAxisLinesWidth);
272 dst.draw_line_strip({272 dst.draw_line_strip({
273 FloatPoint(inner_w - space_at_right, spacing + ((inner_h - space_at_bottom) - spacing) / 2),273 FloatPoint(inner_w - kSpaceRight, kSpacing + ((inner_h - kSpaceBottom) - kSpacing) / 2),
274 FloatPoint(inner_w - space_at_right - 3, spacing + ((inner_h - space_at_bottom) - spacing) / 2)},274 FloatPoint(inner_w - kSpaceRight - 3, kSpacing + ((inner_h - kSpaceBottom) - kSpacing) / 2)},
275 kAxisLineColor, kAxisLinesWidth);275 kAxisLineColor, kAxisLinesWidth);
276276
277 // print the used unit277 // print the used unit
278 const Image* xtick = UI::g_fh1->render(xtick_text_style(get_generic_unit_name(unit)));278 const Image* xtick = UI::g_fh1->render(xtick_text_style(get_generic_unit_name(unit)));
279 dst.blit(Point(2, spacing + 2), xtick, BlendMode::UseAlpha, UI::Align::kCenterLeft);279 dst.blit(Point(2, kSpacing + 2), xtick, BlendMode::UseAlpha, UI::Align::kCenterLeft);
280}280}
281281
282} // namespace282} // namespace
283283
284WuiPlotArea::WuiPlotArea284WuiPlotArea::WuiPlotArea
285 (UI::Panel * const parent,285 (UI::Panel * const parent,
286 int32_t const x, int32_t const y, int32_t const w, int32_t const h)286 int32_t const x, int32_t const y, int32_t const w, int32_t const h,
287 uint32_t sample_rate, Plotmode plotmode)
287:288:
288UI::Panel (parent, x, y, w, h),289UI::Panel (parent, x, y, w, h),
289plotmode_(PLOTMODE_ABSOLUTE),290plotmode_(plotmode),
290sample_rate_(0),291sample_rate_(sample_rate),
291needs_update_(true),292needs_update_(true),
292lastupdate_(0),293lastupdate_(0),
294xline_length_(get_inner_w() - kSpaceRight - kSpacing),
295yline_length_(get_inner_h() - kSpaceBottom - kSpacing),
293time_ms_(0),296time_ms_(0),
294highest_scale_(0),297highest_scale_(0),
295sub_(0.0f),298sub_(0.0f),
@@ -300,19 +303,19 @@
300}303}
301304
302305
303uint32_t WuiPlotArea::get_game_time() {306uint32_t WuiPlotArea::get_game_time() const {
304 uint32_t game_time = 0;307 uint32_t game_time = 0;
305308
306 // Find running time of the game, based on the plot data309 // Find running time of the game, based on the plot data
307 for (uint32_t plot = 0; plot < plotdata_.size(); ++plot)310 for (uint32_t plot = 0; plot < plotdata_.size(); ++plot)
308 if (game_time < plotdata_[plot].dataset->size() * sample_rate_)311 if (game_time < plotdata_[plot].absolute_data->size() * sample_rate_)
309 game_time = plotdata_[plot].dataset->size() * sample_rate_;312 game_time = plotdata_[plot].absolute_data->size() * sample_rate_;
310 return game_time;313 return game_time;
311}314}
312315
313std::vector<std::string> WuiPlotArea::get_labels() {316std::vector<std::string> WuiPlotArea::get_labels() const {
314 std::vector<std::string> labels;317 std::vector<std::string> labels;
315 for (int32_t i = 0; i < game_time_id_; i++) {318 for (uint32_t i = 0; i < game_time_id_; i++) {
316 Units unit = get_suggested_unit(time_in_ms[i], false);319 Units unit = get_suggested_unit(time_in_ms[i], false);
317 labels.push_back(get_value_with_unit(unit, ms_to_unit(unit, time_in_ms[i])));320 labels.push_back(get_value_with_unit(unit, ms_to_unit(unit, time_in_ms[i])));
318 }321 }
@@ -320,7 +323,7 @@
320 return labels;323 return labels;
321}324}
322325
323uint32_t WuiPlotArea::get_plot_time() {326uint32_t WuiPlotArea::get_plot_time() const {
324 if (time_ == TIME_GAME) {327 if (time_ == TIME_GAME) {
325 // Start with the game time328 // Start with the game time
326 uint32_t time_ms = get_game_time();329 uint32_t time_ms = get_game_time();
@@ -331,14 +334,14 @@
331 // or a multiple of 2h334 // or a multiple of 2h
332 // or a multiple of 20h335 // or a multiple of 20h
333 // or a multiple of 4 days336 // or a multiple of 4 days
334 if (time_ms > 8 * days) {337 if (time_ms > 8 * kDays) {
335 time_ms += - (time_ms % (4 * days)) + 4 * days;338 time_ms += - (time_ms % (4 * kDays)) + 4 * kDays;
336 } else if (time_ms > 40 * hours) {339 } else if (time_ms > 40 * kHours) {
337 time_ms += - (time_ms % (20 * hours)) + 20 * hours;340 time_ms += - (time_ms % (20 * kHours)) + 20 * kHours;
338 } else if (time_ms > 4 * hours) {341 } else if (time_ms > 4 * kHours) {
339 time_ms += - (time_ms % (2 * hours)) + 2 * hours;342 time_ms += - (time_ms % (2 * kHours)) + 2 * kHours;
340 } else {343 } else {
341 time_ms += - (time_ms % (15 * minutes)) + 15 * minutes;344 time_ms += - (time_ms % (15 * kMinutes)) + 15 * kMinutes;
342 }345 }
343 return time_ms;346 return time_ms;
344 } else {347 } else {
@@ -356,7 +359,7 @@
356 * We start to search with i=1 to ensure that at least one option besides359 * We start to search with i=1 to ensure that at least one option besides
357 * "game" will be offered to the user.360 * "game" will be offered to the user.
358 */361 */
359int32_t WuiPlotArea::get_game_time_id() {362uint32_t WuiPlotArea::get_game_time_id() {
360 uint32_t game_time = get_game_time();363 uint32_t game_time = get_game_time();
361 uint32_t i;364 uint32_t i;
362 for (i = 1; i < 7 && time_in_ms[i] <= game_time; i++) {365 for (i = 1; i < 7 && time_in_ms[i] <= game_time; i++) {
@@ -376,29 +379,47 @@
376 needs_update_ = false;379 needs_update_ = false;
377}380}
378381
382int32_t WuiPlotArea::initialize_update() {
383 // Initialize
384 for (uint32_t i = 0; i < plotdata_.size(); ++i) {
385 plotdata_[i].relative_data->clear();
386 }
387 // Get range
388 time_ms_ = get_plot_time();
389 if (plotmode_ == Plotmode::kAbsolute) {
390 sub_ =
391 (xline_length_ - kSpaceLeftOfLabel)
392 /
393 (static_cast<float>(time_ms_)
394 /
395 static_cast<float>(sample_rate_));
396 } else {
397 sub_ = (xline_length_ - kSpaceLeftOfLabel) / static_cast<float>(KNoSamples);
398 }
399
400 // How many do we aggregate when relative plotting
401 return calc_how_many(time_ms_, sample_rate_);
402}
379403
380// Find the maximum value.404// Find the maximum value.
381void WuiPlotArea::update() {405void WuiPlotArea::update() {
382 float const xline_length = get_inner_w() - space_at_right - spacing;406 const int32_t how_many = initialize_update();
383407
384 time_ms_ = get_plot_time();408 // Calculate highest scale
385
386 // How many do we take together when relative ploting
387 const int32_t how_many = calc_how_many(time_ms_, sample_rate_);
388 highest_scale_ = 0;409 highest_scale_ = 0;
389 if (plotmode_ == PLOTMODE_ABSOLUTE) {410 if (plotmode_ == Plotmode::kAbsolute) {
390 for (uint32_t i = 0; i < plotdata_.size(); ++i)411 for (uint32_t i = 0; i < plotdata_.size(); ++i)
391 if (plotdata_[i].showplot) {412 if (plotdata_[i].showplot) {
392 for (uint32_t l = 0; l < plotdata_[i].dataset->size(); ++l)413 for (uint32_t l = 0; l < plotdata_[i].absolute_data->size(); ++l) {
393 if (highest_scale_ < (*plotdata_[i].dataset)[l])414 if (highest_scale_ < (*plotdata_[i].absolute_data)[l]) {
394 highest_scale_ = (*plotdata_[i].dataset)[l];415 highest_scale_ = (*plotdata_[i].absolute_data)[l];
416 }
417 }
395 }418 }
396 } else {419 } else {
397 for (uint32_t plot = 0; plot < plotdata_.size(); ++plot) {420 for (uint32_t plot = 0; plot < plotdata_.size(); ++plot) {
398 if (plotdata_[plot].showplot) {421 if (plotdata_[plot].showplot) {
399422 const std::vector<uint32_t> & dataset = *plotdata_[plot].absolute_data;
400 const std::vector<uint32_t> & dataset = *plotdata_[plot].dataset;
401
402 uint32_t add = 0;423 uint32_t add = 0;
403 // Relative data, first entry is always zero.424 // Relative data, first entry is always zero.
404 for (uint32_t i = 0; i < dataset.size(); ++i) {425 for (uint32_t i = 0; i < dataset.size(); ++i) {
@@ -413,31 +434,21 @@
413 }434 }
414 }435 }
415436
416 // Update the datasets437 // Calculate plot data
417 sub_ =438 if (plotmode_ == Plotmode::kRelative) {
418 (xline_length - space_left_of_label)439 for (uint32_t plot = 0; plot < plotdata_.size(); ++plot) {
419 /440 if (plotdata_[plot].showplot) {
420 (static_cast<float>(time_ms_)441 std::vector<uint32_t> const * dataset = plotdata_[plot].absolute_data;
421 /
422 static_cast<float>(sample_rate_));
423 for (uint32_t plot = 0; plot < plotdata_.size(); ++plot) {
424 if (plotdata_[plot].showplot) {
425 std::vector<uint32_t> const * dataset = plotdata_[plot].dataset;
426
427 std::vector<uint32_t> data;
428 if (plotmode_ == PLOTMODE_RELATIVE) {
429 uint32_t add = 0;442 uint32_t add = 0;
430 // Relative data, first entry is always zero443 // Relative data, first entry is always zero
431 data.push_back(0);444 plotdata_[plot].relative_data->push_back(0);
432 for (uint32_t i = 0; i < dataset->size(); ++i) {445 for (uint32_t i = 0; i < dataset->size(); ++i) {
433 add += (*dataset)[i];446 add += (*dataset)[i];
434 if (0 == ((i + 1) % how_many)) {447 if (0 == ((i + 1) % how_many)) {
435 data.push_back(add);448 plotdata_[plot].relative_data->push_back(add);
436 add = 0;449 add = 0;
437 }450 }
438 }451 }
439 dataset = &data;
440 sub_ = (xline_length - space_left_of_label) / static_cast<float>(nr_samples);
441 }452 }
442 }453 }
443 }454 }
@@ -449,23 +460,26 @@
449 * Draw this. This is the main function460 * Draw this. This is the main function
450 */461 */
451void WuiPlotArea::draw(RenderTarget & dst) {462void WuiPlotArea::draw(RenderTarget & dst) {
452 float const xline_length = get_inner_w() - space_at_right - spacing;463 draw_plot(dst, get_inner_h() - kSpaceBottom, std::to_string(highest_scale_), highest_scale_);
453 float const yline_length = get_inner_h() - space_at_bottom - spacing;464}
454465
455 draw_diagram(time_ms_, get_inner_w(), get_inner_h(), xline_length, dst);466void WuiPlotArea::draw_plot(RenderTarget& dst, float yoffset, const std::string& yscale_label,
467 uint32_t highest_scale) {
468 draw_diagram(time_ms_, get_inner_w(), get_inner_h(), xline_length_, dst);
456469
457 // print the maximal value into the top right corner470 // print the maximal value into the top right corner
458 draw_value471 draw_value
459 (std::to_string(highest_scale_), RGBColor(60, 125, 0),472 (yscale_label, RGBColor(60, 125, 0),
460 Point(get_inner_w() - space_at_right - 2, spacing + 2), dst);473 Point(get_inner_w() - kSpaceRight - 2, kSpacing + 2), dst);
461474
462 // plot the pixels475 // plot the pixels
463 for (uint32_t plot = 0; plot < plotdata_.size(); ++plot) {476 for (uint32_t plot = 0; plot < plotdata_.size(); ++plot) {
464 if (plotdata_[plot].showplot) {477 if (plotdata_[plot].showplot) {
465 RGBColor color = plotdata_[plot].plotcolor;
466 std::vector<uint32_t> const * dataset = plotdata_[plot].dataset;
467 draw_plot_line478 draw_plot_line
468 (dst, dataset, yline_length, highest_scale_, sub_, color, get_inner_h() - space_at_bottom);479 (dst,
480 (plotmode_ == Plotmode::kRelative) ?
481 plotdata_[plot].relative_data : plotdata_[plot].absolute_data,
482 highest_scale, sub_, plotdata_[plot].plotcolor, yoffset);
469 }483 }
470 }484 }
471}485}
@@ -476,34 +490,37 @@
476 * \param sub horizontal difference between 2 y values490 * \param sub horizontal difference between 2 y values
477 */491 */
478void WuiPlotArea::draw_plot_line492void WuiPlotArea::draw_plot_line
479 (RenderTarget & dst, std::vector<uint32_t> const * dataset, float const yline_length,493 (RenderTarget & dst, std::vector<uint32_t> const * dataset,
480 uint32_t const highest_scale, float const sub, RGBColor const color, int32_t const yoffset)494 uint32_t const highest_scale, float const sub, RGBColor const color, int32_t const yoffset)
481{495{
482 float posx = get_inner_w() - space_at_right;496 if (!dataset->empty()) {
483 const int lx = get_inner_w() - space_at_right;497 float posx = get_inner_w() - kSpaceRight;
484 int ly = yoffset;498 const int lx = get_inner_w() - kSpaceRight;
485 // Init start point of the plot line with the first data value.499 int ly = yoffset;
486 // This prevents that the plot starts always at zero500 // Init start point of the plot line with the first data value.
487 if (int value = (*dataset)[dataset->size() - 1]) {501 // This prevents that the plot starts always at zero
488 ly -= static_cast<int32_t>(scale_value(yline_length, highest_scale, value));502
489 }503 if (int value = (*dataset)[dataset->size() - 1]) {
490504 ly -= static_cast<int32_t>(scale_value(yline_length_, highest_scale, value));
491 std::vector<FloatPoint> points;505 }
492 points.emplace_back(lx, ly);506
493507 std::vector<FloatPoint> points;
494 for (int32_t i = dataset->size() - 1; i > 0 && posx > spacing; --i) {508 points.emplace_back(lx, ly);
495 int32_t const curx = static_cast<int32_t>(posx);509
496 int32_t cury = yoffset;510 for (int32_t i = dataset->size() - 1; i > 0 && posx > kSpacing; --i) {
497511 int32_t const curx = static_cast<int32_t>(posx);
498 // Scale the line to the available space512 int32_t cury = yoffset;
499 if (int32_t value = (*dataset)[i]) {513
500 const float length_y = scale_value(yline_length, highest_scale, value);514 // Scale the line to the available space
501 cury -= static_cast<int32_t>(length_y);515 if (int32_t value = (*dataset)[i]) {
502 }516 const float length_y = scale_value(yline_length_, highest_scale, value);
503 points.emplace_back(curx, cury);517 cury -= static_cast<int32_t>(length_y);
504 posx -= sub;518 }
505 }519 points.emplace_back(curx, cury);
506 dst.draw_line_strip(points, color, kPlotLinesWidth);520 posx -= sub;
521 }
522 dst.draw_line_strip(points, color, kPlotLinesWidth);
523 }
507}524}
508525
509/*526/*
@@ -517,7 +534,8 @@
517 if (id >= plotdata_.size())534 if (id >= plotdata_.size())
518 plotdata_.resize(id + 1);535 plotdata_.resize(id + 1);
519536
520 plotdata_[id].dataset = data;537 plotdata_[id].absolute_data = data;
538 plotdata_[id].relative_data = new std::vector<uint32_t>(); // Will be filled in the update() function.
521 plotdata_[id].showplot = false;539 plotdata_[id].showplot = false;
522 plotdata_[id].plotcolor = color;540 plotdata_[id].plotcolor = color;
523541
@@ -544,17 +562,9 @@
544 needs_update_ = true;562 needs_update_ = true;
545}563}
546564
547/*
548 * Set sample rate the data uses
549 */
550void WuiPlotArea::set_sample_rate(uint32_t const id) {
551 sample_rate_ = id;
552 needs_update_ = true;
553}
554
555565
556void WuiPlotAreaSlider::draw(RenderTarget & dst) {566void WuiPlotAreaSlider::draw(RenderTarget & dst) {
557 int32_t new_game_time_id = plot_area_.get_game_time_id();567 uint32_t new_game_time_id = plot_area_.get_game_time_id();
558 if (new_game_time_id != last_game_time_id_) {568 if (new_game_time_id != last_game_time_id_) {
559 last_game_time_id_ = new_game_time_id;569 last_game_time_id_ = new_game_time_id;
560 set_labels(plot_area_.get_labels());570 set_labels(plot_area_.get_labels());
@@ -565,31 +575,27 @@
565575
566DifferentialPlotArea::DifferentialPlotArea576DifferentialPlotArea::DifferentialPlotArea
567 (UI::Panel * const parent,577 (UI::Panel * const parent,
568 int32_t const x, int32_t const y, int32_t const w, int32_t const h)578 int32_t const x, int32_t const y, int32_t const w, int32_t const h,
579 uint32_t sample_rate, Plotmode plotmode)
569:580:
570WuiPlotArea (parent, x, y, w, h)581WuiPlotArea (parent, x, y, w, h, sample_rate, plotmode)
571{582{
572 update();583 update();
573}584}
574585
575void DifferentialPlotArea::update() {586void DifferentialPlotArea::update() {
576 float const xline_length = get_inner_w() - space_at_right - spacing;587 const int32_t how_many = initialize_update();
577588
578 time_ms_ = get_plot_time();589 // Calculate highest scale
579
580 // How many do we take together when relative ploting
581 const int32_t how_many = calc_how_many(time_ms_, sample_rate_);
582
583 // Find max and min value
584 int32_t max = 0;590 int32_t max = 0;
585 int32_t min = 0;591 int32_t min = 0;
586592
587 if (plotmode_ == PLOTMODE_ABSOLUTE) {593 if (plotmode_ == Plotmode::kAbsolute) {
588 for (uint32_t i = 0; i < plotdata_.size(); ++i)594 for (uint32_t i = 0; i < plotdata_.size(); ++i)
589 if (plotdata_[i].showplot) {595 if (plotdata_[i].showplot) {
590 for (uint32_t l = 0; l < plotdata_[i].dataset->size(); ++l) {596 for (uint32_t l = 0; l < plotdata_[i].absolute_data->size(); ++l) {
591 int32_t temp = (*plotdata_[i].dataset)[l] -597 int32_t temp = (*plotdata_[i].absolute_data)[l] -
592 (*negative_plotdata_[i].dataset)[l];598 (*negative_plotdata_[i].absolute_data)[l];
593 if (max < temp) max = temp;599 if (max < temp) max = temp;
594 if (min > temp) min = temp;600 if (min > temp) min = temp;
595 }601 }
@@ -598,8 +604,8 @@
598 for (uint32_t plot = 0; plot < plotdata_.size(); ++plot)604 for (uint32_t plot = 0; plot < plotdata_.size(); ++plot)
599 if (plotdata_[plot].showplot) {605 if (plotdata_[plot].showplot) {
600606
601 const std::vector<uint32_t> & dataset = *plotdata_[plot].dataset;607 const std::vector<uint32_t> & dataset = *plotdata_[plot].absolute_data;
602 const std::vector<uint32_t> & ndataset = *negative_plotdata_[plot].dataset;608 const std::vector<uint32_t> & ndataset = *negative_plotdata_[plot].absolute_data;
603609
604 int32_t add = 0;610 int32_t add = 0;
605 // Relative data, first entry is always zero.611 // Relative data, first entry is always zero.
@@ -616,77 +622,43 @@
616622
617 // Use equal positive and negative range623 // Use equal positive and negative range
618 min = abs(min);624 min = abs(min);
619 highest_scale_ = 0;625 highest_scale_ = (min > max) ? min : max;
620 if (min > max) {626
621 highest_scale_ = min;627 // Calculate plot data
622 } else {628 if (plotmode_ == Plotmode::kRelative) {
623 highest_scale_ = max;629 for (uint32_t plot = 0; plot < plotdata_.size(); ++plot) {
624 }630 if (plotdata_[plot].showplot) {
625631 std::vector<uint32_t> const * dataset = plotdata_[plot].absolute_data;
626 // plot the pixels632 std::vector<uint32_t> const * ndataset = negative_plotdata_[plot].absolute_data;
627 sub_ =633 uint32_t add = 0;
628 xline_length
629 /
630 (static_cast<float>(time_ms_)
631 /
632 static_cast<float>(sample_rate_));
633 for (uint32_t plot = 0; plot < plotdata_.size(); ++plot)
634 if (plotdata_[plot].showplot) {
635 std::vector<uint32_t> const * dataset = plotdata_[plot].dataset;
636 std::vector<uint32_t> const * ndataset = negative_plotdata_[plot].dataset;
637
638 std::vector<uint32_t> data_;
639 if (plotmode_ == PLOTMODE_RELATIVE) {
640 int32_t add = 0;
641 // Relative data, first entry is always zero634 // Relative data, first entry is always zero
642 data_.push_back(0);635 plotdata_[plot].relative_data->push_back(0);
643 for (uint32_t i = 0; i < dataset->size(); ++i) {636 for (uint32_t i = 0; i < dataset->size(); ++i) {
644 add += (*dataset)[i] - (*ndataset)[i];637 add += (*dataset)[i] - (*ndataset)[i];
645 if (0 == ((i + 1) % how_many)) {638 if (0 == ((i + 1) % how_many)) {
646 data_.push_back(add);639 plotdata_[plot].relative_data->push_back(add);
647 add = 0;640 add = 0;
648 }641 }
649 }642 }
650 dataset = &data_;
651 sub_ = xline_length / static_cast<float>(nr_samples);
652 }643 }
653 }644 }
645 }
654}646}
655647
656void DifferentialPlotArea::draw(RenderTarget & dst) {648void DifferentialPlotArea::draw(RenderTarget & dst) {
657 float const xline_length = get_inner_w() - space_at_right - spacing;
658 float const yline_length = get_inner_h() - space_at_bottom - spacing;
659 // yoffset of the zero line649 // yoffset of the zero line
660 float const yoffset = spacing + ((get_inner_h() - space_at_bottom) - spacing) / 2;650 float const yoffset = kSpacing + ((get_inner_h() - kSpaceBottom) - kSpacing) / 2;
651 draw_plot(dst, yoffset, std::to_string(highest_scale_), 2 * highest_scale_);
661652
662 time_ms_ = get_plot_time();653 // Print the min value
663 draw_diagram(time_ms_, get_inner_w(), get_inner_h(), xline_length, dst);654 draw_value
655 ((boost::format("-%u") % (highest_scale_)).str(), RGBColor(125, 0, 0),
656 Point(get_inner_w() - kSpaceRight - 2, get_inner_h() - kSpacing - 15), dst);
664657
665 // draw zero line658 // draw zero line
666 dst.draw_line_strip({FloatPoint(get_inner_w() - space_at_right, yoffset),659 dst.draw_line_strip({FloatPoint(get_inner_w() - kSpaceRight, yoffset),
667 FloatPoint(get_inner_w() - space_at_right - xline_length, yoffset)},660 FloatPoint(get_inner_w() - kSpaceRight - xline_length_, yoffset)},
668 kZeroLineColor, kPlotLinesWidth);661 kZeroLineColor, kPlotLinesWidth);
669
670 // Print the min and max values
671 draw_value
672 (std::to_string(highest_scale_), RGBColor(60, 125, 0),
673 Point(get_inner_w() - space_at_right - 2, spacing + 2), dst);
674
675 draw_value
676 ((boost::format("-%u") % highest_scale_).str(), RGBColor(125, 0, 0),
677 Point(get_inner_w() - space_at_right - 2, get_inner_h() - spacing - 15), dst);
678
679 // plot the pixels
680 for (uint32_t plot = 0; plot < plotdata_.size(); ++plot)
681 if (plotdata_[plot].showplot) {
682
683 RGBColor color = plotdata_[plot].plotcolor;
684 std::vector<uint32_t> const * dataset = plotdata_[plot].dataset;
685
686 // Highest_scale represent the space between zero line and top.
687 // -> half of the whole differential plot area
688 draw_plot_line(dst, dataset, yline_length, highest_scale_ * 2, sub_, color, yoffset);
689 }
690}662}
691663
692/**664/**
@@ -696,9 +668,10 @@
696void DifferentialPlotArea::register_negative_plot_data668void DifferentialPlotArea::register_negative_plot_data
697 (uint32_t const id, std::vector<uint32_t> const * const data) {669 (uint32_t const id, std::vector<uint32_t> const * const data) {
698670
699 if (id >= negative_plotdata_.size())671 if (id >= negative_plotdata_.size()) {
700 negative_plotdata_.resize(id + 1);672 negative_plotdata_.resize(id + 1);
673 }
701674
702 negative_plotdata_[id].dataset = data;675 negative_plotdata_[id].absolute_data = data;
703 needs_update_ = true;676 needs_update_ = true;
704}677}
705678
=== modified file 'src/wui/plot_area.h'
--- src/wui/plot_area.h 2016-03-19 17:30:37 +0000
+++ src/wui/plot_area.h 2016-06-10 17:28:35 +0000
@@ -44,16 +44,17 @@
44 TIME_16_HOURS,44 TIME_16_HOURS,
45 TIME_GAME,45 TIME_GAME,
46 };46 };
47 enum PLOTMODE {47 enum class Plotmode {
48 // Always take the samples of some times together, so that the graph is48 // Always aggregate the samples of some time periods, so that the graph is
49 // not completely zigg-zagged.49 // not completely zig-zagged.
50 PLOTMODE_RELATIVE,50 kRelative,
5151 kAbsolute
52 PLOTMODE_ABSOLUTE
53 };52 };
5453
54 // sample_rate is in in milliseconds
55 WuiPlotArea55 WuiPlotArea
56 (UI::Panel * parent, int32_t x, int32_t y, int32_t w, int32_t h);56 (UI::Panel * parent, int32_t x, int32_t y, int32_t w, int32_t h,
57 uint32_t sample_rate, Plotmode plotmode);
5758
58 /// Calls update() if needed59 /// Calls update() if needed
59 void think() override;60 void think() override;
@@ -65,51 +66,54 @@
65 needs_update_ = true;66 needs_update_ = true;
66 }67 }
6768
68 void set_time_id(int32_t time) {69 void set_time_id(uint32_t time) {
69 if (time == game_time_id_)70 if (time == game_time_id_)
70 set_time(TIME_GAME);71 set_time(TIME_GAME);
71 else72 else
72 set_time(static_cast<TIME>(time));73 set_time(static_cast<TIME>(time));
73 needs_update_ = true;74 needs_update_ = true;
74 }75 }
75 TIME get_time() {return static_cast<TIME>(time_); }76 TIME get_time() const {return static_cast<TIME>(time_); }
76 int32_t get_time_id() {77 int32_t get_time_id() const {
77 if (time_ == TIME_GAME)78 if (time_ == TIME_GAME)
78 return game_time_id_;79 return game_time_id_;
79 else80 else
80 return time_;81 return time_;
81 }82 }
82 void set_sample_rate(uint32_t id); // in milliseconds
8383
84 int32_t get_game_time_id();84 uint32_t get_game_time_id();
8585
86 void register_plot_data86 void register_plot_data
87 (uint32_t id, const std::vector<uint32_t> * data, RGBColor);87 (uint32_t id, const std::vector<uint32_t> * data, RGBColor);
88 void show_plot(uint32_t id, bool t);88 void show_plot(uint32_t id, bool t);
8989
90 void set_plotmode(int32_t id) {plotmode_ = id;}
91
92 void set_plotcolor(uint32_t id, RGBColor color);90 void set_plotcolor(uint32_t id, RGBColor color);
9391
94 std::vector<std::string> get_labels();92 std::vector<std::string> get_labels() const;
9593
96protected:94protected:
95 void draw_plot(RenderTarget& dst, float yoffset, const std::string& yscale_label,
96 uint32_t highest_scale);
97 void draw_plot_line97 void draw_plot_line
98 (RenderTarget & dst, std::vector<uint32_t> const * dataset, float const yline_length,98 (RenderTarget & dst, std::vector<uint32_t> const * dataset,
99 uint32_t const highest_scale, float const sub, RGBColor const color, int32_t yoffset);99 uint32_t const highest_scale, float const sub, RGBColor const color, int32_t yoffset);
100 uint32_t get_plot_time();100 uint32_t get_plot_time() const;
101 /// Recalculates the data101 /// Recalculates the data
102 virtual void update();102 virtual void update();
103 // Initializes relative_dataset and time scaling.
104 // Returns how many values will be aggregated when relative plotting
105 int32_t initialize_update();
103106
104 struct PlotData {107 struct PlotData {
105 const std::vector<uint32_t> * dataset;108 const std::vector<uint32_t> * absolute_data; // The absolute dataset
109 std::vector<uint32_t> * relative_data; // The relative dataset
106 bool showplot;110 bool showplot;
107 RGBColor plotcolor;111 RGBColor plotcolor;
108 };112 };
109 std::vector<PlotData> plotdata_;113 std::vector<PlotData> plotdata_;
110114
111 int32_t plotmode_;115 Plotmode plotmode_;
112 int32_t sample_rate_;116 uint32_t sample_rate_;
113117
114 /// Whether there has ben a data update since the last time that think() was executed118 /// Whether there has ben a data update since the last time that think() was executed
115 bool needs_update_;119 bool needs_update_;
@@ -117,15 +121,17 @@
117 uint32_t lastupdate_;121 uint32_t lastupdate_;
118122
119 /// For first updating and then plotting the data123 /// For first updating and then plotting the data
124 float const xline_length_;
125 float const yline_length_;
120 uint32_t time_ms_;126 uint32_t time_ms_;
121 uint32_t highest_scale_;127 uint32_t highest_scale_;
122 float sub_;128 float sub_;
123129
124private:130private:
125 uint32_t get_game_time();131 uint32_t get_game_time() const;
126132
127 TIME time_; // How much do you want to list133 TIME time_; // How much do you want to list
128 int32_t game_time_id_; // what label is used for TIME_GAME134 uint32_t game_time_id_; // what label is used for TIME_GAME
129};135};
130136
131/**137/**
@@ -161,7 +167,7 @@
161167
162private:168private:
163 WuiPlotArea & plot_area_;169 WuiPlotArea & plot_area_;
164 int32_t last_game_time_id_;170 uint32_t last_game_time_id_;
165};171};
166172
167/**173/**
@@ -172,7 +178,8 @@
172struct DifferentialPlotArea : public WuiPlotArea {178struct DifferentialPlotArea : public WuiPlotArea {
173public:179public:
174 DifferentialPlotArea180 DifferentialPlotArea
175 (UI::Panel * parent, int32_t x, int32_t y, int32_t w, int32_t h);181 (UI::Panel * parent, int32_t x, int32_t y, int32_t w, int32_t h,
182 uint32_t sample_rate, Plotmode plotmode);
176183
177 void draw(RenderTarget &) override;184 void draw(RenderTarget &) override;
178185
@@ -184,13 +191,14 @@
184 void update() override;191 void update() override;
185192
186private:193private:
187
188 /**194 /**
189 * for the negative plotdata only the values matter. The color and195 * For the negative plotdata, only the values matter. The color and
190 * visibility is determined by the normal plotdata.196 * visibility is determined by the normal plotdata.
197 * We don't need relative data to fill - this is also done in the
198 * normal plotdata
191 */199 */
192 struct ReducedPlotData {200 struct ReducedPlotData {
193 const std::vector<uint32_t> * dataset;201 const std::vector<uint32_t> * absolute_data;
194 };202 };
195 std::vector<ReducedPlotData> negative_plotdata_;203 std::vector<ReducedPlotData> negative_plotdata_;
196};204};
197205
=== modified file 'src/wui/ware_statistics_menu.cc'
--- src/wui/ware_statistics_menu.cc 2016-03-30 07:20:05 +0000
+++ src/wui/ware_statistics_menu.cc 2016-06-10 17:28:35 +0000
@@ -164,9 +164,9 @@
164 plot_production_ =164 plot_production_ =
165 new WuiPlotArea165 new WuiPlotArea
166 (tabs,166 (tabs,
167 0, 0, kPlotWidth, kPlotHeight + kSpacing);167 0, 0, kPlotWidth, kPlotHeight + kSpacing,
168 plot_production_->set_sample_rate(STATISTICS_SAMPLE_TIME);168 kStatisticsSampleTime,
169 plot_production_->set_plotmode(WuiPlotArea::PLOTMODE_RELATIVE);169 WuiPlotArea::Plotmode::kRelative);
170170
171 tabs->add171 tabs->add
172 ("production", g_gr->images().get(pic_tab_production),172 ("production", g_gr->images().get(pic_tab_production),
@@ -175,9 +175,9 @@
175 plot_consumption_ =175 plot_consumption_ =
176 new WuiPlotArea176 new WuiPlotArea
177 (tabs,177 (tabs,
178 0, 0, kPlotWidth, kPlotHeight + kSpacing);178 0, 0, kPlotWidth, kPlotHeight + kSpacing,
179 plot_consumption_->set_sample_rate(STATISTICS_SAMPLE_TIME);179 kStatisticsSampleTime,
180 plot_consumption_->set_plotmode(WuiPlotArea::PLOTMODE_RELATIVE);180 WuiPlotArea::Plotmode::kRelative);
181181
182 tabs->add182 tabs->add
183 ("consumption", g_gr->images().get(pic_tab_consumption),183 ("consumption", g_gr->images().get(pic_tab_consumption),
@@ -186,9 +186,9 @@
186 plot_economy_ =186 plot_economy_ =
187 new DifferentialPlotArea187 new DifferentialPlotArea
188 (tabs,188 (tabs,
189 0, 0, kPlotWidth, kPlotHeight + kSpacing);189 0, 0, kPlotWidth, kPlotHeight + kSpacing,
190 plot_economy_->set_sample_rate(STATISTICS_SAMPLE_TIME);190 kStatisticsSampleTime,
191 plot_economy_->set_plotmode(WuiPlotArea::PLOTMODE_RELATIVE);191 WuiPlotArea::Plotmode::kRelative);
192192
193 tabs->add193 tabs->add
194 ("economy_health", g_gr->images().get(pic_tab_economy),194 ("economy_health", g_gr->images().get(pic_tab_economy),
@@ -196,9 +196,9 @@
196196
197 plot_stock_ = new WuiPlotArea197 plot_stock_ = new WuiPlotArea
198 (tabs,198 (tabs,
199 0, 0, kPlotWidth, kPlotHeight + kSpacing);199 0, 0, kPlotWidth, kPlotHeight + kSpacing,
200 plot_stock_->set_sample_rate(STATISTICS_SAMPLE_TIME);200 kStatisticsSampleTime,
201 plot_stock_->set_plotmode(WuiPlotArea::PLOTMODE_ABSOLUTE);201 WuiPlotArea::Plotmode::kAbsolute);
202202
203 tabs->add203 tabs->add
204 ("stock", g_gr->images().get(pic_tab_stock),204 ("stock", g_gr->images().get(pic_tab_stock),

Subscribers

People subscribed via source and target branches

to status/vote changes: