#include "component_display.h" #include "schema_display.h" namespace display { Schema::Schema() { this->setScene(&scene); } void Schema::setSchema(std::optional schema) { scene.clear(); this->schema = schema; if(schema.has_value()) { for(auto &instance: schema->instances) { Component *group = nullptr; auto component = dynamic_cast(instance); if(component) { group = Component::ofComponent(component); } auto bus = dynamic_cast(instance); if(bus) { group = Component::ofBus(bus); } if(group != nullptr) { group->setPos(instance->position.first, instance->position.second); scene.addItem(group); } } for(auto &wire: schema->wires) { auto group = Component::ofWire(wire); group->setPos(wire->position.first, wire->position.second); scene.addItem(group); } } } } // namespace display