NAP
sequencecontrollercurve.h
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 
5 #pragma once
6 
7 // Local Includes
8 #include "sequencecontroller.h"
9 #include "sequencecurveenums.h"
10 #include "sequencetrackcurve.h"
11 
12 // External Includes
13 #include <mathutils.h>
14 
15 namespace nap {
17 
18  // forward declares
19  class SequenceService;
20 
25  {
26  RTTI_ENABLE(SequenceController)
27  public:
35 
42  double segmentDurationChange(const std::string& trackID, const std::string& segmentID, float duration);
43 
47  template<typename T>
48  void addNewCurveTrack();
49 
58  void changeCurveSegmentValue(const std::string& trackID, const std::string& segmentID, float newValue,
59  int curveIndex, sequencecurveenums::ESegmentValueTypes valueType);
60 
68  void insertCurvePoint(const std::string& trackID, const std::string& segmentID, float pos, int curveIndex);
69 
77  void deleteCurvePoint(const std::string& trackID, const std::string& segmentID, int index, int curveIndex);
78 
88  void changeCurvePoint(const std::string& trackID, const std::string& segmentID, int pointIndex, int curveIndex,
89  float time, float value);
90 
102  bool changeTanPoint(const std::string& trackID, const std::string& segmentID, int pointIndex, int curveIndex,
103  sequencecurveenums::ETanPointTypes tanType, float time, float value);
104 
111  template<typename T>
112  void changeMinMaxCurveTrack(const std::string& trackID, T minimum, T maximum);
113 
120  template<typename T>
121  void changeCurveType(SequenceTrackSegment& segment, math::ECurveInterp type, int curveIndex);
122 
129  const SequenceTrackSegment* insertSegment(const std::string& trackID, double time) override;
130 
136  void deleteSegment(const std::string& trackID, const std::string& segmentID) override;
137 
142  void insertTrack(rtti::TypeInfo type) override;
143 
148  void updateCurveSegments(const std::string& trackID);
149 
157  void changeCurveType(const std::string& trackID, const std::string& segmentID, math::ECurveInterp type,
158  int curveIndex);
159 
160  protected:
165  template<typename T>
166  void updateCurveSegments(SequenceTrack& track);
167 
174  template<typename T>
175  const SequenceTrackSegment* insertCurveSegment(const std::string& trackID, double time);
176 
188  template<typename T>
189  bool changeTanPoint(SequenceTrackSegment& segment, const std::string& trackID, int pointIndex, int curveIndex,
190  sequencecurveenums::ETanPointTypes tanType, float time, float value);
191 
200  template<typename T>
201  void changeCurvePoint(SequenceTrackSegment& segment, int pointIndex, int curveIndex, float time, float value);
202 
203  template<typename T>
204  void changeLastCurvePoint(SequenceTrackSegment& segment, int curveIndex, float time, float value);
205 
212  template<typename T>
213  void deleteCurvePoint(SequenceTrackSegment& segment, int index, int curveIndex);
214 
221  template<typename T>
222  void insertCurvePoint(SequenceTrackSegment& segment, float pos, int curveIndex);
223 
232  template<typename T>
233  void changeCurveSegmentValue(SequenceTrack& track, SequenceTrackSegment& segment, float newValue, int curveIndex, sequencecurveenums::ESegmentValueTypes valueType);
234 
235  // map for updating segments
236  std::unordered_map<rttr::type, std::function<void(SequenceTrack&)>> mUpdateSegmentFunctionMap;
237 
238  // map for inserting segments
239  std::unordered_map<rttr::type, std::function<const SequenceTrackSegment*(const std::string&,double)>> mInsertSegmentFunctionMap;
240 
241  // maps containing function pointers to templated functions
242  // the reason for this is that actions are not templated and when handled by the gui contain rtti type information
243  // in order to call the right templated controller function, function calls are stored in a map with type information as key value
244  // this makes it also possible to add other curved tracks when extending the controller
245  std::unordered_map<rtti::TypeInfo, std::function<void(SequenceControllerCurve*)>> mInsertTrackFunctionMap;
246  std::unordered_map<rtti::TypeInfo, std::function<bool(SequenceTrackSegment&, const std::string&, const int, const int, sequencecurveenums::ETanPointTypes, float, float)>> mChangeTanPointFunctionMap;
247  std::unordered_map<rtti::TypeInfo, std::function<void(SequenceTrackSegment&, const int, const int, float, float)>> mChangeCurvePointFunctionMap;
248  std::unordered_map<rtti::TypeInfo, std::function<void(SequenceTrackSegment&, const int, float, float)>> mChangeLastCurvePointFunctionMap;
249  std::unordered_map<rtti::TypeInfo, std::function<void(SequenceTrackSegment&, const int, int)>> mDeleteCurvePointFunctionMap;
250  std::unordered_map<rtti::TypeInfo, std::function<void(SequenceTrackSegment&, float, int)>> mInsertCurvePointFunctionMap;
252  std::unordered_map<rtti::TypeInfo, std::function<void(SequenceTrackSegment&, math::ECurveInterp type, int curveIndex)>> mChangeCurveTypeFunctionMap;
253  };
254 
256  // Forward declarations
258 
259  template<>
260  void NAPAPI SequenceControllerCurve::changeMinMaxCurveTrack<float>(const std::string& trackID, float minimum, float maximum);
261 }
262 
263 #include "sequencecontrollercurve_template.h"
nap::SequenceControllerCurve::mInsertTrackFunctionMap
std::unordered_map< rtti::TypeInfo, std::function< void(SequenceControllerCurve *)> > mInsertTrackFunctionMap
Definition: sequencecontrollercurve.h:245
nap::SequenceControllerCurve::mDeleteCurvePointFunctionMap
std::unordered_map< rtti::TypeInfo, std::function< void(SequenceTrackSegment &, const int, int)> > mDeleteCurvePointFunctionMap
Definition: sequencecontrollercurve.h:249
nap::sequencecurveenums::ETanPointTypes
ETanPointTypes
Definition: sequencecurveenums.h:13
nap::SequencePlayer
Definition: sequenceplayer.h:36
nap::math::ECurveInterp
ECurveInterp
Definition: fcurve.h:20
nap::SequenceEditor
Definition: sequenceeditor.h:32
nap::SequenceController
Definition: sequencecontroller.h:25
nap::sequencecurveenums::ESegmentValueTypes
ESegmentValueTypes
Definition: sequencecurveenums.h:18
nap::SequenceService
Definition: sequenceservice.h:42
nap::SequenceControllerCurve::mChangeSegmentValueFunctionMap
std::unordered_map< rtti::TypeInfo, std::function< void(SequenceTrack &, SequenceTrackSegment &segment, float, int, sequencecurveenums::ESegmentValueTypes)> > mChangeSegmentValueFunctionMap
Definition: sequencecontrollercurve.h:251
nap::SequenceTrackSegment
Definition: sequencetracksegment.h:19
nap::SequenceControllerCurve::mInsertCurvePointFunctionMap
std::unordered_map< rtti::TypeInfo, std::function< void(SequenceTrackSegment &, float, int)> > mInsertCurvePointFunctionMap
Definition: sequencecontrollercurve.h:250
nap::SequenceControllerCurve::mChangeCurvePointFunctionMap
std::unordered_map< rtti::TypeInfo, std::function< void(SequenceTrackSegment &, const int, const int, float, float)> > mChangeCurvePointFunctionMap
Definition: sequencecontrollercurve.h:247
nap::SequenceControllerCurve::mChangeLastCurvePointFunctionMap
std::unordered_map< rtti::TypeInfo, std::function< void(SequenceTrackSegment &, const int, float, float)> > mChangeLastCurvePointFunctionMap
Definition: sequencecontrollercurve.h:248
nap::SequenceControllerCurve::mChangeCurveTypeFunctionMap
std::unordered_map< rtti::TypeInfo, std::function< void(SequenceTrackSegment &, math::ECurveInterp type, int curveIndex)> > mChangeCurveTypeFunctionMap
Definition: sequencecontrollercurve.h:252
nap::SequenceTrack
Definition: sequencetrack.h:22
nap::SequenceControllerCurve
Definition: sequencecontrollercurve.h:24
nap::SequenceControllerCurve::mChangeTanPointFunctionMap
std::unordered_map< rtti::TypeInfo, std::function< bool(SequenceTrackSegment &, const std::string &, const int, const int, sequencecurveenums::ETanPointTypes, float, float)> > mChangeTanPointFunctionMap
Definition: sequencecontrollercurve.h:246
nap::SequenceControllerCurve::mUpdateSegmentFunctionMap
std::unordered_map< rttr::type, std::function< void(SequenceTrack &)> > mUpdateSegmentFunctionMap
Definition: sequencecontrollercurve.h:236
nap
Definition: templateapp.h:17
nap::rtti::TypeInfo
rttr::type TypeInfo
Definition: typeinfo.h:140