Changeset 202 for trunk/src


Ignore:
Timestamp:
05/04/2009 12:22:36 PM (3 years ago)
Author:
guyru
Message:

Add simple histogram to statistics

Location:
trunk/src
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/Makefile.am

    r199 r202  
    1515        settings_dialog.h \ 
    1616        ScoreDice.cpp \ 
     17        simple_histogram.cpp \ 
    1718        statistics.cpp \ 
    1819        statistics_dialog.cpp \ 
     
    3435        MainFrame.h \ 
    3536        ScoreDice.h \ 
     37        simple_histogram.h \ 
    3638        statistics.h \ 
    3739        statistics_dialog.h \ 
  • trunk/src/statistics.cpp

    r201 r202  
    3434Statistics::Statistics(configuration::Configuration *backend) 
    3535{ 
     36        this->backend = backend; 
    3637        try { 
    3738                load_data(); 
     
    4546        string tmp; 
    4647        vector<string> tmp_vec; 
    47         this->backend = backend; 
    4848         
    4949        tmp = backend->get("statistics_games_started"); 
     
    5959 
    6060        BOOST_FOREACH(string i, tmp_vec) { 
    61                 score_distribution.push_back(atoi(i.c_str())); 
     61                _score_distribution.push_back(atoi(i.c_str())); 
    6262        } 
    6363 
     
    8282        score_slot = score/score_distribution_granuality; 
    8383        score_slot = score_slot<score_distributions_slots ? score_slot : score_slot; 
    84         score_distribution[score_slot]++; 
     84        _score_distribution[score_slot]++; 
    8585        save(); 
    8686} 
     
    9393 
    9494        tmp = ""; 
    95         BOOST_FOREACH(int i, score_distribution) { 
     95        BOOST_FOREACH(int i, _score_distribution) { 
    9696                tmp += stringify(i) + ","; 
    9797        } 
     
    108108        _last_reset = time(NULL); 
    109109 
    110         score_distribution = vector<int>(score_distributions_slots, 0); 
     110        _score_distribution = vector<int>(score_distributions_slots, 0); 
    111111         
    112112        save(); 
  • trunk/src/statistics.h

    r201 r202  
    4949        int games_finished() { return _games_finished; } 
    5050        time_t last_reset() { return _last_reset; } 
     51        std::vector<int> score_distribution() { return _score_distribution; } 
    5152 
    5253private: 
     
    6566        time_t _last_reset; 
    6667 
    67         std::vector<int> score_distribution; 
     68        std::vector<int> _score_distribution; 
    6869        configuration::Configuration *backend; 
    6970}; 
  • trunk/src/statistics_dialog.cpp

    r199 r202  
    4646        games_started = new wxStaticText(this, wxID_ANY, wxT("")); 
    4747        games_finished = new wxStaticText(this, wxID_ANY, wxT("")); 
     48        histogram = new SimpleHistogram(this, wxID_ANY); 
    4849        statistics_reset_date = new wxStaticText(this, wxID_ANY, wxT("")); 
    4950} 
     
    6162        tmp = wxT("Last reset: ") + reset_time.Format(); 
    6263        statistics_reset_date->SetLabel(tmp); 
     64 
     65        vector<int> score_dist = m_stats->score_distribution(); 
     66        vector<double> dist (score_dist.begin(), score_dist.end()); 
     67        histogram->SetData(dist); 
    6368} 
    6469 
     
    7176        game_counts->AddStretchSpacer(10); 
    7277        game_counts->Add(games_finished); 
    73         top_sizer->Add(game_counts,10,wxEXPAND); 
     78        top_sizer->Add(game_counts,0,wxEXPAND,10); 
    7479 
    7580        wxStaticBoxSizer* score_distribution = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, wxT("Score Distribution") ), wxHORIZONTAL); 
    76         top_sizer->Add(score_distribution,10,wxEXPAND); 
     81        score_distribution->Add(histogram, 1, wxEXPAND, 10); 
     82        top_sizer->Add(score_distribution,10,wxEXPAND, 10); 
    7783 
    78         top_sizer->Add(statistics_reset_date,10,wxEXPAND); 
     84        top_sizer->Add(statistics_reset_date,0,wxEXPAND,10); 
    7985         
    8086        wxBoxSizer *button_sizer = new wxBoxSizer( wxHORIZONTAL ); 
  • trunk/src/statistics_dialog.h

    r199 r202  
    2222 
    2323#include "statistics.h" 
     24#include "simple_histogram.h" 
    2425#include <wx/wx.h> 
    2526#include <wx/dialog.h> 
     
    4647        wxStaticText *games_finished; 
    4748        wxStaticText *statistics_reset_date; 
     49        SimpleHistogram* histogram; 
    4850 
    4951        statistics::Statistics* m_stats; 
Note: See TracChangeset for help on using the changeset viewer.