forestSelectionTool.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2012 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #ifndef _FOREST_EDITOR_SELECTIONTOOL_H_
  23. #define _FOREST_EDITOR_SELECTIONTOOL_H_
  24. #ifndef _FOREST_EDITOR_TOOL_H_
  25. #include "forest/editor/forestTool.h"
  26. #endif
  27. #ifndef _FORESTITEM_H_
  28. #include "forest/forestItem.h"
  29. #endif
  30. #ifndef _TSELECTION_H_
  31. #include "gui/worldEditor/tSelection.h"
  32. #endif
  33. class Forest;
  34. class Gizmo;
  35. class GizmoProfile;
  36. class ForestUpdateAction;
  37. class ForestItemSelection : public Selection<ForestItem>
  38. {
  39. public:
  40. void setForestData( ForestData* data ) { mData = data; }
  41. protected:
  42. void offsetObject( ForestItem &object, const Point3F &delta );
  43. void rotateObject( ForestItem &object, const EulerF &delta, const Point3F &origin );
  44. void scaleObject( ForestItem &object, const Point3F &delta );
  45. protected:
  46. ForestData *mData;
  47. };
  48. class ForestSelectionTool : public ForestTool
  49. {
  50. typedef ForestTool Parent;
  51. protected:
  52. Gizmo *mGizmo;
  53. GizmoProfile *mGizmoProfile;
  54. ForestItem mHoverItem;
  55. ForestItemSelection mSelection;
  56. ForestItemSelection mDragSelection;
  57. bool mDragSelect;
  58. RectI mDragRect;
  59. Point2I mDragStart;
  60. bool mMouseDown;
  61. bool mMouseDragged;
  62. ColorI mDragRectColor;
  63. bool mUsingGizmo;
  64. Box3F mBounds;
  65. ForestUpdateAction *mCurrAction;
  66. void _selectItem( const ForestItem &item );
  67. public:
  68. ForestSelectionTool();
  69. virtual ~ForestSelectionTool();
  70. DECLARE_CONOBJECT( ForestSelectionTool );
  71. // ForestTool
  72. virtual void setParentEditor( ForestEditorCtrl *editor );
  73. virtual void setActiveForest( Forest *forest );
  74. virtual void on3DMouseDown( const Gui3DMouseEvent &evt );
  75. virtual void on3DMouseUp( const Gui3DMouseEvent &evt );
  76. virtual void on3DMouseMove( const Gui3DMouseEvent &evt );
  77. virtual void on3DMouseDragged( const Gui3DMouseEvent &evt );
  78. virtual void onRender3D();
  79. virtual void onRender2D();
  80. virtual bool updateGuiInfo();
  81. virtual void updateGizmo();
  82. virtual void onUndoAction();
  83. S32 getSelectionCount() const { return mSelection.size(); }
  84. void deleteSelection();
  85. void clearSelection();
  86. void cutSelection();
  87. void copySelection();
  88. void pasteSelection();
  89. };
  90. #endif // _FOREST_EDITOR_SELECTIONTOOL_H_