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 
43  double segmentDurationChange(const std::string& trackID, const std::string& segmentID, float duration, bool adjustFollowingSegments);
44 
51  void setSegmentLocked(const std::string& trackID, const std::string& segmentID, bool locked);
52 
56  template<typename T>
57  void addNewCurveTrack();
58 
67  void changeCurveSegmentValue(const std::string& trackID, const std::string& segmentID, float newValue,
68  int curveIndex, sequencecurveenums::ESegmentValueTypes valueType);
69 
77  void insertCurvePoint(const std::string& trackID, const std::string& segmentID, float pos, int curveIndex);
78 
86  void deleteCurvePoint(const std::string& trackID, const std::string& segmentID, int index, int curveIndex);
87 
97  void changeCurvePoint(const std::string& trackID, const std::string& segmentID, int pointIndex, int curveIndex,
98  float time, float value);
99 
111  bool changeTanPoint(const std::string& trackID, const std::string& segmentID, int pointIndex, int curveIndex,
112  sequencecurveenums::ETanPointTypes tanType, float time, float value);
113 
120  template<typename T>
121  void changeMinMaxCurveTrack(const std::string& trackID, T minimum, T maximum);
122 
129  template<typename T>
130  void changeCurveType(SequenceTrackSegment& segment, math::ECurveInterp type, int curveIndex);
131 
138  const SequenceTrackSegment* insertSegment(const std::string& trackID, double time) override;
139 
145  void deleteSegment(const std::string& trackID, const std::string& segmentID) override;
146 
151  void insertTrack(rtti::TypeInfo type) override;
152 
157  void updateCurveSegments(const std::string& trackID);
158 
166  void changeCurveType(const std::string& trackID, const std::string& segmentID, math::ECurveInterp type,
167  int curveIndex);
168 
175  void changeSegmentColor(const std::string& trackID, const std::string& segmentID, const RGBAColorFloat& newColor);
176 
177  protected:
182  template<typename T>
183  void updateCurveSegments(SequenceTrack& track);
184 
191  template<typename T>
192  const SequenceTrackSegment* insertCurveSegment(const std::string& trackID, double time);
193 
205  template<typename T>
206  bool changeTanPoint(SequenceTrackSegment& segment, const std::string& trackID, int pointIndex, int curveIndex,
207  sequencecurveenums::ETanPointTypes tanType, float time, float value);
208 
217  template<typename T>
218  void changeCurvePoint(SequenceTrackSegment& segment, int pointIndex, int curveIndex, float time, float value);
219 
220  template<typename T>
221  void changeLastCurvePoint(SequenceTrackSegment& segment, int curveIndex, float time, float value);
222 
229  template<typename T>
230  void deleteCurvePoint(SequenceTrackSegment& segment, int index, int curveIndex);
231 
238  template<typename T>
239  void insertCurvePoint(SequenceTrackSegment& segment, float pos, int curveIndex);
240 
249  template<typename T>
250  void changeCurveSegmentValue(SequenceTrack& track, SequenceTrackSegment& segment, float newValue, int curveIndex, sequencecurveenums::ESegmentValueTypes valueType);
251 
252  // map for updating segments
253  std::unordered_map<rttr::type, std::function<void(SequenceTrack&)>> mUpdateSegmentFunctionMap;
254 
255  // map for inserting segments
256  std::unordered_map<rttr::type, std::function<const SequenceTrackSegment*(const std::string&,double)>> mInsertSegmentFunctionMap;
257 
258  // maps containing function pointers to templated functions
259  // the reason for this is that actions are not templated and when handled by the gui contain rtti type information
260  // in order to call the right templated controller function, function calls are stored in a map with type information as key value
261  // this makes it also possible to add other curved tracks when extending the controller
262  std::unordered_map<rtti::TypeInfo, std::function<void(SequenceControllerCurve*)>> mInsertTrackFunctionMap;
263  std::unordered_map<rtti::TypeInfo, std::function<bool(SequenceTrackSegment&, const std::string&, const int, const int, sequencecurveenums::ETanPointTypes, float, float)>> mChangeTanPointFunctionMap;
264  std::unordered_map<rtti::TypeInfo, std::function<void(SequenceTrackSegment&, const int, const int, float, float)>> mChangeCurvePointFunctionMap;
265  std::unordered_map<rtti::TypeInfo, std::function<void(SequenceTrackSegment&, const int, float, float)>> mChangeLastCurvePointFunctionMap;
266  std::unordered_map<rtti::TypeInfo, std::function<void(SequenceTrackSegment&, const int, int)>> mDeleteCurvePointFunctionMap;
267  std::unordered_map<rtti::TypeInfo, std::function<void(SequenceTrackSegment&, float, int)>> mInsertCurvePointFunctionMap;
269  std::unordered_map<rtti::TypeInfo, std::function<void(SequenceTrackSegment&, math::ECurveInterp type, int curveIndex)>> mChangeCurveTypeFunctionMap;
270  };
271 
273  // Forward declarations
275 
276  template<>
277  void NAPAPI SequenceControllerCurve::changeMinMaxCurveTrack<float>(const std::string& trackID, float minimum, float maximum);
278 }
279 
280 #include "sequencecontrollercurve_template.h"
nap::SequenceControllerCurve::mInsertTrackFunctionMap
std::unordered_map< rtti::TypeInfo, std::function< void(SequenceControllerCurve *)> > mInsertTrackFunctionMap
Definition: sequencecontrollercurve.h:262
nap::SequenceControllerCurve::mDeleteCurvePointFunctionMap
std::unordered_map< rtti::TypeInfo, std::function< void(SequenceTrackSegment &, const int, int)> > mDeleteCurvePointFunctionMap
Definition: sequencecontrollercurve.h:266
nap::sequencecurveenums::ETanPointTypes
ETanPointTypes
Definition: sequencecurveenums.h:13
nap::SequencePlayer
Definition: sequenceplayer.h:37
nap::math::ECurveInterp
ECurveInterp
Definition: fcurve.h:20
nap::SequenceEditor
Definition: sequenceeditor.h:49
nap::SequenceController
Definition: sequencecontroller.h:25
nap::sequencecurveenums::ESegmentValueTypes
ESegmentValueTypes
Definition: sequencecurveenums.h:18
nap::RGBAColor< float >
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:268
nap::SequenceTrackSegment
Definition: sequencetracksegment.h:19
nap::SequenceControllerCurve::mInsertCurvePointFunctionMap
std::unordered_map< rtti::TypeInfo, std::function< void(SequenceTrackSegment &, float, int)> > mInsertCurvePointFunctionMap
Definition: sequencecontrollercurve.h:267
nap::SequenceControllerCurve::mChangeCurvePointFunctionMap
std::unordered_map< rtti::TypeInfo, std::function< void(SequenceTrackSegment &, const int, const int, float, float)> > mChangeCurvePointFunctionMap
Definition: sequencecontrollercurve.h:264
nap::SequenceControllerCurve::mChangeLastCurvePointFunctionMap
std::unordered_map< rtti::TypeInfo, std::function< void(SequenceTrackSegment &, const int, float, float)> > mChangeLastCurvePointFunctionMap
Definition: sequencecontrollercurve.h:265
nap::SequenceControllerCurve::mChangeCurveTypeFunctionMap
std::unordered_map< rtti::TypeInfo, std::function< void(SequenceTrackSegment &, math::ECurveInterp type, int curveIndex)> > mChangeCurveTypeFunctionMap
Definition: sequencecontrollercurve.h:269
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:263
nap::SequenceControllerCurve::mUpdateSegmentFunctionMap
std::unordered_map< rttr::type, std::function< void(SequenceTrack &)> > mUpdateSegmentFunctionMap
Definition: sequencecontrollercurve.h:253
nap
Definition: templateapp.h:17
nap::rtti::TypeInfo
rttr::type TypeInfo
Definition: typeinfo.h:140