synfig-core  1.0.3
valuenode_bone.h
Go to the documentation of this file.
1 /* === S Y N F I G ========================================================= */
22 /* ========================================================================= */
23 
24 /* === S T A R T =========================================================== */
25 
26 #ifndef __SYNFIG_VALUENODE_BONE_H
27 #define __SYNFIG_VALUENODE_BONE_H
28 
29 /* === H E A D E R S ======================================================= */
30 
31 #include <synfig/valuenode.h>
32 
33 /* === M A C R O S ========================================================= */
34 
35 /* === C L A S S E S & S T R U C T S ======================================= */
36 
37 namespace synfig {
38 
40 {
41  ValueNode::RHandle name_;
42  ValueNode::RHandle origin_;
43  ValueNode::RHandle angle_;
44  ValueNode::RHandle scalelx_;
45  ValueNode::RHandle scalex_;
46  ValueNode::RHandle length_;
47  ValueNode::RHandle width_;
48  ValueNode::RHandle tipwidth_;
49  ValueNode::RHandle depth_;
50  ValueNode::RHandle parent_;
51 
52 protected:
54  ValueNode_Bone(const ValueBase &value, etl::loose_handle<Canvas> canvas = 0);
55 
56 public:
57 
58  typedef etl::handle<ValueNode_Bone> Handle;
59  typedef etl::handle<const ValueNode_Bone> ConstHandle;
60  typedef etl::loose_handle<ValueNode_Bone> LooseHandle;
61  typedef std::map<synfig::GUID, LooseHandle> BoneMap;
62  typedef std::map<etl::loose_handle<const Canvas>, BoneMap> CanvasMap;
63  typedef std::set<LooseHandle> BoneSet;
64  typedef std::list<LooseHandle> BoneList;
65 
66  virtual ValueBase operator()(Time t)const;
67 
68  virtual ValueNode::Handle clone(etl::loose_handle<Canvas> canvas, const GUID& deriv_guid=GUID())const;
69 
70  virtual ~ValueNode_Bone();
71  virtual void set_guid(const GUID& new_guid);
72  virtual void set_root_canvas(etl::loose_handle<Canvas> canvas);
73 
74  virtual String get_name()const;
75  virtual String get_local_name()const;
76  virtual String get_bone_name(Time t)const;
77 
78  virtual ValueNode::LooseHandle get_link_vfunc(int i)const;
79 
80  // checks if point belongs to the range of influence of current bone
81  bool have_influence_on(Time t, const Vector &x)const
82  { return (*this)(t).get(Bone()).have_influence_on(x); }
83 
84 protected:
86  virtual bool set_link_vfunc(int i,ValueNode::Handle x);
87 
88  virtual void on_changed();
89 
90 public:
92 
94  static bool check_type(Type &type);
95  static ValueNode_Bone* create(const ValueBase &x, etl::loose_handle<Canvas> canvas = 0);
96  virtual Vocab get_children_vocab_vfunc()const;
98  String unique_name(String name)const;
99  static void show_bone_map(etl::loose_handle<Canvas> canvas, const char *file, int line, String text, Time t=0);
100  static BoneMap get_bone_map(etl::handle<const Canvas> canvas);
101  static BoneList get_ordered_bones(etl::handle<const Canvas> canvas);
102 
104  virtual bool is_root()const { return false; }
105 
106  // return a set of the bones that affect the given valuenode
107  // recurses through the valuenodes in the waypoints if it's animated,
108  // through the subnodes if it's linkable,
109  // and through the bone itself it's a bone constant
110  static BoneSet get_bones_referenced_by(ValueNode::Handle value_node, bool recursive = true);
111 
112  // return a set of the bones that would be affected if the given ValueNode were edited
113  // value_node is either a ValueNode_Const or a ValueNode_Animated, of type VALUENODE_BONE
115 
116  // return a set of the bones that can be parents of the given ValueNode without causing loops
118 
120 
121 #ifdef _DEBUG
122  virtual void ref()const;
123  virtual bool unref()const;
124  virtual void rref()const;
125  virtual void runref()const;
126 #endif
127 
128 private:
129  virtual Matrix get_animated_matrix(Time t, Point child_origin)const;
130  Matrix get_animated_matrix(Time t, Real scalex, Real scaley, Angle angle, Point origin, ValueNode_Bone::ConstHandle parent)const;
131  ValueNode_Bone::ConstHandle get_parent(Time t)const;
132 
133 }; // END of class ValueNode_Bone
134 
136 {
137 public:
138 
140  virtual ~ValueNode_Bone_Root();
141 
142  virtual ValueBase operator()(Time t)const;
143 
144  virtual String get_name()const;
145  virtual String get_local_name()const;
146  virtual String get_bone_name(Time t)const;
147 
148  virtual void set_guid(const GUID& new_guid);
149  virtual void set_root_canvas(etl::loose_handle<Canvas> canvas);
150 
151  virtual int link_count()const;
152  virtual bool is_root()const { return true; }
153 
154 private:
155  Matrix get_animated_matrix(Time t, Point child_origin)const;
156 
157 protected:
159 
160 public:
161  static bool check_type(Type &type);
162  static ValueNode_Bone* create(const ValueBase &x);
163 
164 #ifdef _DEBUG
165  virtual void ref()const;
166  virtual bool unref()const;
167  virtual void rref()const;
168  virtual void runref()const;
169 #endif
170 
171 }; // END of class ValueNode_Bone_Root
172 
173 }; // END of namespace synfig
174 
175 /* === E N D =============================================================== */
176 
177 #endif