77
88using namespace Vizzu ;
99using namespace Vizzu ::Anim;
10- using namespace Vizzu ::Diag;
1110using namespace std ::literals::chrono_literals;
1211
1312void Planner::createPlan (const Diag::Diagram &source,
1413 const Diag::Diagram &target,
15- Diag::Diagram &actual)
14+ Diag::Diagram &actual,
15+ const Options &options)
1616{
17+ typedef SectionId::EnumType SectionId;
18+
1719 this ->source = &source;
1820 this ->target = ⌖
1921 this ->actual = &actual;
22+ this ->options = &options;
2023
2124 ::Anim::Group::clear ();
2225
2326 Morph::StyleMorphFactory (source.getStyle (), target.getStyle (),
24- actual.getStyle (), *this );
27+ actual.getStyle (), *this ,
28+ options.get (SectionId::style, ::Anim::Options (500ms)));
2529
2630 if (source.getOptions ()->title .get () != target.getOptions ()->title .get ())
2731 addElement (
@@ -30,67 +34,67 @@ void Planner::createPlan(const Diag::Diagram &source,
3034 source.getOptions ()->title .ref (),
3135 target.getOptions ()->title .ref (),
3236 actual.getOptions ()->title .ref ()),
33- :: Anim::Options (500ms));
37+ options. get (SectionId::title, :: Anim::Options (500ms) ));
3438
3539 if (anyMarker (
3640 [&](const auto &source, const auto &target) -> bool {
3741 return (bool )(source.enabled && !target.enabled );
3842 }))
39- addMorph<Morph::Enable> (1s);
43+ addMorph (SectionId::enable, :: Anim::Options (1s) );
4044
41- if (needColor ()) addMorph<Morph::Color> (500ms);
45+ if (needColor ()) addMorph (SectionId::color, :: Anim::Options (500ms) );
4246
4347 if (source.getOptions ()->polar .get ()
4448 != target.getOptions ()->polar .get ()
4549 || source.getOptions ()->angle .get ()
4650 != target.getOptions ()->angle .get ())
47- addMorph<Morph::CoordinateSystem> (1s);
51+ addMorph (SectionId::coordSystem, :: Anim::Options (1s) );
4852
4953 const auto &src = source.getOptions ()->shapeType .get ();
5054 const auto &trg = target.getOptions ()->shapeType .get ();
51- if ((bool )src.getFactor (ShapeType::Circle) && src != trg)
52- addMorph<Morph::Shape> (1s);
55+ if ((bool )src.getFactor (Diag:: ShapeType::Circle) && src != trg)
56+ addMorph (SectionId::shape, :: Anim::Options (1s) );
5357
5458 if (positionMorphNeeded ())
5559 {
56- addMorph<Morph::Vertical> (1s);
57- addMorph<Morph::Horizontal> (1s);
60+ addMorph (SectionId::y, :: Anim::Options (1s) );
61+ addMorph (SectionId::x, :: Anim::Options (1s) );
5862 }
5963 else
6064 {
6165 if (verticalBeforeHorizontal ())
6266 {
63- if (needVertical ()) addMorph<Morph::Vertical>(750ms);
64- if (needHorizontal ()) addMorph<Morph::Horizontal>(750ms, 750ms);
67+ if (needVertical ()) addMorph (SectionId::y, ::Anim::Options (750ms));
68+ if (needHorizontal ()) addMorph (SectionId::x,
69+ ::Anim::Options (750ms, 750ms));
6570 }
6671 else
6772 {
68- if (needHorizontal ()) addMorph<Morph::Horizontal>(750ms);
69- if (needVertical ()) addMorph<Morph::Vertical>(750ms, 750ms);
73+ if (needHorizontal ()) addMorph (SectionId::x, ::Anim::Options (750ms));
74+ if (needVertical ()) addMorph (SectionId::y,
75+ ::Anim::Options (750ms, 750ms));
7076 }
7177 }
7278
73- if (!(bool )src.getFactor (ShapeType::Circle) && src != trg)
74- addMorph<Morph::Shape> (1s);
79+ if (!(bool )src.getFactor (Diag:: ShapeType::Circle) && src != trg)
80+ addMorph (SectionId::shape, :: Anim::Options (1s) );
7581
7682 if (anyMarker (
7783 [&](const auto &source, const auto &target) {
7884 return (bool )(!source.enabled && target.enabled );
7985 }))
80- addMorph<Morph::Enable> (1s);
86+ addMorph (SectionId::enable, :: Anim::Options (1s) );
8187
8288 if (!source.getOptions ()->polar .get ()
8389 && target.getOptions ()->polar .get ())
84- addMorph<Morph::CoordinateSystem> (1s);
90+ addMorph (SectionId::coordSystem, :: Anim::Options (1s) );
8591}
8692
87- template <typename M>
88- void Planner::addMorph (std::chrono::nanoseconds duration,
89- std::chrono::nanoseconds delay)
93+ void Planner::addMorph (SectionId sectionId, const ::Anim::Options &autoOptions)
9094{
9195 addElement (
92- std::move (std::make_unique<M>( *source, *target, *actual) ),
93- ::Anim::Options (duration, delay )
96+ Morph::AbstractMorph::create (sectionId, *source, *target, *actual),
97+ options-> get (sectionId, autoOptions )
9498 );
9599}
96100
@@ -112,20 +116,20 @@ bool Planner::anyMarker(
112116bool Planner::positionMorphNeeded () const
113117{
114118 return Diag::canOverlap (
115- (ShapeType::Type)source->getOptions ()->shapeType .get ())
119+ (Diag:: ShapeType::Type)source->getOptions ()->shapeType .get ())
116120 || Diag::canOverlap (
117- (ShapeType::Type)target->getOptions ()->shapeType .get ());
121+ (Diag:: ShapeType::Type)target->getOptions ()->shapeType .get ());
118122}
119123
120124bool Planner::needColor () const
121125{
122126 return source->anySelected != target->anySelected
123127 || source->getOptions ()->legend .get ()
124128 != target->getOptions ()->legend .get ()
125- || source->discreteAxises .at (Scale::Type::Color)
126- != target->discreteAxises .at (Scale::Type::Color)
127- || source->discreteAxises .at (Scale::Type::Lightness)
128- != target->discreteAxises .at (Scale::Type::Lightness)
129+ || source->discreteAxises .at (Diag:: Scale::Type::Color)
130+ != target->discreteAxises .at (Diag:: Scale::Type::Color)
131+ || source->discreteAxises .at (Diag:: Scale::Type::Lightness)
132+ != target->discreteAxises .at (Diag:: Scale::Type::Lightness)
129133 || anyMarker (
130134 [&](const auto &source, const auto &target)
131135 {
@@ -139,16 +143,16 @@ size_t Planner::discreteCount(const Diag::Diagram *diagram,
139143 Diag::Scale::Type type) const
140144{
141145 return diagram->getOptions ()->getScales ()
142- .at (Scales::Id{type, Scales::Index{0 }})
146+ .at (Diag:: Scales::Id{type, Diag:: Scales::Index{0 }})
143147 .discretesIds ().size ();
144148}
145149
146150bool Planner::verticalBeforeHorizontal () const
147151{
148- auto srcXcnt = discreteCount (source, Scale::X);
149- auto srcYcnt = discreteCount (source, Scale::Y);
150- auto trgXcnt = discreteCount (target, Scale::X);
151- auto trgYcnt = discreteCount (target, Scale::Y);
152+ auto srcXcnt = discreteCount (source, Diag:: Scale::X);
153+ auto srcYcnt = discreteCount (source, Diag:: Scale::Y);
154+ auto trgXcnt = discreteCount (target, Diag:: Scale::X);
155+ auto trgYcnt = discreteCount (target, Diag:: Scale::Y);
152156
153157 if ((trgYcnt != srcYcnt) || (trgXcnt != srcXcnt))
154158 {
0 commit comments