lltoolface.cpp 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /**
  2. * @file lltoolface.cpp
  3. * @brief A tool to manipulate faces
  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. #include "llviewerprecompiledheaders.h"
  33. #include "lltoolface.h"
  34. #include "llfloatertools.h"
  35. //MK
  36. #include "mkrlinterface.h"
  37. //mk
  38. #include "llselectmgr.h"
  39. #include "lltoolview.h"
  40. #include "llviewercontrol.h"
  41. #include "llviewerobject.h"
  42. #include "llviewerwindow.h"
  43. #include "llvoavatarself.h"
  44. LLToolFace gToolFace;
  45. LLToolFace::LLToolFace()
  46. : LLTool("Texture")
  47. {
  48. }
  49. //virtual
  50. bool LLToolFace::handleDoubleClick(S32 x, S32 y, MASK mask)
  51. {
  52. if (!gSelectMgr.getSelection()->isEmpty())
  53. {
  54. // You should already have an object selected from the mousedown.
  55. // If so, show its properties
  56. if (gFloaterToolsp)
  57. {
  58. gFloaterToolsp->showPanel(LLFloaterTools::PANEL_FACE);
  59. }
  60. return true;
  61. }
  62. // Nothing selected means the first mouse click was probably bad, so try
  63. // again.
  64. return false;
  65. }
  66. //virtual
  67. bool LLToolFace::handleMouseDown(S32 x, S32 y, MASK mask)
  68. {
  69. gViewerWindowp->pickAsync(x, y, mask, pickCallback);
  70. return true;
  71. }
  72. //static
  73. void LLToolFace::pickCallback(const LLPickInfo& pick_info)
  74. {
  75. LLViewerObject* hit_obj = pick_info.getObject();
  76. if (!hit_obj)
  77. {
  78. if (pick_info.mKeyMask != MASK_SHIFT)
  79. {
  80. gSelectMgr.deselectAll();
  81. }
  82. return;
  83. }
  84. if (hit_obj->isAvatar())
  85. {
  86. // Clicked on an avatar, so do not do anything
  87. return;
  88. }
  89. //MK
  90. if (gRLenabled && !gRLInterface.canTouch(hit_obj) &&
  91. !hit_obj->isAttachment())
  92. {
  93. return;
  94. }
  95. //mk
  96. // Clicked on a world object, try to pick the appropriate face
  97. S32 hit_face = pick_info.mObjectFace;
  98. if (pick_info.mKeyMask & MASK_SHIFT)
  99. {
  100. // If object not selected, need to inform sim
  101. if ( !hit_obj->isSelected() )
  102. {
  103. // Object was not selected so add the object and face
  104. gSelectMgr.selectObjectOnly(hit_obj, hit_face);
  105. }
  106. else if (!gSelectMgr.getSelection()->contains(hit_obj, hit_face))
  107. {
  108. // Object is selected, but not this face, so add it.
  109. gSelectMgr.addAsIndividual(hit_obj, hit_face);
  110. }
  111. else
  112. {
  113. // Object is selected, as is this face, so remove the face.
  114. gSelectMgr.remove(hit_obj, hit_face);
  115. // BUG: If you remove the last face, the simulator won't know
  116. // about it.
  117. }
  118. }
  119. else
  120. {
  121. // Clicked without modifiers, select only this face
  122. gSelectMgr.deselectAll();
  123. gSelectMgr.selectObjectOnly(hit_obj, hit_face);
  124. }
  125. }
  126. //virtual
  127. void LLToolFace::handleSelect()
  128. {
  129. // From now on, draw faces
  130. gSelectMgr.setTEMode(true);
  131. }
  132. //virtual
  133. void LLToolFace::handleDeselect()
  134. {
  135. // Stop drawing faces
  136. gSelectMgr.setTEMode(false);
  137. }
  138. //virtual
  139. void LLToolFace::render()
  140. {
  141. // For now, do nothing
  142. }