Welcome to mirror list, hosted at ThFree Co, Russian Federation.

animation.cpp « animation « drape_frontend - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a750cc264593a7de1410847d1334f32adcf8466e (plain)
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
#include "animation.hpp"

namespace df
{

// static
bool Animation::GetCachedProperty(TPropertyCache const & properties, Object object, ObjectProperty property, PropertyValue & value)
{
  auto const it = properties.find(make_pair(object, property));
  if (it != properties.end())
  {
    value = it->second;
    return true;
  }
  return false;
}

// static
void Animation::GetCurrentScreen(TPropertyCache const & properties, ScreenBase const & screen, ScreenBase & currentScreen)
{
  currentScreen = screen;

  if (!properties.empty())
  {
    double scale = currentScreen.GetScale();
    double angle = currentScreen.GetAngle();
    m2::PointD pos = currentScreen.GlobalRect().GlobalZero();

    PropertyValue value;
    if (GetCachedProperty(properties, Object::MapPlane, ObjectProperty::Scale, value))
      scale = value.m_valueD;

    if (GetCachedProperty(properties, Object::MapPlane, ObjectProperty::Angle, value))
      angle = value.m_valueD;

    if (GetCachedProperty(properties, Object::MapPlane, ObjectProperty::Position, value))
      pos = value.m_valuePointD;

    currentScreen.SetFromParams(pos, angle, scale);
  }
}

bool Animation::CouldBeBlendedWith(Animation const & animation) const
{
  bool hasSameObject = false;
  TAnimObjects const & objects = animation.GetObjects();
  for (auto const & object : objects)
  {
    if (HasObject(object))
    {
      hasSameObject = true;
      break;
    }
  }

  return !hasSameObject || ((GetType() != animation.GetType()) &&
      m_couldBeBlended && animation.m_couldBeBlended);
}

bool Animation::HasTargetProperty(Object object, ObjectProperty property) const
{
  return HasProperty(object, property);
}

// static
bool Animation::GetMinDuration(Interpolator const & interpolator, double & minDuration)
{
  if (interpolator.IsActive())
  {
    double const duration = interpolator.GetMinDuration();
    if (duration >= 0.0)
      minDuration = minDuration >= 0.0 ? min(duration, minDuration) : duration;
    else
      return false;
  }
  return true;
}

// static
bool Animation::GetMaxDuration(Interpolator const & interpolator, double & maxDuration)
{
  if (interpolator.IsActive())
  {
    double const duration = interpolator.GetMaxDuration();
    if (duration >= 0.0)
      maxDuration = maxDuration >= 0.0 ? max(duration, maxDuration) : duration;
    else
      return false;
  }
  return true;
}

} // namespace df