TubeTool.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. FinalSun/FinalAlert 2 Mission Editor
  3. Copyright (C) 1999-2024 Electronic Arts, Inc.
  4. Authored by Matthias Wagner
  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. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program. If not, see <https://www.gnu.org/licenses/>.
  15. */
  16. #pragma once
  17. #include "MapTool.h"
  18. #include <vector>
  19. class CTube;
  20. class AddTubeTool: public MapTool
  21. {
  22. public:
  23. AddTubeTool(CMapData& map, CIsoView& view, bool bidirectional);
  24. virtual ~AddTubeTool() = default;
  25. void finish();
  26. virtual bool onRButtonUp(const ProjectedCoords& projCoords, const MapCoords& mapCoords3d, MapToolMouseFlags flags);
  27. virtual void onLButtonDblClick(const ProjectedCoords& projCoords, const MapCoords& mapCoords3d, MapToolMouseFlags flags);
  28. virtual void onLButtonUp(const ProjectedCoords& projCoords, const MapCoords& mapCoords3d, MapToolMouseFlags flags);
  29. virtual void onMouseMove(const ProjectedCoords& projCoords, const MapCoords& mapCoords3d, MapToolMouseFlags flags);
  30. virtual void render();
  31. protected:
  32. AddTubeTool& operator=(const AddTubeTool& other) = delete;
  33. virtual std::unique_ptr<CTube> getTubeToModify(const MapCoords& mapCoords3d, const ProjectedCoords& projCoords, MapToolMouseFlags flags) const;
  34. virtual std::unique_ptr<CTube> createNewTube(const MapCoords& mapCoords3d) const;
  35. private:
  36. std::unique_ptr<CTube> m_tube;
  37. std::unique_ptr<CTube> m_mm_tube;
  38. std::unique_ptr<CTube> m_hover_tube;
  39. std::vector<std::unique_ptr<CTube>> m_modified_tubes;
  40. bool m_bidirectional;
  41. };
  42. class ModifyTubeTool : public AddTubeTool
  43. {
  44. public:
  45. ModifyTubeTool(CMapData& map, CIsoView& view, bool bidirectional);
  46. virtual ~ModifyTubeTool() = default;
  47. protected:
  48. ModifyTubeTool& operator=(const AddTubeTool& other) = delete;
  49. virtual std::unique_ptr<CTube> getTubeToModify(const MapCoords& mapCoords3d, const ProjectedCoords& projCoords, MapToolMouseFlags flags) const;
  50. virtual std::unique_ptr<CTube> createNewTube(const MapCoords& mapCoords3d) const;
  51. private:
  52. };
  53. class RemoveTubeTool : public MapTool
  54. {
  55. public:
  56. RemoveTubeTool(CMapData& map, CIsoView& view);
  57. virtual ~RemoveTubeTool() = default;
  58. virtual void onMouseMove(const ProjectedCoords& projCoords, const MapCoords& mapCoords3d, MapToolMouseFlags flags);
  59. virtual void render();
  60. protected:
  61. RemoveTubeTool& operator=(const RemoveTubeTool& other) = delete;
  62. private:
  63. std::vector<std::unique_ptr<CTube>> m_hover_tubes;
  64. };