root/cafu/trunk/CaWE/ToolClip.hpp

Revision 457, 4.4 KB (checked in by Carsten, 4 months ago)

Using UltraEdit's multi-line search-and-replace-in-files feature, replaced


^#ifndef _(CAFU|CF|CFS|CA)_(.*)_$
^#define _\1_\2_$

with

#ifndef CAFU_\2_INCLUDED
#define CAFU_\2_INCLUDED

and


^#ifndef _(.*)_HPP_$
^#define _\1_HPP_$

with

#ifndef CAFU_\1_HPP_INCLUDED
#define CAFU_\1_HPP_INCLUDED

Closes #91.

Line 
1/*
2=================================================================================
3This file is part of Cafu, the open-source game engine and graphics engine
4for multiplayer, cross-platform, real-time 3D action.
5Copyright (C) 2002-2012 Carsten Fuchs Software.
6
7Cafu is free software: you can redistribute it and/or modify it under the terms
8of the GNU General Public License as published by the Free Software Foundation,
9either version 3 of the License, or (at your option) any later version.
10
11Cafu is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
12without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
13PURPOSE. See the GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with Cafu. If not, see <http://www.gnu.org/licenses/>.
17
18For support and more information about Cafu, visit us at <http://www.cafu.de>.
19=================================================================================
20*/
21
22#ifndef CAFU_TOOL_CLIP_HPP_INCLUDED
23#define CAFU_TOOL_CLIP_HPP_INCLUDED
24
25#include "Tool.hpp"
26#include "Math3D/Plane3.hpp"
27#include "Templates/Array.hpp"
28
29
30struct ClipResultT;
31class OptionsBar_ClipBrushesToolT;
32class ViewWindowT;
33
34
35class ToolClipT : public ToolT
36{
37    public:
38
39    /// The constructor.
40    ToolClipT(MapDocumentT& MapDoc, ToolManagerT& ToolMan, wxWindow* ParentOptionsBar);
41
42    /// The destructor.
43    ~ToolClipT();
44
45    /// This is called by the options bar whenever the clip mode has changed.
46    void NoteClipModeChanged();
47
48
49    // Implementations/overrides of ToolT methods.
50    int       GetWxEventID() const { return ChildFrameT::ID_MENU_TOOLS_TOOL_CLIP; }
51    wxWindow* GetOptionsBar();
52    void      OnActivate(ToolT* OldTool);
53    void      OnDeactivate(ToolT* NewTool);
54
55    bool OnKeyDown2D   (ViewWindow2DT& ViewWindow, wxKeyEvent&   KE);
56    bool OnLMouseDown2D(ViewWindow2DT& ViewWindow, wxMouseEvent& ME);
57    bool OnLMouseUp2D  (ViewWindow2DT& ViewWindow, wxMouseEvent& ME);
58    bool OnMouseMove2D (ViewWindow2DT& ViewWindow, wxMouseEvent& ME);
59    bool OnKeyDown3D   (ViewWindow3DT& ViewWindow, wxKeyEvent&   KE);
60
61    void RenderTool2D(Renderer2DT& Renderer) const;
62    void RenderTool3D(Renderer3DT& Renderer) const;
63
64    // The TypeSys related declarations for this class.
65    virtual const cf::TypeSys::TypeInfoT* GetType() const { return &TypeInfo; }
66    static void* CreateInstance(const cf::TypeSys::CreateParamsT& Params);
67    static const cf::TypeSys::TypeInfoT TypeInfo;
68
69
70    private:
71
72    enum ToolStateT
73    {
74        IDLE_EMPTY,         ///< The initial state of the tool: The LMB has not yet been clicked, and the two points that define the clip plane are still undefined.
75        IDLE_HAVE_POINTS,   ///< The clip points have been set, but currently none of them is being dragged.
76        DRAG_POINT_0,       ///< The user is dragging the first  clip point.
77        DRAG_POINT_1        ///< The user is dragging the second clip point.
78    };
79
80
81    /// Returns the index of the clip point in ViewWindow at PointWS (in window space), or -1 if none.
82    int HitTest(ViewWindow2DT& ViewWindow, const wxPoint& PointWS);
83
84    /// Updates the m_ClipResults, based on the the map documents current selection.
85    void UpdateClipResults();
86
87    /// Handles key down events that are common to the 2D and 3D views.
88    bool OnKeyDown(ViewWindowT& ViewWindow, wxKeyEvent& KE);
89
90
91    ToolStateT           m_ToolState;           ///< The state this tool is currently in.
92    Vector3fT            m_ClipPoints[2];       ///< The two clip points that define the plane used for clipping the brushes.
93    int                  m_Clip3rdAxis;         ///< The third axis of the view in which the m_ClipPoints were defined. This also defines one of the span vectors of the clip plane.
94    ArrayT<ClipResultT*> m_ClipResults;         ///< The current results of the clipping operation, updated by UpdateClipResults(). Never touch the Workpiece member, it can be invalid whenever the user had a chance to interfere since the last call to UpdateClipResults(), e.g. by deleting (via the menu) the selected brushes!
95    bool                 m_DrawMeasurements;    ///< Whether to draw dimensions of the clipped brushes in the 2D views.
96
97    OptionsBar_ClipBrushesToolT* m_OptionsBar;  ///< The options bar for this tool.
98};
99
100#endif
Note: See TracBrowser for help on using the browser.