Choreonoid
1.8
|
#include <Item.h>
Public Types | |
enum | Attribute { SubItem, Attached, Temporal, LoadOnly, NumAttributes, SUB_ITEM = SubItem, TEMPORAL = Temporal, LOAD_ONLY = LoadOnly } |
enum | CheckId { LogicalSumOfAllChecks = -1, PrimaryCheck = 0 } |
typedef std::function< bool(Item *item)> | ItemPredicate |
Public Member Functions | |
virtual | ~Item () |
Item & | operator= (const Item &rhs)=delete |
int | classId () const |
Item * | createNewInstance () const |
void | assign (Item *srcItem) |
Copy item properties as much as possible like the assignment operator. More... | |
Item * | duplicate (Item *duplicatedParentItem=nullptr) const |
Item * | duplicateSubTree () const |
This function creates a copy of the item including its descendant items. More... | |
Item * | duplicateAll () const |
const std::string & | name () const |
virtual bool | setName (const std::string &name) |
virtual std::string | displayName () const |
void | setDisplayNameModifier (std::function< std::string(const Item *item)> modifier) |
SignalProxy< void(const std::string &oldName)> | sigNameChanged () |
void | notifyNameChange () |
This function notifies the system of a displayName change. More... | |
void | setAttribute (Attribute attribute) |
void | unsetAttribute (Attribute attribute) |
bool | hasAttribute (Attribute attribute) const |
bool | isSubItem () const |
void | setSubItemAttributes () |
bool | isTemporal () const |
void | setTemporal (bool on=true) |
bool | isSelected () const |
void | setSelected (bool on, bool isCurrent=false) |
void | setSubTreeItemsSelected (bool on) |
bool | isChecked (int checkId=PrimaryCheck) const |
void | setChecked (bool on) |
void | setChecked (int checkId, bool on) |
int | numCheckStates () const |
int | numChildren () const |
int | countDescendantItems () const |
Item * | childItem () const |
Item * | prevItem () const |
Item * | nextItem () const |
Item * | lastChildItem () const |
Item * | parentItem () const |
Item * | headItem () const |
RootItem * | findRootItem () const |
bool | isConnectedToRoot () const |
Item * | localRootItem () const |
bool | addChildItem (Item *item, bool isManualOperation=false) |
bool | insertChildItem (Item *item, Item *nextItem, bool isManualOperation=false) |
bool | insertChild (Item *position, Item *item, bool isManualOperation=false) |
bool | addSubItem (Item *item) |
bool | insertSubItem (Item *item, Item *nextItem) |
void | removeFromParentItem () |
void | detachFromParentItem () |
void | clearChildren () |
template<class ItemType > | |
ItemType * | find (const std::string &path="") |
Item * | findItem (const std::string &path) const |
template<class ItemType > | |
ItemType * | findItem (const std::string &path) const |
template<class ItemType > | |
ItemType * | findItem (std::function< bool(ItemType *item)> pred=nullptr) const |
Item * | findChildItem (const std::string &path, std::function< bool(Item *item)> pred=nullptr) const |
template<class ItemType > | |
ItemType * | findChildItem (const std::string &path, std::function< bool(ItemType *item)> pred=nullptr) const |
template<class ItemType > | |
ItemType * | findChildItem (std::function< bool(ItemType *item)> pred=nullptr) const |
Item * | findSubItem (const std::string &path) const |
template<class ItemType > | |
ItemType * | findSubItem (const std::string &path="") const |
template<class ItemType > | |
ItemType * | findOwnerItem (bool includeSelf=false) const |
bool | isOwnedBy (Item *item) const |
ItemList | childItems (std::function< bool(Item *item)> pred=nullptr) const |
template<class ItemType > | |
ItemList< ItemType > | childItems (std::function< bool(ItemType *item)> pred=nullptr) const |
ItemList | descendantItems (std::function< bool(Item *item)> pred=nullptr) const |
template<class ItemType > | |
ItemList< ItemType > | descendantItems (std::function< bool(ItemType *item)> pred=nullptr) const |
ItemList | selectedDescendantItems (std::function< bool(Item *item)> pred=nullptr) const |
template<class ItemType > | |
ItemList< ItemType > | selectedDescendantItems (std::function< bool(Item *item)> pred=nullptr) const |
bool | traverse (std::function< bool(Item *)> pred) |
template<class ItemType > | |
bool | traverse (std::function< bool(ItemType *item)> pred=nullptr) |
SignalProxy< void()> | sigTreePathChanged () |
SignalProxy< void()> | sigTreePositionChanged () |
SignalProxy< void(Item *topItem, Item *prevTopParentItem)> | sigTreePositionChanged2 () |
SignalProxy< void()> | sigPositionChanged () |
SignalProxy< void()> | sigSubTreeChanged () |
SignalProxy< void()> | sigDisconnectedFromRoot () |
SignalProxy< void()> | sigDetachedFromRoot () |
SignalProxy< void(bool on)> | sigSelectionChanged () |
SignalProxy< void(int checkId, bool on)> | sigAnyCheckToggled () |
SignalProxy< void(bool on)> | sigCheckToggled (int checkId=PrimaryCheck) |
virtual void | notifyUpdate () |
SignalProxy< void()> | sigUpdated () |
bool | setAddon (ItemAddon *addon) |
void | removeAddon (ItemAddon *addon) |
template<class AddonType > | |
AddonType * | findAddon () |
template<class AddonType > | |
AddonType * | getAddon () |
std::vector< ItemAddon * > | addons () |
bool | load (const std::string &filename, const std::string &format=std::string(), const Mapping *options=nullptr) |
bool | load (const std::string &filename, Item *parent, const std::string &format=std::string(), const Mapping *options=nullptr) |
bool | save (const std::string &filename, const std::string &format=std::string(), const Mapping *options=nullptr) |
bool | overwrite (bool forceOverwrite=false, const std::string &format=std::string()) |
const std::string & | filePath () const |
Full path file name. More... | |
std::string | fileName () const |
File name without the directory. More... | |
const std::string & | fileFormat () const |
const Mapping * | fileOptions () const |
std::time_t | fileModificationTime () const |
bool | isConsistentWithFile () const |
void | updateFileInformation (const std::string &filename, const std::string &format, Mapping *options=nullptr) |
void | setConsistentWithFile (bool isConsistent) |
void | suggestFileUpdate () |
void | clearFileInformation () |
Use this function to disable the implicit overwrite next time. More... | |
bool | reload () |
bool | replace (Item *originalItem) |
Item * | findOriginalItem () const |
Item * | findReplacementItem () const |
void | putProperties (PutPropertyFunction &putProperty) |
virtual bool | store (Archive &archive) |
virtual bool | restore (const Archive &archive) |
Public Member Functions inherited from cnoid::Referenced | |
virtual | ~Referenced () |
Static Public Member Functions | |
template<class ItemType > | |
static ItemPredicate | getItemPredicate () |
template<class ItemType > | |
static ItemPredicate | getItemPredicate (std::function< bool(ItemType *item)> pred) |
static Item * | find (const std::string &path) |
Protected Member Functions | |
Item () | |
Item (const std::string &name) | |
Item (const Item &item) | |
virtual void | doAssign (Item *srcItem) |
Implement the code to copy properties like the assingment operator. More... | |
virtual Item * | doDuplicate () const |
Override this function to allow duplication of an instance. More... | |
virtual Item * | doDuplicate (Item *duplicatedParentItem) const |
virtual bool | onNewTreePositionCheck (bool isManualOperation, std::function< void()> &out_callbackWhenAdded) |
virtual void | onAddedToParent () |
virtual void | onTreePathChanged () |
virtual void | onTreePositionChanged () |
virtual void | onPositionChanged () |
virtual void | onConnectedToRoot () |
virtual void | onRemovedFromParent (Item *parentItem, bool isParentBeingDeleted) |
virtual void | onDisconnectedFromRoot () |
virtual bool | onChildItemAboutToBeAdded (Item *childItem, bool isManualOperation) |
virtual void | doPutProperties (PutPropertyFunction &putProperty) |
Protected Member Functions inherited from cnoid::Referenced | |
Referenced () | |
Referenced (const Referenced &) | |
int | refCount () const |
typedef std::function<bool(Item* item)> cnoid::Item::ItemPredicate |
enum cnoid::Item::CheckId |
|
protected |
|
protected |
|
protected |
|
virtual |
bool Item::addChildItem | ( | Item * | item, |
bool | isManualOperation = false |
||
) |
std::vector< ItemAddon * > Item::addons | ( | ) |
bool Item::addSubItem | ( | Item * | item | ) |
This function adds a sub item to the item. The sub item is an item that is a required element of the main item, and the sub item cannot be removed from the main item.
void Item::assign | ( | Item * | srcItem | ) |
Copy item properties as much as possible like the assignment operator.
|
inline |
|
inline |
|
inline |
void Item::clearChildren | ( | ) |
void Item::clearFileInformation | ( | ) |
Use this function to disable the implicit overwrite next time.
int Item::countDescendantItems | ( | ) | const |
Item * Item::createNewInstance | ( | ) | const |
|
inline |
|
inline |
|
virtual |
Reimplemented in cnoid::CoordinateFrameItem.
|
protectedvirtual |
Implement the code to copy properties like the assingment operator.
Reimplemented in cnoid::BodyItem.
|
protectedvirtual |
Override this function to allow duplication of an instance.
Reimplemented in cnoid::BodyItem, cnoid::MultiPointSetItem, cnoid::CoordinateFrameListItem, cnoid::PointSetItem, cnoid::RootItem, cnoid::AISTSimulatorItem, cnoid::BodyMotionItem, cnoid::PositionTagGroupItem, cnoid::MprProgramItemBase, cnoid::CoordinateFrameItem, cnoid::WorldItem, cnoid::WorldLogFileItem, cnoid::BodyTrackingCameraItem, cnoid::SceneItem, cnoid::BodyMarkerItem, cnoid::MultiSeqItem< MultiSeqType >, cnoid::PythonScriptItem, cnoid::PythonSimScriptItem, cnoid::Vector3SeqItem, cnoid::ReferencedObjectSeqItem, cnoid::SimpleControllerItem, cnoid::BodyMotionControllerItem, cnoid::IoConnectionMapItem, cnoid::MprMultiVariableListItem, cnoid::SubProjectItem, cnoid::MessageLogItem, cnoid::MultiDeviceStateSeqItem, cnoid::LightingItem, cnoid::BodyContactPointLoggerItem, cnoid::SensorVisualizerItem, cnoid::FolderItem, cnoid::LinkOffsetFrameListItem, cnoid::ControllerLogItem, cnoid::MaterialTableItem, cnoid::KinematicSimulatorItem, cnoid::AudioItem, cnoid::GLVisionSimulatorItem, cnoid::MediaItem, cnoid::CollisionSeqItem, cnoid::ZMPSeqItem, and cnoid::ExtCommandItem.
Use this overload if the duplication process needs to know the duplicated parent item.
Reimplemented in cnoid::DeviceOverwriteItem, and cnoid::LinkShapeOverwriteItem.
|
protectedvirtual |
This function is used to put a standard properties of the item. You can implement the standard properties by overriding this function.
Reimplemented in cnoid::SimulatorItem, cnoid::BodyItem, cnoid::MultiPointSetItem, cnoid::DeviceOverwriteItem, cnoid::CoordinateFrameListItem, cnoid::MprControllerItemBase, cnoid::PointSetItem, cnoid::ControllerItem, cnoid::AISTSimulatorItem, cnoid::PositionTagGroupItem, cnoid::CoordinateFrameItem, cnoid::WorldLogFileItem, cnoid::WorldItem, cnoid::SceneItem, cnoid::BodyTrackingCameraItem, cnoid::MprProgramItemBase, cnoid::BodyMarkerItem, cnoid::LinkShapeOverwriteItem, cnoid::AbstractMultiSeqItem, cnoid::PythonScriptItem, cnoid::PythonSimScriptItem, cnoid::SimpleControllerItem, cnoid::BodyMotionControllerItem, cnoid::MprMultiVariableListItem, cnoid::SubProjectItem, cnoid::MessageLogItem, cnoid::LightingItem, cnoid::AbstractSeqItem, cnoid::KinematicSimulatorItem, cnoid::MaterialTableItem, cnoid::AudioItem, cnoid::GLVisionSimulatorItem, cnoid::SimulationScriptItem, cnoid::MediaItem, cnoid::ZMPSeqItem, cnoid::ExtCommandItem, and cnoid::SubSimulatorItem.
|
inline |
Item * Item::duplicateSubTree | ( | ) | const |
This function creates a copy of the item including its descendant items.
const std::string & Item::fileFormat | ( | ) | const |
std::time_t Item::fileModificationTime | ( | ) | const |
std::string Item::fileName | ( | ) | const |
File name without the directory.
const Mapping * Item::fileOptions | ( | ) | const |
const std::string & Item::filePath | ( | ) | const |
Full path file name.
|
inlinestatic |
This is equivalent to RootItem::instance()->findItem(path);
|
inline |
|
inline |
|
inline |
Find an item that has the corresponding path from a child item to it
|
inline |
|
inline |
|
inline |
Find an item that has the corresponding path to it in the sub tree
|
inline |
|
inline |
Item * Item::findOriginalItem | ( | ) | const |
|
inline |
Item * Item::findReplacementItem | ( | ) | const |
RootItem * Item::findRootItem | ( | ) | const |
|
inline |
Find a sub item that has the corresponding path from a direct sub item to it
|
inline |
|
inline |
|
inlinestatic |
|
inlinestatic |
bool Item::hasAttribute | ( | Attribute | attribute | ) | const |
Item * Item::headItem | ( | ) | const |
bool Item::isChecked | ( | int | checkId = PrimaryCheck | ) | const |
bool Item::isConnectedToRoot | ( | ) | const |
bool Item::isConsistentWithFile | ( | ) | const |
bool Item::isOwnedBy | ( | Item * | item | ) | const |
|
inline |
bool Item::isSubItem | ( | ) | const |
bool Item::isTemporal | ( | ) | const |
If this is true, the item is not automatically saved or overwritten when a project is saved. For example, a motion item which is produced as a simulation result may be an temporal item because a user may not want to save the result. If a user manually save the item, the item becomes a non-temporal item. Or if a child item is manually attached to a temporal item, the item becomes non-temporal one as well.
|
inline |
bool Item::load | ( | const std::string & | filename, |
const std::string & | format = std::string() , |
||
const Mapping * | options = nullptr |
||
) |
This function loads the data of the item from a file by using a registered FileIO object. To make this function available, a FileIO object must be registered to an ItemManager in advance with its registerFileIO function.
bool Item::load | ( | const std::string & | filename, |
Item * | parent, | ||
const std::string & | format = std::string() , |
||
const Mapping * | options = nullptr |
||
) |
An overload version of the load function.
parent | specify this when the item is newly created one and will be attached to a parent item if loading succeeds. |
Item * Item::localRootItem | ( | ) | const |
|
inline |
|
inline |
void Item::notifyNameChange | ( | ) |
This function notifies the system of a displayName change.
|
virtual |
Reimplemented in cnoid::BodyMotionItem, cnoid::WorldLogFileItem, and cnoid::PointSetItem.
int Item::numCheckStates | ( | ) | const |
|
inline |
|
protectedvirtual |
Reimplemented in cnoid::CoordinateFrameItem.
|
protectedvirtual |
This function is called when a child item is about to be added to this item. By overriding this function, you can check a child item and prevent the item from being added if necessary.
Reimplemented in cnoid::CoordinateFrameListItem, and cnoid::BodyMotionItem.
|
protectedvirtual |
This function is called when the item has been connected to the item tree with RootItem as the root. Note that this function is called before onTreePathChanged and onTreePositionChanged are called.
Reimplemented in cnoid::BodyItem, cnoid::PositionTagGroupItem, cnoid::MprProgramItemBase, cnoid::SubProjectItem, and cnoid::MessageLogItem.
|
protectedvirtual |
Reimplemented in cnoid::SimulatorItem, cnoid::CoordinateFrameListItem, cnoid::MprControllerItemBase, cnoid::PositionTagGroupItem, cnoid::PythonScriptItem, cnoid::PythonSimScriptItem, cnoid::SimpleControllerItem, cnoid::BodyMotionControllerItem, cnoid::MessageLogItem, cnoid::SensorVisualizerItem, and cnoid::ExtCommandItem.
|
protectedvirtual |
Reimplemented in cnoid::BodyElementOverwriteItem, and cnoid::PositionTagGroupItem.
|
protectedvirtual |
|
protectedvirtual |
Reimplemented in cnoid::CoordinateFrameItem.
|
protectedvirtual |
This function is called at the same time as sigTreePathChanged. The order in which it is called precedes the signal. By overriding this function in a derived item class, you can implement the necessary processing when the path in the item tree is changed.
Reimplemented in cnoid::BodyElementOverwriteItem, cnoid::SimulatorItem, cnoid::BodyItem, cnoid::MprProgramItemBase, cnoid::WorldLogFileItem, cnoid::BodyTrackingCameraItem, cnoid::BodyMarkerItem, cnoid::SimpleControllerItem, cnoid::IoConnectionMapItem, and cnoid::SensorVisualizerItem.
|
protectedvirtual |
This function is similar to the onTreePathChanged function. The condition to call this function is same as sigTreePositionChanged, and the order in which it is called precedes the signal.
Reimplemented in cnoid::CoordinateFrameListItem.
bool Item::overwrite | ( | bool | forceOverwrite = false , |
const std::string & | format = std::string() |
||
) |
This function save the data of the item to the file from which the data of the item has been loaded. If the data has not been loaded from a file, a file save dialog to specify a file opens.
|
inline |
|
inline |
void Item::putProperties | ( | PutPropertyFunction & | putProperty | ) |
bool Item::reload | ( | ) |
void Item::removeAddon | ( | ItemAddon * | addon | ) |
void Item::removeFromParentItem | ( | ) |
bool Item::replace | ( | Item * | originalItem | ) |
|
virtual |
Reimplemented in cnoid::SimulatorItem, cnoid::BodyItem, cnoid::DeviceOverwriteItem, cnoid::MprControllerItemBase, cnoid::ControllerItem, cnoid::PointSetItem, cnoid::CoordinateFrameListItem, cnoid::RootItem, cnoid::MultiPointSetItem, cnoid::AISTSimulatorItem, cnoid::BodyMotionItem, cnoid::PositionTagGroupItem, cnoid::WorldLogFileItem, cnoid::WorldItem, cnoid::BodyTrackingCameraItem, cnoid::MprProgramItemBase, cnoid::BodyMarkerItem, cnoid::SceneItem, cnoid::LinkShapeOverwriteItem, cnoid::CoordinateFrameItem, cnoid::PythonScriptItem, cnoid::PythonSimScriptItem, cnoid::SimpleControllerItem, cnoid::BodyMotionControllerItem, cnoid::SubProjectItem, cnoid::MessageLogItem, cnoid::LightingItem, cnoid::IoConnectionMapItem, cnoid::MultiDeviceStateSeqItem, cnoid::SensorVisualizerItem, cnoid::MprMultiVariableListItem, cnoid::AbstractSeqItem, cnoid::KinematicSimulatorItem, cnoid::FolderItem, cnoid::MaterialTableItem, cnoid::AudioItem, cnoid::GLVisionSimulatorItem, cnoid::SimulationScriptItem, cnoid::MediaItem, cnoid::ExtCommandItem, cnoid::CollisionSeqItem, and cnoid::SubSimulatorItem.
bool Item::save | ( | const std::string & | filename, |
const std::string & | format = std::string() , |
||
const Mapping * | options = nullptr |
||
) |
This function saves the data of the item to a file by using a registered FileIO object. To make this function available, a FileIO object must be registered to an ItemManager in advance with its registerFileIO function.
|
inline |
bool Item::setAddon | ( | ItemAddon * | addon | ) |
void Item::setAttribute | ( | Attribute | attribute | ) |
void Item::setChecked | ( | bool | on | ) |
void Item::setChecked | ( | int | checkId, |
bool | on | ||
) |
void Item::setConsistentWithFile | ( | bool | isConsistent | ) |
void Item::setDisplayNameModifier | ( | std::function< std::string(const Item *item)> | modifier | ) |
|
virtual |
Reimplemented in cnoid::DeviceOverwriteItem, cnoid::BodyItem, cnoid::BodyTrackingCameraItem, cnoid::SceneItem, cnoid::PointSetItem, cnoid::BodyMarkerItem, cnoid::PositionTagGroupItem, and cnoid::MprProgramItemBase.
void Item::setSelected | ( | bool | on, |
bool | isCurrent = false |
||
) |
void Item::setSubItemAttributes | ( | ) |
void Item::setSubTreeItemsSelected | ( | bool | on | ) |
void Item::setTemporal | ( | bool | on = true | ) |
SignalProxy< void(int checkId, bool on)> Item::sigAnyCheckToggled | ( | ) |
SignalProxy< void(bool on)> Item::sigCheckToggled | ( | int | checkId = PrimaryCheck | ) |
|
inline |
SignalProxy< void()> Item::sigDisconnectedFromRoot | ( | ) |
SignalProxy< void(const std::string &oldName)> Item::sigNameChanged | ( | ) |
SignalProxy< void()> Item::sigPositionChanged | ( | ) |
SignalProxy< void(bool isSelected)> Item::sigSelectionChanged | ( | ) |
SignalProxy< void()> Item::sigSubTreeChanged | ( | ) |
This signal is emitted when the structure or elements of the sub tree changes.
SignalProxy< void()> Item::sigTreePathChanged | ( | ) |
This signal is emitted when the path from the root to this item in an item tree is changed. The path changes include the addition or removal of this item to or from the item tree. The item tree can contain or not contain the RootItem instance as the tree root. Note that the signal is emitted before RootItem::sigTreeChanged().
SignalProxy< void()> Item::sigTreePositionChanged | ( | ) |
This signal is emitted when the position of this item in the item tree is changed. In contrast to sigTreePathChanged, this signal is emitted when the order of the item in the parent item is changed even if the path to the item is not changed. Except for that, this signal is same as sigTreePathChanged.
SignalProxy< void(Item *topItem, Item *prevTopParentItem)> Item::sigTreePositionChanged2 | ( | ) |
The arguments of this signal should be included in sigTreePositionChanged. However, the current implementation of the signal template class does now allow the omission of arguments in connecting a slot function and these arguments are not frequently used. Therefore the signal with the arguments are defined separately from the signal without arguments. If the Signal template class is improved so that it can omit arguments in the slot connection, it is better to integrate the signals. In any case, do not use this signal if you don't have a special reason.
SignalProxy< void()> Item::sigUpdated | ( | ) |
|
virtual |
Reimplemented in cnoid::SimulatorItem, cnoid::BodyItem, cnoid::DeviceOverwriteItem, cnoid::MprControllerItemBase, cnoid::ControllerItem, cnoid::PointSetItem, cnoid::CoordinateFrameListItem, cnoid::RootItem, cnoid::MultiPointSetItem, cnoid::AISTSimulatorItem, cnoid::BodyMotionItem, cnoid::PositionTagGroupItem, cnoid::WorldLogFileItem, cnoid::WorldItem, cnoid::BodyTrackingCameraItem, cnoid::MprProgramItemBase, cnoid::BodyMarkerItem, cnoid::SceneItem, cnoid::LinkShapeOverwriteItem, cnoid::CoordinateFrameItem, cnoid::PythonScriptItem, cnoid::PythonSimScriptItem, cnoid::SimpleControllerItem, cnoid::BodyMotionControllerItem, cnoid::SubProjectItem, cnoid::MessageLogItem, cnoid::LightingItem, cnoid::IoConnectionMapItem, cnoid::MultiDeviceStateSeqItem, cnoid::SensorVisualizerItem, cnoid::MprMultiVariableListItem, cnoid::AbstractSeqItem, cnoid::KinematicSimulatorItem, cnoid::FolderItem, cnoid::MaterialTableItem, cnoid::AudioItem, cnoid::GLVisionSimulatorItem, cnoid::SimulationScriptItem, cnoid::MediaItem, cnoid::ExtCommandItem, cnoid::CollisionSeqItem, and cnoid::SubSimulatorItem.
void Item::suggestFileUpdate | ( | ) |
bool Item::traverse | ( | std::function< bool(Item *)> | pred | ) |
|
inline |
void Item::unsetAttribute | ( | Attribute | attribute | ) |
void Item::updateFileInformation | ( | const std::string & | filename, |
const std::string & | format, | ||
Mapping * | options = nullptr |
||
) |