C++ IComponent类代码示例

本文整理汇总了C++中IComponent的典型用法代码示例。如果您正苦于以下问题:C++ IComponent类的具体用法?C++ IComponent怎么用?C++ IComponent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


C++ IComponent类代码示例

在下文中一共展示了IComponent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Component_SetProperty

static duk_ret_t Component_SetProperty(duk_context* ctx)
{
    /* 'this' binding: handler
     * [0]: target
     * [1]: key
     * [2]: val
     * [3]: receiver (proxy)
     */
    const char* attrName = duk_to_string(ctx, 1);
    if (attrName && attrName[0] >= 'a' && attrName[0] <= 'z')
    {
        IComponent* comp = GetWeakObject<IComponent>(ctx, 0);
        if (comp)
        {
            IAttribute* attr = comp->AttributeById(String(attrName));
            AssignAttributeValue(ctx, 2, attr, AttributeChange::Default);
            return 1;
        }
    }

    // Fallthrough to ordinary properties
    duk_dup(ctx, 1);
    duk_dup(ctx, 2);
    duk_put_prop(ctx, 0);
    duk_push_true(ctx);
    return 1;
}
开发者ID:realXtend,项目名称:tundra-urho3d,代码行数:27,代码来源:BindingsHelpers.cpp

示例2: moveComponent

/**
 * Add/modify an entry in the parameter map for the given component
 * to update its position. The component is const
 * as the move doesn't actually change the object
 * @param comp A reference to the component to move
 * @param pmap A reference to the ParameterMap that will hold the new position
 * @param pos The new position
 * @param positionType Defines how the given position should be interpreted @see
 * TransformType enumeration
 */
void moveComponent(const IComponent &comp, ParameterMap &pmap,
                   const Kernel::V3D &pos, const TransformType positionType) {
    //
    // This behaviour was copied from how MoveInstrumentComponent worked
    //

    // First set it to the new absolute position
    V3D newPos = pos;
    switch (positionType) {
    case Absolute: // Do nothing
        break;
    case Relative:
        newPos += comp.getPos();
        break;
    default:
        throw std::invalid_argument("moveComponent -  Unknown positionType: " +
                                    boost::lexical_cast<std::string>(positionType));
    }

    // Then find the corresponding relative position
    auto parent = comp.getParent();
    if (parent) {
        newPos -= parent->getPos();
        Quat rot = parent->getRotation();
        rot.inverse();
        rot.rotate(newPos);
    }

    // Add a parameter for the new position
    pmap.addV3D(comp.getComponentID(), "pos", newPos);
}
开发者ID:nimgould,项目名称:mantid,代码行数:41,代码来源:ComponentHelper.cpp

示例3: rotateComponent

/**
 * Add/modify an entry in the parameter map for the given component
 * to update its rotation. The component is const
 * as the move doesn't actually change the object
 * @param comp A reference to the component to move
 * @param pmap A reference to the ParameterMap that will hold the new position
 * @param rot The rotation quaternion
 * @param rotType Defines how the given rotation should be interpreted @see
 * TransformType enumeration
 */
void rotateComponent(const IComponent &comp, ParameterMap &pmap,
                     const Kernel::Quat &rot, const TransformType rotType) {
    //
    // This behaviour was copied from how RotateInstrumentComponent worked
    //

    Quat newRot = rot;
    if (rotType == Absolute) {
        // Find the corresponding relative position
        auto parent = comp.getParent();
        if (parent) {
            Quat rot0 = parent->getRelativeRot();
            rot0.inverse();
            newRot = rot * rot0;
        }
    } else if (rotType == Relative) {
        const Quat &Rot0 = comp.getRelativeRot();
        newRot = Rot0 * rot;
    } else {
        throw std::invalid_argument("rotateComponent -  Unknown rotType: " +
                                    boost::lexical_cast<std::string>(rotType));
    }

    // Add a parameter for the new rotation
    pmap.addQuat(comp.getComponentID(), "rot", newRot);
}
开发者ID:nimgould,项目名称:mantid,代码行数:36,代码来源:ComponentHelper.cpp

示例4: _CompFactory

IComponent* KEditDialogImpl::_CompFactory()
{
    IComponent* pCompTmp = NULL;

    switch(m_uSelItemID)
    {
    case enRadio_Begin + 0:
        pCompTmp = new KCompText;
        break;
    case enRadio_Begin + 1:
        pCompTmp = new KCompButton;
        break;
    case enRadio_Begin + 2:
        pCompTmp = new KCompImgbtn;
        break;
    case enRadio_Begin + 3:
        pCompTmp = new KCompImg;
        break;
    default:
        pCompTmp = new KCompText;
        break;
    }

    if (pCompTmp != NULL)
    {
        pCompTmp->InitComp();
    }
    return pCompTmp;
}
开发者ID:LineDotTeam,项目名称:BKEditor,代码行数:29,代码来源:uieditor_logic.cpp

示例5: fprintf

GameObject EntityFactory::createObjectFromIML(
    const std::string &name, const IMLNode *iml) const
{
  //printf("EntityFactory::createObjectFromIML: '%s'\n", name.c_str());
  IMLNode *node = iml->findByName(name);
  if (!node || name.empty()) {
    fprintf(stderr, "Unable to create entity: '%s'\n", name.c_str());
    return GameObject(0);
  }
  EntityManager &em = EntityManager::instance();
  GameObject entity = em.createEntity();
  std::list<IMLNode*> &components_iml = node->getChildren();
  std::list<IMLNode*>::iterator it = components_iml.begin();
  for (; it != components_iml.end(); ++it) {
    IMLTag *tag = dynamic_cast<IMLTag*>(*it);
    if (tag) {
      ComponentFactory &cf = ComponentFactory::instance();
      IComponent *comp = cf.create((*it)->getName());
      if (!comp) {
        fprintf(stderr, "Unable to create component: %s\n",
            (*it)->getName().c_str());
      } else {
        comp->loadIML(*tag);
        em.addComponentToEntity(comp, entity);
      }
    }
  }
  return entity;
}
开发者ID:Th30n,项目名称:into-the-dungeon,代码行数:29,代码来源:EntityFactory.cpp

示例6: VisualObject

VisualSizer::VisualSizer(shared_ptr<ObjectBase> obj,wxWindow *parent)
: VisualObject(obj)
{
	IComponent *comp = obj->GetObjectInfo()->GetComponent();
	if (comp)
	{

		/*  wxObject* yo = parent;
		IObject *objer =  obj.get();
		wxStaticBox* box = new wxStaticBox( (wxWindow*)yo, -1,
		objer->GetPropertyAsString(wxT("label")));

		wxStaticBoxSizer* sizer = new wxStaticBoxSizer(box,
		objer->GetPropertyAsInteger(wxT("orient")));

		SetSizer( sizer );*/

		SetSizer((wxSizer *)(comp->Create(obj.get(),parent)));
	}
	else
	{
		// para que no pete ponemos un sizer por defecto, aunque deberá mostrar algun
		// mensaje de advertencia
		SetSizer(new wxBoxSizer(wxVERTICAL));
	}

	shared_ptr<Property> pminsize  = obj->GetProperty( wxT("minimum_size") );
	if (pminsize)
	{
		wxSize minsize = StringToSize(pminsize->GetValue());
		m_sizer->SetMinSize( minsize );
		m_sizer->Layout();
	}
}
开发者ID:idrassi,项目名称:wxFormBuilder,代码行数:34,代码来源:visualobj.cpp

示例7: rq

IComponent* CComponentManager::ConstructComponent(CEntityHandle ent, ComponentTypeId cid)
{
	JSContext* cx = m_ScriptInterface.GetContext();
	JSAutoRequest rq(cx);

	std::map<ComponentTypeId, ComponentType>::const_iterator it = m_ComponentTypesById.find(cid);
	if (it == m_ComponentTypesById.end())
	{
		LOGERROR("Invalid component id %d", cid);
		return NULL;
	}

	const ComponentType& ct = it->second;

	ENSURE((size_t)ct.iid < m_ComponentsByInterface.size());

	boost::unordered_map<entity_id_t, IComponent*>& emap1 = m_ComponentsByInterface[ct.iid];
	if (emap1.find(ent.GetId()) != emap1.end())
	{
		LOGERROR("Multiple components for interface %d", ct.iid);
		return NULL;
	}

	std::map<entity_id_t, IComponent*>& emap2 = m_ComponentsByTypeId[cid];

	// If this is a scripted component, construct the appropriate JS object first
	JS::RootedValue obj(cx);
	if (ct.type == CT_Script)
	{
		m_ScriptInterface.CallConstructor(ct.ctor.get(), JS::HandleValueArray::empty(), &obj);
		if (obj.isNull())
		{
			LOGERROR("Script component constructor failed");
			return NULL;
		}
	}

	// Construct the new component
	IComponent* component = ct.alloc(m_ScriptInterface, obj);
	ENSURE(component);

	component->SetEntityHandle(ent);
	component->SetSimContext(m_SimContext);

	// Store a reference to the new component
	emap1.insert(std::make_pair(ent.GetId(), component));
	emap2.insert(std::make_pair(ent.GetId(), component));
	// TODO: We need to more careful about this - if an entity is constructed by a component
	// while we're iterating over all components, this will invalidate the iterators and everything
	// will break.
	// We probably need some kind of delayed addition, so they get pushed onto a queue and then
	// inserted into the world later on. (Be careful about immediation deletion in that case, too.)

	SEntityComponentCache* cache = ent.GetComponentCache();
	ENSURE(cache != NULL && ct.iid < (int)cache->numInterfaces && cache->interfaces[ct.iid] == NULL);
	cache->interfaces[ct.iid] = component;

	return component;
}
开发者ID:2asoft,项目名称:0ad,代码行数:59,代码来源:ComponentManager.cpp

示例8:

/**
* 在模型销毁的时候,
* 需判断组件是否由自身创建.
* 检查m_SelfOwn,
* 若为true,
* 则需要同时销毁所有组件.
*/
Model::~Model()
{
    for (UINT32 i = 0; i < m_ComponentList.size(); ++i)
    {
        IComponent *component = m_ComponentList[i];
        component->Destroy();
    }
}
开发者ID:chinarustin,项目名称:aep,代码行数:15,代码来源:model.cpp

示例9: FOR_EACH_SIZE

bool IEntity::EnterComponents()
{
	size_t count = mComponents.Count();
	FOR_EACH_SIZE(i, count)
	{
		IComponent* component = mComponents[i];
		RETURN_FALSE_IF_FALSE(component->Enter());
	}
开发者ID:fjz13,项目名称:Medusa,代码行数:8,代码来源:IEntity.cpp

示例10: RemoveComponentRaw

 void Entity::RemoveComponentRaw(QObject* comp)
 {
     IComponent* compPtr = dynamic_cast<IComponent*>(comp);
     if (compPtr)
     {
         ComponentPtr ptr = GetComponent(compPtr->TypeName(), compPtr->Name()); //the shared_ptr to this component
         RemoveComponent(ptr);
     }
 }
开发者ID:A-K,项目名称:naali,代码行数:9,代码来源:Entity.cpp

示例11: ConstructComponent

bool CComponentManager::AddComponent(entity_id_t ent, ComponentTypeId cid, const CParamNode& paramNode)
{
	IComponent* component = ConstructComponent(ent, cid);
	if (!component)
		return false;

	component->Init(paramNode);
	return true;
}
开发者ID:nahumfarchi,项目名称:0ad,代码行数:9,代码来源:ComponentManager.cpp

示例12: while

void Entity::Update(void)
{
    std::list<IComponent*>::iterator iter = m_components.begin();
	while(iter != m_components.end())
	{
        IComponent * component = *iter;
		component->Update();
        iter++;
	}
}
开发者ID:MatthewWGross,项目名称:Gilead,代码行数:10,代码来源:Entity.cpp

示例13: LogWarning

void Entity::RemoveComponentRaw(QObject* comp)
{
    LogWarning("Entity::RemoveComponentRaw: This function is deprecated and will be removed. Use RemoveComponent or RemoveComponentById instead.");
    IComponent* compPtr = dynamic_cast<IComponent*>(comp);
    if (compPtr)
    {
        ComponentPtr ptr = Component(compPtr->TypeName(), compPtr->Name()); //the shared_ptr to this component
        RemoveComponent(ptr);
    }
}
开发者ID:katik,项目名称:naali,代码行数:10,代码来源:Entity.cpp

示例14: make_key_set

void GameObject::setLayer(Layer* layer_in) {
	layer = layer_in;
	
	std::set<ComponentId> keys;
	make_key_set(components, keys);
	
	for (std::set<ComponentId>::iterator it=keys.begin() ; it != keys.end(); it++ ) {
		IComponent* component = getComponent(*it);
		component->setOwner(this);
	}
}
开发者ID:rasslingcats,项目名称:calico,代码行数:11,代码来源:GameObject.cpp

示例15: addCopy

/** AddCopy method
 * @param comp :: component to add
 * @return number of components in the assembly
 *
 *  Add a copy of a component in the assembly.
 *  Comp is cloned if valid, then added in the assembly
 *  This becomes the parent of the cloned component
 */
int CompAssembly::addCopy(IComponent *comp) {
  if (m_map)
    throw std::runtime_error(
        "CompAssembly::addCopy() called for a parametrized CompAssembly.");

  if (comp) {
    IComponent *newcomp = comp->clone();
    newcomp->setParent(this);
    m_children.push_back(newcomp);
  }
  return static_cast<int>(m_children.size());
}
开发者ID:mkoennecke,项目名称:mantid,代码行数:20,代码来源:CompAssembly.cpp

本文标签属性:

示例:示例图

代码:代码编程

上一篇:C++ Control::Render方法代码示例
下一篇:C++ HID_USB_DEVICE函数代码示例

为您推荐