Ejemplo n.º 1
0
        /// <summary>
        /// executes last state redo to part or its group
        /// current state is pushed into undo
        /// </summary>
        /// <param name="part"></param>

        public void Redo(SceneObjectPart part)
        {
            lock (m_undo)
            {
                UndoState nUndo;

                // expire undo
                if (m_undo.Count > 0)
                {
                    nUndo = m_undo.First.Value;
                    if (nUndo != null && nUndo.checkExpire())
                    {
                        m_undo.Clear();
                    }
                }

                if (m_redo.Count > 0)
                {
                    UndoState gofwd = m_redo.First.Value;
                    // check expired
                    if (gofwd != null && gofwd.checkExpire())
                    {
                        m_redo.Clear();
                        return;
                    }

                    if (gofwd != null)
                    {
                        m_redo.RemoveFirst();

                        // limite undo size
                        while (m_undo.Count >= size)
                        {
                            m_undo.RemoveLast();
                        }

                        nUndo = new UndoState(part, gofwd.data.change);   // new value in part should it be full gofwd copy?
                        m_undo.AddFirst(nUndo);

                        gofwd.PlayState(part);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// adds a new state undo to part or its group, with changes indicated by what bits
        /// </summary>
        /// <param name="part"></param>
        /// <param name="change">bit field with what is changed</param>

        public void StoreUndo(SceneObjectPart part, ObjectChangeType change)
        {
            lock (m_undo)
            {
                UndoState last;

                if (m_redo.Count > 0) // last code seems to clear redo on every new undo
                {
                    m_redo.Clear();
                }

                if (m_undo.Count > 0)
                {
                    // check expired entry
                    last = m_undo.First.Value;
                    if (last != null && last.checkExpire())
                    {
                        m_undo.Clear();
                    }
                    else
                    {
                        // see if we actually have a change
                        if (last != null)
                        {
                            if (last.Compare(part, change))
                            {
                                return;
                            }
                        }
                    }
                }

                // limite size
                while (m_undo.Count >= size)
                {
                    m_undo.RemoveLast();
                }

                UndoState nUndo = new UndoState(part, change);
                m_undo.AddFirst(nUndo);
            }
        }
Ejemplo n.º 3
0
        public void StoreUndoState()
        {
            if (!Undoing)
            {
                if (m_parentGroup != null)
                {
                    lock (m_undo)
                    {
                        if (m_undo.Count > 0)
                        {
                            UndoState last = m_undo.Peek();
                            if (last != null)
                            {
                                if (last.Compare(this))
                                    return;
                            }
                        }

                        if (m_parentGroup.GetSceneMaxUndo() > 0)
                        {
                            UndoState nUndo = new UndoState(this);

                            m_undo.Push(nUndo);
                        }

                    }
                }
            }
        }
Ejemplo n.º 4
0
        public void Redo()
        {
            lock (m_redo)
            {
                if (m_redo.Count > 0)
                {
                    UndoState nUndo = new UndoState(this);
                    m_undo.Push(nUndo);

                    UndoState gofwd = m_redo.Pop();
                    if (gofwd != null)
                        gofwd.PlayfwdState(this);
                }
            }
        }
Ejemplo n.º 5
0
        public void Redo()
        {
            lock (m_undo)
            {
//                m_log.DebugFormat(
//                    "[SCENE OBJECT PART]: Handling redo request for {0} {1}, stack size {2}",
//                    Name, LocalId, m_redo.Count);

                if (m_redo.Count > 0)
                {
                    UndoState gofwd = m_redo[m_redo.Count - 1];
                    m_redo.RemoveAt(m_redo.Count - 1);

                    if (ParentGroup.Scene.MaxUndoCount > 0)
                    {
                        UndoState nUndo = new UndoState(this, gofwd.ForGroup);

                        m_undo.Add(nUndo);

                        if (m_undo.Count > ParentGroup.Scene.MaxUndoCount)
                            m_undo.RemoveAt(0);
                    }

                    gofwd.PlayfwdState(this);

//                m_log.DebugFormat(
//                    "[SCENE OBJECT PART]: Handled redo request for {0} {1}, stack size now {2}",
//                    Name, LocalId, m_redo.Count);
                }
            }
        }
Ejemplo n.º 6
0
        public void StoreUndoState()
        {
            if (!Undoing)
            {
                if (!IgnoreUndoUpdate)
                {
                    IBackupModule backup = null;
                    if(ParentGroup != null && 
                        ParentGroup.Scene != null)
                        backup = ParentGroup.Scene.RequestModuleInterface<IBackupModule>();

                    if (m_parentGroup != null && 
                        ParentGroup.Scene != null &&
                        (backup == null || (backup != null && !backup.LoadingPrims)))
                    {
                        lock (m_undo)
                        {
                            if (m_undo.Count > 0)
                            {
                                UndoState last = m_undo.Peek();
                                if (last != null)
                                {
                                    if (last.Compare(this))
                                        return;
                                }
                            }

                            UndoState nUndo = new UndoState(this);
                            m_undo.Push(nUndo);
                        }
                    }
                }
            }
        }
Ejemplo n.º 7
0
        public void Undo()
        {
            lock (m_undo)
            {
//                m_log.DebugFormat(
//                    "[SCENE OBJECT PART]: Handling undo request for {0} {1}, stack size {2}",
//                    Name, LocalId, m_undo.Count);

                if (m_undo.Count > 0)
                {
                    UndoState goback = m_undo.Pop();

                    if (goback != null)
                    {
                        UndoState nUndo = null;
        
                        if (m_parentGroup.GetSceneMaxUndo() > 0)
                        {
                            nUndo = new UndoState(this, goback.ForGroup);
                        }

                        goback.PlaybackState(this);

                        if (nUndo != null)
                            m_redo.Push(nUndo);
                    }
                }

//                m_log.DebugFormat(
//                    "[SCENE OBJECT PART]: Handled undo request for {0} {1}, stack size now {2}",
//                    Name, LocalId, m_undo.Count);
            }
        }
Ejemplo n.º 8
0
        public void StoreUndoState()
        {
            if (!Undoing)
            {
                if (!IgnoreUndoUpdate)
                {
                    if (m_parentGroup != null)
                    {
//                        m_log.DebugFormat("[SCENE OBJECT PART]: Storing undo state for {0} {1}", Name, LocalId);

                        lock (m_undo)
                        {
                            if (m_undo.Count > 0)
                            {
                                UndoState last = m_undo.Peek();
                                if (last != null)
                                {
                                    if (last.Compare(this))
                                        return;
                                }
                            }

                            if (m_parentGroup.GetSceneMaxUndo() > 0)
                            {
                                UndoState nUndo = new UndoState(this);

                                m_undo.Push(nUndo);
                            }
                        }
                    }
                }
//                else
//                {
//                    m_log.DebugFormat("[SCENE OBJECT PART]: Ignoring undo store for {0} {1}", Name, LocalId);
//                }
            }
//            else
//            {
//                m_log.DebugFormat("[SCENE OBJECT PART]: Ignoring undo store for {0} {1} since already undoing", Name, LocalId);
//            }
        }
Ejemplo n.º 9
0
 public void Undo()
 {
     lock (m_undo)
     {
         if (m_undo.Count > 0)
         {
             UndoState nUndo = null;
             if (m_parentGroup.GetSceneMaxUndo() > 0)
             {
                 nUndo = new UndoState(this);
             }
             UndoState goback = m_undo.Pop();
             if (goback != null)
             {
                 goback.PlaybackState(this);
                 if (nUndo != null)
                     m_redo.Push(nUndo);
             }
         }
     }
 }
Ejemplo n.º 10
0
        public void Redo()
        {
            lock (m_redo)
            {
                if (m_parentGroup.GetSceneMaxUndo() > 0)
                {
                    UndoState nUndo = new UndoState(this);

                    m_undo.Push(nUndo);
                }
                UndoState gofwd = m_redo.Pop();
                if (gofwd != null)
                    gofwd.PlayfwdState(this);
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// executes last state redo to part or its group
        /// current state is pushed into undo
        /// </summary>
        /// <param name="part"></param>

        public void Redo(SceneObjectPart part)
        {
            lock (m_undo)
            {
                UndoState nUndo;

                // expire undo
                if (m_undo.Count > 0)
                {
                    nUndo = m_undo.First.Value;
                    if (nUndo != null && nUndo.checkExpire())
                        m_undo.Clear();
                }

                if (m_redo.Count > 0)
                {
                    UndoState gofwd = m_redo.First.Value;
                    // check expired
                    if (gofwd != null && gofwd.checkExpire())
                    {
                        m_redo.Clear();
                        return;
                    }

                    if (gofwd != null)
                    {
                        m_redo.RemoveFirst();

                        // limite undo size
                        while (m_undo.Count >= size)
                            m_undo.RemoveLast();

                        nUndo = new UndoState(part, gofwd.data.change);   // new value in part should it be full gofwd copy?
                        m_undo.AddFirst(nUndo);

                        gofwd.PlayState(part);
                    }
                }
            }
        }
Ejemplo n.º 12
0
        /// <summary>
        /// adds a new state undo to part or its group, with changes indicated by what bits
        /// </summary>
        /// <param name="part"></param>
        /// <param name="change">bit field with what is changed</param>

        public void StoreUndo(SceneObjectPart part, ObjectChangeType change)
        {
            lock (m_undo)
            {
                UndoState last;

                if (m_redo.Count > 0) // last code seems to clear redo on every new undo
                {
                    m_redo.Clear();
                }

                if (m_undo.Count > 0)
                {
                    // check expired entry
                    last = m_undo.First.Value;
                    if (last != null && last.checkExpire())
                        m_undo.Clear();
                    else
                    {
                        // see if we actually have a change
                        if (last != null)
                        {
                            if (last.Compare(part, change))
                                return;
                        }
                    }
                }

                // limite size
                while (m_undo.Count >= size)
                    m_undo.RemoveLast();

                UndoState nUndo = new UndoState(part, change);
                m_undo.AddFirst(nUndo);
            }
        }
Ejemplo n.º 13
0
        public void Redo()
        {
//            m_log.DebugFormat("[SCENE OBJECT PART]: Handling redo request for {0} {1}", Name, LocalId);

            lock (m_redo)
            {
                if (m_parentGroup.GetSceneMaxUndo() > 0)
                {
                    UndoState nUndo = new UndoState(this);

                    m_undo.Push(nUndo);
                }

                UndoState gofwd = m_redo.Pop();

                if (gofwd != null)
                    gofwd.PlayfwdState(this);
            }
        }
Ejemplo n.º 14
0
        public void StoreUndoState(bool forGroup)
        {
            if (!Undoing)
            {
                if (!IgnoreUndoUpdate)
                {
                    if (ParentGroup != null)
                    {
                        lock (m_undo)
                        {
                            if (m_undo.Count > 0)
                            {
                                UndoState last = m_undo.Peek();
                                if (last != null)
                                {
                                    // TODO: May need to fix for group comparison
                                    if (last.Compare(this))
                                    {
    //                                        m_log.DebugFormat(
    //                                            "[SCENE OBJECT PART]: Not storing undo for {0} {1} since current state is same as last undo state, initial stack size {2}",
    //                                            Name, LocalId, m_undo.Count);
    
                                        return;
                                    }
                                }
                            }
    
    //                            m_log.DebugFormat(
    //                                "[SCENE OBJECT PART]: Storing undo state for {0} {1}, forGroup {2}, initial stack size {3}",
    //                                Name, LocalId, forGroup, m_undo.Count);
    
                            if (ParentGroup.GetSceneMaxUndo() > 0)
                            {
                                UndoState nUndo = new UndoState(this, forGroup);
    
                                m_undo.Push(nUndo);
    
                                if (m_redo.Count > 0)
                                    m_redo.Clear();
    
    //                                m_log.DebugFormat(
    //                                    "[SCENE OBJECT PART]: Stored undo state for {0} {1}, forGroup {2}, stack size now {3}",
    //                                    Name, LocalId, forGroup, m_undo.Count);
                            }
                        }
                    }
                }
//                else
//                {
//                    m_log.DebugFormat("[SCENE OBJECT PART]: Ignoring undo store for {0} {1}", Name, LocalId);
//                }
            }
//            else
//            {
//                m_log.DebugFormat(
//                    "[SCENE OBJECT PART]: Ignoring undo store for {0} {1} since already undoing", Name, LocalId);
//            }
        }
Ejemplo n.º 15
0
        public void StoreUndoState(bool forGroup)
        {
            if (ParentGroup == null || ParentGroup.Scene == null)
                return;

            if (Undoing)
            {
//                m_log.DebugFormat(
//                    "[SCENE OBJECT PART]: Ignoring undo store for {0} {1} since already undoing", Name, LocalId);
                return;
            }

            if (IgnoreUndoUpdate)
            {
//                    m_log.DebugFormat("[SCENE OBJECT PART]: Ignoring undo store for {0} {1}", Name, LocalId);
                return;
            }

            lock (m_undo)
            {
                if (m_undo.Count > 0)
                {
                    UndoState last = m_undo[m_undo.Count - 1];
                    if (last != null)
                    {
                        // TODO: May need to fix for group comparison
                        if (last.Compare(this))
                        {
//                                        m_log.DebugFormat(
//                                            "[SCENE OBJECT PART]: Not storing undo for {0} {1} since current state is same as last undo state, initial stack size {2}",
//                                            Name, LocalId, m_undo.Count);

                            return;
                        }
                    }
                }

//                                m_log.DebugFormat(
//                                    "[SCENE OBJECT PART]: Storing undo state for {0} {1}, forGroup {2}, initial stack size {3}",
//                                    Name, LocalId, forGroup, m_undo.Count);

                if (ParentGroup.Scene.MaxUndoCount > 0)
                {
                    UndoState nUndo = new UndoState(this, forGroup);

                    m_undo.Add(nUndo);

                    if (m_undo.Count > ParentGroup.Scene.MaxUndoCount)
                        m_undo.RemoveAt(0);

                    if (m_redo.Count > 0)
                        m_redo.Clear();

//                                    m_log.DebugFormat(
//                                        "[SCENE OBJECT PART]: Stored undo state for {0} {1}, forGroup {2}, stack size now {3}",
//                                        Name, LocalId, forGroup, m_undo.Count);
                }
            }
        }
Ejemplo n.º 16
0
        public void Redo()
        {
            lock (m_undo)
            {
//                m_log.DebugFormat(
//                    "[SCENE OBJECT PART]: Handling redo request for {0} {1}, stack size {2}",
//                    Name, LocalId, m_redo.Count);

                if (m_redo.Count > 0)
                {
                    UndoState gofwd = m_redo.Pop();
    
                    if (gofwd != null)
                    {
                        if (ParentGroup.GetSceneMaxUndo() > 0)
                        {
                            UndoState nUndo = new UndoState(this, gofwd.ForGroup);
    
                            m_undo.Push(nUndo);
                        }
    
                        gofwd.PlayfwdState(this);
                    }

//                m_log.DebugFormat(
//                    "[SCENE OBJECT PART]: Handled redo request for {0} {1}, stack size now {2}",
//                    Name, LocalId, m_redo.Count);
                }
            }
        }
Ejemplo n.º 17
0
        public void StoreUndoState()
        {
            if (!Undoing)
            {
                if (!IgnoreUndoUpdate)
                {
                    if (m_parentGroup != null && 
                        ParentGroup.Scene != null &&
                        !ParentGroup.Scene.LoadingPrims)
                    {
                        lock (m_undo)
                        {
                            if (m_undo.Count > 0)
                            {
                                UndoState last = m_undo.Peek();
                                if (last != null)
                                {
                                    if (last.Compare(this))
                                        return;
                                }
                            }

                            UndoState nUndo = new UndoState(this);
                            m_undo.Push(nUndo);
                        }
                    }
                }
            }
        }