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_MapView2D 21 #define TrenchBroom_MapView2D 22 23 #include "MathUtils.h" 24 #include "Model/ModelTypes.h" 25 #include "Renderer/OrthographicCamera.h" 26 #include "View/Action.h" 27 #include "View/MapViewBase.h" 28 #include "View/ViewTypes.h" 29 30 namespace TrenchBroom { 31 class Logger; 32 33 namespace Model { 34 class PickResult; 35 } 36 37 namespace Renderer { 38 class Compass; 39 class MapRenderer; 40 class RenderBatch; 41 class RenderContext; 42 } 43 44 namespace View { 45 class MapView2D : public MapViewBase { 46 public: 47 typedef enum { 48 ViewPlane_XY, 49 ViewPlane_XZ, 50 ViewPlane_YZ 51 } ViewPlane; 52 private: 53 Renderer::OrthographicCamera m_camera; 54 public: 55 MapView2D(wxWindow* parent, Logger* logger, MapDocumentWPtr document, MapViewToolBox& toolBox, Renderer::MapRenderer& renderer, GLContextManager& contextManager, ViewPlane viewPlane); 56 ~MapView2D(); 57 private: 58 void initializeCamera(ViewPlane viewPlane); 59 void initializeToolChain(MapViewToolBox& toolBox); 60 private: // notification 61 void bindObservers(); 62 void unbindObservers(); 63 void cameraDidChange(const Renderer::Camera* camera); 64 private: // interaction events 65 void bindEvents(); 66 private: // implement ToolBoxConnector interface 67 PickRequest doGetPickRequest(int x, int y) const; 68 Model::PickResult doPick(const Ray3& pickRay) const; 69 private: // implement RenderView interface 70 void doUpdateViewport(int x, int y, int width, int height); 71 private: // implement MapView interface 72 Vec3 doGetPasteObjectsDelta(const BBox3& bounds, const BBox3& referenceBounds) const; 73 bool doCanSelectTall(); 74 void doSelectTall(); 75 void doFocusCameraOnSelection(bool animate); 76 77 void doMoveCameraToPosition(const Vec3& position, bool animate); 78 void animateCamera(const Vec3f& position, const Vec3f& direction, const Vec3f& up, const wxLongLong duration = DefaultCameraAnimationDuration); 79 80 void doMoveCameraToCurrentTracePoint(); 81 private: // implement MapViewBase interface 82 Vec3 doGetMoveDirection(Math::Direction direction) const; 83 Vec3 doComputePointEntityPosition(const BBox3& bounds) const; 84 85 ActionContext doGetActionContext() const; 86 wxAcceleratorTable doCreateAccelerationTable(ActionContext context) const; 87 bool doCancel(); 88 89 Renderer::RenderContext doCreateRenderContext(); 90 void doRenderGrid(Renderer::RenderContext& renderContext, Renderer::RenderBatch& renderBatch); 91 void doRenderMap(Renderer::MapRenderer& renderer, Renderer::RenderContext& renderContext, Renderer::RenderBatch& renderBatch); 92 void doRenderTools(MapViewToolBox& toolBox, Renderer::RenderContext& renderContext, Renderer::RenderBatch& renderBatch); 93 void doRenderExtras(Renderer::RenderContext& renderContext, Renderer::RenderBatch& renderBatch); 94 private: // implement CameraLinkableView interface 95 void doLinkCamera(CameraLinkHelper& linkHelper); 96 }; 97 } 98 } 99 100 #endif /* defined(TrenchBroom_MapView2D) */ 101