![]() |
Tulip
4.6.0
Better Visualization Through Research
|
00001 /* 00002 * 00003 * This file is part of Tulip (www.tulip-software.org) 00004 * 00005 * Authors: David Auber and the Tulip development Team 00006 * from LaBRI, University of Bordeaux 00007 * 00008 * Tulip is free software; you can redistribute it and/or modify 00009 * it under the terms of the GNU Lesser General Public License 00010 * as published by the Free Software Foundation, either version 3 00011 * of the License, or (at your option) any later version. 00012 * 00013 * Tulip is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00016 * See the GNU General Public License for more details. 00017 * 00018 */ 00019 #include <tulip/ForEach.h> 00020 00021 template<typename PropType, typename NodeType, typename EdgeType> 00022 PropertyAnimation<PropType, NodeType, EdgeType>::PropertyAnimation(tlp::Graph *graph, PropType *start, PropType *end, PropType *out, 00023 tlp::BooleanProperty *selection, int frameCount, bool computeNodes, bool computeEdges, QObject* parent) : 00024 00025 Animation(frameCount,parent), _graph(graph), _start(0), _end(0), _out(out), _computeNodes(computeNodes), _computeEdges(computeEdges) { 00026 00027 assert(out); 00028 assert(start); 00029 assert(end); 00030 assert(end->getGraph()->getRoot() == start->getGraph()->getRoot()); 00031 assert(end->getGraph()->getRoot() == out->getGraph()->getRoot()); 00032 assert(graph); 00033 assert(frameCount > 0); 00034 00035 this->_start = new PropType(start->getGraph()); 00036 *(this->_start) = *start; 00037 this->_end = new PropType(end->getGraph()); 00038 *(this->_end) = *end; 00039 00040 if (!selection) { 00041 this->_selection = new tlp::BooleanProperty(graph); 00042 this->_selection->setAllNodeValue(true); 00043 this->_selection->setAllEdgeValue(true); 00044 } 00045 else { 00046 this->_selection = new tlp::BooleanProperty(selection->getGraph()); 00047 *(this->_selection) = *selection; 00048 } 00049 } 00050 00051 template<typename PropType, typename NodeType, typename EdgeType> 00052 PropertyAnimation<PropType, NodeType, EdgeType>::~PropertyAnimation() { 00053 delete _start; 00054 delete _end; 00055 delete _selection; 00056 } 00057 00058 template<typename PropType, typename NodeType, typename EdgeType> 00059 void PropertyAnimation<PropType, NodeType, EdgeType>::frameChanged(int f) { 00060 if (_computeNodes) { 00061 tlp::node n; 00062 forEach(n, _graph->getNodes()) { 00063 if (_selection->getNodeValue(n)) 00064 _out->setNodeValue(n, getNodeFrameValue(_start->getNodeValue(n), _end->getNodeValue(n), f)); 00065 } 00066 } 00067 00068 if (_computeEdges) { 00069 tlp::edge e; 00070 forEach(e, _graph->getEdges()) { 00071 if (_selection->getEdgeValue(e)) 00072 _out->setEdgeValue(e, getEdgeFrameValue(_start->getEdgeValue(e), _end->getEdgeValue(e), f)); 00073 } 00074 } 00075 }