Commit 79f45db2 authored by twanvl's avatar twanvl

Some more statistics tweaks;

Another minor fix for alignment of sorted columns
parent c06e2254
...@@ -1044,6 +1044,18 @@ statistics category: ...@@ -1044,6 +1044,18 @@ statistics category:
dimension: card color dimension: card color
dimension: converted mana cost dimension: converted mana cost
statistics category:
name: color / colored cost
type: scatter
dimension: card color
dimension: colored mana cost
statistics category:
name: cost / colored cost
type: scatter
dimension: converted mana cost
dimension: colored mana cost
#statistics field: #statistics field:
# name: creature type # name: creature type
# data 1: # data 1:
......
...@@ -209,10 +209,7 @@ void CardListBase::rebuild() { ...@@ -209,10 +209,7 @@ void CardListBase::rebuild() {
// we are sorting by this column // we are sorting by this column
sort_by_column = i; sort_by_column = i;
// and display an arrow in the header // and display an arrow in the header
wxListItem li; SetColumnImage(i, sort_ascending ? 0 : 1);
li.m_mask = wxLIST_MASK_IMAGE;
li.m_image = sort_ascending ? 0 : 1; // arrow up/down
SetColumn(i, li);
} }
++i; ++i;
} }
......
...@@ -224,9 +224,9 @@ void BarGraph::draw(RotatedDC& dc, int current, DrawLayer layer) const { ...@@ -224,9 +224,9 @@ void BarGraph::draw(RotatedDC& dc, int current, DrawLayer layer) const {
RealRect bar = bar_graph_bar(rect, current, count, 0, group.size, axis.max); RealRect bar = bar_graph_bar(rect, current, count, 0, group.size, axis.max);
dc.SetPen(*wxTRANSPARENT_PEN); dc.SetPen(*wxTRANSPARENT_PEN);
dc.SetBrush(lerp(bg, group.color, 0.25)); dc.SetBrush(lerp(bg, group.color, 0.25));
dc.DrawRectangle(bar.move(-5,-5,10,10)); dc.DrawRectangle(bar.move(-5,-5,10,5));
dc.SetBrush(lerp(bg, group.color, 0.5)); dc.SetBrush(lerp(bg, group.color, 0.5));
dc.DrawRectangle(bar.move(-2,-2,4,4)); dc.DrawRectangle(bar.move(-2,-2,4,2));
} }
} else if (layer == LAYER_VALUES) { } else if (layer == LAYER_VALUES) {
// Draw bars // Draw bars
...@@ -406,8 +406,8 @@ void ScatterGraph::draw(RotatedDC& dc, const vector<int>& current, DrawLayer lay ...@@ -406,8 +406,8 @@ void ScatterGraph::draw(RotatedDC& dc, const vector<int>& current, DrawLayer lay
RealSize size(rect.width / axis1.groups.size(), rect.height / axis2.groups.size()); // size for a single cell RealSize size(rect.width / axis1.groups.size(), rect.height / axis2.groups.size()); // size for a single cell
double step = min(size.width, size.height) / sqrt((double)max_value) / 2.01; double step = min(size.width, size.height) / sqrt((double)max_value) / 2.01;
// Draw // Draw
dc.SetPen(*wxTRANSPARENT_PEN);
if (layer == LAYER_SELECTION) { if (layer == LAYER_SELECTION) {
dc.SetPen(*wxTRANSPARENT_PEN);
Color bg = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW); Color bg = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
int cur1 = this->axis1 < current.size() ? current[this->axis1] : -1; int cur1 = this->axis1 < current.size() ? current[this->axis1] : -1;
int cur2 = this->axis2 < current.size() ? current[this->axis2] : -1; int cur2 = this->axis2 < current.size() ? current[this->axis2] : -1;
...@@ -425,6 +425,8 @@ void ScatterGraph::draw(RotatedDC& dc, const vector<int>& current, DrawLayer lay ...@@ -425,6 +425,8 @@ void ScatterGraph::draw(RotatedDC& dc, const vector<int>& current, DrawLayer lay
dc.DrawRectangle(RealRect(rect.x, rect.bottom() - (cur2+1) * size.height, rect.width, size.height)); dc.DrawRectangle(RealRect(rect.x, rect.bottom() - (cur2+1) * size.height, rect.width, size.height));
} }
} else { } else {
Color fg = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
dc.SetPen(fg);
size_t i = 0; size_t i = 0;
double x = rect.left(); double x = rect.left();
FOR_EACH_CONST(g1, axis1.groups) { FOR_EACH_CONST(g1, axis1.groups) {
...@@ -475,9 +477,24 @@ void GraphLabelAxis::draw(RotatedDC& dc, int current, DrawLayer layer) const { ...@@ -475,9 +477,24 @@ void GraphLabelAxis::draw(RotatedDC& dc, int current, DrawLayer layer) const {
int count = int(axis.groups.size()); int count = int(axis.groups.size());
// Draw // Draw
dc.SetFont(*wxNORMAL_FONT); dc.SetFont(*wxNORMAL_FONT);
if (layer == LAYER_SELECTION) { Color bg = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
Color fg = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
if (layer == LAYER_SELECTION && current >= 0) {
// highlight selection // highlight selection
} else if (layer != LAYER_AXES) { GraphGroup& group = axis.groups[current];
if (direction == HORIZONTAL) {
double width = rect.width / count; // width of an item
dc.SetBrush(lerp(bg,group.color,0.5));
dc.SetPen(*wxTRANSPARENT_PEN);
RealSize text_size = dc.GetTextExtent(group.name);
dc.DrawRectangle(RealRect(rect.x + current * width, rect.bottom(), width, text_size.height + 5));
} else {
double height = rect.height / count;
dc.SetBrush(lerp(bg,group.color,0.5));
dc.SetPen(*wxTRANSPARENT_PEN);
dc.DrawRectangle(RealRect(rect.x, rect.bottom() - (current+1)*height, -78, height));
}
} else if (layer == LAYER_AXES) {
if (direction == HORIZONTAL) { if (direction == HORIZONTAL) {
double width = rect.width / count; // width of an item double width = rect.width / count; // width of an item
// Draw labels // Draw labels
...@@ -491,11 +508,9 @@ void GraphLabelAxis::draw(RotatedDC& dc, int current, DrawLayer layer) const { ...@@ -491,11 +508,9 @@ void GraphLabelAxis::draw(RotatedDC& dc, int current, DrawLayer layer) const {
x += width; x += width;
} }
// Draw lines // Draw lines
Color bg = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
Color fg = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
if (draw_lines) { if (draw_lines) {
dc.SetPen(lerp(bg, fg, 0.5));
for (int i = 0 ; i < count ; ++i) { for (int i = 0 ; i < count ; ++i) {
dc.SetPen(i == current ? fg : lerp(bg, fg, 0.3));
if (draw_lines == DRAW_LINES_BETWEEN) { if (draw_lines == DRAW_LINES_BETWEEN) {
dc.DrawLine(RealPoint(rect.x + (i+1.0)*width, rect.top()), RealPoint(rect.x + (i+1.0)*width, rect.bottom())); dc.DrawLine(RealPoint(rect.x + (i+1.0)*width, rect.top()), RealPoint(rect.x + (i+1.0)*width, rect.bottom()));
} else { } else {
...@@ -507,11 +522,11 @@ void GraphLabelAxis::draw(RotatedDC& dc, int current, DrawLayer layer) const { ...@@ -507,11 +522,11 @@ void GraphLabelAxis::draw(RotatedDC& dc, int current, DrawLayer layer) const {
dc.SetPen(fg); dc.SetPen(fg);
dc.DrawLine(rect.topLeft(), rect.bottomLeft()); dc.DrawLine(rect.topLeft(), rect.bottomLeft());
} else { } else {
double height = rect.height / count; // width of an item double height = rect.height / count;
// Draw labels // Draw labels
double y = rect.bottom(); double y = rect.bottom();
FOR_EACH_CONST(g, axis.groups) { FOR_EACH_CONST(g, axis.groups) {
// draw label, aligned bottom center // draw label, aligned middle right
RealSize text_size = dc.GetTextExtent(g.name); RealSize text_size = dc.GetTextExtent(g.name);
//dc.SetClippingRegion(RealRect(x + 2, rect.bottom() + 3, width - 4, text_size.height)); //dc.SetClippingRegion(RealRect(x + 2, rect.bottom() + 3, width - 4, text_size.height));
dc.DrawText(g.name, align_in_rect(ALIGN_MIDDLE_RIGHT, text_size, RealRect(-4, y, 0, -height))); dc.DrawText(g.name, align_in_rect(ALIGN_MIDDLE_RIGHT, text_size, RealRect(-4, y, 0, -height)));
...@@ -519,11 +534,9 @@ void GraphLabelAxis::draw(RotatedDC& dc, int current, DrawLayer layer) const { ...@@ -519,11 +534,9 @@ void GraphLabelAxis::draw(RotatedDC& dc, int current, DrawLayer layer) const {
y -= height; y -= height;
} }
// Draw lines // Draw lines
Color bg = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
Color fg = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
if (draw_lines) { if (draw_lines) {
dc.SetPen(lerp(bg, fg, 0.5));
for (int i = 0 ; i < count ; ++i) { for (int i = 0 ; i < count ; ++i) {
dc.SetPen(i == current ? fg : lerp(bg, fg, 0.3));
if (draw_lines == DRAW_LINES_BETWEEN) { if (draw_lines == DRAW_LINES_BETWEEN) {
dc.DrawLine(RealPoint(rect.left(), rect.bottom() - (i+1.0)*height), RealPoint(rect.right(), rect.bottom() - (i+1.0)*height)); dc.DrawLine(RealPoint(rect.left(), rect.bottom() - (i+1.0)*height), RealPoint(rect.right(), rect.bottom() - (i+1.0)*height));
} else { } else {
...@@ -561,21 +574,39 @@ void GraphValueAxis::draw(RotatedDC& dc, int current, DrawLayer layer) const { ...@@ -561,21 +574,39 @@ void GraphValueAxis::draw(RotatedDC& dc, int current, DrawLayer layer) const {
GraphAxis& axis = axis_data(); GraphAxis& axis = axis_data();
double step_height = rect.height / axis.max; // height of a single value double step_height = rect.height / axis.max; // height of a single value
dc.SetFont(*wxNORMAL_FONT); dc.SetFont(*wxNORMAL_FONT);
UInt label_step = (UInt)floor(max(1.0, (dc.GetCharHeight() + 1) / step_height)); // values per labeled line int label_step = ceil(max(1.0, (dc.GetCharHeight()) / step_height)); // values per labeled line
// Colors // Colors
Color bg = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW); Color bg = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
Color fg = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT); Color fg = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
// Draw backlines (horizontal) and value labels // Draw backlines (horizontal) and value labels
dc.SetPen(lerp(bg, fg, 0.5)); dc.SetPen(lerp(bg, fg, 0.3));
for (UInt i = 0 ; i <= axis.max ; ++i) { int highlight = current >= 0 ? (int)axis.groups[current].size : -1;
if (i % label_step == 0) { for (int i = 0 ; i <= (int)axis.max ; ++i) {
if (i % label_step == 0 || i == highlight) {
// highlight?
if (i == highlight) {
wxFont font(*wxNORMAL_FONT);
font.SetWeight(wxBOLD);
dc.SetFont(font);
dc.SetPen(fg);
}
// draw line
int y = rect.bottom() - i * step_height; int y = rect.bottom() - i * step_height;
dc.DrawLine(RealPoint(rect.left() - 2, y), RealPoint(rect.right(), y)); dc.DrawLine(RealPoint(rect.left() - 2, y), RealPoint(rect.right(), y));
// draw label, aligned middle right // draw label, aligned middle right
if (! ((i < highlight && i + label_step > highlight) ||
(i > highlight && i - label_step < highlight)) || current == -1) {
// don't draw labels before/after current to make room
String label; label << i; String label; label << i;
RealSize text_size = dc.GetTextExtent(label); RealSize text_size = dc.GetTextExtent(label);
dc.DrawText(label, align_in_rect(ALIGN_MIDDLE_RIGHT, text_size, RealRect(rect.x - 4, y, 0, 0))); dc.DrawText(label, align_in_rect(ALIGN_MIDDLE_RIGHT, text_size, RealRect(rect.x - 4, y, 0, 0)));
} }
// restore font/pen
if (i == highlight) {
dc.SetFont(*wxNORMAL_FONT);
dc.SetPen(lerp(bg, fg, 0.5));
}
}
} }
// Draw axis // Draw axis
dc.SetPen(fg); dc.SetPen(fg);
......
...@@ -69,6 +69,8 @@ class ItemList : public wxListView { ...@@ -69,6 +69,8 @@ class ItemList : public wxListView {
void sortBy(long column, bool ascending); void sortBy(long column, bool ascending);
/// Refresh the card list (resort, refresh and reselect current item) /// Refresh the card list (resort, refresh and reselect current item)
void refreshList(); void refreshList();
/// Set the image of a column header (fixes wx bug)
void SetColumnImage(int col, int image);
/// Select an item, send an event to the parent /// Select an item, send an event to the parent
/** If focus then the item is also focused and selected in the actual control. /** If focus then the item is also focused and selected in the actual control.
...@@ -92,8 +94,6 @@ class ItemList : public wxListView { ...@@ -92,8 +94,6 @@ class ItemList : public wxListView {
private: private:
struct ItemComparer; // for comparing items struct ItemComparer; // for comparing items
void SetColumnImage(int col, int image);
// --------------------------------------------------- : Window events // --------------------------------------------------- : Window events
DECLARE_EVENT_TABLE(); DECLARE_EVENT_TABLE();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment