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_RotateObjectsTool 21 #define TrenchBroom_RotateObjectsTool 22 23 #include "TrenchBroom.h" 24 #include "VecMath.h" 25 #include "Model/Hit.h" 26 #include "View/Tool.h" 27 #include "View/RotateObjectsHandle.h" 28 29 namespace TrenchBroom { 30 namespace Renderer { 31 class Camera; 32 } 33 34 namespace View { 35 class Grid; 36 class RotateObjectsHandle; 37 class RotateObjectsToolPage; 38 39 class RotateObjectsTool : public Tool { 40 private: 41 MapDocumentWPtr m_document; 42 RotateObjectsToolPage* m_toolPage; 43 RotateObjectsHandle m_handle; 44 double m_angle; 45 bool m_firstActivation; 46 public: 47 RotateObjectsTool(MapDocumentWPtr document); 48 49 bool doActivate(); 50 51 const Grid& grid() const; 52 53 void updateToolPageAxis(RotateObjectsHandle::HitArea area); 54 55 double angle() const; 56 void setAngle(double angle); 57 58 Vec3 rotationCenter() const; 59 void setRotationCenter(const Vec3& position); 60 void resetRotationCenter(); 61 FloatType handleRadius() const; 62 63 void beginRotation(); 64 void commitRotation(); 65 void cancelRotation(); 66 67 FloatType snapRotationAngle(FloatType angle) const; 68 void applyRotation(const Vec3& center, const Vec3& axis, FloatType angle); 69 70 Model::Hit pick2D(const Ray3& pickRay, const Renderer::Camera& camera); 71 Model::Hit pick3D(const Ray3& pickRay, const Renderer::Camera& camera); 72 73 Vec3 rotationAxis(RotateObjectsHandle::HitArea area) const; 74 Vec3 rotationAxisHandle(RotateObjectsHandle::HitArea area, const Vec3& cameraPos) const; 75 76 void renderHandle2D(Renderer::RenderContext& renderContext, Renderer::RenderBatch& renderBatch); 77 void renderHandle3D(Renderer::RenderContext& renderContext, Renderer::RenderBatch& renderBatch); 78 void renderHighlight2D(Renderer::RenderContext& renderContext, Renderer::RenderBatch& renderBatch, RotateObjectsHandle::HitArea area); 79 void renderHighlight3D(Renderer::RenderContext& renderContext, Renderer::RenderBatch& renderBatch, RotateObjectsHandle::HitArea area); 80 private: 81 wxWindow* doCreatePage(wxWindow* parent); 82 String doGetIconName() const; 83 }; 84 } 85 } 86 87 #endif /* defined(TrenchBroom_RotateObjectsTool) */ 88