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_ResizeBrushesToolController
21 #define TrenchBroom_ResizeBrushesToolController
22 
23 #include "Model/Hit.h"
24 #include "Renderer/EdgeRenderer.h"
25 #include "View/ToolController.h"
26 
27 namespace TrenchBroom {
28     namespace Model {
29         class PickResult;
30     }
31 
32     namespace Renderer {
33         class RenderBatch;
34         class RenderContext;
35     }
36 
37     namespace View {
38         class InputState;
39         class ResizeBrushesTool;
40 
41         class ResizeBrushesToolController : public ToolControllerBase<PickingPolicy, KeyPolicy, MousePolicy, MouseDragPolicy, RenderPolicy, NoDropPolicy> {
42         protected:
43             ResizeBrushesTool* m_tool;
44         protected:
45             ResizeBrushesToolController(ResizeBrushesTool* tool);
46         public:
47             virtual ~ResizeBrushesToolController();
48         private:
49             Tool* doGetTool();
50 
51             void doPick(const InputState& inputState, Model::PickResult& pickResult);
52 
53             void doModifierKeyChange(const InputState& inputState);
54 
55             void doMouseMove(const InputState& inputState);
56 
57             bool doStartMouseDrag(const InputState& inputState);
58             bool doMouseDrag(const InputState& inputState);
59             void doEndMouseDrag(const InputState& inputState);
60             void doCancelMouseDrag();
61 
62             void doSetRenderOptions(const InputState& inputState, Renderer::RenderContext& renderContext) const;
63             void doRender(const InputState& inputState, Renderer::RenderContext& renderContext, Renderer::RenderBatch& renderBatch);
64             Renderer::DirectEdgeRenderer buildEdgeRenderer();
65 
66             bool doCancel();
67 
68             void updateDragFaces(const InputState& inputState);
69             bool handleInput(const InputState& inputState) const;
70         private:
71             virtual Model::Hit doPick(const Ray3& pickRay, const Model::PickResult& pickResult) = 0;
72         };
73 
74         class ResizeBrushesToolController2D : public ResizeBrushesToolController {
75         public:
76             ResizeBrushesToolController2D(ResizeBrushesTool* tool);
77         private:
78             Model::Hit doPick(const Ray3& pickRay, const Model::PickResult& pickResult);
79         };
80 
81         class ResizeBrushesToolController3D : public ResizeBrushesToolController {
82         public:
83             ResizeBrushesToolController3D(ResizeBrushesTool* tool);
84         private:
85             Model::Hit doPick(const Ray3& pickRay, const Model::PickResult& pickResult);
86         };
87     }
88 }
89 
90 #endif /* defined(TrenchBroom_ResizeBrushesToolController) */
91