20 template <
typename PropType,
typename NodeType,
typename EdgeType>
21 CachedPropertyAnimation<PropType, NodeType, EdgeType>::CachedPropertyAnimation(
22 tlp::Graph *graph, PropType *start, PropType *end, PropType *out,
25 : PropertyAnimation<PropType, NodeType, EdgeType>(graph, start, end, out, selection, frameCount,
26 computeNodes, computeEdges, parent) {
28 if (this->_computeNodes) {
29 for (
auto n : this->_graph->nodes()) {
30 if (this->equalNodes(this->_end->getNodeValue(n), this->_start->getNodeValue(n))) {
31 this->_selection->setNodeValue(n,
false);
33 this->_out->setNodeValue(n, this->_end->getNodeValue(n));
38 if (this->_computeEdges) {
39 for (
auto e : this->_graph->edges()) {
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() {}
52 template <
typename PropType,
typename NodeType,
typename EdgeType>
53 void CachedPropertyAnimation<PropType, NodeType, EdgeType>::frameChanged(
int f) {
54 if (this->_computeNodes) {
55 computedNodeSteps.clear();
56 for (
auto n : this->_graph->nodes()) {
57 if (this->_selection && !this->_selection->getNodeValue(n))
60 std::pair<NodeType, NodeType> values(this->_start->getNodeValue(n),
61 this->_end->getNodeValue(n));
64 if (computedNodeSteps.find(values) == computedNodeSteps.end()) {
65 frameValue = this->getNodeFrameValue(values.first, values.second, f);
66 computedNodeSteps[values] = frameValue;
68 frameValue = computedNodeSteps[values];
70 this->_out->setNodeValue(n, frameValue);
74 if (this->_computeEdges) {
75 computedEdgeSteps.clear();
76 for (
auto e : this->_graph->edges()) {
77 if (this->_selection && !this->_selection->getEdgeValue(e))
80 std::pair<EdgeType, EdgeType> values(this->_start->getEdgeValue(e),
81 this->_end->getEdgeValue(e));
84 if (computedEdgeSteps.find(values) == computedEdgeSteps.end()) {
85 frameValue = this->getEdgeFrameValue(values.first, values.second, f);
86 computedEdgeSteps[values] = frameValue;
88 frameValue = computedEdgeSteps[values];
90 this->_out->setEdgeValue(e, frameValue);
A graph property that maps a boolean value to graph elements.