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
///////////////////////////////////////////////////////////////////////////////
// Callback for when a row's selectability checkbox is changed in the grid.
// Changes the selectability member of the layer to match the row that was
// changed.
//
void LayersPanel::LayerSelectableChanged( const GridRowChangeArgs& args )
{
    const std::string& name = m_Grid->GetRowName( args.m_RowNumber );
    M_LayerDumbPtr::const_iterator layerItr = m_Layers.find( name );
    if ( layerItr != m_Layers.end() )
    {
        Layer* layer = layerItr->second;
        bool selectable = m_Grid->IsRowSelectableChecked( args.m_RowNumber );

        layer->SetSelectable( selectable );

        if (!selectable)
        {
            OS_ObjectDumbPtr newSelection;

            OS_ObjectDumbPtr selection = layer->GetOwner()->GetSelection().GetItems();
            OS_ObjectDumbPtr::Iterator itr = selection.Begin();
            OS_ObjectDumbPtr::Iterator end = selection.End();
            for ( ; itr != end; ++itr )
            {
                SceneNode* node = Reflect::SafeCast<SceneNode>( *itr );

                if (!node || !layer->ContainsMember( node ))
                {
                    newSelection.Append(*itr);
                }
            }

            if (newSelection.Size() != selection.Size())
            {
                layer->GetOwner()->GetSelection().SetItems( newSelection );
            }
        }

        layer->GetOwner()->Execute( false );
    }
    else
    {
        Log::Error( TXT( "LayerSelectableChanged - layer named %s not found\n" ), name.c_str() );
        HELIUM_BREAK();
    }
}
Esempio n. 3
0
bool CurveEditTool::ValidateSelection( OS_ObjectDumbPtr& items )
{
	OS_ObjectDumbPtr result;

	OS_ObjectDumbPtr::Iterator itr = items.Begin();
	OS_ObjectDumbPtr::Iterator end = items.End();
	for( ; itr != end; ++itr )
	{
		CurveControlPoint* p = Reflect::SafeCast<CurveControlPoint>( *itr );

		if ( !p )
		{
			continue;
		}

		bool appendPoint = true;
		if ( s_CurrentSelection )
		{
			appendPoint = false;
			OS_SceneNodeDumbPtr::Iterator curveItr = m_SelectedCurves.Begin();
			OS_SceneNodeDumbPtr::Iterator curveEnd = m_SelectedCurves.End();
			for ( ; curveItr != curveEnd; ++curveItr )
			{
				if ( p->GetParent() == *curveItr )
				{
					appendPoint = true;
					break;
				}
			}
		}

		if ( appendPoint )
		{
			result.Append( p );
		}
	}

	items = result;

	if ( items.Empty() )
	{
		OS_ObjectDumbPtr::Iterator itr = items.Begin();
		OS_ObjectDumbPtr::Iterator end = items.End();
		for( ; itr != end; ++itr )
		{
			Curve* c = Reflect::SafeCast<Curve>( *itr );

			if ( !c )
			{
				continue;
			}

			result.Append( c );
			break;
		}
	}

	items = result;

	return !items.Empty();
}
Esempio n. 4
0
UndoCommandPtr Selection::SetItems(const OS_ObjectDumbPtr& items, const SelectionChangingSignature::Delegate& emitterChanging, const SelectionChangedSignature::Delegate& emitterChanged)
{
	if (items.Empty())
	{
		return Clear(emitterChanging, emitterChanged);
	}

	EDITOR_SCENE_SCOPE_TIMER( ("") );

	SimpleTimer timer;

	OS_ObjectDumbPtr selectableItems;

	{
		OS_ObjectDumbPtr::Iterator itr = items.Begin();
		OS_ObjectDumbPtr::Iterator end = items.End();
		for ( ; itr != end; ++itr )
		{
			SceneNode *pSceneNode = Reflect::SafeCast<SceneNode>(*itr);

			if (!pSceneNode || pSceneNode->IsSelectable())
			{
				selectableItems.Append(*itr);
			}
		}
	}

	UndoCommandPtr command;

	SelectionChangingArgs args ( items );
	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 = selectableItems;

		{
			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(true);
				}
			}
		}

		m_SelectionChanged.RaiseWithEmitter(m_Items, emitterChanged);
	}

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

	return command;
}