本文整理汇总了C++中ItemList::extractChildItems方法的典型用法代码示例。如果您正苦于以下问题:C++ ItemList::extractChildItems方法的具体用法?C++ ItemList::extractChildItems怎么用?C++ ItemList::extractChildItems使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ItemList
的用法示例。
在下文中一共展示了ItemList::extractChildItems方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: load
void OnlineViewerServerImpl::load(string name, string url)
{
string filepath;
QRegExp filePattern("(\\w+)://(.+)");
if(filePattern.exactMatch(url.c_str())){
string protocol = filePattern.cap(1).toStdString();
if(protocol == "file"){
filepath = filePattern.cap(2).toStdString();
} else {
mv->putln(
fmt(_("OnlineViewer: The model file at \"%1%\" cannot be read. %2% protocol is not supported."))
% url % protocol);
return;
}
} else {
filepath = url;
}
// search for registered body items
BodyItemInfo* info = findInfo(name);
if(info && info->bodyItem->filePath() == filepath){
info->needToSelectLogItem = true;
// mv->putln(fmt(_("OnlineViewer: \"%1%\" at \"%2%\" has already been loaded.")) % name % url);
return;
}
// search for existing body items
RootItem* rootItem = RootItem::instance();
ItemList<BodyItem> bodyItems;
bodyItems.extractChildItems(rootItem);
for(int i=0; i < bodyItems.size(); ++i){
BodyItemPtr bodyItem = bodyItems[i];
if(bodyItem->name() == name && bodyItem->filePath() == filepath){
registerBodyItem(bodyItem);
return;
}
}
// load a new body item
BodyItemPtr bodyItem = new BodyItem();
mv->putln(fmt(_("OnlineViewer: Loading \"%1%\" at \"%2%\"."))
% name % url);
mv->flush();
if(!bodyItem->load(filepath)){
mv->putln(fmt(_("OnlineViewer: Loading \"%1%\" failed.")) % name);
} else {
bodyItem->setName(name);
ItemList<WorldItem> worldItems;
if(worldItems.extractChildItems(rootItem)){
worldItems.front()->addChildItem(bodyItem);
} else {
rootItem->addChildItem(bodyItem);
}
ItemTreeView::instance()->checkItem(bodyItem, true);
registerBodyItem(bodyItem);
}
}
示例2: storeProperties
bool EditableSceneBodyImpl::storeProperties(Archive& archive)
{
ListingPtr states = new Listing();
ItemList<BodyItem> bodyItems;
bodyItems.extractChildItems(RootItem::instance());
for(size_t i=0; i < bodyItems.size(); ++i){
BodyItem* bodyItem = bodyItems[i];
EditableSceneBody* sceneBody = bodyItem->existingSceneBody();
if(sceneBody){
ValueNodePtr id = archive.getItemId(bodyItem);
if(id){
EditableSceneBodyImpl* impl = sceneBody->impl;
MappingPtr state = new Mapping();
state->insert("bodyItem", id);
state->write("showCenterOfMass", impl->isCmVisible);
state->write("showZmp", impl->isZmpVisible);
states->append(state);
}
}
}
if(!states->empty()){
archive.insert("editableSceneBodies", states);
return true;
}
return false;
}
示例3: forEachSimulator
void SimulationBar::forEachSimulator(boost::function<void(SimulatorItem* simulator)> callback, bool doSelect)
{
MessageView* mv = MessageView::instance();
/*
ItemList<SimulatorItem> simulators =
ItemTreeView::mainInstance()->selectedItems<SimulatorItem>();
*/
ItemList<SimulatorItem> simulators =
ItemTreeView::mainInstance()->selectedItems<SimulatorItem>();
if(simulators.empty()){
simulators.extractChildItems(RootItem::instance());
if(simulators.empty()){
mv->notify(_("There is no simulator item."));
} else if(simulators.size() > 1){
simulators.clear();
mv->notify(_("Please select a simulator item to simulate."));
} else {
if(doSelect){
ItemTreeView::instance()->selectItem(simulators.front());
}
}
}
typedef map<WorldItem*, SimulatorItem*> WorldToSimulatorMap;
WorldToSimulatorMap worldToSimulator;
for(int i=0; i < simulators.size(); ++i){
SimulatorItem* simulator = simulators.get(i);
WorldItem* world = simulator->findOwnerItem<WorldItem>();
if(world){
WorldToSimulatorMap::iterator p = worldToSimulator.find(world);
if(p == worldToSimulator.end()){
worldToSimulator[world] = simulator;
} else {
p->second = 0; // skip if multiple simulators are selected
}
}
}
for(int i=0; i < simulators.size(); ++i){
SimulatorItem* simulator = simulators.get(i);
WorldItem* world = simulator->findOwnerItem<WorldItem>();
if(!world){
mv->notify(format(_("%1% cannot be processed because it is not related with a world."))
% simulator->name());
} else {
WorldToSimulatorMap::iterator p = worldToSimulator.find(world);
if(p != worldToSimulator.end()){
if(!p->second){
mv->notify(format(_("%1% cannot be processed because another simulator"
"in the same world is also selected."))
% simulator->name());
} else {
callback(simulator);
}
}
}
}
}
示例4: readCollisionData
void CollisionSeq::readCollisionData(int nFrames, const Listing& values)
{
/*
WorldItem* worldItem = collisionSeqItem_->findOwnerItem<WorldItem>();
if(!worldItem)
return;
*/
WorldItem* worldItem = 0;
RootItem* rootItem = RootItem::instance();
ItemList<WorldItem> worldItems;
if(worldItems.extractChildItems(rootItem)){
worldItem = worldItems.front();
}
if(!worldItem)
return;
for(int i=0; i < nFrames; ++i){
const Mapping& frameNode = *values[i].toMapping();
const Listing& linkPairs = *frameNode.findListing("LinkPairs");
Frame f = frame(i);
f[0] = std::make_shared<CollisionLinkPairList>();
for(int j=0; j<linkPairs.size(); j++){
CollisionLinkPairPtr destLinkPair = std::make_shared<CollisionLinkPair>();
const Mapping& linkPair = *linkPairs[j].toMapping();
string body0name = linkPair["body0"].toString();
string body1name = linkPair["body1"].toString();
string link0name = linkPair["link0"].toString();
string link1name = linkPair["link1"].toString();
BodyItem* body0Item = worldItem->findChildItem<BodyItem>(body0name);
Body* body0=0;
Body* body1=0;
Link* link0=0;
Link* link1=0;
if(body0Item){
body0 = body0Item->body();
link0 = body0->link(link0name);
}
BodyItem* body1Item = worldItem->findChildItem<BodyItem>(body1name);
if(body1Item){
body1 = body1Item->body();
link1 = body1->link(link1name);
}
destLinkPair->body[0] = body0;
destLinkPair->link[0] = link0;
destLinkPair->body[1] = body1;
destLinkPair->link[1] = link1;
const Listing& collisions = *linkPair.findListing("Collisions");
for(int k=0; k<collisions.size(); k++){
destLinkPair->collisions.push_back(Collision());
Collision& destCol = destLinkPair->collisions.back();
const Listing& collision = *collisions[k].toListing();
destCol.point = Vector3(collision[0].toDouble(), collision[1].toDouble(), collision[2].toDouble());
destCol.normal = Vector3(collision[3].toDouble(), collision[4].toDouble(), collision[5].toDouble());
destCol.depth = collision[6].toDouble();
}
f[0]->push_back(destLinkPair);
}
}
}
示例5: updateColdetBodyInfos
void WorldItemImpl::updateColdetBodyInfos(vector<ColdetBodyInfo>& infos)
{
infos.clear();
ItemList<BodyItem> bodyItems;
bodyItems.extractChildItems(self);
for(auto bodyItem : bodyItems){
if(bodyItem->isCollisionDetectionEnabled()){
infos.push_back(ColdetBodyInfo(bodyItem));
}
}
}
示例6: updatesub
void OpenHRPOnlineViewerItemImpl::updatesub(const WorldState& state)
{
if(!worldItem){
RootItem* rootItem = RootItem::instance();
ItemList<WorldItem> worldItems;
if(worldItems.extractChildItems(rootItem)){
worldItem = worldItems.front();
} else {
worldItem = new WorldItem();
worldItem->setName("World");
rootItem->addChildItem(worldItem);
ItemTreeView::instance()->checkItem(worldItem, true);
}
worldItemConnections.add(
worldItem->sigDisconnectedFromRoot().connect(
boost::bind(&OpenHRPOnlineViewerItemImpl::onWorldItemDetachedFromRoot, this)));
}
if(!collisionSeqItem){
collisionSeqItem = worldItem->findChildItem<CollisionSeqItem>(collisionLogName);
if(!collisionSeqItem){
collisionSeqItem = new CollisionSeqItem();
collisionSeqItem->setTemporal();
collisionSeqItem->setName(collisionLogName);
worldItem->addChildItem(collisionSeqItem);
}
resetCollisionLogItem(collisionSeqItem);
needToSelectCollisionLogItem = true;
}
if(needToSelectCollisionLogItem){
ItemTreeView::instance()->selectItem(collisionSeqItem, true);
needToSelectCollisionLogItem = false;
}
const CollisionSeqPtr& colSeq = collisionSeqItem->collisionSeq();
int frame = colSeq->frameOfTime(state.time);
int lastFrame = std::max(0, std::min(frame, colSeq->numFrames()));
colSeq->setNumFrames(frame + 1);
CollisionLinkPairListPtr collisionPairs = boost::make_shared<CollisionLinkPairList>();
updateCollision(state, collisionPairs.get());
for(int i=lastFrame; i <= frame; ++i){
CollisionSeq::Frame collisionPairs0 = colSeq->frame(i);
collisionPairs0[0] = collisionPairs;
}
forEachBody(state, boost::bind(&OpenHRPOnlineViewerItemImpl::updateLog, this, _1, _2, _3, _4));
}
示例7: forEachTargetBodyItem
static void forEachTargetBodyItem(boost::function<void(BodyItem*)> callback)
{
ItemTreeView* itemTreeView = ItemTreeView::instance();
ItemList<BodyItem> bodyItems;
bodyItems.extractChildItems(RootItem::instance());
for(int i=0; i < bodyItems.size(); ++i){
BodyItem* bodyItem = bodyItems.get(i);
bool isTarget = itemTreeView->isItemSelected(bodyItem);
if(!isTarget){
WorldItem* worldItem = bodyItem->findOwnerItem<WorldItem>();
if(worldItem && itemTreeView->isItemSelected(worldItem)){
isTarget = true;
}
}
if(isTarget){
callback(bodyItem);
}
}
}
示例8: initializeScene
/**
\todo use cache of the cloned scene graph nodes
*/
void VisionRenderer::initializeScene(const vector<SimulationBody*>& simBodies)
{
sceneGroup = new SgGroup;
#ifndef CNOID_REFERENCED_USE_ATOMIC_COUNTER
simImpl->cloneMap.clear();
#endif
// create scene bodies
for(size_t i=0; i < simBodies.size(); ++i){
SceneBody* sceneBody = new SceneBody(simBodies[i]->body());
#ifndef CNOID_REFERENCED_USE_ATOMIC_COUNTER
sceneBody->cloneShapes(simImpl->cloneMap);
#endif
sceneBodies.push_back(sceneBody);
sceneGroup->addChild(sceneBody);
}
if(simImpl->shootAllSceneObjects){
WorldItem* worldItem = simImpl->self->findOwnerItem<WorldItem>();
if(worldItem){
ItemList<> items;
items.extractChildItems(worldItem);
for(size_t i=0; i < items.size(); ++i){
Item* item = items.get(i);
SceneProvider* sceneProvider = dynamic_cast<SceneProvider*>(item);
if(sceneProvider && !dynamic_cast<BodyItem*>(item)){
SgNode* scene = sceneProvider->getScene(simImpl->cloneMap);
if(scene){
sceneGroup->addChild(scene);
}
}
}
}
}
}