| 67 | } |
| 68 | |
| 69 | FloorplanJS FloorplanJSForwardTranslator::updateFloorplanJS(const FloorplanJS& floorplan, const Model& model, bool removeMissingObjects) { |
| 70 | m_logSink.setThreadId(std::this_thread::get_id()); |
| 71 | m_logSink.resetStringStream(); |
| 72 | |
| 73 | FloorplanJS result(floorplan.toJSON()); |
| 74 | |
| 75 | // first have to update all the names |
| 76 | |
| 77 | // update resources first since these will have references to them |
| 78 | std::vector<FloorplanObject> unitObjects; |
| 79 | for (const auto& unit : model.getConcreteModelObjects<BuildingUnit>()) { |
| 80 | FloorplanObject unitObject("", unit.nameString(), unit.handle()); |
| 81 | unitObjects.push_back(unitObject); |
| 82 | } |
| 83 | result.updateBuildingUnits(unitObjects, removeMissingObjects); |
| 84 | |
| 85 | std::vector<FloorplanObject> zoneObjects; |
| 86 | for (const auto& zone : model.getConcreteModelObjects<ThermalZone>()) { |
| 87 | FloorplanObject zoneObject("", zone.nameString(), zone.handle()); |
| 88 | |
| 89 | boost::optional<RenderingColor> color = zone.renderingColor(); |
| 90 | if (color) { |
| 91 | zoneObject.setDataString("color", color->colorString()); |
| 92 | } |
| 93 | |
| 94 | zoneObjects.push_back(zoneObject); |
| 95 | } |
| 96 | result.updateThermalZones(zoneObjects, removeMissingObjects); |
| 97 | |
| 98 | std::vector<FloorplanObject> spaceTypeObjects; |
| 99 | for (const auto& spaceType : model.getConcreteModelObjects<SpaceType>()) { |
| 100 | FloorplanObject spaceTypeObject("", spaceType.nameString(), spaceType.handle()); |
| 101 | |
| 102 | boost::optional<RenderingColor> color = spaceType.renderingColor(); |
| 103 | if (color) { |
| 104 | spaceTypeObject.setDataString("color", color->colorString()); |
| 105 | } |
| 106 | |
| 107 | spaceTypeObjects.push_back(spaceTypeObject); |
| 108 | } |
| 109 | result.updateSpaceTypes(spaceTypeObjects, removeMissingObjects); |
| 110 | |
| 111 | std::vector<FloorplanObject> setObjects; |
| 112 | for (const auto& set : model.getConcreteModelObjects<DefaultConstructionSet>()) { |
| 113 | FloorplanObject setObject("", set.nameString(), set.handle()); |
| 114 | |
| 115 | //boost::optional<RenderingColor> color = set.renderingColor(); |
| 116 | //if (color){ |
| 117 | // setObject.setDataString("color", color->colorString()); |
| 118 | //} |
| 119 | |
| 120 | setObjects.push_back(setObject); |
| 121 | } |
| 122 | result.updateConstructionSets(setObjects, removeMissingObjects); |
| 123 | |
| 124 | // do stories and spaces after resources |
| 125 | std::vector<FloorplanObject> storyObjects; |
| 126 | for (const auto& story : model.getConcreteModelObjects<BuildingStory>()) { |