diff --git a/examples/calculator/DivisionModel.hpp b/examples/calculator/DivisionModel.hpp index ea5e6b09a..1b7865c7c 100644 --- a/examples/calculator/DivisionModel.hpp +++ b/examples/calculator/DivisionModel.hpp @@ -59,23 +59,23 @@ class DivisionModel : public MathOperationDataModel if (n2 && (n2->number() == 0.0)) { state._state = QtNodes::NodeValidationState::State::Error; state._stateMessage = QStringLiteral("Division by zero error"); - setValidatonState(state); + setValidationState(state); _result.reset(); } else if ( n2 && (n2->number() < 1e-5)) { state._state = QtNodes::NodeValidationState::State::Warning; state._stateMessage = QStringLiteral("Very small divident. Result might overflow"); - setValidatonState(state); + setValidationState(state); if (n1) { _result = std::make_shared(n1->number() / n2->number()); } else { _result.reset(); } } else if (n1 && n2) { - setValidatonState(state); + setValidationState(state); _result = std::make_shared(n1->number() / n2->number()); } else { QtNodes::NodeValidationState state; - setValidatonState(state); + setValidationState(state); _result.reset(); } diff --git a/examples/calculator/LongProcessingRandomNumber.hpp b/examples/calculator/LongProcessingRandomNumber.hpp new file mode 100644 index 000000000..d64f4ba7b --- /dev/null +++ b/examples/calculator/LongProcessingRandomNumber.hpp @@ -0,0 +1,83 @@ +#pragma once + +#include +#include +#include +#include +#include + +#include "MathOperationDataModel.hpp" +#include "DecimalData.hpp" + +/// The model generates a random value in a long processing schema, +/// as it should demonstrate the usage of the NodeProcessingStatus. +/// The random number is generate in the [n1, n2] interval. +class RandomNumberModel : public MathOperationDataModel +{ +public: + RandomNumberModel() { + this->setNodeProcessingStatus(QtNodes::NodeProcessingStatus::Empty); + + + QObject::connect(this, &NodeDelegateModel::computingStarted, this, [this]() { + if (_number1.lock() && _number2.lock()) { + this->setNodeProcessingStatus( + QtNodes::NodeProcessingStatus::Processing); + } + + emit requestNodeUpdate(); + }); + QObject::connect(this, &NodeDelegateModel::computingFinished, this, [this]() { + this->setNodeProcessingStatus( + QtNodes::NodeProcessingStatus::Updated); + + emit requestNodeUpdate(); + }); + } + virtual ~RandomNumberModel() {} + +public: + QString caption() const override { return QStringLiteral("Random Number"); } + + QString name() const override { return QStringLiteral("Random Number"); } + +private: + void compute() override + { + Q_EMIT computingStarted(); + PortIndex const outPortIndex = 0; + + auto n1 = _number1.lock(); + auto n2 = _number2.lock(); + + QTimer *timer = new QTimer(this); + timer->start(1000); + int secondsRemaining = 3; + connect(timer, &QTimer::timeout, this, [=]() mutable { + if (--secondsRemaining <= 0) { + timer->stop(); + if (n1 && n2) { + double a = n1->number(); + double b = n2->number(); + + if (a > b) { + setNodeProcessingStatus(QtNodes::NodeProcessingStatus::Failed); + + emit requestNodeUpdate(); + return; + } + + double upper = std::nextafter(b, std::numeric_limits::max()); + double randomValue = QRandomGenerator::global()->generateDouble() * (upper - a) + a; + + _result = std::make_shared(randomValue); + Q_EMIT computingFinished(); + } else { + _result.reset(); + } + + Q_EMIT dataUpdated(outPortIndex); + } + }); + } +}; diff --git a/examples/calculator/headless_main.cpp b/examples/calculator/headless_main.cpp index e4dafa022..89103a4f2 100644 --- a/examples/calculator/headless_main.cpp +++ b/examples/calculator/headless_main.cpp @@ -1,5 +1,6 @@ #include "AdditionModel.hpp" #include "DivisionModel.hpp" +#include "LongProcessingRandomNumber.hpp" #include "MultiplicationModel.hpp" #include "NumberDisplayDataModel.hpp" #include "NumberSourceDataModel.hpp" @@ -27,6 +28,8 @@ static std::shared_ptr registerDataModels() ret->registerModel("Operators"); + ret->registerModel("Operators"); + return ret; } diff --git a/examples/calculator/main.cpp b/examples/calculator/main.cpp index 980c0f23a..4d2504f02 100644 --- a/examples/calculator/main.cpp +++ b/examples/calculator/main.cpp @@ -14,6 +14,7 @@ #include "AdditionModel.hpp" #include "DivisionModel.hpp" +#include "LongProcessingRandomNumber.hpp" #include "MultiplicationModel.hpp" #include "NumberDisplayDataModel.hpp" #include "NumberSourceDataModel.hpp" @@ -40,6 +41,8 @@ static std::shared_ptr registerDataModels() ret->registerModel("Operators"); + ret->registerModel("Operators"); + return ret; } diff --git a/include/QtNodes/internal/DefaultNodePainter.hpp b/include/QtNodes/internal/DefaultNodePainter.hpp index 589800ddd..953faa065 100644 --- a/include/QtNodes/internal/DefaultNodePainter.hpp +++ b/include/QtNodes/internal/DefaultNodePainter.hpp @@ -32,6 +32,8 @@ class NODE_EDITOR_PUBLIC DefaultNodePainter : public AbstractNodePainter void drawResizeRect(QPainter *painter, NodeGraphicsObject &ngo) const; + void drawProcessingIndicator(QPainter *painter, NodeGraphicsObject &ngo) const; + void drawValidationIcon(QPainter *painter, NodeGraphicsObject &ngo) const; private: diff --git a/include/QtNodes/internal/Definitions.hpp b/include/QtNodes/internal/Definitions.hpp index efd9bbd3e..8c01475f9 100644 --- a/include/QtNodes/internal/Definitions.hpp +++ b/include/QtNodes/internal/Definitions.hpp @@ -33,6 +33,7 @@ enum class NodeRole { OutPortCount = 9, ///< `unsigned int` Widget = 10, ///< Optional `QWidget*` or `nullptr` ValidationState = 11, ///< Enum NodeValidationState of the node + ProcessingStatus = 12 ///< Enum NodeProcessingStatus of the node }; Q_ENUM_NS(NodeRole) diff --git a/include/QtNodes/internal/NodeDelegateModel.hpp b/include/QtNodes/internal/NodeDelegateModel.hpp index b47596f3a..8730805ca 100644 --- a/include/QtNodes/internal/NodeDelegateModel.hpp +++ b/include/QtNodes/internal/NodeDelegateModel.hpp @@ -3,6 +3,7 @@ #include #include +#include #include #include "Definitions.hpp" @@ -19,9 +20,9 @@ namespace QtNodes { struct NodeValidationState { enum class State : int { - Valid = 0, ///< All required inputs are present and correct. - Warning = 1, ///< Some inputs are missing or questionable, processing may be unreliable. - Error = 2, ///< Inputs or settings are invalid, preventing successful computation. + Valid = 0, ///< All required inputs are present and correct. + Warning = 1, ///< Some inputs are missing or questionable, processing may be unreliable. + Error = 2, ///< Inputs or settings are invalid, preventing successful computation. }; bool isValid() { return _state == State::Valid; }; QString const message() { return _stateMessage; } @@ -31,6 +32,19 @@ struct NodeValidationState QString _stateMessage{""}; }; +/** +* Describes the node status, depending on its current situation +*/ +enum class NodeProcessingStatus : int { + NoStatus = 0, ///< No processing status is shown in the Node UI. + Updated = 1, ///< Node is up to date; its outputs reflect the current inputs and parameters. + Processing = 2, ///< Node is currently running a computation. + Pending = 3, ///< Node is out of date and waiting to be recomputed (e.g. manual/queued run). + Empty = 4, ///< Node has no valid input data; nothing to compute. + Failed = 5, ///< The last computation ended with an error. + Partial = 6, ///< Computation finished incompletely; only partial results are available. +}; + class StyleCollection; /** @@ -39,7 +53,9 @@ class StyleCollection; * AbstractGraphModel. * This class is the same what has been called NodeDataModel before v3. */ -class NODE_EDITOR_PUBLIC NodeDelegateModel : public QObject, public Serializable +class NODE_EDITOR_PUBLIC NodeDelegateModel + : public QObject + , public Serializable { Q_OBJECT @@ -48,15 +64,15 @@ class NODE_EDITOR_PUBLIC NodeDelegateModel : public QObject, public Serializable virtual ~NodeDelegateModel() = default; + /// It is possible to hide caption in GUI + virtual bool captionVisible() const { return true; } + /// Name makes this model unique virtual QString name() const = 0; /// Caption is used in GUI virtual QString caption() const = 0; - /// It is possible to hide caption in GUI - virtual bool captionVisible() const { return true; } - /// Port caption is used in GUI to label individual ports virtual QString portCaption(PortType, PortIndex) const { return QString(); } @@ -66,12 +82,16 @@ class NODE_EDITOR_PUBLIC NodeDelegateModel : public QObject, public Serializable /// Validation State will default to Valid, but you can manipulate it by overriding in an inherited class virtual NodeValidationState validationState() const { return _nodeValidationState; } -public: + /// Returns the curent processing status + virtual NodeProcessingStatus processingStatus() const { return _processingStatus; } + QJsonObject save() const override; void load(QJsonObject const &) override; - void setValidatonState(const NodeValidationState &validationState); + void setValidationState(const NodeValidationState &validationState); + + void setNodeProcessingStatus(NodeProcessingStatus status); virtual unsigned int nPorts(PortType portType) const = 0; @@ -80,8 +100,16 @@ class NODE_EDITOR_PUBLIC NodeDelegateModel : public QObject, public Serializable virtual ConnectionPolicy portConnectionPolicy(PortType, PortIndex) const; NodeStyle const &nodeStyle() const; + void setNodeStyle(NodeStyle const &style); + QPixmap processingStatusIcon() const; + + void setStatusIcon(NodeProcessingStatus status, const QPixmap &pixmap); + + void setStatusIconStyle(ProcessingIconStyle const &style); + +public: virtual void setInData(std::shared_ptr nodeData, PortIndex const portIndex) = 0; virtual std::shared_ptr outData(PortIndex const port) = 0; @@ -114,10 +142,20 @@ public Q_SLOTS: void dataInvalidated(PortIndex const index); void computingStarted(); + void computingFinished(); void embeddedWidgetSizeUpdated(); + /// Request an update of the node's UI. + /** + * Emit this signal whenever some internal state change requires + * the node to be repainted. The containing graph model will + * propagate the update to the scene. + */ + void requestNodeUpdate(); + + /// Call this function before deleting the data associated with ports. /** * @brief Call this function before deleting the data associated with ports. * The function notifies the Graph Model and makes it remove and recompute the @@ -144,8 +182,11 @@ public Q_SLOTS: NodeStyle _nodeStyle; NodeValidationState _nodeValidationState; + + NodeProcessingStatus _processingStatus{NodeProcessingStatus::NoStatus}; }; } // namespace QtNodes Q_DECLARE_METATYPE(QtNodes::NodeValidationState) +Q_DECLARE_METATYPE(QtNodes::NodeProcessingStatus) diff --git a/include/QtNodes/internal/NodeGraphicsObject.hpp b/include/QtNodes/internal/NodeGraphicsObject.hpp index eab83c768..b3c01b904 100644 --- a/include/QtNodes/internal/NodeGraphicsObject.hpp +++ b/include/QtNodes/internal/NodeGraphicsObject.hpp @@ -1,5 +1,6 @@ #pragma once +#include #include #include diff --git a/include/QtNodes/internal/NodeStyle.hpp b/include/QtNodes/internal/NodeStyle.hpp index 9cb4a250c..9ecd953cd 100644 --- a/include/QtNodes/internal/NodeStyle.hpp +++ b/include/QtNodes/internal/NodeStyle.hpp @@ -1,5 +1,6 @@ #pragma once +#include #include #include "Export.hpp" @@ -7,6 +8,25 @@ namespace QtNodes { +/** + * Describes the position of the processing icon on the node ui + */ +enum class ProcessingIconPos { + BottomLeft = 0, /// icon on the bottom left position + BottomRight = 1, /// icon on the bottom right position +}; + +/** + * Defines the processing icon style; + */ +struct ProcessingIconStyle +{ + ProcessingIconPos _pos{ProcessingIconPos::BottomRight}; + double _size{20.0}; + double _margin{8.0}; + int _resolution{64}; +}; + class NODE_EDITOR_PUBLIC NodeStyle : public Style { public: @@ -51,5 +71,14 @@ class NODE_EDITOR_PUBLIC NodeStyle : public Style float ConnectionPointDiameter; float Opacity; + + QIcon statusUpdated{QStringLiteral("://status_icons/updated.svg")}; + QIcon statusProcessing{QStringLiteral("://status_icons/processing.svg")}; + QIcon statusPending{QStringLiteral("://status_icons/pending.svg")}; + QIcon statusInvalid{QStringLiteral("://status_icons/failed.svg")}; + QIcon statusEmpty{QStringLiteral("://status_icons/empty.svg")}; + QIcon statusPartial{QStringLiteral("://status_icons/partial.svg")}; + + ProcessingIconStyle processingIconStyle{}; }; } // namespace QtNodes diff --git a/resources/resources.qrc b/resources/resources.qrc index 08aec37e6..f9da26fcd 100644 --- a/resources/resources.qrc +++ b/resources/resources.qrc @@ -2,5 +2,11 @@ DefaultStyle.json info-tooltip.svg + status_icons/empty.svg + status_icons/failed.svg + status_icons/partial.svg + status_icons/pending.svg + status_icons/processing.svg + status_icons/updated.svg diff --git a/resources/status_icons/empty.svg b/resources/status_icons/empty.svg new file mode 100644 index 000000000..21d5e820b --- /dev/null +++ b/resources/status_icons/empty.svg @@ -0,0 +1,12 @@ + + + + + + + + \ No newline at end of file diff --git a/resources/status_icons/failed.svg b/resources/status_icons/failed.svg new file mode 100644 index 000000000..90f53d66c --- /dev/null +++ b/resources/status_icons/failed.svg @@ -0,0 +1,14 @@ + + + + + + + + + + \ No newline at end of file diff --git a/resources/status_icons/partial.svg b/resources/status_icons/partial.svg new file mode 100644 index 000000000..78522eca3 --- /dev/null +++ b/resources/status_icons/partial.svg @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/resources/status_icons/pending.svg b/resources/status_icons/pending.svg new file mode 100644 index 000000000..7e74e3fb0 --- /dev/null +++ b/resources/status_icons/pending.svg @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/resources/status_icons/processing.svg b/resources/status_icons/processing.svg new file mode 100644 index 000000000..03ac710ac --- /dev/null +++ b/resources/status_icons/processing.svg @@ -0,0 +1,20 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/resources/status_icons/updated.svg b/resources/status_icons/updated.svg new file mode 100644 index 000000000..5c1075e2b --- /dev/null +++ b/resources/status_icons/updated.svg @@ -0,0 +1,14 @@ + + + + + + + + + + \ No newline at end of file diff --git a/src/DataFlowGraphModel.cpp b/src/DataFlowGraphModel.cpp index 396437241..fa5655cde 100644 --- a/src/DataFlowGraphModel.cpp +++ b/src/DataFlowGraphModel.cpp @@ -96,6 +96,10 @@ NodeId DataFlowGraphModel::addNode(QString const nodeType) this, &DataFlowGraphModel::portsInserted); + connect(model.get(), &NodeDelegateModel::requestNodeUpdate, this, [newId, this]() { + Q_EMIT nodeUpdated(newId); + }); + _models[newId] = std::move(model); Q_EMIT nodeCreated(newId); @@ -294,6 +298,11 @@ QVariant DataFlowGraphModel::nodeData(NodeId nodeId, NodeRole role) const auto validationState = model->validationState(); result = QVariant::fromValue(validationState); } break; + + case NodeRole::ProcessingStatus: { + auto processingStatus = model->processingStatus(); + result = QVariant::fromValue(processingStatus); + } break; } return result; @@ -358,7 +367,17 @@ bool DataFlowGraphModel::setNodeData(NodeId nodeId, NodeRole role, QVariant valu if (value.canConvert()) { auto state = value.value(); if (auto node = delegateModel(nodeId); node != nullptr) { - node->setValidatonState(state); + node->setValidationState(state); + } + } + Q_EMIT nodeUpdated(nodeId); + } break; + + case NodeRole::ProcessingStatus: { + if (value.canConvert()) { + auto status = value.value(); + if (auto node = delegateModel(nodeId); node != nullptr) { + node->setNodeProcessingStatus(status); } } Q_EMIT nodeUpdated(nodeId); @@ -567,6 +586,9 @@ void DataFlowGraphModel::loadNode(QJsonObject const &nodeJson) &NodeDelegateModel::portsInserted, this, &DataFlowGraphModel::portsInserted); + connect(model.get(), &NodeDelegateModel::requestNodeUpdate, this, [restoredNodeId, this]() { + Q_EMIT nodeUpdated(restoredNodeId); + }); _models[restoredNodeId] = std::move(model); diff --git a/src/DefaultHorizontalNodeGeometry.cpp b/src/DefaultHorizontalNodeGeometry.cpp index 8f3e07aad..a30121d2a 100644 --- a/src/DefaultHorizontalNodeGeometry.cpp +++ b/src/DefaultHorizontalNodeGeometry.cpp @@ -1,5 +1,4 @@ #include "DefaultHorizontalNodeGeometry.hpp" - #include "AbstractGraphModel.hpp" #include "NodeData.hpp" @@ -55,6 +54,12 @@ void DefaultHorizontalNodeGeometry::recomputeSize(NodeId const nodeId) const height += _portSpasing; // space above caption height += _portSpasing; // space below caption + QVariant var = _graphModel.nodeData(nodeId, NodeRole::ProcessingStatus); + auto processingStatusValue = var.value(); + + if (processingStatusValue != 0) + height += 20; + unsigned int inPortWidth = maxPortsTextAdvance(nodeId, PortType::In); unsigned int outPortWidth = maxPortsTextAdvance(nodeId, PortType::Out); diff --git a/src/DefaultNodePainter.cpp b/src/DefaultNodePainter.cpp index 1bd2bc5f5..d313d3a82 100644 --- a/src/DefaultNodePainter.cpp +++ b/src/DefaultNodePainter.cpp @@ -5,6 +5,7 @@ #include "BasicGraphicsScene.hpp" #include "ConnectionGraphicsObject.hpp" #include "ConnectionIdUtils.hpp" +#include "DataFlowGraphModel.hpp" #include "NodeDelegateModel.hpp" #include "NodeGraphicsObject.hpp" #include "NodeState.hpp" @@ -14,7 +15,6 @@ #include - namespace QtNodes { void DefaultNodePainter::paint(QPainter *painter, NodeGraphicsObject &ngo) const @@ -33,6 +33,8 @@ void DefaultNodePainter::paint(QPainter *painter, NodeGraphicsObject &ngo) const drawEntryLabels(painter, ngo); + drawProcessingIndicator(painter, ngo); + drawResizeRect(painter, ngo); drawValidationIcon(painter, ngo); @@ -82,7 +84,6 @@ void DefaultNodePainter::drawNodeRect(QPainter *painter, NodeGraphicsObject &ngo QPen p(color, penWidth); painter->setPen(p); - QLinearGradient gradient(QPointF(0.0, 0.0), QPointF(2.0, size.height())); gradient.setColorAt(0.0, nodeStyle.GradientColor0); gradient.setColorAt(0.10, nodeStyle.GradientColor1); @@ -113,7 +114,6 @@ void DefaultNodePainter::drawConnectionPoints(QPainter *painter, NodeGraphicsObj auto reducedDiameter = diameter * 0.6; for (PortType portType : {PortType::Out, PortType::In}) { - auto portCountRole = (portType == PortType::Out) ? NodeRole::OutPortCount : NodeRole::InPortCount; size_t const n = model.nodeData(nodeId, portCountRole).toUInt(); @@ -293,6 +293,41 @@ void DefaultNodePainter::drawResizeRect(QPainter *painter, NodeGraphicsObject &n } } +void DefaultNodePainter::drawProcessingIndicator(QPainter *painter, NodeGraphicsObject &ngo) const +{ + AbstractGraphModel &model = ngo.graphModel(); + NodeId const nodeId = ngo.nodeId(); + + auto *dfModel = dynamic_cast(&model); + if (!dfModel) + return; + + auto *delegate = dfModel->delegateModel(nodeId); + if (!delegate) + return; + + AbstractNodeGeometry &geometry = ngo.nodeScene()->nodeGeometry(); + + QSize size = geometry.size(nodeId); + + QPixmap pixmap = delegate->processingStatusIcon(); + NodeStyle nodeStyle = delegate->nodeStyle(); + + ProcessingIconStyle iconStyle = nodeStyle.processingIconStyle; + + qreal iconSize = iconStyle._size; + qreal margin = iconStyle._margin; + + qreal x = margin; + + if (iconStyle._pos == ProcessingIconPos::BottomRight) { + x = size.width() - iconSize - margin; + } + + QRect r(x, size.height() - iconSize - margin, iconSize, iconSize); + painter->drawPixmap(r, pixmap); +} + void DefaultNodePainter::drawValidationIcon(QPainter *painter, NodeGraphicsObject &ngo) const { AbstractGraphModel &model = ngo.graphModel(); @@ -329,13 +364,11 @@ void DefaultNodePainter::drawValidationIcon(QPainter *painter, NodeGraphicsObjec painter->setBrush(color); painter->drawEllipse(center, iconSize.width() / 2.0 + 2.0, iconSize.height() / 2.0 + 2.0); - QPainter imgPainter(&pixmap); imgPainter.setCompositionMode(QPainter::CompositionMode_SourceIn); imgPainter.fillRect(pixmap.rect(), nodeStyle.FontColor); imgPainter.end(); - painter->drawPixmap(center.toPoint() - QPoint(iconSize.width() / 2, iconSize.height() / 2), pixmap); diff --git a/src/NodeDelegateModel.cpp b/src/NodeDelegateModel.cpp index 34cf2cb22..81f1d08c8 100644 --- a/src/NodeDelegateModel.cpp +++ b/src/NodeDelegateModel.cpp @@ -24,7 +24,7 @@ void NodeDelegateModel::load(QJsonObject const &) // } -void NodeDelegateModel::setValidatonState(const NodeValidationState &validationState) +void NodeDelegateModel::setValidationState(const NodeValidationState &validationState) { _nodeValidationState = validationState; } @@ -56,4 +56,63 @@ void NodeDelegateModel::setNodeStyle(NodeStyle const &style) _nodeStyle = style; } +QPixmap NodeDelegateModel::processingStatusIcon() const +{ + int resolution = _nodeStyle.processingIconStyle._resolution; + switch (_processingStatus) { + case NodeProcessingStatus::NoStatus: + return {}; + case NodeProcessingStatus::Updated: + return _nodeStyle.statusUpdated.pixmap(resolution); + case NodeProcessingStatus::Processing: + return _nodeStyle.statusProcessing.pixmap(resolution); + case NodeProcessingStatus::Pending: + return _nodeStyle.statusPending.pixmap(resolution); + case NodeProcessingStatus::Empty: + return _nodeStyle.statusEmpty.pixmap(resolution); + case NodeProcessingStatus::Failed: + return _nodeStyle.statusInvalid.pixmap(resolution); + case NodeProcessingStatus::Partial: + return _nodeStyle.statusPartial.pixmap(resolution); + } + + return {}; +} + +void NodeDelegateModel::setStatusIcon(NodeProcessingStatus status, const QPixmap &pixmap) +{ + switch (status) { + case NodeProcessingStatus::NoStatus: + break; + case NodeProcessingStatus::Updated: + _nodeStyle.statusUpdated = QIcon(pixmap); + break; + case NodeProcessingStatus::Processing: + _nodeStyle.statusProcessing = QIcon(pixmap); + break; + case NodeProcessingStatus::Pending: + _nodeStyle.statusPending = QIcon(pixmap); + break; + case NodeProcessingStatus::Empty: + _nodeStyle.statusEmpty = QIcon(pixmap); + break; + case NodeProcessingStatus::Failed: + _nodeStyle.statusInvalid = QIcon(pixmap); + break; + case NodeProcessingStatus::Partial: + _nodeStyle.statusPartial = QIcon(pixmap); + break; + } +} + +void NodeDelegateModel::setStatusIconStyle(const ProcessingIconStyle &style) +{ + _nodeStyle.processingIconStyle = style; +} + +void NodeDelegateModel::setNodeProcessingStatus(NodeProcessingStatus status) +{ + _processingStatus = status; +} + } // namespace QtNodes diff --git a/src/NodeGraphicsObject.cpp b/src/NodeGraphicsObject.cpp index 4db8ed903..3eb94b359 100644 --- a/src/NodeGraphicsObject.cpp +++ b/src/NodeGraphicsObject.cpp @@ -16,7 +16,6 @@ #include - namespace QtNodes { NodeGraphicsObject::NodeGraphicsObject(BasicGraphicsScene &scene, NodeId nodeId) @@ -65,6 +64,8 @@ NodeGraphicsObject::NodeGraphicsObject(BasicGraphicsScene &scene, NodeId nodeId) if (_nodeId == nodeId) setLockedState(); }); + + QVariant var = _graphModel.nodeData(_nodeId, NodeRole::ProcessingStatus); } AbstractGraphModel &NodeGraphicsObject::graphModel() const diff --git a/src/NodeStyle.cpp b/src/NodeStyle.cpp index b3079b332..2c232fb44 100644 --- a/src/NodeStyle.cpp +++ b/src/NodeStyle.cpp @@ -8,7 +8,6 @@ #include - using QtNodes::NodeStyle; inline void initResources() @@ -89,14 +88,14 @@ void NodeStyle::setNodeStyle(QString jsonText) #define NODE_STYLE_READ_BOOL(values, variable) \ { \ - auto valueRef = values[#variable]; \ - NODE_STYLE_CHECK_UNDEFINED_VALUE(valueRef, variable) \ - variable = valueRef.toBool(); \ + auto valueRef = values[#variable]; \ + NODE_STYLE_CHECK_UNDEFINED_VALUE(valueRef, variable) \ + variable = valueRef.toBool(); \ } #define NODE_STYLE_WRITE_BOOL(values, variable) \ { \ - values[#variable] = variable; \ + values[#variable] = variable; \ } void NodeStyle::loadJson(QJsonObject const &json)