void PropertyValuesDispatcher::afterSetEdgeValue(tlp::PropertyInterface *sourceProp, const tlp::edge e) { if (_modifying) return; _modifying = true; if (sourceProp->getGraph()->getRoot() == _source->getRoot()) { PropertyInterface *targetProp = _target->getProperty(sourceProp->getName()); std::string strVal = sourceProp->getEdgeStringValue(e); vector<int> vect = _graphEntitiesToDisplayedNodes->getEdgeValue(e); for(vector<int>::iterator it = vect.begin(); it != vect.end(); ++it) targetProp->setNodeStringValue(node(*it), strVal); edge ee = _edgesMap[e]; // corresponding edge may not exist if e // has been added after the build of the MatrixView if (ee.isValid()) targetProp->setEdgeStringValue(_edgesMap[e], sourceProp->getEdgeStringValue(e)); } else if (sourceProp->getGraph()->getRoot() == _target->getRoot()) { PropertyInterface *targetProp = _source->getProperty(sourceProp->getName()); unsigned int id = _displayedEdgesToGraphEdges->getEdgeValue(e); std::string strVal = sourceProp->getEdgeStringValue(e); targetProp->setEdgeStringValue(edge(id), strVal); vector<int> vect = _graphEntitiesToDisplayedNodes->getEdgeValue(edge(id)); for(vector<int>::iterator it = vect.begin(); it != vect.end(); ++it) sourceProp->setNodeStringValue(node(*it), strVal); } _modifying = false; }
//========================================== void ElementPropertiesWidget::propertyTableValueChanged(int row, int col) { if (col == 0) return; // cerr << __PRETTY_FUNCTION__ << endl; QString property = propertyTable->item(row, 0)->text(); QString value = ((TulipTableWidgetItem *)propertyTable->item(row, col))->textForTulip(); PropertyInterface *editedProperty = graph->getProperty(property.toUtf8().data()); if (editedProperty==NULL) return; //cerr << "Value :" << value.toUtf8().data() << endl; bool result=true; switch(displayMode) { case NODE: // allow to undo graph->push(); result=editedProperty->setNodeStringValue(currentNode, value.toUtf8().data()); break; case EDGE: // allow to undo graph->push(); result=editedProperty->setEdgeStringValue(currentEdge, value.toUtf8().data()); break; } if (!result) { QMessageBox::critical( 0, "Tulip Property Editor Change Failed", QString("The value entered for this property is not correct,\n" "The change won't be applied\n" "Modify the entered value to apply the changes.") ); } else { switch(displayMode) { case NODE: emit tulipNodePropertyChanged(graph, currentNode, property, value); break; case EDGE: emit tulipEdgePropertyChanged(graph, currentEdge, property, value); break; } } //} }
void PropertyValuesDispatcher::afterSetNodeValue(tlp::PropertyInterface *sourceProp, const tlp::node n) { if (_modifying) return; _modifying = true; if (sourceProp->getGraph()->getRoot() == _source->getRoot()) { PropertyInterface *targetProp = _target->getProperty(sourceProp->getName()); std::string strVal = sourceProp->getNodeStringValue(n); vector<int> vect = _graphEntitiesToDisplayedNodes->getNodeValue(n); for(vector<int>::iterator it = vect.begin(); it != vect.end(); ++it) targetProp->setNodeStringValue(node(*it), strVal); } else if (sourceProp->getGraph()->getRoot() == _target->getRoot()) { PropertyInterface *targetProp = _source->getProperty(sourceProp->getName()); unsigned int id = _displayedNodesToGraphEntities->getNodeValue(n); if (_displayedNodesAreNodes->getNodeValue(n)) { targetProp->setNodeStringValue(node(id), sourceProp->getNodeStringValue(n)); // update the other node vector<int> vect = _graphEntitiesToDisplayedNodes->getNodeValue(node(id)); for(vector<int>::iterator it = vect.begin(); it != vect.end(); ++it) { node n1(*it); if (n1 != n) sourceProp->setNodeStringValue(n1, sourceProp->getNodeStringValue(n)); } } else { targetProp->setEdgeStringValue(edge(id), sourceProp->getNodeStringValue(n)); sourceProp->setEdgeStringValue(_edgesMap[edge(id)], sourceProp->getNodeStringValue(n)); vector<int> vect = _graphEntitiesToDisplayedNodes->getEdgeValue(edge(id)); for(vector<int>::iterator it = vect.begin(); it != vect.end(); ++it) { node n1(*it); if (n1 != n) sourceProp->setNodeStringValue(n1, sourceProp->getNodeStringValue(n)); } } } _modifying = false; }