19 #include <tulip/ForEach.h> 21 template<
typename PropType,
typename NodeType,
typename EdgeType>
22 CachedPropertyAnimation<PropType, NodeType, EdgeType>::CachedPropertyAnimation(
tlp::Graph *graph, PropType *start, PropType *end, PropType *out,
23 tlp::BooleanProperty *selection,
int frameCount,
bool computeNodes,
bool computeEdges,QObject* parent) :
24 PropertyAnimation<PropType, NodeType, EdgeType> (graph, start, end, out, selection, frameCount, computeNodes, computeEdges,parent) {
26 if (this->_computeNodes) {
28 forEach (n, this->_graph->getNodes()) {
29 if (this->equalNodes(this->_end->getNodeValue(n), this->_start->getNodeValue(n))) {
30 this->_selection->setNodeValue(n,
false);
32 this->_out->setNodeValue(n,this->_end->getNodeValue(n));
37 if (this->_computeEdges) {
39 forEach (e, this->_graph->getEdges()) {
40 if (this->equalEdges(this->_end->getEdgeValue(e), this->_start->getEdgeValue(e))) {
41 this->_selection->setEdgeValue(e,
false);
43 this->_out->setEdgeValue(e,end->getEdgeValue(e));
49 template<
typename PropType,
typename NodeType,
typename EdgeType>
50 CachedPropertyAnimation<PropType, NodeType, EdgeType>::~CachedPropertyAnimation() {
53 template<
typename PropType,
typename NodeType,
typename EdgeType>
54 void CachedPropertyAnimation<PropType, NodeType, EdgeType>::frameChanged(
int f) {
55 if (this->_computeNodes) {
56 computedNodeSteps.clear();
58 forEach(n, this->_graph->getNodes()) {
59 if (this->_selection && !this->_selection->getNodeValue(n))
62 std::pair<NodeType, NodeType> values(this->_start->getNodeValue(n), this->_end->getNodeValue(n));
65 if (computedNodeSteps.find(values) == computedNodeSteps.end()) {
66 frameValue = this->getNodeFrameValue(values.first, values.second, f);
67 computedNodeSteps[values] = frameValue;
70 frameValue = computedNodeSteps[values];
72 this->_out->setNodeValue(n, frameValue);
76 if (this->_computeEdges) {
77 computedEdgeSteps.clear();
79 forEach(e, this->_graph->getEdges()) {
80 if (this->_selection && !this->_selection->getEdgeValue(e))
83 std::pair<EdgeType, EdgeType> values(this->_start->getEdgeValue(e), this->_end->getEdgeValue(e));
86 if (computedEdgeSteps.find(values) == computedEdgeSteps.end()) {
87 frameValue = this->getEdgeFrameValue(values.first, values.second, f);
88 computedEdgeSteps[values] = frameValue;
91 frameValue = computedEdgeSteps[values];
93 this->_out->setEdgeValue(e, frameValue);
A graph property that maps a boolean value to graph elements.
The edge struct represents an edge in a Graph object.
The node struct represents a node in a Graph object.