Rumba C++ SDK
Channel.h
Go to the documentation of this file.
1 /*
2 
3  *
4  ***
5  *****
6  ********************* Mercenaries Engineering SARL
7  ***************** Copyright (C) 2023
8  *************
9  ********* http://www.mercenaries-engineering.com
10  ***********
11  **** ****
12  ** **
13 
14 */
15 #pragma once
16 
17 #include <optional>
18 #include <unordered_set>
19 
20 #include "ChannelMode.h"
21 #include "NodeDelegate.h"
22 #include "Plug.h"
23 
24 namespace maquina
25 {
26 class AnimCurve;
27 
29 MAQUINA_EXPORT std::string channel_plug_to_channel_path(const Plug& channel_plug);
30 
32 MAQUINA_EXPORT std::optional<std::pair<Plug, std::string>> channel_plug_to_controller_plug(const Plug& channel_plug);
33 
35 
37 // TODO optional
38 MAQUINA_EXPORT Plug channel_path_to_channel_plug(const StringView& channel_path, const Node& document, Node* layer = nullptr);
39 
41 
42 MAQUINA_EXPORT bool extract_channel_path(const std::string& channel_path, std::string& asset_path,
43  std::string& ctrl_path, std::string& plug, std::string& subchannel);
44 
46 
51  const std::vector<Plug>& plugs,
52  Node& layer,
53  bool check_editable = true,
54  bool selection_mask = true
55 );
56 
58 
60 MAQUINA_EXPORT void layer_animated_plugs(const Node& layer, std::unordered_set<Plug>& animated_plugs, bool only_curve = true, bool recursive = true);
61 
63 MAQUINA_EXPORT std::vector<Plug> channels_in_layer(const Node& layer);
64 
66 
70  const std::vector<Plug>& channels,
71  Node& layer,
72  bool undo_stack
73 );
74 
77 
79 
95 class Channel
96 {
97 public:
98 
100  MAQUINA_EXPORT std::vector<Node> layers() const;
101 
103 
105  MAQUINA_EXPORT bool assign_to_layer(Node& layer) const;
106 
108  MAQUINA_EXPORT void remove_from_layer(Node& layer, bool undo_stack=true) const;
109 
111  MAQUINA_EXPORT bool is_assigned(const Node& layer) const;
112 
114  MAQUINA_EXPORT bool is_editable() const;
115 
117 
118  MAQUINA_EXPORT bool is_editable(const Node& layer) const;
119 
121 
122  MAQUINA_EXPORT bool is_target(const Node& layer) const;
123 
124  // TODO optional
126  MAQUINA_EXPORT std::unique_ptr<Node> target_layer() const;
127 
129  MAQUINA_EXPORT std::optional<Node> animation_layer_blend(const Node &layer) const;
130 
131  // TODO optional
133  MAQUINA_EXPORT std::unique_ptr<Node> animation_curve_node(const Node& layer) const;
134 
135  // TODO optional
137  MAQUINA_EXPORT std::unique_ptr<AnimCurve> animation_curve(const Node& layer) const;
138 
139  // TODO optional
141 
142  MAQUINA_EXPORT std::unique_ptr<AnimCurve> new_animation_curve() const;
143 
144  // TODO optional
146 
147  MAQUINA_EXPORT std::unique_ptr<AnimCurve> duplicate_animation_curve(const Node& layer) const;
148 
150 
152 
154 
155  MAQUINA_EXPORT void remove_animation_curve(const Node& layer);
156 
157  // TODO optional
159 
161  MAQUINA_EXPORT Value value(float frame, const Node& layer) const;
162 
164 
166  MAQUINA_EXPORT bool as_bool(float frame, const Node& layer) const;
167 
169 
171  MAQUINA_EXPORT int as_int(float frame, const Node& layer) const;
172 
174 
176  MAQUINA_EXPORT float as_float(float frame, const Node& layer) const;
177 
179 
181  const Value& value,
182  const Node& layer
183  );
184 
186 
187  MAQUINA_EXPORT bool set_key(
188  const Value& value,
189  float frame,
190  const Node& layer
191  );
192 
195 
198 
200  Plug channel_plug() const { return _plug; }
201 
204 
205  MAQUINA_EXPORT bool operator==(const Channel& o) const;
206  MAQUINA_EXPORT bool operator!=(const Channel& o) const;
207 private:
208  Plug _plug; // The channel plug
209 };
210 
212 
214 // TODO optional
215 MAQUINA_EXPORT Plug controller_plug(const Plug& channel_plug);
216 
217 }
MAQUINA_EXPORT bool operator!=(const Channel &o) const
Plug channel_plug() const
Return the actual channel plug (first plug connected to the animation graph)
Definition: Channel.h:200
MAQUINA_EXPORT ChannelType channel_type() const
Return the channel type.
MAQUINA_EXPORT std::unique_ptr< Node > animation_curve_node(const Node &layer) const
If available, returns the animation curve node of this channel for the specified layer.
MAQUINA_EXPORT bool is_target(const Node &layer) const
Return true if layer is the target for this channel.
MAQUINA_EXPORT std::vector< Node > layers() const
Return the layers this channel is assigned to.
MAQUINA_EXPORT std::unique_ptr< Node > target_layer() const
If available, return the channel&#39;s target layer.
ChannelType
Predefined channel types.
Definition: ChannelType.h:23
MAQUINA_EXPORT std::optional< Node > animation_layer_blend(const Node &layer) const
If available, returns the animation layer blend node of this channel for the specified layer...
MAQUINA_EXPORT std::optional< std::pair< Plug, std::string > > channel_plug_to_controller_plug(const Plug &channel_plug)
Get the channel path on a channel plug.
MAQUINA_EXPORT bool operator==(const Channel &o) const
MAQUINA_EXPORT bool add_plugs_to_layer(const std::vector< Plug > &plugs, Node &layer, bool check_editable=true, bool selection_mask=true)
Update the animation graph so that these plug channels are animated in the layer. ...
MAQUINA_EXPORT void remove_channels_from_layer(const std::vector< Plug > &channels, Node &layer, bool undo_stack)
Update the animation graph so that these plug channels are not animated anymore in the layer...
This version of the SDK is unstable, i-e, it may change with no warning.
Definition: AddCurveAction.h:20
An animation curve abstraction, can animate any type of value, bool, int, float or other values...
Definition: AnimCurve.h:55
StringViewBase< char, std::string > StringView
Definition: StringView.h:376
MAQUINA_EXPORT bool as_bool(float frame, const Node &layer) const
If available, returns the channel value for the specified frame and on the specified layer as a boole...
ChannelMode
The channel modes.
Definition: ChannelMode.h:23
MAQUINA_EXPORT std::string channel_plug_to_channel_path(const Plug &channel_plug)
Get the channel path on a channel plug.
MAQUINA_EXPORT ChannelMode channel_mode() const
Return the channel mode.
MAQUINA_EXPORT void remove_animation_curve(const Node &layer)
Remove the channel&#39;s animation curve on this layer if it exists.
MAQUINA_EXPORT Plug channel_path_to_channel_plug(const StringView &channel_path, const Node &document, Node *layer=nullptr)
Get the channel plug using a channel path.
MAQUINA_EXPORT Plug controller_plug(const Plug &channel_plug)
Return the controller plug driven by channel_plug.
MAQUINA_EXPORT float as_float(float frame, const Node &layer) const
If available, returns the channel value for the specified frame and on the specified layer as a float...
MAQUINA_EXPORT Value value(float frame, const Node &layer) const
If available, returns the channel value for the specified frame and on the specified layer...
#define MAQUINA_EXPORT
Definition: Export.h:31
A node plug.
Definition: Plug.h:59
MAQUINA_EXPORT std::unique_ptr< AnimCurve > new_animation_curve() const
Returns a new, empty animation curve of the correct type for that channel.
MAQUINA_EXPORT std::unique_ptr< AnimCurve > animation_curve(const Node &layer) const
If available, returns the animation curve of this channel for the specified layer. Do not modify this value.
MAQUINA_EXPORT bool anim_curve_keys_selected()
Return true if the curve editor is open and keys are selected in it.
MAQUINA_EXPORT bool is_assigned(const Node &layer) const
Return true if this channel is assigned to the layer.
MAQUINA_EXPORT bool set_animation_curve(AnimCurve &animation_curve, const Node &layer)
Set the new animation curve of this channel for the specified layer.
Node&#39;s plugs and node delegate&#39;s attributes may be modified by animation layers through channels...
Definition: Channel.h:95
MAQUINA_EXPORT bool set_key(const Value &value, float frame, const Node &layer)
Set the channel value at the specified frame and on the specified layer.
MAQUINA_EXPORT int as_int(float frame, const Node &layer) const
If available, returns the channel value for the specified frame and on the specified layer as an int...
MAQUINA_EXPORT void remove_from_layer(Node &layer, bool undo_stack=true) const
Remove this channel from the layer.
MAQUINA_EXPORT bool is_editable() const
Return true if this channel is editable.
MAQUINA_EXPORT bool set_value(const Value &value, const Node &layer)
Set the channel value on the specified layer. If animated, add or set the keyframe at the current fra...
MAQUINA_EXPORT bool extract_channel_path(const std::string &channel_path, std::string &asset_path, std::string &ctrl_path, std::string &plug, std::string &subchannel)
Parse the channel path and extract the asset, controller, plug and subchannel strings.
MAQUINA_EXPORT std::optional< Node > document(const std::string &path, bool comparable=false)
Return the document node associated to that file path.
MAQUINA_EXPORT bool assign_to_layer(Node &layer) const
Assign this channel to the layer.
MAQUINA_EXPORT std::unique_ptr< AnimCurve > duplicate_animation_curve(const Node &layer) const
Returns a copy of the current animation curve for that channel on that layer. If the channel is not a...
MAQUINA_EXPORT void layer_animated_plugs(const Node &layer, std::unordered_set< Plug > &animated_plugs, bool only_curve=true, bool recursive=true)
Return the list of animated plugs in the layer.
Base class of all Rumba nodes.
Definition: Node.h:37
MAQUINA_EXPORT std::vector< Plug > channels_in_layer(const Node &layer)
Return the list of channels that are animated in the layer.
Base class of all Rumba values.
Definition: Value.h:34