Initial Commit
[HECS.git] / DimensionsDialog.cpp
blob7eda8af3d0059428869dafbd85ca4964c785ab63
1 /***************************************************************************
2 * *
3 * DimensionsDialog.cpp Copyright (C) 2008 by Jon Rumble *
4 * j.w.rumble@reading.ac.uk *
5 * *
6 * *
7 * This file is part of HECS, *
8 * *
9 * HECS is free software: you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation, either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 * *
15 * HECS is distributed in the hope that it will be useful, *
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18 * GNU General Public License for more details. *
19 * *
20 * You should have received a copy of the GNU General Public License *
21 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
22 ***************************************************************************/
24 #include "DimensionsDialog.h"
26 DimensionsDialog::DimensionsDialog (QWidget *parent)
27 : QDialog(parent)
29 ui.setupUi(this);
30 m_firstFloorArea = 0.00;
31 m_secondFloorArea = 0.00;
32 m_thirdFloorArea = 0.00;
33 m_firstFloorHeight = 0.00;
34 m_secondFloorHeight = 0.00;
35 m_thirdFloorHeight = 0.00;
38 void DimensionsDialog::setModel(RdSap *modelIn)
40 sapModel = modelIn;
41 initVars();
44 void DimensionsDialog::calcSqMetre()
46 double result = 0.00;
47 QString numOut = ui.sqFeetInput->text();
48 result = sqFeettoSquareMetres(numOut.toDouble());
49 numOut.number(result);
50 ui.sqMetreLbl->setText(QString::number(result,'f',2));
54 void DimensionsDialog::onFirstFloorAreaChanged()
57 m_firstFloorArea = ui.firstFloorAreaEdit->text().toDouble();
59 double valOut = m_firstFloorArea +
60 m_secondFloorArea +
61 m_thirdFloorArea;
63 ui.totalFloorAreaLbl->setText(QString::number(valOut,'f',2));
65 //Update Model through pointer
66 sapModel->dwelling->set_firstFloorArea(m_firstFloorArea);
69 void DimensionsDialog::onSecondFloorAreaChanged()
72 m_secondFloorArea = ui.secondFloorAreaEdit->text().toDouble();
74 double valOut = m_firstFloorArea +
75 m_secondFloorArea +
76 m_thirdFloorArea;
78 ui.totalFloorAreaLbl->setText(QString::number(valOut,'f',2));
81 //Update Model through pointer
82 sapModel->dwelling->set_secondFloorArea(m_secondFloorArea);
84 void DimensionsDialog::onThirdFloorAreaChanged()
88 m_thirdFloorArea = ui.thirdFloorAreaEdit->text().toDouble();
90 double valOut = m_firstFloorArea +
91 m_secondFloorArea +
92 m_thirdFloorArea;
94 ui.totalFloorAreaLbl->setText(QString::number(valOut,'f',2));
96 //Update Model through pointer
97 sapModel->dwelling->set_thirdFloorArea(m_thirdFloorArea);
100 void DimensionsDialog::onNumChimneysCbxChanged()
102 int valOut = ui.numChimneysCbx->currentIndex();
103 sapModel->ventilation->set_numChimneys(valOut);
106 void DimensionsDialog::onNumWindowsCbxChanged()
108 sapModel->windowArea();
110 if (ui.numWindowsCbx->currentIndex() == 0)
112 double tmp = sapModel->getRdWindowArea();
113 sapModel->setRdWindowArea(tmp*0.75);
116 if (ui.numWindowsCbx->currentIndex() == 2)
118 double tmp = sapModel->getRdWindowArea();
119 sapModel->setRdWindowArea(tmp*1.25);
126 void DimensionsDialog::onFirstFloorHeightChanged()
129 m_firstFloorHeight = ui.firstFloorHeightEdit->text().toDouble();
131 double valOut = (m_firstFloorArea*m_firstFloorHeight)+
132 (m_secondFloorArea*m_secondFloorHeight)+
133 (m_thirdFloorArea*m_thirdFloorHeight);
136 ui.totalVolumeLbl->setText(QString::number(valOut,'f',2));
138 //Update Model through pointer
139 sapModel->dwelling->set_firstFloorHeight(m_firstFloorHeight);
142 void DimensionsDialog::onSecondFloorHeightChanged()
145 m_secondFloorHeight = ui.secondFloorHeightEdit->text().toDouble();
147 double valOut = (m_firstFloorArea*m_firstFloorHeight)+
148 (m_secondFloorArea*m_secondFloorHeight)+
149 (m_thirdFloorArea*m_thirdFloorHeight);
152 ui.totalVolumeLbl->setText(QString::number(valOut,'f',2));
154 //Update Model through pointer
155 sapModel->dwelling->set_secondFloorHeight(m_secondFloorHeight);
158 void DimensionsDialog::onThirdFloorHeightChanged()
161 m_thirdFloorHeight = ui.thirdFloorHeightEdit->text().toDouble();
163 double valOut = (m_firstFloorArea*m_firstFloorHeight)+
164 (m_secondFloorArea*m_secondFloorHeight)+
165 (m_thirdFloorArea*m_thirdFloorHeight);
168 ui.totalVolumeLbl->setText(QString::number(valOut,'f',2));
170 //Update Model through pointer
171 sapModel->dwelling->set_secondFloorHeight(m_secondFloorHeight);
174 void DimensionsDialog::onNumGasFiresCbxChanged()
176 int valOut = ui.numGasFiresCbx->currentIndex();
177 sapModel->ventilation->set_numGasFluelessFires(valOut);
180 void DimensionsDialog::initVars()
182 QObject::connect(ui.firstFloorAreaEdit, SIGNAL(textChanged(QString)), this, SLOT(onFirstFloorAreaChanged()));
184 QObject::connect(ui.firstFloorHeightEdit, SIGNAL(textChanged(QString)), this, SLOT(onFirstFloorHeightChanged()));
186 QObject::connect(ui.secondFloorHeightEdit, SIGNAL(textChanged(QString)), this, SLOT(onSecondFloorHeightChanged()));
188 QObject::connect(ui.thirdFloorHeightEdit, SIGNAL(textChanged(QString)), this, SLOT(onThirdFloorHeightChanged()));
191 QObject::connect(ui.secondFloorAreaEdit, SIGNAL(textChanged(QString)), this, SLOT(onSecondFloorAreaChanged()));
193 QObject::connect(ui.thirdFloorAreaEdit, SIGNAL(textChanged(QString)), this, SLOT(onThirdFloorAreaChanged()));
195 QObject::connect(ui.numChimneysCbx,SIGNAL(currentIndexChanged(QString)),this ,SLOT(onNumChimneysCbxChanged()));
197 QObject::connect(ui.numGasFiresCbx,SIGNAL(currentIndexChanged(QString)),this ,SLOT(onNumGasFiresCbxChanged()));
199 QObject::connect(ui.numWindowsCbx,SIGNAL(currentIndexChanged(QString)),this ,SLOT(onNumWindowsCbxChanged()));
201 //Populate Adress Details
202 ui.houseNumLbl->setText(sapModel->dwelling->get_houseNumber());
203 ui.addressLbl->setText(sapModel->dwelling->get_address());
204 ui.postcodeLbl->setText(sapModel->dwelling->get_postcode());
208 // END OF DimensionsDialog.cpp