PageRenderTime 177ms CodeModel.GetById 149ms app.highlight 21ms RepoModel.GetById 1ms app.codeStats 1ms

/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
  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
 27#include "llviewerprecompiledheaders.h"
 28
 29// File includes
 30#include "lltoolface.h" 
 31
 32// Library includes
 33#include "llfloaterreg.h"
 34#include "v3math.h"
 35
 36// Viewer includes
 37#include "llviewercontrol.h"
 38#include "llselectmgr.h"
 39#include "llviewerobject.h"
 40#include "llviewerwindow.h"
 41#include "llfloatertools.h"
 42
 43//
 44// Member functions
 45//
 46
 47LLToolFace::LLToolFace()
 48:	LLTool(std::string("Texture"))
 49{ }
 50
 51
 52LLToolFace::~LLToolFace()
 53{ }
 54
 55
 56BOOL LLToolFace::handleDoubleClick(S32 x, S32 y, MASK mask)
 57{
 58	if (!LLSelectMgr::getInstance()->getSelection()->isEmpty())
 59	{
 60		// You should already have an object selected from the mousedown.
 61		// If so, show its properties
 62		LLFloaterReg::showInstance("build", "Texture");
 63		return TRUE;
 64	}
 65	else
 66	{
 67		// Nothing selected means the first mouse click was probably
 68		// bad, so try again.
 69		return FALSE;
 70	}
 71}
 72
 73
 74BOOL LLToolFace::handleMouseDown(S32 x, S32 y, MASK mask)
 75{
 76	gViewerWindow->pickAsync(x, y, mask, pickCallback);
 77	return TRUE;
 78}
 79
 80void LLToolFace::pickCallback(const LLPickInfo& pick_info)
 81{
 82	LLViewerObject* hit_obj	= pick_info.getObject();
 83	if (hit_obj)
 84	{
 85		S32 hit_face = pick_info.mObjectFace;
 86		
 87		if (hit_obj->isAvatar())
 88		{
 89			// ...clicked on an avatar, so don't do anything
 90			return;
 91		}
 92
 93		// ...clicked on a world object, try to pick the appropriate face
 94
 95		if (pick_info.mKeyMask & MASK_SHIFT)
 96		{
 97			// If object not selected, need to inform sim
 98			if ( !hit_obj->isSelected() )
 99			{
100				// object wasn't selected so add the object and face
101				LLSelectMgr::getInstance()->selectObjectOnly(hit_obj, hit_face);
102			}
103			else if (!LLSelectMgr::getInstance()->getSelection()->contains(hit_obj, hit_face) )
104			{
105				// object is selected, but not this face, so add it.
106				LLSelectMgr::getInstance()->addAsIndividual(hit_obj, hit_face);
107			}
108			else
109			{
110				// object is selected, as is this face, so remove the face.
111				LLSelectMgr::getInstance()->remove(hit_obj, hit_face);
112
113				// BUG: If you remove the last face, the simulator won't know about it.
114			}
115		}
116		else
117		{
118			// clicked without modifiers, select only
119			// this face
120			LLSelectMgr::getInstance()->deselectAll();
121			LLSelectMgr::getInstance()->selectObjectOnly(hit_obj, hit_face);
122		}
123	}
124	else
125	{
126		if (!(pick_info.mKeyMask == MASK_SHIFT))
127		{
128			LLSelectMgr::getInstance()->deselectAll();
129		}
130	}
131}
132
133
134void LLToolFace::handleSelect()
135{
136	// From now on, draw faces
137	LLSelectMgr::getInstance()->setTEMode(TRUE);
138}
139
140
141void LLToolFace::handleDeselect()
142{
143	// Stop drawing faces
144	LLSelectMgr::getInstance()->setTEMode(FALSE);
145}
146
147
148void LLToolFace::render()
149{
150	// for now, do nothing
151}