#include "NumberDisplayDataModel.hpp" #include "DecimalData.hpp" #include NumberDisplayDataModel:: NumberDisplayDataModel() : _label{nullptr} { } unsigned int NumberDisplayDataModel:: nPorts(PortType portType) const { unsigned int result = 1; switch (portType) { case PortType::In: result = 1; break; case PortType::Out: result = 0; default: break; } return result; } NodeDataType NumberDisplayDataModel:: dataType(PortType, PortIndex) const { return DecimalData().type(); } std::shared_ptr NumberDisplayDataModel:: outData(PortIndex) { std::shared_ptr ptr; return ptr; } void NumberDisplayDataModel:: setInData(std::shared_ptr data, int) { auto numberData = std::dynamic_pointer_cast(data); if (numberData) { modelValidationState = NodeValidationState::Valid; modelValidationError = QString(); _label->setText(numberData->numberAsText()); } else { modelValidationState = NodeValidationState::Warning; modelValidationError = QStringLiteral("Missing or incorrect inputs"); _label->clear(); } _label->adjustSize(); } QWidget* NumberDisplayDataModel:: embeddedWidget() { if (!_label) { _label = new QLabel(); _label->setMargin(3); } return _label; } NodeValidationState NumberDisplayDataModel:: validationState() const { return modelValidationState; } QString NumberDisplayDataModel:: validationMessage() const { return modelValidationError; }