PageRenderTime 39ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/newview/lltoolface.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 151 lines | 81 code | 23 blank | 47 comment | 9 complexity | a11fcee1b502cb59145da7a0399edb65 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file lltoolface.cpp
  3. * @brief A tool to manipulate faces
  4. *
  5. * $LicenseInfo:firstyear=2001&license=viewerlgpl$
  6. * Second Life Viewer Source Code
  7. * Copyright (C) 2010, Linden Research, Inc.
  8. *
  9. * This library is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation;
  12. * version 2.1 of the License only.
  13. *
  14. * This library is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with this library; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. *
  23. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  24. * $/LicenseInfo$
  25. */
  26. #include "llviewerprecompiledheaders.h"
  27. // File includes
  28. #include "lltoolface.h"
  29. // Library includes
  30. #include "llfloaterreg.h"
  31. #include "v3math.h"
  32. // Viewer includes
  33. #include "llviewercontrol.h"
  34. #include "llselectmgr.h"
  35. #include "llviewerobject.h"
  36. #include "llviewerwindow.h"
  37. #include "llfloatertools.h"
  38. //
  39. // Member functions
  40. //
  41. LLToolFace::LLToolFace()
  42. : LLTool(std::string("Texture"))
  43. { }
  44. LLToolFace::~LLToolFace()
  45. { }
  46. BOOL LLToolFace::handleDoubleClick(S32 x, S32 y, MASK mask)
  47. {
  48. if (!LLSelectMgr::getInstance()->getSelection()->isEmpty())
  49. {
  50. // You should already have an object selected from the mousedown.
  51. // If so, show its properties
  52. LLFloaterReg::showInstance("build", "Texture");
  53. return TRUE;
  54. }
  55. else
  56. {
  57. // Nothing selected means the first mouse click was probably
  58. // bad, so try again.
  59. return FALSE;
  60. }
  61. }
  62. BOOL LLToolFace::handleMouseDown(S32 x, S32 y, MASK mask)
  63. {
  64. gViewerWindow->pickAsync(x, y, mask, pickCallback);
  65. return TRUE;
  66. }
  67. void LLToolFace::pickCallback(const LLPickInfo& pick_info)
  68. {
  69. LLViewerObject* hit_obj = pick_info.getObject();
  70. if (hit_obj)
  71. {
  72. S32 hit_face = pick_info.mObjectFace;
  73. if (hit_obj->isAvatar())
  74. {
  75. // ...clicked on an avatar, so don't do anything
  76. return;
  77. }
  78. // ...clicked on a world object, try to pick the appropriate face
  79. if (pick_info.mKeyMask & MASK_SHIFT)
  80. {
  81. // If object not selected, need to inform sim
  82. if ( !hit_obj->isSelected() )
  83. {
  84. // object wasn't selected so add the object and face
  85. LLSelectMgr::getInstance()->selectObjectOnly(hit_obj, hit_face);
  86. }
  87. else if (!LLSelectMgr::getInstance()->getSelection()->contains(hit_obj, hit_face) )
  88. {
  89. // object is selected, but not this face, so add it.
  90. LLSelectMgr::getInstance()->addAsIndividual(hit_obj, hit_face);
  91. }
  92. else
  93. {
  94. // object is selected, as is this face, so remove the face.
  95. LLSelectMgr::getInstance()->remove(hit_obj, hit_face);
  96. // BUG: If you remove the last face, the simulator won't know about it.
  97. }
  98. }
  99. else
  100. {
  101. // clicked without modifiers, select only
  102. // this face
  103. LLSelectMgr::getInstance()->deselectAll();
  104. LLSelectMgr::getInstance()->selectObjectOnly(hit_obj, hit_face);
  105. }
  106. }
  107. else
  108. {
  109. if (!(pick_info.mKeyMask == MASK_SHIFT))
  110. {
  111. LLSelectMgr::getInstance()->deselectAll();
  112. }
  113. }
  114. }
  115. void LLToolFace::handleSelect()
  116. {
  117. // From now on, draw faces
  118. LLSelectMgr::getInstance()->setTEMode(TRUE);
  119. }
  120. void LLToolFace::handleDeselect()
  121. {
  122. // Stop drawing faces
  123. LLSelectMgr::getInstance()->setTEMode(FALSE);
  124. }
  125. void LLToolFace::render()
  126. {
  127. // for now, do nothing
  128. }