<commit_before>/***************************************************************
 * Name:      tankkausApp.h
 * Purpose:   Defines Application Class
 * Author:    Kaprot ()
 * Created:   2015-09-19
 * Copyright: Kaprot ()
 * License:   MIT
 * **************************************************************/

#include "tankkausMain.h"
#include <wx/msgdlg.h>
#include <wx/textfile.h>
#include <wx/dir.h>
//#include <wx/dc.h>
#include <wx/dcclient.h>
#include <wx/dynarray.h>
#include <wx/textdlg.h>
#define  STORE_LABEL  "Store"
#define  NEW_VEHICLE_LABEL  "New Vehicle"

//(*InternalHeaders(tankkausDialog)
#include <wx/string.h>
#include <wx/intl.h>
//*)

//helper functions
enum wxbuildinfoformat {
    short_f, long_f };

wxString wxbuildinfo(wxbuildinfoformat format)
{
    wxString wxbuild(wxVERSION_STRING);

    if (format == long_f )
    {
#if defined(__WXMSW__)
        wxbuild << _T("-Windows");
#elif defined(__UNIX__)
        wxbuild << _T("-Linux");
#endif

#if wxUSE_UNICODE
        wxbuild << _T("-Unicode build");
#else
        wxbuild << _T("-ANSI build");
#endif // wxUSE_UNICODE
    }

    return wxbuild;
}

//(*IdInit(tankkausDialog)
const long tankkausDialog::ID_PANEL1 = wxNewId();
const long tankkausDialog::ID_COMBOBOX1 = wxNewId();
const long tankkausDialog::ID_DATEPICKERCTRL1 = wxNewId();
const long tankkausDialog::ID_TEXTCTRL1 = wxNewId();
const long tankkausDialog::ID_TEXTCTRL2 = wxNewId();
const long tankkausDialog::ID_BUTTON3 = wxNewId();
const long tankkausDialog::ID_BUTTON1 = wxNewId();
const long tankkausDialog::ID_BUTTON2 = wxNewId();
const long tankkausDialog::ID_CHECKBOX1 = wxNewId();
const long tankkausDialog::ID_SLIDER1 = wxNewId();
//*)

BEGIN_EVENT_TABLE(tankkausDialog,wxDialog)
    //(*EventTable(tankkausDialog)
    //*)
END_EVENT_TABLE()
void tankkausDialog::UpdateCarList()
{
    wxString filename;
    wxDir dir(wxGetCwd());
    carsComboBox->Clear();
    bool cont = dir.GetFirst(&filename, wxEmptyString, wxDIR_DIRS | wxDIR_FILES);
    while ( cont )
        {
        //printf("%s\n", filename.c_str());
        if (filename.EndsWith(".csv"))carsComboBox->Append(filename);
        cont = dir.GetNext(&filename);
        //
        }
}
tankkausDialog::tankkausDialog(wxWindow* parent,wxWindowID id)
{
    //(*Initialize(tankkausDialog)
    wxBoxSizer* BoxSizer3;

    Create(parent, wxID_ANY, _("Tankkaus"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE, _T("wxID_ANY"));
    SetClientSize(wxSize(661,310));
    BoxSizer1 = new wxBoxSizer(wxHORIZONTAL);
    Panel1 = new wxPanel(this, ID_PANEL1, wxDefaultPosition, wxSize(366,300), wxTAB_TRAVERSAL, _T("ID_PANEL1"));
    BoxSizer1->Add(Panel1, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
    BoxSizer3 = new wxBoxSizer(wxVERTICAL);
    carsComboBox = new wxComboBox(this, ID_COMBOBOX1, wxEmptyString, wxDefaultPosition, wxSize(140,29), 0, 0, 0, wxDefaultValidator, _T("ID_COMBOBOX1"));
    BoxSizer3->Add(carsComboBox, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 1);
    DatePickerCtrl1 = new wxDatePickerCtrl(this, ID_DATEPICKERCTRL1, wxDefaultDateTime, wxDefaultPosition, wxSize(140,29), wxDP_DEFAULT|wxDP_SHOWCENTURY, wxDefaultValidator, _T("ID_DATEPICKERCTRL1"));
    BoxSizer3->Add(DatePickerCtrl1, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 1);
    txtLiter = new wxTextCtrl(this, ID_TEXTCTRL1, wxEmptyString, wxDefaultPosition, wxSize(140,29), 0, wxDefaultValidator, _T("ID_TEXTCTRL1"));
    txtLiter->SetToolTip(_("Liter"));
    txtLiter->SetHelpText(_("Liter"));
    BoxSizer3->Add(txtLiter, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 1);
    txtKm = new wxTextCtrl(this, ID_TEXTCTRL2, wxEmptyString, wxDefaultPosition, wxSize(140,29), 0, wxDefaultValidator, _T("ID_TEXTCTRL2"));
    txtKm->SetToolTip(_("Km"));
    txtKm->SetHelpText(_("Km"));
    BoxSizer3->Add(txtKm, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 1);
    btnStore = new wxButton(this, ID_BUTTON3, _(" New Vehicle"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON3"));
    BoxSizer3->Add(btnStore, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 1);
    Button1 = new wxButton(this, ID_BUTTON1, _("About"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON1"));
    BoxSizer3->Add(Button1, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 1);
    Button2 = new wxButton(this, ID_BUTTON2, _("Quit"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON2"));
    BoxSizer3->Add(Button2, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 1);
    tripMeterCheck = new wxCheckBox(this, ID_CHECKBOX1, _("No Trip Meter"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_CHECKBOX1"));
    tripMeterCheck->SetValue(true);
    BoxSizer3->Add(tripMeterCheck, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 1);
    Slider1 = new wxSlider(this, ID_SLIDER1, 0, 0, 100, wxDefaultPosition, wxSize(140,29), 0, wxDefaultValidator, _T("ID_SLIDER1"));
    BoxSizer3->Add(Slider1, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 1);
    BoxSizer1->Add(BoxSizer3, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
    SetSizer(BoxSizer1);
    SetSizer(BoxSizer1);
    Layout();

    Panel1->Connect(wxEVT_PAINT,(wxObjectEventFunction)&tankkausDialog::OnPanel1Paint,0,this);
    Connect(ID_COMBOBOX1,wxEVT_COMMAND_COMBOBOX_SELECTED,(wxObjectEventFunction)&tankkausDialog::OnComboBox1Selected);
    Connect(ID_TEXTCTRL1,wxEVT_COMMAND_TEXT_UPDATED,(wxObjectEventFunction)&tankkausDialog::OntxtLiterText);
    Connect(ID_TEXTCTRL2,wxEVT_COMMAND_TEXT_UPDATED,(wxObjectEventFunction)&tankkausDialog::OntxtKmText);
    Connect(ID_BUTTON3,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&tankkausDialog::OnbtnStoreClick);
    Connect(ID_BUTTON1,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&tankkausDialog::OnAbout);
    Connect(ID_BUTTON2,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&tankkausDialog::OnQuit);
    Connect(ID_SLIDER1,wxEVT_SCROLL_TOP|wxEVT_SCROLL_BOTTOM|wxEVT_SCROLL_LINEUP|wxEVT_SCROLL_LINEDOWN|wxEVT_SCROLL_PAGEUP|wxEVT_SCROLL_PAGEDOWN|wxEVT_SCROLL_THUMBTRACK|wxEVT_SCROLL_THUMBRELEASE|wxEVT_SCROLL_CHANGED,(wxObjectEventFunction)&tankkausDialog::OnSlider1CmdScroll1);
    Connect(ID_SLIDER1,wxEVT_SCROLL_CHANGED,(wxObjectEventFunction)&tankkausDialog::OnSlider1CmdScroll1);
    //*)

    UpdateCarList();
    //float cons[32000];
    //int dates[32000];
    //float kmBefore=0;
}

tankkausDialog::~tankkausDialog()
{
    //(*Destroy(tankkausDialog)
    //*)
}

void tankkausDialog::OnQuit(wxCommandEvent& event)
{
    Close();
}

void tankkausDialog::OnAbout(wxCommandEvent& event)
{
    wxString msg = _("Tankkaus\n") + wxbuildinfo(long_f);
    wxMessageBox(msg, _("Tankkaus"));
}
float processLine (wxString txtLine,float *cons,int *dates,int *counter,float kmBefore=0)<commit_msg>btnStore is set to NEW_VEHICLE_LABEL in class constructor<commit_after>/***************************************************************
 * Name:      tankkausApp.h
 * Purpose:   Defines Application Class
 * Author:    Kaprot ()
 * Created:   2015-09-19
 * Copyright: Kaprot ()
 * License:   MIT
 * **************************************************************/

#include "tankkausMain.h"
#include <wx/msgdlg.h>
#include <wx/textfile.h>
#include <wx/dir.h>
//#include <wx/dc.h>
#include <wx/dcclient.h>
#include <wx/dynarray.h>
#include <wx/textdlg.h>
#define  STORE_LABEL  "Store"
#define  NEW_VEHICLE_LABEL  "New Vehicle"

//(*InternalHeaders(tankkausDialog)
#include <wx/string.h>
#include <wx/intl.h>
//*)

//helper functions
enum wxbuildinfoformat {
    short_f, long_f };

wxString wxbuildinfo(wxbuildinfoformat format)
{
    wxString wxbuild(wxVERSION_STRING);

    if (format == long_f )
    {
#if defined(__WXMSW__)
        wxbuild << _T("-Windows");
#elif defined(__UNIX__)
        wxbuild << _T("-Linux");
#endif

#if wxUSE_UNICODE
        wxbuild << _T("-Unicode build");
#else
        wxbuild << _T("-ANSI build");
#endif // wxUSE_UNICODE
    }

    return wxbuild;
}

//(*IdInit(tankkausDialog)
const long tankkausDialog::ID_PANEL1 = wxNewId();
const long tankkausDialog::ID_COMBOBOX1 = wxNewId();
const long tankkausDialog::ID_DATEPICKERCTRL1 = wxNewId();
const long tankkausDialog::ID_TEXTCTRL1 = wxNewId();
const long tankkausDialog::ID_TEXTCTRL2 = wxNewId();
const long tankkausDialog::ID_BUTTON3 = wxNewId();
const long tankkausDialog::ID_BUTTON1 = wxNewId();
const long tankkausDialog::ID_BUTTON2 = wxNewId();
const long tankkausDialog::ID_CHECKBOX1 = wxNewId();
const long tankkausDialog::ID_SLIDER1 = wxNewId();
//*)

BEGIN_EVENT_TABLE(tankkausDialog,wxDialog)
    //(*EventTable(tankkausDialog)
    //*)
END_EVENT_TABLE()
void tankkausDialog::UpdateCarList()
{
    wxString filename;
    wxDir dir(wxGetCwd());
    carsComboBox->Clear();
    bool cont = dir.GetFirst(&filename, wxEmptyString, wxDIR_DIRS | wxDIR_FILES);
    while ( cont )
        {
        //printf("%s\n", filename.c_str());
        if (filename.EndsWith(".csv"))carsComboBox->Append(filename);
        cont = dir.GetNext(&filename);
        //
        }
}
tankkausDialog::tankkausDialog(wxWindow* parent,wxWindowID id)
{
    //(*Initialize(tankkausDialog)
    wxBoxSizer* BoxSizer3;

    Create(parent, wxID_ANY, _("Tankkaus"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE, _T("wxID_ANY"));
    SetClientSize(wxSize(661,310));
    BoxSizer1 = new wxBoxSizer(wxHORIZONTAL);
    Panel1 = new wxPanel(this, ID_PANEL1, wxDefaultPosition, wxSize(366,300), wxTAB_TRAVERSAL, _T("ID_PANEL1"));
    BoxSizer1->Add(Panel1, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
    BoxSizer3 = new wxBoxSizer(wxVERTICAL);
    carsComboBox = new wxComboBox(this, ID_COMBOBOX1, wxEmptyString, wxDefaultPosition, wxSize(140,29), 0, 0, 0, wxDefaultValidator, _T("ID_COMBOBOX1"));
    BoxSizer3->Add(carsComboBox, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 1);
    DatePickerCtrl1 = new wxDatePickerCtrl(this, ID_DATEPICKERCTRL1, wxDefaultDateTime, wxDefaultPosition, wxSize(140,29), wxDP_DEFAULT|wxDP_SHOWCENTURY, wxDefaultValidator, _T("ID_DATEPICKERCTRL1"));
    BoxSizer3->Add(DatePickerCtrl1, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 1);
    txtLiter = new wxTextCtrl(this, ID_TEXTCTRL1, wxEmptyString, wxDefaultPosition, wxSize(140,29), 0, wxDefaultValidator, _T("ID_TEXTCTRL1"));
    txtLiter->SetToolTip(_("Liter"));
    txtLiter->SetHelpText(_("Liter"));
    BoxSizer3->Add(txtLiter, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 1);
    txtKm = new wxTextCtrl(this, ID_TEXTCTRL2, wxEmptyString, wxDefaultPosition, wxSize(140,29), 0, wxDefaultValidator, _T("ID_TEXTCTRL2"));
    txtKm->SetToolTip(_("Km"));
    txtKm->SetHelpText(_("Km"));
    BoxSizer3->Add(txtKm, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 1);
    btnStore = new wxButton(this, ID_BUTTON3, _(" New Vehicle"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON3"));
    BoxSizer3->Add(btnStore, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 1);
    Button1 = new wxButton(this, ID_BUTTON1, _("About"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON1"));
    BoxSizer3->Add(Button1, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 1);
    Button2 = new wxButton(this, ID_BUTTON2, _("Quit"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON2"));
    BoxSizer3->Add(Button2, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 1);
    tripMeterCheck = new wxCheckBox(this, ID_CHECKBOX1, _("No Trip Meter"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_CHECKBOX1"));
    tripMeterCheck->SetValue(true);
    BoxSizer3->Add(tripMeterCheck, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 1);
    Slider1 = new wxSlider(this, ID_SLIDER1, 0, 0, 100, wxDefaultPosition, wxSize(140,29), 0, wxDefaultValidator, _T("ID_SLIDER1"));
    BoxSizer3->Add(Slider1, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 1);
    BoxSizer1->Add(BoxSizer3, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
    SetSizer(BoxSizer1);
    SetSizer(BoxSizer1);
    Layout();

    Panel1->Connect(wxEVT_PAINT,(wxObjectEventFunction)&tankkausDialog::OnPanel1Paint,0,this);
    Connect(ID_COMBOBOX1,wxEVT_COMMAND_COMBOBOX_SELECTED,(wxObjectEventFunction)&tankkausDialog::OnComboBox1Selected);
    Connect(ID_TEXTCTRL1,wxEVT_COMMAND_TEXT_UPDATED,(wxObjectEventFunction)&tankkausDialog::OntxtLiterText);
    Connect(ID_TEXTCTRL2,wxEVT_COMMAND_TEXT_UPDATED,(wxObjectEventFunction)&tankkausDialog::OntxtKmText);
    Connect(ID_BUTTON3,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&tankkausDialog::OnbtnStoreClick);
    Connect(ID_BUTTON1,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&tankkausDialog::OnAbout);
    Connect(ID_BUTTON2,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&tankkausDialog::OnQuit);
    Connect(ID_SLIDER1,wxEVT_SCROLL_TOP|wxEVT_SCROLL_BOTTOM|wxEVT_SCROLL_LINEUP|wxEVT_SCROLL_LINEDOWN|wxEVT_SCROLL_PAGEUP|wxEVT_SCROLL_PAGEDOWN|wxEVT_SCROLL_THUMBTRACK|wxEVT_SCROLL_THUMBRELEASE|wxEVT_SCROLL_CHANGED,(wxObjectEventFunction)&tankkausDialog::OnSlider1CmdScroll1);
    Connect(ID_SLIDER1,wxEVT_SCROLL_CHANGED,(wxObjectEventFunction)&tankkausDialog::OnSlider1CmdScroll1);
    //*)

    UpdateCarList();
    btnStore->SetLabel(NEW_VEHICLE_LABEL);
    //float cons[32000];
    //int dates[32000];
    //float kmBefore=0;
}

tankkausDialog::~tankkausDialog()
{
    //(*Destroy(tankkausDialog)
    //*)
}

void tankkausDialog::OnQuit(wxCommandEvent& event)
{
    Close();
}

void tankkausDialog::OnAbout(wxCommandEvent& event)
{
    wxString msg = _("Tankkaus\n") + wxbuildinfo(long_f);
    wxMessageBox(msg, _("Tankkaus"));
}
float processLine (wxString txtLine,float *cons,int *dates,int *counter,float kmBefore=0)
{'fraction_non_alphanumeric': 0.14509297149831288, 'fraction_numerical': 0.0239787493718142, 'mean_word_length': 6.612021857923497, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 60, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3693850', 'n_tokens_mistral': 5361, 'n_tokens_neox': 5281, 'n_words': 727}