示例#1
0
bool DataManager::undoAction()
{
    if ( !canUndo() )
        return false;

	osg::ref_ptr<ReversibleAction> action = static_cast<ReversibleAction*>( _undoStack.back().get() );
	_undoStack.pop_back();

	bool undoSucceeded = action->undoAction( this, this );

    // if the undo failed, we are probably in some undefined application state, so
    // clear out the undo stack just to be safe.
    if ( !undoSucceeded )
    {
        clearUndoActions();
    }

    if ( undoSucceeded )
    {
        ViewVector& views = action->getViews();
        for( ViewVector::iterator i = views.begin(); i != views.end(); ++i )
            i->get()->requestRedraw();
    }

    return undoSucceeded;
}
示例#2
0
bool DataManager::doAction( void* sender, Action* action_, bool reversible )
{
    // this ensures that the action will be unref'd and deleted after running
    osg::ref_ptr<Action> action = action_;

    bool undoInProgress = sender == this;

    for( ActionCallbackList::iterator i = _beforeCallbacks.begin(); i != _beforeCallbacks.end(); ++i )
        i->get()->operator()( sender, action.get() );

    bool actionSucceeded = false;

    if ( !action->isCanceled() || undoInProgress )
    {
        actionSucceeded = action->doAction( sender, this );

        if ( !undoInProgress && actionSucceeded )
        {
            if ( action->isCheckpoint() )
            {
                clearUndoActions();
            }
            else if ( reversible && action->isReversible() )
            {
                _undoStack.push_back( action.get() );
                if ( (int)_undoStack.size() > _maxUndoStackSize )
                {
                    _undoStack.pop_front();
                }
            }
        }

        //todo: during-action callbacks here? like in pogo?

        for( ActionCallbackList::iterator j = _afterCallbacks.begin(); j != _afterCallbacks.end(); ++j )
            j->get()->operator()( sender, action.get() );
    }

    if ( actionSucceeded )
    {
        ViewVector& views = action_->getViews();
        for( ViewVector::iterator i = views.begin(); i != views.end(); ++i )
            i->get()->requestRedraw();
    }

    return actionSucceeded;
}
void TerrainProfileWidget::refreshViews()
{
    // to support ON_DEMAND rendering.
    for (ViewVector::iterator it = _views.begin(); it != _views.end(); ++it)
        it->get()->requestRedraw();
}