1 /* 2 Copyright (C) 2010-2014 Kristian Duske 3 4 This file is part of TrenchBroom. 5 6 TrenchBroom is free software: you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation, either version 3 of the License, or 9 (at your option) any later version. 10 11 TrenchBroom is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with TrenchBroom. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 20 #include "BrushContentTypeBuilder.h" 21 22 namespace TrenchBroom { 23 namespace Model { Result(const BrushContentType::FlagType i_contentType,const bool i_transparent)24 BrushContentTypeBuilder::Result::Result(const BrushContentType::FlagType i_contentType, const bool i_transparent) : 25 contentType(i_contentType), 26 transparent(i_transparent) {} 27 BrushContentTypeBuilder(const BrushContentType::List & contentTypes)28 BrushContentTypeBuilder::BrushContentTypeBuilder(const BrushContentType::List& contentTypes) : 29 m_contentTypes(contentTypes) {} 30 buildContentType(const Brush * brush) const31 BrushContentTypeBuilder::Result BrushContentTypeBuilder::buildContentType(const Brush* brush) const { 32 BrushContentType::FlagType flags = 0; 33 bool transparent = false; 34 35 BrushContentType::List::const_iterator it, end; 36 for (it = m_contentTypes.begin(), end = m_contentTypes.end(); it != end; ++it) { 37 const BrushContentType& contentType = *it; 38 if (contentType.evaluate(brush)) { 39 flags |= contentType.flagValue(); 40 transparent |= contentType.transparent(); 41 } 42 } 43 return Result(flags, transparent); 44 } 45 } 46 } 47