本文整理汇总了C++中ObjectList::addObject方法的典型用法代码示例。如果您正苦于以下问题:C++ ObjectList::addObject方法的具体用法?C++ ObjectList::addObject怎么用?C++ ObjectList::addObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObjectList
的用法示例。
在下文中一共展示了ObjectList::addObject方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mergeObjectList
void Player::mergeObjectList(ObjectList &orig, const ObjectList &newobjs, SelectionFlags_t flags)
{
if(flags == SelectionFlags::SET)
{
orig = newobjs;
}
else if(flags == SelectionFlags::ADD)
{
for(ObjectList::const_iterator it = newobjs.begin(); it != newobjs.end(); ++it)
{
ObjectList::const_iterator it2 = std::find(orig.begin(), orig.end(), *it);
if(it2 == orig.end())
orig.addObject(*it);
}
} /* else if(flags == SelectionFlags::ADD) */
else if(flags == SelectionFlags::REMOVE)
{
for(ObjectList::const_iterator it = newobjs.begin(); it != newobjs.end(); ++it)
{
ObjectList::iterator it2 = std::find(orig.begin(), orig.end(), *it);
if(it2 != orig.end())
orig.erase(it2);
}
} /* else if(flags == SelectionFlags::REMOVE) */
}
示例2: findObjectByRect
ObjectPtr Game::findObjectByRect(ObjectList &matched_objs, int left, int top, int right, int bottom, unsigned int flags)
{
ObjectList &objs = this->getObjectList();
matched_objs.clear();
for(ObjectList::const_iterator it = objs.begin(); it != objs.end(); ++it)
{
const ObjectPtr &obj = *it;
if(obj->insideRect(left, top, right, bottom))
{
//fprintf(stderr, "adding object %s\n", obj->getObjectName());
matched_objs.addObject(obj);
}
}
if(matched_objs.empty())
return ObjectPtr();
else
return *matched_objs.begin();
}
示例3: getAnnotations
ObjectList PBImage::getAnnotations(int id) const {
ObjectList annotations = ObjectList();
protobuf::CameraLocation location = protobuf::HEAD_LEFT;
if (id == 0) {
location = protobuf::HEAD_LEFT;
} else if (id == 1) {
location = protobuf::HEAD_RIGHT;
}
if (mLoadedFrame != NULL) {
for (int i = 0; i < mLoadedFrame->camera_size(); i++) {
const protobuf::ProtoBufFrame_Camera& cam = mLoadedFrame->camera(i);
if (cam.type().location() == location) {
for (int o = 0; o < cam.objects_size(); ++o) {
const protobuf::ProtoBufFrame_Object obj = cam.objects(o);
Object::ObjectType type;
switch (obj.type()) {
case protobuf::BALL:
type = Object::BALL;
break;
case protobuf::GOAL_POLE_YELLOW:
type = Object::GOAL_POLE_YELLOW;
break;
case protobuf::GOAL_YELLOW_CROSSBAR:
type = Object::GOAL_YELLOW_CROSSBAR;
break;
case protobuf::ROBOT:
type = Object::ROBOT;
break;
case protobuf::ROBOT_CYAN:
type = Object::ROBOT_CYAN;
break;
case protobuf::ROBOT_MAGENTA:
type = Object::ROBOT_MAGENTA;
break;
case protobuf::LINE:
type = Object::LINE;
break;
case protobuf::LINE_POINT:
type = Object::LINE_POINT;
break;
case protobuf::OBSTACLE:
type = Object::OBSTACLE;
break;
case protobuf::FIELD_LINE:
type = Object::FIELD_LINE;
break;
case protobuf::UNKNOWN:
default:
Debugger::DEBUG("PBImage","Unsupported ObjectType!");
type = Object::UNKNOWN;
break;
}
Object ob = Object(obj.box().x1(), obj.box().y1(),
obj.box().x2(), obj.box().y2(), type);
annotations.addObject(ob);
}
}
}
}
return annotations;
}