41 lines
1.1 KiB
C++
41 lines
1.1 KiB
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->instances) {
|
|
ComponentWrapper *group = nullptr;
|
|
auto component = dynamic_cast<domain::ComponentInstance*>(instance);
|
|
if(component) {
|
|
group = ComponentWrapper::ofComponent(component);
|
|
}
|
|
auto bus = dynamic_cast<domain::BusInstance*>(instance);
|
|
if(bus) {
|
|
group = ComponentWrapper::ofBus(bus);
|
|
}
|
|
if(group != nullptr) {
|
|
group->setPos(instance->position.first, instance->position.second);
|
|
scene.addItem(group);
|
|
}
|
|
}
|
|
for(auto &wire: schema->wires) {
|
|
auto group = ComponentWrapper::ofWire(wire);
|
|
group->setPos(wire->position.first, wire->position.second);
|
|
scene.addItem(group);
|
|
}
|
|
}
|
|
}
|
|
|
|
} // namespace display
|