/usr/include/simgear/props/PropertyInterpolationMgr.hxx is in libsimgear-dev 1:2018.1.1+dfsg-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | // Subsystem that manages interpolation of properties.
//
// Copyright (C) 2013 Thomas Geymayer <tomgey@gmail.com>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
#ifndef SG_PROPERTY_INTERPOLATION_MGR_HXX_
#define SG_PROPERTY_INTERPOLATION_MGR_HXX_
#include "PropertyInterpolator.hxx"
#include <simgear/math/sg_types.hxx>
#include <simgear/misc/make_new.hxx>
#include <simgear/props/props.hxx>
#include <simgear/structure/subsystem_mgr.hxx>
#include <list>
namespace simgear
{
/**
* Subsystem that manages interpolation of properties.
*
* By default the numeric values of the properties are interpolated. For
* example, for strings this is probably not the wanted behavior. For this
* adapter classes can be registered to allow providing specific
* interpolations for certain types of properties. Using the type "color",
* provided by ColorInterpolator, strings containing %CSS colors can also be
* interpolated.
*
* Additionally different functions can be used for easing of the animation.
* By default "linear" (constant animation speed) and "swing" (smooth
* acceleration and deceleration) are available.
*/
class PropertyInterpolationMgr:
public SGSubsystem
{
public:
typedef PropertyInterpolator* (*InterpolatorFactory)();
PropertyInterpolationMgr();
/**
* Update all active interpolators.
*/
void update(double dt);
/**
* Create a new property interpolator.
*
* @note To actually use it the interpolator needs to be attached to a
* property using PropertyInterpolationMgr::interpolate.
*
* @param type Type of animation ("numeric", "color", etc.)
* @param target Property containing target value
* @param duration Duration if the animation (in seconds)
* @param easing Type of easing ("linear", "swing", etc.)
*/
PropertyInterpolator*
createInterpolator( const std::string& type,
const SGPropertyNode& target,
double duration,
const std::string& easing );
/**
* Add animation of the given property from its current value to the
* target value of the interpolator. If no interpolator is given any
* existing animation of the given property is aborted.
*
* @param prop Property to be interpolated
* @param interp Interpolator used for interpolation
*/
bool interpolate( SGPropertyNode* prop,
PropertyInterpolatorRef interp = 0 );
bool interpolate( SGPropertyNode* prop,
const std::string& type,
const SGPropertyNode& target,
double duration,
const std::string& easing );
bool interpolate( SGPropertyNode* prop,
const std::string& type,
const PropertyList& values,
const double_list& deltas,
const std::string& easing );
/**
* Register factory for interpolation type.
*/
void addInterpolatorFactory( const std::string& type,
InterpolatorFactory factory );
template<class T>
void addInterpolatorFactory(const std::string& type)
{
addInterpolatorFactory
(
type,
&simgear::make_new_derived<PropertyInterpolator, T>
);
}
/**
* Register easing function.
*/
void addEasingFunction(const std::string& type, easing_func_t func);
/**
* Set property containing real time delta (not sim time)
*
* TODO better pass both deltas to all update methods...
*/
void setRealtimeProperty(SGPropertyNode* node);
protected:
typedef std::map<std::string, InterpolatorFactory> InterpolatorFactoryMap;
typedef std::map<std::string, easing_func_t> EasingFunctionMap;
typedef std::pair< SGPropertyNode*,
PropertyInterpolatorRef > PropertyInterpolatorPair;
typedef std::list<PropertyInterpolatorPair> InterpolatorList;
struct PredicateIsSameProp;
InterpolatorFactoryMap _interpolator_factories;
EasingFunctionMap _easing_functions;
InterpolatorList _interpolators;
SGPropertyNode_ptr _rt_prop;
};
} // namespace simgear
#endif /* SG_PROPERTY_INTERPOLATION_MGR_HXX_ */
|