-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathFacilityShadingGridView.cpp
More file actions
562 lines (452 loc) · 24.3 KB
/
FacilityShadingGridView.cpp
File metadata and controls
562 lines (452 loc) · 24.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
/***********************************************************************************************************************
* OpenStudio(R), Copyright (c) OpenStudio Coalition and other contributors.
* See also https://openstudiocoalition.org/about/software_license/
***********************************************************************************************************************/
#include "FacilityShadingGridView.hpp"
#include "OSDropZone.hpp"
#include "OSItemSelectorButtons.hpp"
#include "../shared_gui_components/OSCheckBox.hpp"
#include "../shared_gui_components/OSGridView.hpp"
#include "../shared_gui_components/OSObjectSelector.hpp"
#include <openstudio/model/Blind.hpp>
#include <openstudio/model/Blind_Impl.hpp>
#include <openstudio/model/ConstructionBase.hpp>
#include <openstudio/model/ConstructionBase_Impl.hpp>
#include <openstudio/model/Model.hpp>
#include <openstudio/model/Model_Impl.hpp>
#include <openstudio/model/ModelObject.hpp>
#include <openstudio/model/ModelObject_Impl.hpp>
#include <openstudio/model/Schedule.hpp>
#include <openstudio/model/Schedule_Impl.hpp>
#include <openstudio/model/ShadingSurface.hpp>
#include <openstudio/model/ShadingSurface_Impl.hpp>
#include <openstudio/model/ShadingSurfaceGroup.hpp>
#include <openstudio/model/ShadingSurfaceGroup_Impl.hpp>
#include <openstudio/utilities/core/Assert.hpp>
#include <openstudio/utilities/core/Compare.hpp>
#include <openstudio/utilities/idd/IddEnums.hxx>
#include <openstudio/utilities/idd/OS_ShadingSurface_FieldEnums.hxx>
#include <openstudio/utilities/idd/OS_ShadingSurfaceGroup_FieldEnums.hxx>
#include <openstudio/utilities/idd/OS_WindowMaterial_Blind_FieldEnums.hxx>
#include <openstudio/utilities/units/QuantityConverter.hpp>
#include <QBoxLayout>
#include <QCheckBox>
#include <QComboBox>
#include <QLabel>
#include <QLineEdit>
#include <QRegularExpressionValidator>
// These defines provide a common area for field display names
// used on column headers, and other grid widgets
#define NAME "Shading Surface Group Name"
#define SELECTED "All"
#define DISPLAYNAME "Display Name"
#define CADOBJECTID "CAD Object ID"
// GENERAL
#define TYPE "Type" // read only
#define SHADINGSURFACENAME "Shading Surface Name" // read only
#define CONSTRUCTIONNAME "Construction Name"
#define TRANSMITTANCESCHEDULENAME "Transmittance Schedule Name"
// FILTERS
#define SHADINGSURFACETYPE "Shading Surface Type"
#define SHADINGSURFACEGROUPNAME "Shading Surface Group Name"
#define ORIENTATIONGREATERTHAN "Degrees Orientation >"
#define ORIENTATIONLESSTHAN "Degrees Orientation <"
#define TILTGREATERTHAN "Degrees Tilt >"
#define TILTLESSTHAN "Degrees Tilt <"
namespace openstudio {
FacilityShadingGridView::FacilityShadingGridView(bool isIP, bool displayAdditionalProps, const model::Model& model, QWidget* parent)
: GridViewSubTab(isIP, displayAdditionalProps, model, parent) {
std::vector<model::ShadingSurfaceGroup> shadingGroups = model.getConcreteModelObjects<model::ShadingSurfaceGroup>();
// Filter out the 'Space' shadingSurfaceTypes
// These are displayed on the Space's "Shading" subtab
shadingGroups.erase(std::remove_if(shadingGroups.begin(), shadingGroups.end(),
[](const model::ShadingSurfaceGroup& sg) { return sg.shadingSurfaceType() == "Space"; }),
shadingGroups.end());
auto modelObjects = subsetCastVector<model::ModelObject>(shadingGroups);
std::sort(modelObjects.begin(), modelObjects.end(), openstudio::WorkspaceObjectNameLess());
m_gridController = new FacilityShadingGridController(isIP, displayAdditionalProps, "Shading Surface Group", IddObjectType::OS_ShadingSurfaceGroup,
model, modelObjects);
m_gridView = new OSGridView(m_gridController, "Shading Surface Group", "Drop Shading\nSurface Group", false, parent);
setGridController(m_gridController);
setGridView(m_gridView);
// Filters
QLabel* label = nullptr;
QVBoxLayout* layout = nullptr;
auto* filterGridLayout = new QGridLayout();
filterGridLayout->setContentsMargins(7, 4, 0, 8);
filterGridLayout->setSpacing(5);
label = new QLabel();
label->setText("Filters:");
label->setObjectName("H2");
filterGridLayout->addWidget(label, filterGridLayout->rowCount(), filterGridLayout->columnCount(), Qt::AlignTop | Qt::AlignLeft);
// SHADINGSURFACEGROUPNAME
layout = new QVBoxLayout();
label = new QLabel();
label->setText(SHADINGSURFACENAME);
label->setObjectName("H3");
layout->addWidget(label, Qt::AlignTop | Qt::AlignLeft);
m_nameFilter = new QLineEdit();
m_nameFilter->setFixedWidth(OSItem::ITEM_WIDTH);
// Evan note: there are issues with using the signal textChanged or textEdited, related to the design and updating of the gridview (loss of focus, and updates per key stroke)
connect(m_nameFilter, &QLineEdit::editingFinished, this, &openstudio::FacilityShadingGridView::nameFilterChanged);
QRegularExpression nameRegex("^\\S.*");
auto* nameValidator = new QRegularExpressionValidator(nameRegex, this);
m_nameFilter->setValidator(nameValidator);
layout->addWidget(m_nameFilter, Qt::AlignTop | Qt::AlignLeft);
layout->addStretch();
filterGridLayout->addLayout(layout, filterGridLayout->rowCount() - 1, filterGridLayout->columnCount());
// SHADINGSURFACETYPE
layout = new QVBoxLayout();
label = new QLabel();
label->setText(SHADINGSURFACETYPE);
label->setObjectName("H3");
layout->addWidget(label, Qt::AlignTop | Qt::AlignLeft);
m_typeFilter = new QComboBox();
m_typeFilter->addItem("All");
m_typeFilter->addItem("Site");
m_typeFilter->addItem("Building");
// Space-level shading is on the Space's "Shading" subtab
//m_typeFilter->addItem("Space");
m_typeFilter->setFixedWidth(OSItem::ITEM_WIDTH);
connect(m_typeFilter, &QComboBox::currentTextChanged, this, &openstudio::FacilityShadingGridView::typeFilterChanged);
layout->addWidget(m_typeFilter, Qt::AlignTop | Qt::AlignLeft);
layout->addStretch();
filterGridLayout->addLayout(layout, filterGridLayout->rowCount() - 1, filterGridLayout->columnCount());
// TILTGREATERTHAN
layout = new QVBoxLayout();
label = new QLabel();
label->setText(TILTGREATERTHAN);
label->setObjectName("H3");
layout->addWidget(label, Qt::AlignTop | Qt::AlignLeft);
m_tiltGreaterThanFilter = new QLineEdit();
m_tiltGreaterThanFilter->setFixedWidth(OSItem::ITEM_WIDTH);
connect(m_tiltGreaterThanFilter, &QLineEdit::editingFinished, this, &openstudio::FacilityShadingGridView::tiltFilterChanged);
QRegularExpression regex("^(-?\\d*\\.?\\d+)?$");
auto* validator = new QRegularExpressionValidator(regex, this);
m_tiltGreaterThanFilter->setValidator(validator);
layout->addWidget(m_tiltGreaterThanFilter, Qt::AlignTop | Qt::AlignLeft);
layout->addStretch();
filterGridLayout->addLayout(layout, filterGridLayout->rowCount() - 1, filterGridLayout->columnCount());
//TILTLESSTHAN
layout = new QVBoxLayout();
label = new QLabel();
label->setText(TILTLESSTHAN);
label->setObjectName("H3");
layout->addWidget(label, Qt::AlignTop | Qt::AlignLeft);
m_tiltLessThanFilter = new QLineEdit();
m_tiltLessThanFilter->setFixedWidth(OSItem::ITEM_WIDTH);
// Evan note: there are issues with using the signal textChanged or textEdited, related to the design and updating of the gridview (loss of focus, and updates per key stroke)
connect(m_tiltLessThanFilter, &QLineEdit::editingFinished, this, &openstudio::FacilityShadingGridView::tiltFilterChanged);
validator = new QRegularExpressionValidator(regex, this);
m_tiltLessThanFilter->setValidator(validator);
layout->addWidget(m_tiltLessThanFilter, Qt::AlignTop | Qt::AlignLeft);
layout->addStretch();
filterGridLayout->addLayout(layout, filterGridLayout->rowCount() - 1, filterGridLayout->columnCount());
// ORIENTATIONGREATERTHAN
layout = new QVBoxLayout();
label = new QLabel();
label->setText(ORIENTATIONGREATERTHAN);
label->setObjectName("H3");
layout->addWidget(label, Qt::AlignTop | Qt::AlignLeft);
m_orientationGreaterThanFilter = new QLineEdit();
m_orientationGreaterThanFilter->setFixedWidth(OSItem::ITEM_WIDTH);
connect(m_orientationGreaterThanFilter, &QLineEdit::editingFinished, this, &openstudio::FacilityShadingGridView::orientationFilterChanged);
validator = new QRegularExpressionValidator(regex, this);
m_orientationGreaterThanFilter->setValidator(validator);
layout->addWidget(m_orientationGreaterThanFilter, Qt::AlignTop | Qt::AlignLeft);
layout->addStretch();
filterGridLayout->addLayout(layout, filterGridLayout->rowCount() - 1, filterGridLayout->columnCount());
// ORIENTATIONLESSTHAN
layout = new QVBoxLayout();
label = new QLabel();
label->setText(ORIENTATIONLESSTHAN);
label->setObjectName("H3");
layout->addWidget(label, Qt::AlignTop | Qt::AlignLeft);
m_orientationLessThanFilter = new QLineEdit();
m_orientationLessThanFilter->setFixedWidth(OSItem::ITEM_WIDTH);
// Evan note: there are issues with using the signal textChanged or textEdited, related to the design and updating of the gridview (loss of focus, and updates per key stroke)
connect(m_orientationLessThanFilter, &QLineEdit::editingFinished, this, &openstudio::FacilityShadingGridView::orientationFilterChanged);
validator = new QRegularExpressionValidator(regex, this);
m_orientationLessThanFilter->setValidator(validator);
layout->addWidget(m_orientationLessThanFilter, Qt::AlignTop | Qt::AlignLeft);
layout->addStretch();
filterGridLayout->addLayout(layout, filterGridLayout->rowCount() - 1, filterGridLayout->columnCount());
filterGridLayout->setRowStretch(filterGridLayout->rowCount(), 100);
filterGridLayout->setColumnStretch(filterGridLayout->columnCount(), 100);
m_gridView->addLayoutToContentLayout(filterGridLayout);
m_gridView->addSpacingToContentLayout(7);
}
void FacilityShadingGridView::nameFilterChanged() {
m_objectsFilteredByName.clear();
if (m_nameFilter->text().isEmpty()) {
// nothing to filter
} else {
for (const auto& obj : this->m_gridController->selectableObjects()) {
QString objName(obj.name().get().c_str());
if (!objName.contains(m_nameFilter->text(), Qt::CaseInsensitive)) {
m_objectsFilteredByName.insert(obj);
}
}
}
filterChanged();
}
void FacilityShadingGridView::typeFilterChanged(const QString& text) {
m_objectsFilteredByType.clear();
if (m_typeFilter->currentText() == "All") {
// Nothing to filter
} else {
for (const auto& obj : this->m_gridController->selectableObjects()) {
auto parent = obj.parent();
if (parent && parent->iddObjectType() == IddObjectType::OS_ShadingSurfaceGroup) {
if (m_typeFilter->currentText() != parent->cast<model::ShadingSurfaceGroup>().shadingSurfaceType().c_str()) {
m_objectsFilteredByType.insert(obj);
}
}
}
}
filterChanged();
}
void FacilityShadingGridView::orientationFilterChanged() {
m_objectsFilteredByOrientation.clear();
auto upperLimit = std::numeric_limits<double>::max();
auto lowerLimit = std::numeric_limits<double>::lowest();
if (!this->m_orientationLessThanFilter->text().isEmpty()) {
upperLimit = this->m_orientationLessThanFilter->text().toDouble();
}
if (!this->m_orientationGreaterThanFilter->text().isEmpty()) {
lowerLimit = this->m_orientationGreaterThanFilter->text().toDouble();
}
auto convertedValue = convert(upperLimit, "deg", "rad");
OS_ASSERT(convertedValue);
upperLimit = *convertedValue;
convertedValue = convert(lowerLimit, "deg", "rad");
OS_ASSERT(convertedValue);
lowerLimit = *convertedValue;
for (const auto& obj : this->m_gridController->selectableObjects()) {
if (obj.iddObjectType() == IddObjectType::OS_ShadingSurfaceGroup) {
for (const auto& shadingSurface : obj.cast<model::ShadingSurfaceGroup>().shadingSurfaces()) {
auto orientation = shadingSurface.azimuth();
if (orientation >= upperLimit || orientation <= lowerLimit) {
m_objectsFilteredByOrientation.insert(obj);
}
}
}
}
filterChanged();
}
void FacilityShadingGridView::tiltFilterChanged() {
m_objectsFilteredByTilt.clear();
auto upperLimit = std::numeric_limits<double>::max();
auto lowerLimit = std::numeric_limits<double>::lowest();
if (!this->m_tiltLessThanFilter->text().isEmpty()) {
upperLimit = this->m_tiltLessThanFilter->text().toDouble();
}
if (!this->m_tiltGreaterThanFilter->text().isEmpty()) {
lowerLimit = this->m_tiltGreaterThanFilter->text().toDouble();
}
auto convertedValue = convert(upperLimit, "deg", "rad");
OS_ASSERT(convertedValue);
upperLimit = *convertedValue;
convertedValue = convert(lowerLimit, "deg", "rad");
OS_ASSERT(convertedValue);
lowerLimit = *convertedValue;
for (const auto& obj : this->m_gridController->selectableObjects()) {
if (obj.iddObjectType() == IddObjectType::OS_ShadingSurfaceGroup) {
for (const auto& shadingSurface : obj.cast<model::ShadingSurfaceGroup>().shadingSurfaces()) {
auto tilt = shadingSurface.tilt();
if (tilt >= upperLimit || tilt <= lowerLimit) {
m_objectsFilteredByOrientation.insert(obj);
}
}
}
}
filterChanged();
}
void FacilityShadingGridView::filterChanged() {
std::set<openstudio::model::ModelObject> allFilteredObjects = m_objectsFilteredByName;
for (const auto& obj : m_objectsFilteredByTilt) {
allFilteredObjects.insert(obj);
}
for (const auto& obj : m_objectsFilteredByType) {
allFilteredObjects.insert(obj);
}
for (const auto& obj : m_objectsFilteredByOrientation) {
allFilteredObjects.insert(obj);
}
this->m_gridController->setObjectFilter([allFilteredObjects](const model::ModelObject& obj) -> bool {
// return false if object in allFilteredObjects
return allFilteredObjects.count(obj) == 0;
});
}
void FacilityShadingGridView::addObject(const IddObjectType& iddObjectType) {
if (IddObjectType::OS_ShadingSurfaceGroup == iddObjectType.value()) {
model::ShadingSurfaceGroup(this->m_model);
}
}
void FacilityShadingGridView::purgeObjects(const IddObjectType& iddObjectType) {
// If no shading surfaces in the Shading Surface Group -> remove
for (auto& mo : this->m_model.getConcreteModelObjects<model::ShadingSurfaceGroup>()) {
if (mo.shadingSurfaces().empty()) {
mo.remove();
}
}
// If a shading surface isn't part of a Shading Surface Group, it won't be translated to IDF anyways and should be considered orphaned
for (auto& mo : this->m_model.getConcreteModelObjects<model::ShadingSurface>()) {
if (!mo.shadingSurfaceGroup().has_value()) {
mo.remove();
}
}
}
void FacilityShadingGridView::onSelectItem() {
//m_itemSelectorButtons->enableAddButton();
//m_itemSelectorButtons->enableCopyButton();
//m_itemSelectorButtons->enableRemoveButton();
//m_itemSelectorButtons->enablePurgeButton();
}
void FacilityShadingGridView::onClearSelection() {
m_itemSelectorButtons->disableAddButton();
//m_itemSelectorButtons->disableCopyButton();
//m_itemSelectorButtons->disableRemoveButton();
m_itemSelectorButtons->disablePurgeButton();
}
FacilityShadingGridController::FacilityShadingGridController(bool isIP, bool displayAdditionalProps, const QString& headerText,
IddObjectType iddObjectType, const model::Model& model,
const std::vector<model::ModelObject>& modelObjects)
: OSGridController(isIP, headerText, iddObjectType, model, modelObjects, displayAdditionalProps) {
setCategoriesAndFields();
}
void FacilityShadingGridController::setCategoriesAndFields() {
{
std::vector<QString> fields{
SHADINGSURFACENAME,
TRANSMITTANCESCHEDULENAME,
CONSTRUCTIONNAME,
};
std::pair<QString, std::vector<QString>> categoryAndFields = std::make_pair(QString("General"), fields);
addCategoryAndFields(categoryAndFields);
}
OSGridController::setCategoriesAndFields();
}
void FacilityShadingGridController::onCategorySelected(int index) {
OSGridController::onCategorySelected(index);
}
void FacilityShadingGridController::addColumns(const QString& category, std::vector<QString>& fields) {
if (isDisplayAdditionalProps()) {
// We place it after the SHADINGSURFACENAME
fields.insert(fields.begin(), {DISPLAYNAME, CADOBJECTID});
}
// always show name and selected columns
// show type next to name, since it comes from the groups
fields.insert(fields.begin(), {NAME, TYPE, SELECTED});
resetBaseConcepts();
for (const auto& field : fields) {
if (field == NAME) {
addNameLineEditColumn(Heading(QString(NAME), false, false), false, false,
CastNullAdapter<model::ShadingSurfaceGroup>(&model::ShadingSurfaceGroup::name),
CastNullAdapter<model::ShadingSurfaceGroup>(&model::ShadingSurfaceGroup::setName));
}
// Evan note: TODO to correctly use this column we need a new control --
// a dropzone for spaces, and a combo box with site and building as choices
else if (field == TYPE) {
std::function<std::vector<std::string>()> choices([]() {
std::vector<std::string> choices{
"Site",
"Building",
}; // "Space" };
return choices;
});
addComboBoxColumn<std::string, model::ShadingSurfaceGroup>(
Heading(QString(TYPE)), static_cast<std::string (*)(const std::string&)>(&openstudio::toString), choices,
CastNullAdapter<model::ShadingSurfaceGroup>(&model::ShadingSurfaceGroup::shadingSurfaceType),
CastNullAdapter<model::ShadingSurfaceGroup>(&model::ShadingSurfaceGroup::setShadingSurfaceType),
boost::optional<std::function<void(model::ShadingSurfaceGroup*)>>(), boost::optional<std::function<bool(model::ShadingSurfaceGroup*)>>());
} else {
std::function<std::vector<model::ModelObject>(const model::ShadingSurfaceGroup&)> allShadingSurfaces(
[](const model::ShadingSurfaceGroup& t_shadingSurfaceGroup) {
std::vector<model::ModelObject> allModelObjects;
// Only keep shadingSurfaces that are not of the 'Space' shadingSurfaceType
//if( t_shadingSurfaceGroup.shadingSurfaceType() != "Space" ) {
auto shadingSurfaces = t_shadingSurfaceGroup.shadingSurfaces();
allModelObjects.insert(allModelObjects.end(), shadingSurfaces.begin(), shadingSurfaces.end());
// }
return allModelObjects;
});
if (field == SELECTED) {
auto checkbox = QSharedPointer<OSSelectAllCheckBox>(new OSSelectAllCheckBox());
checkbox->setToolTip("Check to select all rows");
connect(checkbox.data(), &OSSelectAllCheckBox::checkStateChanged, this, &FacilityShadingGridController::onSelectAllStateChanged);
connect(this, &FacilityShadingGridController::gridRowSelectionChanged, checkbox.data(), &OSSelectAllCheckBox::onGridRowSelectionChanged);
addSelectColumn(Heading(QString(SELECTED), false, false, checkbox), "Check to select this row", DataSource(allShadingSurfaces, true));
} else if (field == SHADINGSURFACENAME) {
addLoadNameColumn(Heading(QString(SHADINGSURFACENAME), true, false), CastNullAdapter<model::ShadingSurface>(&model::ShadingSurface::name),
CastNullAdapter<model::ShadingSurface>(&model::ShadingSurface::setName),
boost::optional<std::function<void(model::ShadingSurface*)>>(
std::function<void(model::ShadingSurface*)>([](model::ShadingSurface* t_ss) { t_ss->remove(); })),
boost::optional<std::function<bool(model::ShadingSurface*)>>(), DataSource(allShadingSurfaces, true));
} else if (field == DISPLAYNAME) {
addNameLineEditColumn(Heading(QString(DISPLAYNAME), false, false), // heading
false, // isInspectable
false, // isLocked
DisplayNameAdapter<model::ShadingSurface>(&model::ShadingSurface::displayName), // getter
DisplayNameAdapter<model::ShadingSurface>(&model::ShadingSurface::setDisplayName), // setter
boost::optional<std::function<void(model::ShadingSurface*)>>(), // resetter
boost::optional<std::function<bool(model::ShadingSurface*)>>(), // isDefaulted
DataSource(allShadingSurfaces, true) // t_source
);
} else if (field == CADOBJECTID) {
addNameLineEditColumn(Heading(QString(CADOBJECTID), false, false), // heading
false, // isInspectable
false, // isLocked
DisplayNameAdapter<model::ShadingSurface>(&model::ShadingSurface::cadObjectId), // getter
DisplayNameAdapter<model::ShadingSurface>(&model::ShadingSurface::setCADObjectId), // setter
boost::optional<std::function<void(model::ShadingSurface*)>>(), // resetter
boost::optional<std::function<bool(model::ShadingSurface*)>>(), // isDefaulted
DataSource(allShadingSurfaces, true) // t_source
);
} else if (field == CONSTRUCTIONNAME) {
addDropZoneColumn(
Heading(QString(CONSTRUCTIONNAME), true, false), CastNullAdapter<model::ShadingSurface>(&model::ShadingSurface::construction),
CastNullAdapter<model::ShadingSurface>(&model::ShadingSurface::setConstruction),
boost::optional<std::function<void(model::ShadingSurface*)>>(NullAdapter(&model::ShadingSurface::resetConstruction)),
boost::optional<std::function<bool(model::ShadingSurface*)>>(NullAdapter(&model::ShadingSurface::isConstructionDefaulted)),
boost::optional<std::function<std::vector<model::ModelObject>(const model::ShadingSurface*)>>(), DataSource(allShadingSurfaces, true));
} else if (field == TRANSMITTANCESCHEDULENAME) {
std::function<bool(model::ShadingSurface*, const model::Schedule&)> setter(
[](model::ShadingSurface* t_shadingSurface, const model::Schedule& t_schedule) {
auto copy = t_schedule;
return t_shadingSurface->setTransmittanceSchedule(copy);
});
addDropZoneColumn(Heading(QString(TRANSMITTANCESCHEDULENAME), true, false),
CastNullAdapter<model::ShadingSurface>(&model::ShadingSurface::transmittanceSchedule), setter,
boost::optional<std::function<void(model::ShadingSurface*)>>(
CastNullAdapter<model::ShadingSurface>(&model::ShadingSurface::resetTransmittanceSchedule)),
boost::optional<std::function<bool(model::ShadingSurface*)>>(),
boost::optional<std::function<std::vector<model::ModelObject>(const model::ShadingSurface*)>>(),
DataSource(allShadingSurfaces, true));
} else {
// unhandled
OS_ASSERT(false);
}
}
}
}
QString FacilityShadingGridController::getColor(const model::ModelObject& modelObject) {
QColor defaultColor(Qt::lightGray);
return defaultColor.name();
}
void FacilityShadingGridController::checkSelectedFields() {
if (!this->hasHorizontalHeader()) return;
OSGridController::checkSelectedFields();
}
void FacilityShadingGridController::onItemDropped(const OSItemId& itemId) {}
void FacilityShadingGridController::refreshModelObjects() {
auto shadingGroups = model().getConcreteModelObjects<model::ShadingSurfaceGroup>();
// Filter out the 'Space' shadingSurfaceTypes
// These are displayed on the Space's "Shading" subtab
shadingGroups.erase(std::remove_if(shadingGroups.begin(), shadingGroups.end(),
[](const model::ShadingSurfaceGroup& sg) { return sg.shadingSurfaceType() == "Space"; }),
shadingGroups.end());
std::sort(shadingGroups.begin(), shadingGroups.end(), openstudio::WorkspaceObjectNameLess());
setModelObjects(subsetCastVector<model::ModelObject>(shadingGroups));
}
} // namespace openstudio