schema_editor/comdel/display/schema_display.cpp

31 lines
815 B
C++
Raw Normal View History

2022-04-07 22:21:23 +00:00
#include "component_display.h"
#include "schema_display.h"
namespace display {
Schema::Schema()
{
this->setScene(&scene);
}
2022-04-18 09:41:02 +00:00
void Schema::setSchema(domain::Schema* schema)
2022-04-07 22:21:23 +00:00
{
scene.clear();
this->schema = schema;
2022-04-18 09:41:02 +00:00
if(schema != nullptr) {
2022-05-07 11:20:09 +00:00
for(auto &instance: schema->componentInstances) {
2022-05-07 12:19:43 +00:00
ComponentWrapper *component = ComponentWrapper::ofComponent(instance.get());
component->setPos(instance->position.first, instance->position.second);
2022-05-07 11:20:09 +00:00
scene.addItem(component);
2022-04-07 22:21:23 +00:00
}
2022-05-07 11:20:09 +00:00
for(auto &instance: schema->busInstances) {
2022-05-07 12:19:43 +00:00
ComponentWrapper *bus = ComponentWrapper::ofBus(instance.get());
bus->setPos(instance->position.first, instance->position.second);
2022-05-07 11:20:09 +00:00
scene.addItem(bus);
2022-04-07 22:21:23 +00:00
}
}
}
} // namespace display