|
| 1 | +/*********************************************************************************************************************** |
| 2 | +* OpenStudio(R), Copyright (c) OpenStudio Coalition and other contributors. |
| 3 | +* See also https://openstudiocoalition.org/about/software_license/ |
| 4 | +***********************************************************************************************************************/ |
| 5 | + |
| 6 | +#include "HotWaterEquipmentInspectorView.hpp" |
| 7 | +#include "../shared_gui_components/OSLineEdit.hpp" |
| 8 | +#include "../shared_gui_components/OSQuantityEdit.hpp" |
| 9 | +#include "OSDropZone.hpp" |
| 10 | +#include <openstudio/model/HotWaterEquipmentDefinition.hpp> |
| 11 | +#include <openstudio/model/HotWaterEquipmentDefinition_Impl.hpp> |
| 12 | +#include <openstudio/utilities/core/Assert.hpp> |
| 13 | +#include <QVBoxLayout> |
| 14 | +#include <QHBoxLayout> |
| 15 | +#include <QLabel> |
| 16 | +#include <QGridLayout> |
| 17 | +#include <QScrollArea> |
| 18 | +#include <QStackedWidget> |
| 19 | + |
| 20 | +namespace openstudio { |
| 21 | + |
| 22 | +HotWaterEquipmentDefinitionInspectorView::HotWaterEquipmentDefinitionInspectorView(bool isIP, const openstudio::model::Model& model, QWidget* parent) |
| 23 | + : ModelObjectInspectorView(model, true, parent), m_nameEdit(new OSLineEdit2()), m_isIP(isIP) { |
| 24 | + |
| 25 | + auto* visibleWidget = new QWidget(); |
| 26 | + this->stackedWidget()->addWidget(visibleWidget); |
| 27 | + |
| 28 | + auto* mainGridLayout = new QGridLayout(); |
| 29 | + mainGridLayout->setContentsMargins(7, 7, 7, 7); |
| 30 | + mainGridLayout->setSpacing(14); |
| 31 | + visibleWidget->setLayout(mainGridLayout); |
| 32 | + |
| 33 | + // Name |
| 34 | + |
| 35 | + auto* label = new QLabel("Name: "); |
| 36 | + label->setObjectName("H2"); |
| 37 | + mainGridLayout->addWidget(label, 0, 0); |
| 38 | + |
| 39 | + mainGridLayout->addWidget(m_nameEdit, 1, 0, 1, 3); |
| 40 | + |
| 41 | + // Design Level |
| 42 | + |
| 43 | + label = new QLabel("Design Level: "); |
| 44 | + label->setObjectName("H2"); |
| 45 | + mainGridLayout->addWidget(label, 2, 0); |
| 46 | + |
| 47 | + m_designLevelEdit = new OSQuantityEdit2("W", "W", "W", m_isIP); |
| 48 | + connect(this, &HotWaterEquipmentDefinitionInspectorView::toggleUnitsClicked, m_designLevelEdit, &OSQuantityEdit2::onUnitSystemChange); |
| 49 | + mainGridLayout->addWidget(m_designLevelEdit, 3, 0); |
| 50 | + |
| 51 | + // Watts Per Space Floor Area |
| 52 | + |
| 53 | + label = new QLabel("Watts Per Space Floor Area: "); |
| 54 | + label->setObjectName("H2"); |
| 55 | + mainGridLayout->addWidget(label, 2, 1); |
| 56 | + |
| 57 | + m_wattsPerSpaceFloorAreaEdit = new OSQuantityEdit2("W/m^2", "W/m^2", "W/ft^2", m_isIP); |
| 58 | + connect(this, &HotWaterEquipmentDefinitionInspectorView::toggleUnitsClicked, m_wattsPerSpaceFloorAreaEdit, &OSQuantityEdit2::onUnitSystemChange); |
| 59 | + mainGridLayout->addWidget(m_wattsPerSpaceFloorAreaEdit, 3, 1); |
| 60 | + |
| 61 | + // Watts Per Person |
| 62 | + |
| 63 | + label = new QLabel("Watts Per Person: "); |
| 64 | + label->setObjectName("H2"); |
| 65 | + mainGridLayout->addWidget(label, 2, 2); |
| 66 | + |
| 67 | + m_wattsPerPersonEdit = new OSQuantityEdit2("W/person", "W/person", "W/person", m_isIP); |
| 68 | + connect(this, &HotWaterEquipmentDefinitionInspectorView::toggleUnitsClicked, m_wattsPerPersonEdit, &OSQuantityEdit2::onUnitSystemChange); |
| 69 | + mainGridLayout->addWidget(m_wattsPerPersonEdit, 3, 2); |
| 70 | + |
| 71 | + // Fraction Latent |
| 72 | + |
| 73 | + label = new QLabel("Fraction Latent: "); |
| 74 | + label->setObjectName("H2"); |
| 75 | + mainGridLayout->addWidget(label, 4, 0); |
| 76 | + |
| 77 | + m_fractionLatentEdit = new OSQuantityEdit2("", "", "", m_isIP); |
| 78 | + connect(this, &HotWaterEquipmentDefinitionInspectorView::toggleUnitsClicked, m_fractionLatentEdit, &OSQuantityEdit2::onUnitSystemChange); |
| 79 | + mainGridLayout->addWidget(m_fractionLatentEdit, 5, 0); |
| 80 | + |
| 81 | + // Fraction Radiant |
| 82 | + |
| 83 | + label = new QLabel("Fraction Radiant: "); |
| 84 | + label->setObjectName("H2"); |
| 85 | + mainGridLayout->addWidget(label, 4, 1); |
| 86 | + |
| 87 | + m_fractionRadiantEdit = new OSQuantityEdit2("", "", "", m_isIP); |
| 88 | + connect(this, &HotWaterEquipmentDefinitionInspectorView::toggleUnitsClicked, m_fractionRadiantEdit, &OSQuantityEdit2::onUnitSystemChange); |
| 89 | + mainGridLayout->addWidget(m_fractionRadiantEdit, 5, 1); |
| 90 | + |
| 91 | + // Fraction Lost |
| 92 | + |
| 93 | + label = new QLabel("Fraction Lost: "); |
| 94 | + label->setObjectName("H2"); |
| 95 | + mainGridLayout->addWidget(label, 6, 0); |
| 96 | + |
| 97 | + m_fractionLostEdit = new OSQuantityEdit2("", "", "", m_isIP); |
| 98 | + connect(this, &HotWaterEquipmentDefinitionInspectorView::toggleUnitsClicked, m_fractionLostEdit, &OSQuantityEdit2::onUnitSystemChange); |
| 99 | + mainGridLayout->addWidget(m_fractionLostEdit, 7, 0); |
| 100 | + |
| 101 | + // Stretch |
| 102 | + |
| 103 | + mainGridLayout->setRowStretch(8, 100); |
| 104 | + |
| 105 | + label = |
| 106 | + new QLabel("<i>The object models hot water equipment in the zone which consumes district heating, such as cooking equipment or process loads. " |
| 107 | + "All of the energy consumed by the equipment becomes a heat gain in the zone or is lost (exhausted). " |
| 108 | + "This object consumes district heating energy directly and does not cause a load on a hot water plant loop or water heater. " |
| 109 | + "For domestic hot water uses, such as sinks and showers, see WaterUse:Equipment.</i>"); |
| 110 | + label->setWordWrap(true); |
| 111 | + mainGridLayout->addWidget(label, 9, 0, 1, 4); |
| 112 | + |
| 113 | + mainGridLayout->setColumnStretch(3, 100); |
| 114 | +} |
| 115 | + |
| 116 | +void HotWaterEquipmentDefinitionInspectorView::onClearSelection() { |
| 117 | + ModelObjectInspectorView::onClearSelection(); // call parent implementation |
| 118 | + detach(); |
| 119 | +} |
| 120 | + |
| 121 | +void HotWaterEquipmentDefinitionInspectorView::onSelectModelObject(const openstudio::model::ModelObject& modelObject) { |
| 122 | + detach(); |
| 123 | + auto hotwaterEquipmentDefinition = modelObject.cast<model::HotWaterEquipmentDefinition>(); |
| 124 | + attach(hotwaterEquipmentDefinition); |
| 125 | + refresh(); |
| 126 | +} |
| 127 | + |
| 128 | +void HotWaterEquipmentDefinitionInspectorView::onUpdate() { |
| 129 | + refresh(); |
| 130 | +} |
| 131 | + |
| 132 | +void HotWaterEquipmentDefinitionInspectorView::attach(const openstudio::model::HotWaterEquipmentDefinition& hotwaterEquipmentDefinition) { |
| 133 | + m_hotwaterEquipmentDefinition = hotwaterEquipmentDefinition; |
| 134 | + |
| 135 | + // m_nameEdit->bind(hotwaterEquipmentDefinition,"name"); |
| 136 | + m_nameEdit->bind(*m_hotwaterEquipmentDefinition, |
| 137 | + OptionalStringGetter(std::bind(&model::HotWaterEquipmentDefinition::name, m_hotwaterEquipmentDefinition.get_ptr(), true)), |
| 138 | + boost::optional<StringSetterOptionalStringReturn>( |
| 139 | + std::bind(&model::HotWaterEquipmentDefinition::setName, m_hotwaterEquipmentDefinition.get_ptr(), std::placeholders::_1))); |
| 140 | + |
| 141 | + // m_designLevelEdit->bind(hotwaterEquipmentDefinition,"designLevel",m_isIP); |
| 142 | + m_designLevelEdit->bind(m_isIP, *m_hotwaterEquipmentDefinition, |
| 143 | + OptionalDoubleGetter(std::bind(&model::HotWaterEquipmentDefinition::designLevel, m_hotwaterEquipmentDefinition.get_ptr())), |
| 144 | + boost::optional<DoubleSetter>(std::bind( |
| 145 | + static_cast<bool (model::HotWaterEquipmentDefinition::*)(double)>(&model::HotWaterEquipmentDefinition::setDesignLevel), |
| 146 | + m_hotwaterEquipmentDefinition.get_ptr(), std::placeholders::_1))); |
| 147 | + |
| 148 | + // m_wattsPerSpaceFloorAreaEdit->bind(hotwaterEquipmentDefinition,"wattsperSpaceFloorArea",m_isIP); |
| 149 | + m_wattsPerSpaceFloorAreaEdit->bind( |
| 150 | + m_isIP, *m_hotwaterEquipmentDefinition, |
| 151 | + OptionalDoubleGetter(std::bind(&model::HotWaterEquipmentDefinition::wattsperSpaceFloorArea, m_hotwaterEquipmentDefinition.get_ptr())), |
| 152 | + boost::optional<DoubleSetter>( |
| 153 | + std::bind(static_cast<bool (model::HotWaterEquipmentDefinition::*)(double)>(&model::HotWaterEquipmentDefinition::setWattsperSpaceFloorArea), |
| 154 | + m_hotwaterEquipmentDefinition.get_ptr(), std::placeholders::_1))); |
| 155 | + |
| 156 | + // m_wattsPerPersonEdit->bind(hotwaterEquipmentDefinition,"wattsperPerson",m_isIP); |
| 157 | + m_wattsPerPersonEdit->bind( |
| 158 | + m_isIP, *m_hotwaterEquipmentDefinition, |
| 159 | + OptionalDoubleGetter(std::bind(&model::HotWaterEquipmentDefinition::wattsperPerson, m_hotwaterEquipmentDefinition.get_ptr())), |
| 160 | + boost::optional<DoubleSetter>( |
| 161 | + std::bind(static_cast<bool (model::HotWaterEquipmentDefinition::*)(double)>(&model::HotWaterEquipmentDefinition::setWattsperPerson), |
| 162 | + m_hotwaterEquipmentDefinition.get_ptr(), std::placeholders::_1))); |
| 163 | + |
| 164 | + // m_fractionLatentEdit->bind(hotwaterEquipmentDefinition,"fractionLatent",m_isIP); |
| 165 | + m_fractionLatentEdit->bind( |
| 166 | + m_isIP, *m_hotwaterEquipmentDefinition, |
| 167 | + OptionalDoubleGetter(std::bind(&model::HotWaterEquipmentDefinition::fractionLatent, m_hotwaterEquipmentDefinition.get_ptr())), |
| 168 | + boost::optional<DoubleSetter>( |
| 169 | + std::bind(static_cast<bool (model::HotWaterEquipmentDefinition::*)(double)>(&model::HotWaterEquipmentDefinition::setFractionLatent), |
| 170 | + m_hotwaterEquipmentDefinition.get_ptr(), std::placeholders::_1)), |
| 171 | + boost::optional<NoFailAction>(std::bind(&model::HotWaterEquipmentDefinition::resetFractionLatent, m_hotwaterEquipmentDefinition.get_ptr())), |
| 172 | + boost::none, boost::none, |
| 173 | + boost::optional<BasicQuery>(std::bind(&model::HotWaterEquipmentDefinition::isFractionLatentDefaulted, m_hotwaterEquipmentDefinition.get_ptr()))); |
| 174 | + |
| 175 | + // m_fractionRadiantEdit->bind(hotwaterEquipmentDefinition,"fractionRadiant",m_isIP); |
| 176 | + m_fractionRadiantEdit->bind( |
| 177 | + m_isIP, *m_hotwaterEquipmentDefinition, |
| 178 | + OptionalDoubleGetter(std::bind(&model::HotWaterEquipmentDefinition::fractionRadiant, m_hotwaterEquipmentDefinition.get_ptr())), |
| 179 | + boost::optional<DoubleSetter>( |
| 180 | + std::bind(static_cast<bool (model::HotWaterEquipmentDefinition::*)(double)>(&model::HotWaterEquipmentDefinition::setFractionRadiant), |
| 181 | + m_hotwaterEquipmentDefinition.get_ptr(), std::placeholders::_1)), |
| 182 | + boost::optional<NoFailAction>(std::bind(&model::HotWaterEquipmentDefinition::resetFractionRadiant, m_hotwaterEquipmentDefinition.get_ptr())), |
| 183 | + boost::none, boost::none, |
| 184 | + boost::optional<BasicQuery>(std::bind(&model::HotWaterEquipmentDefinition::isFractionRadiantDefaulted, m_hotwaterEquipmentDefinition.get_ptr()))); |
| 185 | + |
| 186 | + // m_fractionLostEdit->bind(hotwaterEquipmentDefinition,"fractionLost",m_isIP); |
| 187 | + m_fractionLostEdit->bind( |
| 188 | + m_isIP, *m_hotwaterEquipmentDefinition, |
| 189 | + OptionalDoubleGetter(std::bind(&model::HotWaterEquipmentDefinition::fractionLost, m_hotwaterEquipmentDefinition.get_ptr())), |
| 190 | + boost::optional<DoubleSetter>( |
| 191 | + std::bind(static_cast<bool (model::HotWaterEquipmentDefinition::*)(double)>(&model::HotWaterEquipmentDefinition::setFractionLost), |
| 192 | + m_hotwaterEquipmentDefinition.get_ptr(), std::placeholders::_1)), |
| 193 | + boost::optional<NoFailAction>(std::bind(&model::HotWaterEquipmentDefinition::resetFractionLost, m_hotwaterEquipmentDefinition.get_ptr())), |
| 194 | + boost::none, boost::none, |
| 195 | + boost::optional<BasicQuery>(std::bind(&model::HotWaterEquipmentDefinition::isFractionLostDefaulted, m_hotwaterEquipmentDefinition.get_ptr()))); |
| 196 | + |
| 197 | + this->stackedWidget()->setCurrentIndex(1); |
| 198 | +} |
| 199 | + |
| 200 | +void HotWaterEquipmentDefinitionInspectorView::detach() { |
| 201 | + this->stackedWidget()->setCurrentIndex(0); |
| 202 | + |
| 203 | + m_nameEdit->unbind(); |
| 204 | + m_designLevelEdit->unbind(); |
| 205 | + m_wattsPerSpaceFloorAreaEdit->unbind(); |
| 206 | + m_wattsPerPersonEdit->unbind(); |
| 207 | + m_fractionLatentEdit->unbind(); |
| 208 | + m_fractionRadiantEdit->unbind(); |
| 209 | + m_fractionLostEdit->unbind(); |
| 210 | + |
| 211 | + m_hotwaterEquipmentDefinition = boost::none; |
| 212 | +} |
| 213 | + |
| 214 | +void HotWaterEquipmentDefinitionInspectorView::refresh() {} |
| 215 | + |
| 216 | +void HotWaterEquipmentDefinitionInspectorView::toggleUnits(bool displayIP) { |
| 217 | + m_isIP = displayIP; |
| 218 | +} |
| 219 | + |
| 220 | +} // namespace openstudio |
0 commit comments