schema_editor/comdel/display/component_display.cpp

43 lines
1.4 KiB
C++

#include "component_display.h"
namespace display {
Component *Component::ofWire(domain::WireInstance *wire) {
auto component = new Component();
component->wireInstance = wire;
component->redraw();
return component;
}
Component *Component::ofComponent(domain::ComponentInstance *instance) {
auto component = new Component();
component->componentInstance = instance;
component->redraw();
return component;
}
Component *Component::ofBus(domain::BusInstance *instance) {
auto component = new Component();
component->busInstance = instance;
component->redraw();
return component;
}
void Component::redraw() {
if(componentInstance) {
componentInstance->component.getDisplay().render(this);
for(auto &pin: componentInstance->component.getPins()) {
pin.getDisplay().render(this);
}
this->addToGroup(new QGraphicsSimpleTextItem(QString::fromStdString(componentInstance->name)));
}
if(busInstance && busInstance->bus.getDisplay()) {
busInstance->bus.getDisplay()->render(this);
this->addToGroup(new QGraphicsSimpleTextItem(QString::fromStdString(busInstance->name)));
}
if(wireInstance) {
wireInstance->display.render(this);
this->addToGroup(new QGraphicsSimpleTextItem(QString::fromStdString(wireInstance->name)));
}
}
} // namespace display