本文整理汇总了C++中ItemList::get方法的典型用法代码示例。如果您正苦于以下问题:C++ ItemList::get方法的具体用法?C++ ItemList::get怎么用?C++ ItemList::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ItemList
的用法示例。
在下文中一共展示了ItemList::get方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
}
}
}
}
示例2: apply
void KinematicFaultCheckerImpl::apply()
{
bool processed = false;
ItemList<BodyMotionItem> items = ItemTreeView::mainInstance()->selectedItems<BodyMotionItem>();
if(items.empty()){
mes.notify(_("No BodyMotionItems are selected."));
} else {
for(size_t i=0; i < items.size(); ++i){
BodyMotionItem* motionItem = items.get(i);
BodyItem* bodyItem = motionItem->findOwnerItem<BodyItem>();
if(!bodyItem){
mes.notify(str(fmt(_("%1% is not owned by any BodyItem. Check skiped.")) % motionItem->name()));
} else {
mes.putln();
mes.notify(str(fmt(_("Applying the Kinematic Fault Checker to %1% ..."))
% motionItem->headItem()->name()));
dynamic_bitset<> linkSelection;
if(selectedJointsRadio.isChecked()){
linkSelection = LinkSelectionView::mainInstance()->linkSelection(bodyItem);
} else if(nonSelectedJointsRadio.isChecked()){
linkSelection = LinkSelectionView::mainInstance()->linkSelection(bodyItem);
linkSelection.flip();
} else {
linkSelection.resize(bodyItem->body()->numLinks(), true);
}
double beginningTime = 0.0;
double endingTime = motionItem->motion()->getTimeLength();
std::numeric_limits<double>::max();
if(onlyTimeBarRangeCheck.isChecked()){
TimeBar* timeBar = TimeBar::instance();
beginningTime = timeBar->minTime();
endingTime = timeBar->maxTime();
}
int n = checkFaults(bodyItem, motionItem, mes.cout(),
positionCheck.isChecked(),
velocityCheck.isChecked(),
collisionCheck.isChecked(),
linkSelection,
beginningTime, endingTime);
if(n > 0){
if(n == 1){
mes.notify(_("A fault has been detected."));
} else {
mes.notify(str(fmt(_("%1% faults have been detected.")) % n));
}
} else {
mes.notify(_("No faults have been detected."));
}
processed = true;
}
}
}
}
示例3: forEachTopItems
void ItemTreeViewImpl::forEachTopItems(const ItemList<>& items, boost::function<void(Item*)> callback)
{
set<Item*> itemSet;
for(size_t i=0; i < items.size(); ++i){
itemSet.insert(items.get(i));
}
for(size_t i=0; i < items.size(); ++i){
Item* item = items.get(i);
bool isChild = false;
Item* parentItem = item->parentItem();
while(parentItem){
set<Item*>::iterator p = itemSet.find(parentItem);
if(p != itemSet.end()){
isChild = true;
break;
}
parentItem = parentItem->parentItem();
}
if(!isChild){
callback(item);
}
}
}
示例4: onSelectionChanged
void MeshShapeItemImpl::onSelectionChanged()
{
ItemList<Item> items = ItemTreeView::mainInstance()->selectedItems();
bool selected = false;
for(size_t i=0; i < items.size(); ++i){
Item* item = items.get(i);
if (item == self) {
selected = true;
}
}
if (isselected != selected) {
isselected = selected;
//positionDragger->setDraggerAlwaysShown(selected);
if (isselected) {
positionDragger->setDraggerAlwaysShown(true);
} else {
positionDragger->setDraggerAlwaysHidden(true);
}
}
}
示例5: 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);
}
}
}
示例6: 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);
}
}
}
}
}
}