Choreonoid  1.8
CoordinateFrameList.h
Go to the documentation of this file.
1 #ifndef CNOID_UTIL_COORDINATE_FRAME_LIST_H
2 #define CNOID_UTIL_COORDINATE_FRAME_LIST_H
3 
4 #include "ClonableReferenced.h"
5 #include "CoordinateFrame.h"
6 #include "Signal.h"
7 #include <string>
8 #include "exportdecl.h"
9 
10 namespace cnoid {
11 
12 class CNOID_EXPORT CoordinateFrameList : public ClonableReferenced
13 {
14 public:
18 
19  CoordinateFrameList& operator=(const CoordinateFrameList& rhs);
20 
21  enum FrameType { Base, Offset };
22  void setFrameType(int type) { frameType_ = type; }
23  int frameType() const { return frameType_; }
24  bool isForBaseFrames() const { return frameType_ == Base; }
25  bool isForOffsetFrames() const { return frameType_ == Offset; }
26 
33  void setFirstElementAsDefaultFrame(bool on = true);
34  bool hasFirstElementAsDefaultFrame() const { return hasFirstElementAsDefaultFrame_; }
35  bool isDefaultFrameId(const GeneralId& id) const;
36 
40  void clear();
41 
42  int numFrames() const;
43  CoordinateFrame* frameAt(int index) const;
44  CoordinateFrame* findFrame(const GeneralId& id) const;
45  int indexOf(CoordinateFrame* frame) const;
46 
47  bool insert(int index, CoordinateFrame* frame);
48  bool append(CoordinateFrame* frame);
49  void removeAt(int index);
50  bool remove(CoordinateFrame* frame);
51 
52  SignalProxy<void(int index)> sigFrameAdded();
53  SignalProxy<void(int index, CoordinateFrame* frame)> sigFrameRemoved();
54  SignalProxy<void(int index, int flags)> sigFrameUpdated();
55 
61  bool resetId(CoordinateFrame* frame, const GeneralId& newId);
62 
66  void resetIdCounter(int id = 0);
67  GeneralId createNextId(int prevId = -1);
68 
69  bool read(const Mapping& archive);
70  void write(Mapping& archive) const;
71  void writeHeader(Mapping& archive) const;
72  void writeFrames(Mapping& archive) const;
73 
74 protected:
75  virtual Referenced* doClone(CloneMap* cloneMap) const override;
76 
77 private:
78  // Called from the CoordinateFrame implementation
79  void notifyFrameUpdate(CoordinateFrame* frame, int flags);
80 
81  class Impl;
82  Impl* impl;
83  int frameType_;
84  bool hasFirstElementAsDefaultFrame_;
85 
86  friend class CoordinateFrame;
87 };
88 
90 
91 }
92 
93 #endif
cnoid::CoordinateFrameListPtr
ref_ptr< CoordinateFrameList > CoordinateFrameListPtr
Definition: CoordinateFrameList.h:89
cnoid::Mapping
Definition: ValueTree.h:253
cnoid::GeneralId
Definition: GeneralId.h:11
cnoid::CoordinateFrameList::isForBaseFrames
bool isForBaseFrames() const
Definition: CoordinateFrameList.h:24
cnoid::CoordinateFrameList::isForOffsetFrames
bool isForOffsetFrames() const
Definition: CoordinateFrameList.h:25
cnoid::write
Listing * write(Mapping *mapping, const std::string &key, const Eigen::MatrixBase< Derived > &x)
Definition: EigenArchive.h:145
cnoid::CoordinateFrameList::FrameType
FrameType
Definition: CoordinateFrameList.h:21
cnoid::read
bool read(const Mapping *mapping, const std::string &key, Eigen::MatrixBase< Derived > &x)
Definition: EigenArchive.h:43
CoordinateFrame.h
cnoid::ref_ptr< CoordinateFrameList >
cnoid::CoordinateFrame
Definition: CoordinateFrame.h:16
cnoid
Definition: AbstractSceneLoader.h:11
cnoid::CoordinateFrameList
Definition: CoordinateFrameList.h:12
cnoid::ClonableReferenced
Definition: ClonableReferenced.h:10
cnoid::CloneMap
Definition: CloneMap.h:13
Signal.h
cnoid::CoordinateFrameList::hasFirstElementAsDefaultFrame
bool hasFirstElementAsDefaultFrame() const
Definition: CoordinateFrameList.h:34
cnoid::Referenced
Definition: Referenced.h:54
cnoid::SignalProxy
Definition: Signal.h:470
cnoid::CoordinateFrameList::frameType
int frameType() const
Definition: CoordinateFrameList.h:23
cnoid::CoordinateFrameList::setFrameType
void setFrameType(int type)
Definition: CoordinateFrameList.h:22
ClonableReferenced.h