fix: dirty system now dirties and cooks descendents of change
This commit is contained in:
@@ -19,15 +19,31 @@ enzo::nt::OpId enzo::nt::NetworkManager::addOperator(op::OpInfo opInfo)
|
|||||||
maxOpId_++;
|
maxOpId_++;
|
||||||
std::unique_ptr<GeometryOperator> newOp = std::make_unique<GeometryOperator>(maxOpId_, opInfo);
|
std::unique_ptr<GeometryOperator> newOp = std::make_unique<GeometryOperator>(maxOpId_, opInfo);
|
||||||
newOp->nodeDirtied.connect(
|
newOp->nodeDirtied.connect(
|
||||||
[this](nt::OpId opId)
|
[this](nt::OpId opId, bool dirtyDescendents)
|
||||||
{
|
{
|
||||||
cookOp(opId);
|
IC();
|
||||||
|
if(dirtyDescendents)
|
||||||
|
{
|
||||||
|
IC();
|
||||||
|
std::vector<OpId> dependentIds = getDependentsGraph(opId);
|
||||||
|
for(OpId dependentId : dependentIds)
|
||||||
|
{
|
||||||
|
IC();
|
||||||
|
// dirty node
|
||||||
|
enzo::nt::GeometryOperator& dependentOp = getGeoOperator(opId);
|
||||||
|
std::cout << "dirtying id: " << dependentId << "\n";
|
||||||
|
dependentOp.dirtyNode(false);
|
||||||
|
|
||||||
if(getDisplayOp()==opId)
|
// cook display op
|
||||||
|
if(getDisplayOp().has_value() && getDisplayOp().value()==dependentId)
|
||||||
{
|
{
|
||||||
enzo::nt::GeometryOperator& displayOp = getGeoOperator(opId);
|
IC();
|
||||||
updateDisplay(displayOp.getOutputGeo(0));
|
cookOp(dependentId);
|
||||||
|
updateDisplay(dependentOp.getOutputGeo(0));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
gopStore_.emplace(maxOpId_, std::move(newOp));
|
gopStore_.emplace(maxOpId_, std::move(newOp));
|
||||||
std::cout << "adding operator " << maxOpId_ << "\n";
|
std::cout << "adding operator " << maxOpId_ << "\n";
|
||||||
@@ -96,7 +112,6 @@ std::vector<enzo::nt::OpId> enzo::nt::NetworkManager::getDependencyGraph(enzo::n
|
|||||||
while(traversalBuffer.size()!=0)
|
while(traversalBuffer.size()!=0)
|
||||||
{
|
{
|
||||||
enzo::nt::OpId currentOp = traversalBuffer.top();
|
enzo::nt::OpId currentOp = traversalBuffer.top();
|
||||||
std::cout << "cooking node: " << currentOp << "\n";
|
|
||||||
traversalBuffer.pop();
|
traversalBuffer.pop();
|
||||||
auto inputConnections = getGeoOperator(currentOp).getInputConnections();
|
auto inputConnections = getGeoOperator(currentOp).getInputConnections();
|
||||||
for(auto connection : inputConnections)
|
for(auto connection : inputConnections)
|
||||||
@@ -114,6 +129,31 @@ std::vector<enzo::nt::OpId> enzo::nt::NetworkManager::getDependencyGraph(enzo::n
|
|||||||
return dependencyGraph;
|
return dependencyGraph;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<enzo::nt::OpId> enzo::nt::NetworkManager::getDependentsGraph(enzo::nt::OpId opId)
|
||||||
|
{
|
||||||
|
std::stack<enzo::nt::OpId> traversalBuffer;
|
||||||
|
std::vector<enzo::nt::OpId> dependencyGraph;
|
||||||
|
traversalBuffer.push(opId);
|
||||||
|
dependencyGraph.push_back(opId);
|
||||||
|
|
||||||
|
while(traversalBuffer.size()!=0)
|
||||||
|
{
|
||||||
|
enzo::nt::OpId currentOp = traversalBuffer.top();
|
||||||
|
traversalBuffer.pop();
|
||||||
|
auto outputConnections = getGeoOperator(currentOp).getOutputConnections();
|
||||||
|
for(auto connection : outputConnections)
|
||||||
|
{
|
||||||
|
if(auto connectionPtr = connection.lock())
|
||||||
|
{
|
||||||
|
traversalBuffer.push(connectionPtr->getOutputOpId());
|
||||||
|
dependencyGraph.push_back(connectionPtr->getOutputOpId());
|
||||||
|
}
|
||||||
|
else { throw std::runtime_error("Connection weak ptr invalid"); }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return dependencyGraph;
|
||||||
|
}
|
||||||
|
|
||||||
std::optional<enzo::nt::OpId> enzo::nt::NetworkManager::getDisplayOp()
|
std::optional<enzo::nt::OpId> enzo::nt::NetworkManager::getDisplayOp()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ private:
|
|||||||
// functions
|
// functions
|
||||||
void cookOp(enzo::nt::OpId opId);
|
void cookOp(enzo::nt::OpId opId);
|
||||||
std::vector<enzo::nt::OpId> getDependencyGraph(enzo::nt::OpId opId);
|
std::vector<enzo::nt::OpId> getDependencyGraph(enzo::nt::OpId opId);
|
||||||
|
std::vector<enzo::nt::OpId> getDependentsGraph(enzo::nt::OpId opId);
|
||||||
|
|
||||||
// variables
|
// variables
|
||||||
// store for geometry operators
|
// store for geometry operators
|
||||||
|
|||||||
@@ -40,17 +40,17 @@ void nt::GeometryOperator::initParameters()
|
|||||||
std::cout << "name: " << t->getName() << "\n";
|
std::cout << "name: " << t->getName() << "\n";
|
||||||
// create parameter
|
// create parameter
|
||||||
auto parameter = std::make_shared<prm::Parameter>(*t);
|
auto parameter = std::make_shared<prm::Parameter>(*t);
|
||||||
parameter->valueChanged.connect(boost::bind(&GeometryOperator::dirtyNode, this));
|
parameter->valueChanged.connect([this](){dirtyNode();});
|
||||||
|
|
||||||
parameters_.push_back(parameter);
|
parameters_.push_back(parameter);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void enzo::nt::GeometryOperator::dirtyNode()
|
void enzo::nt::GeometryOperator::dirtyNode(bool dirtyDescendents)
|
||||||
{
|
{
|
||||||
dirty_=true;
|
dirty_=true;
|
||||||
nodeDirtied(opId_);
|
nodeDirtied(opId_, dirtyDescendents);
|
||||||
}
|
}
|
||||||
|
|
||||||
void enzo::nt::GeometryOperator::cookOp(op::Context context)
|
void enzo::nt::GeometryOperator::cookOp(op::Context context)
|
||||||
@@ -79,11 +79,11 @@ void nt::GeometryOperator::addInputConnection(std::shared_ptr<nt::GeometryConnec
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "Input newConnection added\nConnecting ops " << newConnection->getInputOpId() << " -> " << newConnection->getOutputOpId() << "\n";
|
|
||||||
std::cout << "Connecting index " << newConnection->getInputIndex() << " -> " << newConnection->getOutputIndex() << "\n";
|
|
||||||
// add new newConnection
|
// add new newConnection
|
||||||
inputConnections_.push_back(newConnection);
|
inputConnections_.push_back(newConnection);
|
||||||
std::cout << "size: " << inputConnections_.size() << "\n";
|
|
||||||
|
IC();
|
||||||
|
dirtyNode();
|
||||||
}
|
}
|
||||||
|
|
||||||
void nt::GeometryOperator::addOutputConnection(std::shared_ptr<nt::GeometryConnection> connection)
|
void nt::GeometryOperator::addOutputConnection(std::shared_ptr<nt::GeometryConnection> connection)
|
||||||
|
|||||||
@@ -32,15 +32,15 @@ public:
|
|||||||
|
|
||||||
std::string getTypeName();
|
std::string getTypeName();
|
||||||
|
|
||||||
void dirtyNode();
|
void dirtyNode(bool dirtyDescendents=true);
|
||||||
|
|
||||||
|
|
||||||
unsigned int getMaxInputs() const;
|
|
||||||
unsigned int getMinInputs() const;
|
unsigned int getMinInputs() const;
|
||||||
|
unsigned int getMaxInputs() const;
|
||||||
unsigned int getMaxOutputs() const;
|
unsigned int getMaxOutputs() const;
|
||||||
|
|
||||||
// signals
|
// signals
|
||||||
boost::signals2::signal<void (nt::OpId)> nodeDirtied;
|
boost::signals2::signal<void (nt::OpId opId, bool dirtyDescendents)> nodeDirtied;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -165,8 +165,6 @@ void Network::socketClicked(SocketGraphic* socket, QMouseEvent *event)
|
|||||||
newEdge->setPos(outputNodeSocket->scenePos(), inputNodeSocket->scenePos());
|
newEdge->setPos(outputNodeSocket->scenePos(), inputNodeSocket->scenePos());
|
||||||
scene_->addItem(newEdge);
|
scene_->addItem(newEdge);
|
||||||
destroyFloatingEdge();
|
destroyFloatingEdge();
|
||||||
|
|
||||||
geoOp.dirtyNode();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ NodeGraphic::NodeGraphic(enzo::nt::OpId id, QGraphicsItem *parent)
|
|||||||
enzo::nt::GeometryOperator& geoOp = enzo::nt::nm().getGeoOperator(id);
|
enzo::nt::GeometryOperator& geoOp = enzo::nt::nm().getGeoOperator(id);
|
||||||
titleText_ = geoOp.getTypeName();
|
titleText_ = geoOp.getTypeName();
|
||||||
// TODO: unique node names
|
// TODO: unique node names
|
||||||
subTitleText_ = geoOp.getTypeName();
|
subTitleText_ = "OpID: " + std::to_string(opId_);
|
||||||
constexpr int height = 27;
|
constexpr int height = 27;
|
||||||
constexpr int width = 100;
|
constexpr int width = 100;
|
||||||
bodyRect_ = QRect(-width*0.5f, -height*0.5f, width, height);
|
bodyRect_ = QRect(-width*0.5f, -height*0.5f, width, height);
|
||||||
|
|||||||
Reference in New Issue
Block a user