label tweaks

This commit is contained in:
David Rose 2004-01-08 18:31:52 +00:00
parent d1940ad800
commit efb973de26
7 changed files with 59 additions and 56 deletions

View File

@ -181,31 +181,35 @@ copy_region(int start_x, int end_x, int dest_x) {
// indicated level data.
////////////////////////////////////////////////////////////////////
void GtkStatsStripChart::
draw_slice(int x, int frame_number) {
draw_slice(int x, int w, int frame_number) {
const FrameData &frame = get_frame_data(frame_number);
// Start by clearing the band first.
_pixmap.draw_line(_white_gc, x, 0, x, get_ysize());
while (w > 0) {
// Start by clearing the band first.
_pixmap.draw_line(_white_gc, x, 0, x, get_ysize());
float overall_time = 0.0;
int y = get_ysize();
float overall_time = 0.0;
int y = get_ysize();
FrameData::const_iterator fi;
for (fi = frame.begin(); fi != frame.end(); ++fi) {
const ColorData &cd = (*fi);
overall_time += cd._net_value;
FrameData::const_iterator fi;
for (fi = frame.begin(); fi != frame.end(); ++fi) {
const ColorData &cd = (*fi);
overall_time += cd._net_value;
if (overall_time > get_vertical_scale()) {
// Off the top. Go ahead and clamp it by hand, in case it's so
// far off the top we'd overflow the 16-bit pixel value.
_pixmap.draw_line(get_collector_gc(cd._collector_index), x, y, x, 0);
// And we can consider ourselves done now.
return;
if (overall_time > get_vertical_scale()) {
// Off the top. Go ahead and clamp it by hand, in case it's so
// far off the top we'd overflow the 16-bit pixel value.
_pixmap.draw_line(get_collector_gc(cd._collector_index), x, y, x, 0);
// And we can consider ourselves done now.
break;
}
int top_y = height_to_pixel(overall_time);
_pixmap.draw_line(get_collector_gc(cd._collector_index), x, y, x, top_y);
y = top_y;
}
int top_y = height_to_pixel(overall_time);
_pixmap.draw_line(get_collector_gc(cd._collector_index), x, y, x, top_y);
y = top_y;
x++;
w--;
}
}
@ -215,8 +219,12 @@ draw_slice(int x, int frame_number) {
// Description: Draws a single vertical slice of background color.
////////////////////////////////////////////////////////////////////
void GtkStatsStripChart::
draw_empty(int x) {
_pixmap.draw_line(_white_gc, x, 0, x, get_ysize());
draw_empty(int x, int w) {
while (w > 0) {
_pixmap.draw_line(_white_gc, x, 0, x, get_ysize());
x++;
w--;
}
}
////////////////////////////////////////////////////////////////////

View File

@ -57,8 +57,8 @@ public:
private:
virtual void clear_region();
virtual void copy_region(int start_x, int end_x, int dest_x);
virtual void draw_slice(int x, int frame_number);
virtual void draw_empty(int x);
virtual void draw_slice(int x, int w, int frame_number);
virtual void draw_empty(int x, int w);
virtual void draw_cursor(int x);
virtual void end_draw(int from_x, int to_x);
virtual void idle();

View File

@ -185,21 +185,6 @@ format_number(float value, int guide_bar_units, const string &unit_name) {
return label;
}
// STL function object for sorting labels in order by the collector's
// sort index, used in update_labels(), below.
class SortCollectorLabels {
public:
SortCollectorLabels(const PStatClientData *client_data) :
_client_data(client_data) {
}
bool operator () (int a, int b) const {
return
_client_data->get_collector_def(a)._sort >
_client_data->get_collector_def(b)._sort;
}
const PStatClientData *_client_data;
};
////////////////////////////////////////////////////////////////////
// Function: PStatGraph::update_guide_bars
// Access: Protected

View File

@ -441,7 +441,7 @@ begin_draw(int, int) {
// and end_draw().
////////////////////////////////////////////////////////////////////
void PStatStripChart::
draw_slice(int, int) {
draw_slice(int, int, int) {
}
////////////////////////////////////////////////////////////////////
@ -452,7 +452,7 @@ draw_slice(int, int) {
// represent a portion of the chart that has no data.
////////////////////////////////////////////////////////////////////
void PStatStripChart::
draw_empty(int) {
draw_empty(int, int) {
}
////////////////////////////////////////////////////////////////////
@ -629,19 +629,26 @@ draw_pixels(int first_pixel, int last_pixel) {
const PStatThreadData *thread_data = _view.get_thread_data();
int frame_number = -1;
for (int x = first_pixel; x <= last_pixel; x++) {
int x = first_pixel;
while (x <= last_pixel) {
if (x == _cursor_pixel && !_scroll_mode) {
draw_cursor(x);
x++;
} else {
float time = pixel_to_timestamp(x);
frame_number = thread_data->get_frame_number_at_time(time, frame_number);
if (thread_data->has_frame(frame_number)) {
draw_slice(x, frame_number);
} else {
draw_empty(x);
int w = 1;
while (x + w <= last_pixel &&
thread_data->get_frame_number_at_time(pixel_to_timestamp(x + w), frame_number) == frame_number) {
w++;
}
if (thread_data->has_frame(frame_number)) {
draw_slice(x, w, frame_number);
} else {
draw_empty(x, w);
}
x += w;
}
}
end_draw(first_pixel, last_pixel);

View File

@ -95,8 +95,8 @@ protected:
virtual void clear_region();
virtual void copy_region(int start_x, int end_x, int dest_x);
virtual void begin_draw(int from_x, int to_x);
virtual void draw_slice(int x, int frame_number);
virtual void draw_empty(int x);
virtual void draw_slice(int x, int w, int frame_number);
virtual void draw_empty(int x, int w);
virtual void draw_cursor(int x);
virtual void end_draw(int from_x, int to_x);
virtual void idle();

View File

@ -136,7 +136,7 @@ copy_region(int start_x, int end_x, int dest_x) {
RECT rect = {
_left_margin + dest_x, _top_margin,
_left_margin + end_x - start_x, _top_margin + get_ysize()
_left_margin + dest_x + end_x - start_x, _top_margin + get_ysize()
};
InvalidateRect(_window, &rect, FALSE);
}
@ -149,11 +149,11 @@ copy_region(int start_x, int end_x, int dest_x) {
// indicated level data.
////////////////////////////////////////////////////////////////////
void WinStatsStripChart::
draw_slice(int x, int frame_number) {
draw_slice(int x, int w, int frame_number) {
const FrameData &frame = get_frame_data(frame_number);
// Start by clearing the band first.
RECT rect = { x, 0, x + 1, get_ysize() };
RECT rect = { x, 0, x + w, get_ysize() };
FillRect(_bitmap_dc, &rect, (HBRUSH)GetStockObject(WHITE_BRUSH));
float overall_time = 0.0;
@ -189,8 +189,8 @@ draw_slice(int x, int frame_number) {
// Description: Draws a single vertical slice of background color.
////////////////////////////////////////////////////////////////////
void WinStatsStripChart::
draw_empty(int x) {
RECT rect = { x, 0, x + 1, get_ysize() };
draw_empty(int x, int w) {
RECT rect = { x, 0, x + w, get_ysize() };
FillRect(_bitmap_dc, &rect, (HBRUSH)GetStockObject(WHITE_BRUSH));
}
@ -215,7 +215,10 @@ draw_cursor(int x) {
////////////////////////////////////////////////////////////////////
void WinStatsStripChart::
end_draw(int from_x, int to_x) {
RECT rect = { from_x, 0, to_x + 1, get_ysize() };
RECT rect = {
_left_margin + from_x, _top_margin,
_left_margin + to_x, _top_margin + get_ysize()
};
InvalidateRect(_window, &rect, FALSE);
}

View File

@ -47,8 +47,8 @@ protected:
virtual void clear_region();
virtual void copy_region(int start_x, int end_x, int dest_x);
virtual void draw_slice(int x, int frame_number);
virtual void draw_empty(int x);
virtual void draw_slice(int x, int w, int frame_number);
virtual void draw_empty(int x, int w);
virtual void draw_cursor(int x);
virtual void end_draw(int from_x, int to_x);