lltoolplacer.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /**
  2. * @file lltoolplacer.h
  3. * @brief Tool for placing new objects into the world
  4. *
  5. * $LicenseInfo:firstyear=2001&license=viewergpl$
  6. *
  7. * Copyright (c) 2001-2009, Linden Research, Inc.
  8. *
  9. * Second Life Viewer Source Code
  10. * The source code in this file ("Source Code") is provided by Linden Lab
  11. * to you under the terms of the GNU General Public License, version 2.0
  12. * ("GPL"), unless you have obtained a separate licensing agreement
  13. * ("Other License"), formally executed by you and Linden Lab. Terms of
  14. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  15. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  16. *
  17. * There are special exceptions to the terms and conditions of the GPL as
  18. * it is applied to this Source Code. View the full text of the exception
  19. * in the file doc/FLOSS-exception.txt in this software distribution, or
  20. * online at
  21. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  22. *
  23. * By copying, modifying or distributing this software, you acknowledge
  24. * that you have read and understood your obligations described above,
  25. * and agree to abide by those obligations.
  26. *
  27. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  28. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  29. * COMPLETENESS OR PERFORMANCE.
  30. * $/LicenseInfo$
  31. */
  32. #ifndef LL_TOOLPLACER_H
  33. #define LL_TOOLPLACER_H
  34. #include "llpanel.h"
  35. #include "llprimitive.h"
  36. #include "lltool.h"
  37. class LLButton;
  38. class LLViewerRegion;
  39. class LLToolPlacer : public LLTool
  40. {
  41. protected:
  42. LOG_CLASS(LLToolPlacer);
  43. public:
  44. LLToolPlacer();
  45. virtual bool placeObject(S32 x, S32 y, MASK mask);
  46. virtual bool handleHover(S32 x, S32 y, MASK mask);
  47. virtual void handleSelect(); // do stuff when your tool is selected
  48. virtual void handleDeselect(); // clean up when your tool is deselected
  49. static void setObjectType(LLPCode type) { sObjectType = type; }
  50. static LLPCode getObjectType() { return sObjectType; }
  51. protected:
  52. static LLPCode sObjectType;
  53. private:
  54. S32 getTreeGrassSpecies(std::map<std::string, S32>& table,
  55. const char* control, S32 max);
  56. bool addObject(LLPCode pcode, S32 x, S32 y, U8 use_physics);
  57. bool raycastForNewObjPos(S32 x, S32 y, LLViewerObject** hit_obj,
  58. S32* hit_face, bool* b_hit_land,
  59. LLVector3* ray_start_region,
  60. LLVector3* ray_end_region,
  61. LLViewerRegion** region);
  62. bool addDuplicate(S32 x, S32 y);
  63. };
  64. ////////////////////////////////////////////////////
  65. // LLToolPlacerPanel
  66. constexpr S32 TOOL_PLACER_NUM_BUTTONS = 14;
  67. class LLToolPlacerPanel : public LLPanel
  68. {
  69. public:
  70. LLToolPlacerPanel(const std::string& name, const LLRect& rect);
  71. static void setObjectType(void* data);
  72. static LLPCode sCube;
  73. static LLPCode sPrism;
  74. static LLPCode sPyramid;
  75. static LLPCode sTetrahedron;
  76. static LLPCode sCylinder;
  77. static LLPCode sCylinderHemi;
  78. static LLPCode sCone;
  79. static LLPCode sConeHemi;
  80. static LLPCode sTorus;
  81. static LLPCode sSquareTorus;
  82. static LLPCode sTriangleTorus;
  83. static LLPCode sSphere;
  84. static LLPCode sSphereHemi;
  85. static LLPCode sTree;
  86. static LLPCode sGrass;
  87. private:
  88. void addButton(const std::string& up_state, const std::string& down_state,
  89. LLPCode* pcode);
  90. private:
  91. static S32 sButtonsAdded;
  92. static LLButton* sButtons[TOOL_PLACER_NUM_BUTTONS];
  93. };
  94. #endif