forestUndo.h

Engine/source/forest/editor/forestUndo.h

More...

Classes:

Detailed Description

  1
  2//-----------------------------------------------------------------------------
  3// Copyright (c) 2012 GarageGames, LLC
  4//
  5// Permission is hereby granted, free of charge, to any person obtaining a copy
  6// of this software and associated documentation files (the "Software"), to
  7// deal in the Software without restriction, including without limitation the
  8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  9// sell copies of the Software, and to permit persons to whom the Software is
 10// furnished to do so, subject to the following conditions:
 11//
 12// The above copyright notice and this permission notice shall be included in
 13// all copies or substantial portions of the Software.
 14//
 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 21// IN THE SOFTWARE.
 22//-----------------------------------------------------------------------------
 23
 24#ifndef _FOREST_EDITOR_UNDO_H_
 25#define _FOREST_EDITOR_UNDO_H_
 26
 27#ifndef _UNDO_H_
 28#include "util/undo.h"
 29#endif
 30#ifndef _FORESTITEM_H_
 31#include "forest/forestItem.h"
 32#endif
 33#ifndef __RESOURCE_H__
 34#include "core/resource.h"
 35#endif
 36
 37class ForestData;
 38class ForestEditorCtrl;
 39
 40class ForestUndoAction : public UndoAction
 41{
 42   typedef UndoAction Parent;
 43
 44public:
 45
 46   ForestUndoAction( const Resource<ForestData> &data, ForestEditorCtrl *editor, const char *description );   
 47
 48   // UndoAction
 49   virtual void undo() {}
 50   virtual void redo() {}
 51
 52protected:
 53
 54   ForestEditorCtrl *mEditor;
 55   Vector<ForestItem> mItems;
 56   Resource<ForestData> mData;
 57};
 58
 59class ForestCreateUndoAction : public ForestUndoAction
 60{
 61   typedef ForestUndoAction Parent;
 62
 63public:
 64  
 65   ForestCreateUndoAction( const Resource<ForestData> &data,
 66                           ForestEditorCtrl *editor );
 67
 68   /// Adds the item to the Forest and stores 
 69   /// its info for undo later.
 70   void addItem( ForestItemData *data,
 71                 const Point3F &position,
 72                 F32 rotation,
 73                 F32 scale );
 74
 75   // UndoAction
 76   virtual void undo();
 77   virtual void redo();
 78};
 79
 80
 81class ForestDeleteUndoAction : public ForestUndoAction
 82{
 83   typedef ForestUndoAction Parent;
 84
 85public:
 86  
 87   ForestDeleteUndoAction( const Resource<ForestData> &data,
 88                           ForestEditorCtrl *editor );
 89
 90   ///
 91   void removeItem( const ForestItem &item );
 92   void removeItem( const Vector<ForestItem> &itemList );
 93
 94   // UndoAction
 95   virtual void undo();
 96   virtual void redo();
 97};
 98
 99
100class ForestUpdateAction : public ForestUndoAction
101{
102   typedef ForestUndoAction Parent;
103
104public:
105  
106   ForestUpdateAction(  const Resource<ForestData> &data,
107                        ForestEditorCtrl *editor );
108
109   void saveItem( const ForestItem &item );
110
111   virtual void undo() { _swapState(); }
112   virtual void redo() { _swapState(); }
113
114protected:
115
116   void _swapState();
117};
118
119#endif // _FOREST_EDITOR_UNDO_H_
120
121
122
123