<commit_before>/*
 * Copyright (c) 2013 <NAME> (<EMAIL>)
 *
 * Distributed under the MIT License (MIT) (See accompanying file LICENSE.txt
 * or copy at http://opensource.org/licenses/MIT)
 */

#include "CalculationOutput.hpp"

using namespace pkmnsim;
using namespace std;

CalculationOutput::CalculationOutput(QWidget* parent, int gen): QWidget(parent)
{
    generation = gen;

    QVBoxLayout* mainLayout = new QVBoxLayout();

    QGroupBox* hpGroupBox = new QGroupBox(tr("HP"),this);
    hpGroupBox->setObjectName("hpGroupBox");
    QHBoxLayout* hpLayout = new QHBoxLayout(this);
    QLabel* hpEmptyLabel = new QLabel(tr("Press the Calculate button to show results."));
    hpLayout->addWidget(hpEmptyLabel);
    hpLayout->setAlignment(Qt::AlignCenter);
    
    QGroupBox* attackGroupBox = new QGroupBox(tr("Attack"),this);
    attackGroupBox->setObjectName("attackGroupBox");
    QHBoxLayout* attackLayout = new QHBoxLayout(this);
    QLabel* attackEmptyLabel = new QLabel(tr("Press the Calculate button to show results."));
    attackLayout->addWidget(attackEmptyLabel);
    attackLayout->setAlignment(Qt::AlignCenter);

    QGroupBox* defenseGroupBox = new QGroupBox(tr("Defense"),this);
    defenseGroupBox->setObjectName("defenseGroupBox");
    QHBoxLayout* defenseLayout = new QHBoxLayout(this);
    QLabel* defenseEmptyLabel = new QLabel(tr("Press the Calculate button to show results."));
    defenseLayout->addWidget(defenseEmptyLabel);
    defenseLayout->setAlignment(Qt::AlignCenter);

    QGroupBox* speedGroupBox = new QGroupBox(tr("Speed"),this);
    speedGroupBox->setObjectName("defenseGroupBox");
    QHBoxLayout* speedLayout = new QHBoxLayout(this);
    QLabel* speedEmptyLabel = new QLabel(tr("Press the Calculate button to show results."));
    speedLayout->addWidget(speedEmptyLabel);
    speedLayout->setAlignment(Qt::AlignCenter);

    hpGroupBox->setLayout(hpLayout);
    attackGroupBox->setLayout(attackLayout);
    defenseGroupBox->setLayout(defenseLayout);
    speedGroupBox->setLayout(speedLayout);
    
    mainLayout->addWidget(hpGroupBox);
    mainLayout->addWidget(attackGroupBox);
    mainLayout->addWidget(defenseGroupBox);
    mainLayout->addWidget(speedGroupBox);
    
    if(gen == 1)
    {
        QGroupBox* specialGroupBox = new QGroupBox(tr("Special"),this);
        specialGroupBox->setObjectName("specialGroupBox");
        QHBoxLayout* specialLayout = new QHBoxLayout(this);
        specialGroupBox->setLayout(specialLayout);
        QLabel* specialEmptyLabel = new QLabel(tr("Press the Calculate button to show results."));
        specialLayout->addWidget(specialEmptyLabel);
        specialLayout->setAlignment(Qt::AlignCenter);
        mainLayout->addWidget(specialGroupBox);
    }
    else
    {
        QGroupBox* specialAttackGroupBox = new QGroupBox(tr("Special Attack"),this);
        specialAttackGroupBox->setObjectName("specialAttackGroupBox");
        QHBoxLayout* specialAttackLayout = new QHBoxLayout(this);
        specialAttackGroupBox->setLayout(specialAttackLayout);
        QLabel* specialAttackEmptyLabel = new QLabel(tr("Press the Calculate button to show results."));
        specialAttackLayout->addWidget(specialAttackEmptyLabel);
        specialAttackLayout->setAlignment(Qt::AlignCenter);
        mainLayout->addWidget(specialAttackGroupBox);

        QGroupBox* specialDefenseGroupBox = new QGroupBox(tr("Special Defense"),this);
        specialDefenseGroupBox->setObjectName("specialDefenseGroupBox");
        QHBoxLayout* specialDefenseLayout = new QHBoxLayout(this);
        specialDefenseGroupBox->setLayout(specialDefenseLayout);
        QLabel* specialDefenseEmptyLabel = new QLabel(tr("Press the Calculate button to show results."));
        specialDefenseLayout->addWidget(specialDefenseEmptyLabel);
        specialDefenseLayout->setAlignment(Qt::AlignCenter);
        mainLayout->addWidget(specialDefenseGroupBox);
    }
    
    setLayout(mainLayout);
}

//Slot to call when results are calculated by OptionsGroupBox
void CalculationOutput::getAndShowResults(vector<vector<stat_st> > highest_stats_vecs,
                                          vector<vector<stat_st> > lowest_stats_vecs)
{
    vector<stat_st> high_vec = highest_stats_vecs[generation-1];
    vector<stat_st> low_vec = lowest_stats_vecs[generation-1];

    QList<QGroupBox*> groupBoxQList = this->findChildren<QGroupBox*>();
    for(int i = 0; i < groupBoxQList.count(); i++)
    {
        //Get rid of "Press the Calculate button..." QLabel if it's there
        QList<QLabel*> labelQList = groupBoxQList.at(i)->findChildren<QLabel*>();
        if(labelQList.count()) delete labelQList.at(0);
    }
    
    update();
}<commit_msg>get_type_stats_gui: Successfully updating for some combinations<commit_after>/*
 * Copyright (c) 2013 <NAME> (<EMAIL>)
 *
 * Distributed under the MIT License (MIT) (See accompanying file LICENSE.txt
 * or copy at http://opensource.org/licenses/MIT)
 */

#include "CalculationOutput.hpp"

using namespace pkmnsim;
using namespace std;

CalculationOutput::CalculationOutput(QWidget* parent, int gen): QWidget(parent)
{
    generation = gen;

    QVBoxLayout* mainLayout = new QVBoxLayout();

    QGroupBox* hpGroupBox = new QGroupBox(tr("HP"),this);
    hpGroupBox->setObjectName("hpGroupBox");
    QHBoxLayout* hpLayout = new QHBoxLayout(this);
    QLabel* hpEmptyLabel = new QLabel(tr("Press the Calculate button to show results."));
    hpLayout->addWidget(hpEmptyLabel);
    hpLayout->setAlignment(Qt::AlignCenter);
    
    QGroupBox* attackGroupBox = new QGroupBox(tr("Attack"),this);
    attackGroupBox->setObjectName("attackGroupBox");
    QHBoxLayout* attackLayout = new QHBoxLayout(this);
    QLabel* attackEmptyLabel = new QLabel(tr("Press the Calculate button to show results."));
    attackLayout->addWidget(attackEmptyLabel);
    attackLayout->setAlignment(Qt::AlignCenter);

    QGroupBox* defenseGroupBox = new QGroupBox(tr("Defense"),this);
    defenseGroupBox->setObjectName("defenseGroupBox");
    QHBoxLayout* defenseLayout = new QHBoxLayout(this);
    QLabel* defenseEmptyLabel = new QLabel(tr("Press the Calculate button to show results."));
    defenseLayout->addWidget(defenseEmptyLabel);
    defenseLayout->setAlignment(Qt::AlignCenter);

    QGroupBox* speedGroupBox = new QGroupBox(tr("Speed"),this);
    speedGroupBox->setObjectName("defenseGroupBox");
    QHBoxLayout* speedLayout = new QHBoxLayout(this);
    QLabel* speedEmptyLabel = new QLabel(tr("Press the Calculate button to show results."));
    speedLayout->addWidget(speedEmptyLabel);
    speedLayout->setAlignment(Qt::AlignCenter);

    hpGroupBox->setLayout(hpLayout);
    attackGroupBox->setLayout(attackLayout);
    defenseGroupBox->setLayout(defenseLayout);
    speedGroupBox->setLayout(speedLayout);
    
    mainLayout->addWidget(hpGroupBox);
    mainLayout->addWidget(attackGroupBox);
    mainLayout->addWidget(defenseGroupBox);
    mainLayout->addWidget(speedGroupBox);
    
    if(gen == 1)
    {
        QGroupBox* specialGroupBox = new QGroupBox(tr("Special"),this);
        specialGroupBox->setObjectName("specialGroupBox");
        QHBoxLayout* specialLayout = new QHBoxLayout(this);
        specialGroupBox->setLayout(specialLayout);
        QLabel* specialEmptyLabel = new QLabel(tr("Press the Calculate button to show results."));
        specialLayout->addWidget(specialEmptyLabel);
        specialLayout->setAlignment(Qt::AlignCenter);
        mainLayout->addWidget(specialGroupBox);
    }
    else
    {
        QGroupBox* specialAttackGroupBox = new QGroupBox(tr("Special Attack"),this);
        specialAttackGroupBox->setObjectName("specialAttackGroupBox");
        QHBoxLayout* specialAttackLayout = new QHBoxLayout(this);
        specialAttackGroupBox->setLayout(specialAttackLayout);
        QLabel* specialAttackEmptyLabel = new QLabel(tr("Press the Calculate button to show results."));
        specialAttackLayout->addWidget(specialAttackEmptyLabel);
        specialAttackLayout->setAlignment(Qt::AlignCenter);
        mainLayout->addWidget(specialAttackGroupBox);

        QGroupBox* specialDefenseGroupBox = new QGroupBox(tr("Special Defense"),this);
        specialDefenseGroupBox->setObjectName("specialDefenseGroupBox");
        QHBoxLayout* specialDefenseLayout = new QHBoxLayout(this);
        specialDefenseGroupBox->setLayout(specialDefenseLayout);
        QLabel* specialDefenseEmptyLabel = new QLabel(tr("Press the Calculate button to show results."));
        specialDefenseLayout->addWidget(specialDefenseEmptyLabel);
        specialDefenseLayout->setAlignment(Qt::AlignCenter);
        mainLayout->addWidget(specialDefenseGroupBox);
    }
    
    setLayout(mainLayout);
}

//Slot to call when results are calculated by OptionsGroupBox
void CalculationOutput::getAndShowResults(vector<vector<stat_st> > highest_stats_vecs,
                                          vector<vector<stat_st> > lowest_stats_vecs)
{
    vector<stat_st> high_vec = highest_stats_vecs[generation-1];
    vector<stat_st> low_vec = lowest_stats_vecs[generation-1];

    QList<QGroupBox*> groupBoxQList = this->findChildren<QGroupBox*>();
    for(int i = 0; i < groupBoxQList.count(); i++)
    {
        //Delete all widgets in QGroupBox
        QList<QLabel*> labelQList = groupBoxQList.at(i)->findChildren<QLabel*>();
        for(int j = 0; j < labelQList.count(); j++) delete labelQList.at(j);
        QList<BasePkmnDisplayWidget*> basePkmnQList = groupBoxQList.at(i)->findChildren<BasePkmnDisplayWidget*>();
        for(int j = 0; j < basePkmnQList.count(); j++) delete basePkmnQList.at(j);

        //Add appropriate Pokemon
        base_pkmn::sptr highPkmn = base_pkmn::make(high_vec[i].pkmn_name, generation, false);
        base_pkmn::sptr lowPkmn = base_pkmn::make(low_vec[i].pkmn_name, generation, false);

        //Create BasePkmnDisplayWidgets
        BasePkmnDisplayWidget* highWidget = new BasePkmnDisplayWidget(groupBoxQList.at(i),highPkmn);
        BasePkmnDisplayWidget* lowWidget = new BasePkmnDisplayWidget(groupBoxQList.at(i),lowPkmn);

        //Create QLabels with BasePkmnDisplayWidgets
        QLabel* highLabel = new QLabel(tr("High:"), highWidget);
        QLabel* lowLabel = new QLabel(tr("Low:"), lowWidget);

        //Add widgets to QGroupBoxes
        groupBoxQList.at(i)->layout()->addWidget(highWidget);
        groupBoxQList.at(i)->layout()->addWidget(lowWidget);
    }

    update();
}
{'fraction_non_alphanumeric': 0.11499663752521856, 'fraction_numerical': 0.001825343452781247, 'mean_word_length': 4.441714584422373, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 108, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '920168', 'n_tokens_mistral': 3117, 'n_tokens_neox': 3021, 'n_words': 564}