schema_editor/comdel/display/schema_display.cpp

31 lines
815 B
C++

#include "component_display.h"
#include "schema_display.h"
namespace display {
Schema::Schema()
{
this->setScene(&scene);
}
void Schema::setSchema(domain::Schema* schema)
{
scene.clear();
this->schema = schema;
if(schema != nullptr) {
for(auto &instance: schema->componentInstances) {
ComponentWrapper *component = ComponentWrapper::ofComponent(instance.get());
component->setPos(instance->position.first, instance->position.second);
scene.addItem(component);
}
for(auto &instance: schema->busInstances) {
ComponentWrapper *bus = ComponentWrapper::ofBus(instance.get());
bus->setPos(instance->position.first, instance->position.second);
scene.addItem(bus);
}
}
}
} // namespace display