#include "degreeofcrystallinityform.h"
#include "ui_degreeofcrystallinityform.h"

DegreeOfCrystallinityForm::DegreeOfCrystallinityForm(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::DegreeOfCrystallinityForm)
{
    ui->setupUi(this);
    setWindowTitle("结晶度");
}

DegreeOfCrystallinityForm::~DegreeOfCrystallinityForm()
{
    delete ui;
}

void DegreeOfCrystallinityForm::on_pushButtonCalculate_clicked()
{
    float enthalpy = ui->LineEditEnthalpyOfCrystallization->text().toFloat();
    float enthalpyCold = ui->LineEditEnthalpyOfColdCrystallization->text().toFloat();
    float enthalpyTheory = ui->LineEditTheoreticalEnthalpy->text().toFloat();
    float Xc = (enthalpy - enthalpyCold) / enthalpyTheory * 100;

    QString xcStr = QString::number(Xc,'f',3);
    ui->xcLineEditDegreedOfCrystallinity->setText(xcStr);

    QString str = QString("结晶度Xc(%)= %1%").arg(xcStr);
    emit sigDrawCustomText(str);
}

void DegreeOfCrystallinityForm::on_pushButtonQuit_clicked()
{
    ui->LineEditEnthalpyOfCrystallization->text().clear();
    ui->LineEditEnthalpyOfColdCrystallization->text().clear();
    ui->LineEditTheoreticalEnthalpy->text().clear();
    ui->xcLineEditDegreedOfCrystallinity->text().clear();

    hide();
}
