19 #include <tulip/ForEach.h>
21 template<
typename PropType,
typename RealType,
typename VectorType,
unsigned int SIZE>
22 VectorPropertyAnimation<PropType, RealType, VectorType, SIZE>::VectorPropertyAnimation(
tlp::Graph *graph, PropType *start, PropType *end,
23 PropType *out,
tlp::BooleanProperty *selection,
int frameCount,
bool computeNodes,
bool computeEdges,QObject* parent) :
24 CachedPropertyAnimation<PropType, RealType, RealType> (graph, start, end, out, selection, frameCount, computeNodes, computeEdges,parent) {
26 assert(frameCount > 1);
28 if (this->_computeNodes) {
30 forEach(n, this->_graph->getNodes()) {
31 if (this->_selection && !this->_selection->getNodeValue(n))
34 std::pair<PropVector, PropVector> values(PropVector(this->_start->getNodeValue(n)), PropVector(this->_end->getNodeValue(n)));
36 if (steps.find(values) == steps.end()) {
37 tlp::Vector<double, SIZE> stepsVector;
39 for (
unsigned int i = 0; i < SIZE; ++i)
40 stepsVector[i] = ((
double)values.second[i] - (double)values.first[i]) * 1. / (frameCount - 1);
42 steps[values] = stepsVector;
47 if (this->_computeEdges) {
49 forEach(e, this->_graph->getEdges()) {
50 if (this->_selection && !this->_selection->getEdgeValue(e))
53 std::pair<PropVector, PropVector> values(PropVector(this->_start->getEdgeValue(e)), PropVector(this->_end->getEdgeValue(e)));
55 if (steps.find(values) == steps.end()) {
56 tlp::Vector<double, SIZE> stepsVector;
58 for (
unsigned int i = 0; i < SIZE; ++i)
59 stepsVector[i] = ((
double) (values.second[i] - (double)values.first[i])) * 1. / (frameCount - 1);
61 steps[values] = stepsVector;
67 template<
typename PropType,
typename RealType,
typename VectorType,
unsigned int SIZE>
68 RealType VectorPropertyAnimation<PropType, RealType, VectorType, SIZE>::getNodeFrameValue(
const RealType &startValue,
const RealType &endValue,
70 PropVector result((PropVector)startValue);
71 std::pair<PropVector, PropVector> values(result, (PropVector) endValue);
72 tlp::Vector<double, SIZE> stepVal(steps[values]);
74 for (
unsigned i=0; i < SIZE; ++i)
75 result[i] += stepVal[i] * frame;
77 return RealType(result);
80 template<
typename PropType,
typename RealType,
typename VectorType,
unsigned int SIZE>
81 RealType VectorPropertyAnimation<PropType, RealType, VectorType, SIZE>::getEdgeFrameValue(
const RealType &startValue,
const RealType &endValue,
83 return getNodeFrameValue(startValue, endValue, frame);
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.