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 #ifndef TrenchBroom_VertexCommand 21 #define TrenchBroom_VertexCommand 22 23 #include "Model/ModelTypes.h" 24 #include "View/DocumentCommand.h" 25 26 namespace TrenchBroom { 27 namespace Model { 28 class Snapshot; 29 } 30 31 namespace View { 32 class VertexHandleManager; 33 34 class VertexCommand : public DocumentCommand { 35 private: 36 Model::BrushList m_brushes; 37 Model::Snapshot* m_snapshot; 38 protected: 39 VertexCommand(CommandType type, const String& name, const Model::BrushList& brushes); 40 public: 41 virtual ~VertexCommand(); 42 protected: 43 static void extractVertexMap(const Model::VertexToBrushesMap& vertices, Model::BrushList& brushes, Model::BrushVerticesMap& brushVertices, Vec3::List& vertexPositions); 44 static void extractEdgeMap(const Model::VertexToEdgesMap& edges, Model::BrushList& brushes, Model::BrushEdgesMap& brushEdges, Edge3::List& edgePositions); 45 static void extractFaceMap(const Model::VertexToFacesMap& faces, Model::BrushList& brushes, Model::BrushFacesMap& brushFaces, Polygon3::List& facePositions); 46 private: 47 bool doPerformDo(MapDocumentCommandFacade* document); 48 bool doPerformUndo(MapDocumentCommandFacade* document); 49 bool doIsRepeatable(MapDocumentCommandFacade* document) const; 50 private: 51 void takeSnapshot(); 52 void deleteSnapshot(); 53 private: 54 virtual bool doCanDoVertexOperation(const MapDocument* document) const = 0; 55 virtual bool doVertexOperation(MapDocumentCommandFacade* document) = 0; 56 public: 57 void removeBrushes(VertexHandleManager& manager); 58 void addBrushes(VertexHandleManager& manager); 59 void selectNewHandlePositions(VertexHandleManager& manager); 60 void selectOldHandlePositions(VertexHandleManager& manager); 61 private: 62 virtual void doSelectNewHandlePositions(VertexHandleManager& manager, const Model::BrushList& brushes) = 0; 63 virtual void doSelectOldHandlePositions(VertexHandleManager& manager, const Model::BrushList& brushes) = 0; 64 }; 65 } 66 } 67 68 #endif /* defined(TrenchBroom_VertexCommand) */ 69