Esempio n. 1
0
UndoCommandPtr Selection::AddItems(const OS_ObjectDumbPtr &items, const SelectionChangingSignature::Delegate& emitterChanging, const SelectionChangedSignature::Delegate& emitterChanged)
{
	if ( items.Empty() )
	{
		return NULL;
	}

	EDITOR_SCENE_SCOPE_TIMER( ("") );

	SimpleTimer timer;

	std::vector<Reflect::Object*> added;
	OS_ObjectDumbPtr temp = m_Items;
	OS_ObjectDumbPtr::Iterator itr = items.Begin();
	OS_ObjectDumbPtr::Iterator end = items.End();
	for ( ; itr != end; ++itr )
	{
		if ( temp.Append(*itr) )
		{
			added.push_back(*itr);
		}
	}

	UndoCommandPtr command;

	if ( !temp.Empty() )
	{
		SelectionChangingArgs args ( temp );
		m_SelectionChanging.RaiseWithEmitter( args, emitterChanging );
		if ( !args.m_Veto )
		{
			command = new SelectionChangeCommand( this );

			std::vector<Reflect::Object*>::iterator itr = added.begin();
			std::vector<Reflect::Object*>::iterator end = added.end();
			for ( ; itr != end; ++itr )
			{
				SceneNode *pSceneNode = Reflect::SafeCast<SceneNode>(*itr);
				if (pSceneNode)
				{
					pSceneNode->SetSelected(true);
				}
			}

			m_Items = temp;

			m_SelectionChanged.RaiseWithEmitter(m_Items, emitterChanged);
		}
	}

	Log::Profile( TXT( "Selection AddItems took %fms\n" ), timer.Elapsed());

	return command;
}
Esempio n. 2
0
UndoCommandPtr Selection::Clear(const SelectionChangingSignature::Delegate& emitterChanging, const SelectionChangedSignature::Delegate& emitterChanged)
{
	if (m_Items.Empty())
	{
		return NULL;
	}

	EDITOR_SCENE_SCOPE_TIMER( ("") );

	SimpleTimer timer;

	UndoCommandPtr command;

	OS_ObjectDumbPtr empty;
	SelectionChangingArgs args ( empty );
	m_SelectionChanging.RaiseWithEmitter( args, emitterChanging );
	if ( !args.m_Veto )
	{
		command = new SelectionChangeCommand( this );

		OS_ObjectDumbPtr::Iterator itr = m_Items.Begin();
		OS_ObjectDumbPtr::Iterator end = m_Items.End();
		for ( ; itr != end; ++itr )
		{
			SceneNode *pSceneNode = Reflect::SafeCast<SceneNode>(*itr);
			if (pSceneNode)
			{
				pSceneNode->SetSelected(false);
			}
		}

		m_Items.Clear();

		m_SelectionChanged.RaiseWithEmitter(m_Items, emitterChanged);
	}

	Log::Profile( TXT( "Selection Clear took %fms\n" ), timer.Elapsed());

	return command;
}