PolygonTool.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. ** Command & Conquer Generals(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. // PolygonTool.h
  19. // Polygon area trigger tool for worldbuilder.
  20. // Author: John Ahlquist, Nov. 2001
  21. #pragma once
  22. #ifndef POLYGONTOOL_H
  23. #define POLYGONTOOL_H
  24. #include "Tool.h"
  25. class WorldHeightMapEdit;
  26. class MapObject;
  27. class PolygonTrigger;
  28. class MovePolygonUndoable;
  29. /*************************************************************************/
  30. /** PolygonTool
  31. Does the add/select polygon operation.
  32. ***************************************************************************/
  33. /// Select tile tool.
  34. class PolygonTool : public Tool
  35. {
  36. public:
  37. PolygonTool(void);
  38. ~PolygonTool(void);
  39. protected:
  40. Coord3D m_poly_mouseDownPt;
  41. Coord3D m_poly_unsnappedMouseDownPt;
  42. Bool m_poly_isDraggingPoint;
  43. Bool m_poly_justPicked;
  44. Bool m_poly_mouseUpPlus;///< True if we are over the "Add point" hotspot.
  45. HCURSOR m_poly_plusCursor;
  46. Bool m_poly_mouseUpMove;///< True if we are over the "move" hotspot.
  47. HCURSOR m_poly_moveCursor;
  48. MovePolygonUndoable *m_poly_moveUndoable;
  49. static Bool m_poly_isAdding;
  50. static Int m_poly_dragPointNdx;
  51. static Bool m_poly_isActive;
  52. static PolygonTrigger *m_poly_curSelectedPolygon;
  53. protected:
  54. static Int poly_pickPoint(PolygonTrigger *pTrig, CPoint viewPt, WbView* pView);
  55. static Int poly_getInsertIndex(PolygonTrigger *pTrig, Coord3D loc);
  56. Bool poly_snapToPoly(Coord3D *pLoc);
  57. static Bool poly_pickPoly(PolygonTrigger *pTrig, Coord3D pLoc, Int tolerance);
  58. void poly_pickOnMouseDown(CPoint viewPt, WbView* pView);
  59. void startMouseDown(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc);
  60. public:
  61. static Bool isActive(void) {return m_poly_isActive;};
  62. static Bool deleteSelectedPolygon(void);
  63. static Bool isSelected(PolygonTrigger *pTrig) {return (pTrig && (pTrig==m_poly_curSelectedPolygon));};
  64. static Int getSelectedPointNdx(void) {return m_poly_dragPointNdx;};
  65. static PolygonTrigger *pickPolygon(Coord3D loc, CPoint viewPt, WbView* pView);
  66. static Bool isSelectedOpen(void) {return m_poly_isAdding;};
  67. public:
  68. /// Perform tool on mouse down.
  69. virtual void mouseDown(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc);
  70. virtual void mouseMoved(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc);
  71. virtual void mouseUp(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc);
  72. virtual void setCursor(void);
  73. virtual void activate(); ///< Become the current tool.
  74. virtual void deactivate(); ///< Become not the current tool.
  75. };
  76. #endif //POLYGONTOOL_H