Пример #1
0
shared_ptr<Type> MakeStrongPtr(weak_ptr<Type> pWeakPtr)
{
    if (!pWeakPtr.expired())
        return shared_ptr<Type>(pWeakPtr);
    else
        return shared_ptr<Type>();
}
Пример #2
0
void PropertyList::Init(weak_ptr<Leaf> leaf, wxListCtrl* ctrList)
{
    mLeaf.reset();
    mCtrList = 0;

    if (
        (leaf.expired()) ||
        (ctrList == 0)
        )
        {
            return;
        }

    mLeaf = leaf;
    mCtrList = ctrList;

    shared_ptr<Property> property = wxGetApp().GetProperty();
    if (property.get() != 0)
        {
            property->GetClassList(mLeaf.lock(), mClassList);
        }

    mCtrList->ClearAll();
    mCtrList->InsertColumn(0, _T("name"), wxLIST_FORMAT_LEFT, 120);
    mCtrList->InsertColumn(1, _T("value"), wxLIST_FORMAT_LEFT, 600);
}
Пример #3
0
Factory::Factory(weak_ptr<RootObject> root)
{
    _root = root;
    if (!root.expired() && root.lock()->getType() == "scene")
        _isScene = true;

    registerObjects();
}
Пример #4
0
 virtual void RK_CALL save(ReaK::serialization::oarchive& A, unsigned int) const {
   if(Parent.expired())
     A & RK_SERIAL_SAVE_WITH_ALIAS("Parent",shared_ptr<serialization::serializable>());
   else
     A & RK_SERIAL_SAVE_WITH_ALIAS("Parent",Parent.lock());
   A & RK_SERIAL_SAVE_WITH_NAME(Position)
     & RK_SERIAL_SAVE_WITH_NAME(Rotation);
 };
Пример #5
0
  inline shared_ptr<System> MultiSystemAccess::getSystem2() const {
 
    if (mySystem2.expired()) {
       throw std::runtime_error("expired system2");
    }

    return mySystem2.lock();
  }
Пример #6
0
 /**
  * Returns this 2D pose relative to the global (null) coordinate system.
  */
 self getGlobalPose() const {
   if(!Parent.expired()) {
     self result = Parent.lock()->getGlobalPose();
     result.Position += result.Rotation * Position;
     result.Rotation *= Rotation;
     return result;
   } else
     return *this;
 };
Пример #7
0
//check if it's the right place to set square if so ,set it
void Tetris::SquareSetCheck(const TETRIS_TYPE t_type,weak_ptr<Square> t_wsquare)
{
	if(!t_wsquare.expired()){
		shared_ptr<Square> t_ssquare = t_wsquare.lock();
		if(t_ssquare->ConflictCheck(t_type) == true)
		{
			t_ssquare->SetSquare(t_type);
		}
	}else{
		LogWriter::me->WriteLog("square expired in SquareSetCheck");
	}
}
Пример #8
0
 /**
  * Returns this 2D pose relative to pose P.
  */
 self getPoseRelativeTo(const shared_ptr< const self >& P) const {
   if(!P)
     return getGlobalPose();
   if(isParentPose(P)) {
     if(Parent.lock() == P)
       return *this;
     else
       return Parent.lock()->getPoseRelativeTo(P) * (*this);
   } else if(P->isParentPose( rtti::rk_static_ptr_cast< const self >(mThis)))
     return ~(P->getPoseRelativeTo( rtti::rk_static_ptr_cast< const self >(mThis)));
   else if(Parent.expired())
     return (~(P->getGlobalPose())) * (*this);
   else
     return Parent.lock()->getPoseRelativeTo(P) * (*this);
 };
Пример #9
0
    /**
     * Returns true if P is part of the parent chain from this pose.
     */
    bool isParentPose(const shared_ptr< const self >& P) const {
      if(Parent.expired()) {
	if(P)
	  return true;
	else
	  return false;
      } else {
	if(P)
	  return false;
	else if(P == Parent.lock())
          return true;
	else
	  return Parent.lock()->isParentPose(P);
      };
    };
Пример #10
0
//read input key to move square
void Tetris::SquareCtrl(const TETRIS_TYPE t_type,weak_ptr<Square> t_wsquare)
{
	if(!t_wsquare.expired()){
		shared_ptr<Square> t_ssquare = t_wsquare.lock();
		KeyboardUpdate();
		//down button is pressed
		if(((KeyboardGet(KEY_INPUT_DOWN) > 0)&&(t_type == TETRIS_UP))|| 
			((KeyboardGet(KEY_INPUT_UP) > 0)&&(t_type == TETRIS_DOWN))||
			((KeyboardGet(KEY_INPUT_RIGHT) > 0)&&(t_type == TETRIS_RIGHT))||
			((KeyboardGet(KEY_INPUT_LEFT) > 0)&&(t_type == TETRIS_LEFT))
			){
			t_ssquare->Move(kGODOWN,t_type);
		}
		//left button is pressed
		else if(((KeyboardGet(KEY_INPUT_LEFT) > 0)&&(t_type == TETRIS_UP))|| 
			((KeyboardGet(KEY_INPUT_RIGHT) > 0)&&(t_type == TETRIS_DOWN))||
			((KeyboardGet(KEY_INPUT_DOWN) > 0)&&(t_type == TETRIS_LEFT))||
			((KeyboardGet(KEY_INPUT_UP) > 0)&&(t_type == TETRIS_RIGHT))
			){
			t_ssquare->Move(kGOLEFT,t_type);
		}
		//right button is pressed
		else if(((KeyboardGet(KEY_INPUT_RIGHT) > 0)&&(t_type == TETRIS_UP))|| 
			((KeyboardGet(KEY_INPUT_LEFT) > 0)&&(t_type == TETRIS_DOWN))||
			((KeyboardGet(KEY_INPUT_UP) > 0)&&(t_type == TETRIS_LEFT))||
			((KeyboardGet(KEY_INPUT_DOWN) > 0)&&(t_type == TETRIS_RIGHT))
			){	
			t_ssquare->Move(kGORIGHT,t_type);
		}
		else if(((KeyboardGet(KEY_INPUT_UP) > 0)&&(t_type == TETRIS_UP))|| 
			((KeyboardGet(KEY_INPUT_DOWN) > 0)&&(t_type == TETRIS_DOWN))||
			((KeyboardGet(KEY_INPUT_RIGHT) > 0)&&(t_type == TETRIS_LEFT))||
			((KeyboardGet(KEY_INPUT_LEFT) > 0)&&(t_type == TETRIS_RIGHT))
			){
			t_ssquare->Turn(t_type);
		}else if(KeyboardGet(KEY_INPUT_SPACE ) > 0){
			CtrlBoardChangine(t_type);
		}
		else if (KeyboardGet(KEY_INPUT_Z) == 1){
			SpeedUp();
		}
		else if (KeyboardGet(KEY_INPUT_X) == 1){
			SpeedDown();
		}

	}
}
Пример #11
0
void DirectusMaterial::Reflect(weak_ptr<GameObject> gameobject)
{
    m_inspectedMaterial = weak_ptr<Material>();

    // Catch the evil case
    if (gameobject.expired())
    {
        this->hide();
        return;
    }

    MeshRenderer* meshRenderer = gameobject.lock()->GetComponent<MeshRenderer>().lock().get();
    if (!meshRenderer)
    {
        this->hide();
        return;
    }



    m_inspectedMaterial = meshRenderer->GetMaterial();
    if (m_inspectedMaterial.expired())
    {
        this->hide();
        return;
    }

    // Do the actual reflection
    ReflectName();
    ReflectShader();
    ReflectAlbedo();
    ReflectRoughness();
    ReflectMetallic();
    ReflectNormal();
    ReflectHeight();
    ReflectOcclusion();
    ReflectEmission();
    ReflectMask();
    ReflectTiling();
    ReflectOffset();

    SetPropertiesVisible(m_inspectedMaterial.lock()->IsEditable() ? true : false);

    // Make this widget visible
    this->show();
}
Пример #12
0
void kinematicFrame::SetParent(weak_ptr<Leaf> parent)
{
    shared_ptr<SimSpark> spark = wxGetApp().GetSpark();
    if (spark.get() == 0)
        {
            return;
        }

    if (parent.expired())
    {
        mParent = Leaf::CachedPath<zeitgeist::Leaf>();
    } else
    {
        std::string path = parent.lock()->GetFullPath();
        mParent.SetKey(Core::CacheKey(spark->GetCore()->GetRoot(), path));
    }

    UpdateCached();
}
Пример #13
0
void propertyframe::SetLeaf(weak_ptr<Leaf> leaf)
{
    shared_ptr<SimSpark> spark = wxGetApp().GetSpark();
    if (spark.get() == 0)
        {
            return;
        }

    if (leaf.expired())
    {
        mPath = Leaf::CachedPath<zeitgeist::Leaf>();
    } else
    {
        std::string path = leaf.lock()->GetFullPath();
        mPath.SetKey(Core::CacheKey(spark->GetCore()->GetRoot(), path));
    }

    UpdateCached();
    RefreshProperties();
}
Пример #14
0
void DirectusAudioListener::Reflect(weak_ptr<GameObject> gameobject)
{
    m_inspectedAudioListener = nullptr;

    // Catch the evil case
    if (gameobject.expired())
    {
        this->hide();
        return;
    }

    // Catch the seed of the evil
    m_inspectedAudioListener = gameobject.lock()->GetComponent<AudioListener>().lock().get();
    if (!m_inspectedAudioListener)
    {
        this->hide();
        return;
    }

    // Make this widget visible
    this->show();
}
Пример #15
0
bool Object::addAnnotation(weak_ptr<Annotation> annotation) {
  if (!isActive()) return false;
  if (annotation.expired()) return false;
  return addAnnotation(annotation.lock());
}
Пример #16
0
bool isSame(const weak_ptr<ofxWidget> &lhs, const weak_ptr<ofxWidget>&rhs) {
	return (!lhs.expired() && !rhs.expired() && (!rhs.owner_before(lhs) && !lhs.owner_before(rhs)));
}