Choreonoid  1.8
RootItem.h
Go to the documentation of this file.
1 
5 #ifndef CNOID_BASE_ROOT_ITEM_H
6 #define CNOID_BASE_ROOT_ITEM_H
7 
8 #include "Item.h"
9 #include "exportdecl.h"
10 
11 namespace cnoid {
12 
16 class CNOID_EXPORT RootItem : public Item
17 {
18 public:
19  static void initializeClass(ExtensionManager* ext);
20  static RootItem* instance();
21 
22  [[deprecated("Use RootItem::instance()")]]
23  static RootItem* mainInstance() { return instance(); }
24 
25  RootItem();
26  RootItem(const RootItem& org);
27  virtual ~RootItem();
28 
29  SignalProxy<void(RootItem* rootItem)> sigDestroyed();
30  SignalProxy<void(Item* item)> sigSubTreeAdded();
31  SignalProxy<void(Item* item)> sigItemAdded();
32  SignalProxy<void(Item* item)> sigSubTreeMoved();
33  SignalProxy<void(Item* item)> sigItemMoved();
34  SignalProxy<void(Item* item, bool isMoving)> sigSubTreeRemoving();
35  SignalProxy<void(Item* item, bool isMoving)> sigSubTreeRemoved();
36  SignalProxy<void(Item* assigned, Item* srcItem)> sigItemAssigned();
37  SignalProxy<void(Item* item, const std::string& oldName)> sigItemNameChanged();
38 
39  [[deprecated("Use Item::sigSubTreeChanged()")]]
40  SignalProxy<void()> sigTreeChanged();
41 
42  Item* currentItem();
43 
44  template <class ItemType> ItemList<ItemType> selectedItems() {
45  return getSelectedItems();
46  }
47 
49  return getSelectedItems();
50  }
51 
52  void selectItem(Item* item);
53 
54  SignalProxy<void(Item* item, bool on)> sigSelectionChanged();
55 
56  SignalProxy<void(const ItemList<>& selectedItems)> sigSelectedItemsChanged();
57  void beginItemSelectionChanges();
58  void endItemSelectionChanges();
59 
61  int addCheckEntry(const std::string& description);
62  int numCheckEntries() const;
63  const std::string& checkEntryDescription(int checkId) const;
64  void releaseCheckEntry(int checkId);
65 
66  SignalProxy<void(int checkId)> sigCheckEntryAdded();
67  SignalProxy<void(int checkId)> sigCheckEntryReleased();
68 
69  bool storeCheckStates(int checkId, Archive& archive, const std::string& key);
70  bool restoreCheckStates(int checkId, const Archive& archive, const std::string& key);
71 
73  template <class ItemType> ItemList<ItemType> checkedItems(int checkId = PrimaryCheck) {
74  return getCheckedItems(checkId);
75  }
76 
78  return getSelectedItems();
79  }
80 
81  SignalProxy<void(Item* item, bool on)> sigCheckToggled(int checkId = PrimaryCheck);
82 
83 protected:
84  virtual Item* doDuplicate() const override;
85  virtual bool store(Archive& archive) override;
86  virtual bool restore(const Archive& archive) override;
87 
88 private:
89  friend class Item;
90  class Impl;
91  Impl* impl;
92 
93  // The following functions are called from the implementation of the Item class
94  void notifyEventOnSubTreeAdded(Item* item, std::vector<Item*>& orgSubTreeItems);
95  void notifyEventOnSubTreeMoved(Item* item, std::vector<Item*>& orgSubTreeItems);
96  void notifyEventOnSubTreeRemoving(Item* item, bool isMoving);
97  void notifyEventOnSubTreeRemoved(Item* item, bool isMoving);
98  void emitSigItemAssinged(Item* assigned, Item* srcItem);
99  void emitSigItemNameChanged(Item* item, const std::string& oldName);
100  void emitSigSelectionChanged(Item* item, bool on, bool isCurrent);
101  void requestToEmitSigSelectedItemsChanged();
102  void emitSigCheckToggled(Item* item, int checkId, bool on);
103 
104  const ItemList<>& getSelectedItems();
105  const ItemList<>& getCheckedItems(int checkId);
106 };
107 
109 
110 }
111 
112 #endif
cnoid::RootItem::selectedItems
ItemList< ItemType > selectedItems()
Definition: RootItem.h:44
Item.h
cnoid::ExtensionManager
Definition: ExtensionManager.h:23
cnoid::RootItemPtr
ref_ptr< RootItem > RootItemPtr
Definition: RootItem.h:108
cnoid::RootItem
Definition: RootItem.h:16
cnoid::Archive
Definition: Archive.h:22
cnoid::ref_ptr< RootItem >
cnoid::RootItem::checkedItems
ItemList< ItemType > checkedItems(int checkId=PrimaryCheck)
Definition: RootItem.h:73
cnoid
Definition: AbstractSceneLoader.h:11
cnoid::Item
Definition: Item.h:29
cnoid::ItemList
Definition: Item.h:20
cnoid::RootItem::mainInstance
static RootItem * mainInstance()
Definition: RootItem.h:23
cnoid::SignalProxy
Definition: Signal.h:470
cnoid::RootItem::selectedItems
const ItemList & selectedItems()
Definition: RootItem.h:48
cnoid::RootItem::checkedItems
const ItemList & checkedItems()
Definition: RootItem.h:77