Cafu Engine
Renderer2D.hpp
1 /*
2 Cafu Engine, http://www.cafu.de/
3 Copyright (c) Carsten Fuchs and other contributors.
4 This project is licensed under the terms of the MIT license.
5 */
6 
7 #ifndef CAFU_RENDERER_2D_HPP_INCLUDED
8 #define CAFU_RENDERER_2D_HPP_INCLUDED
9 
10 #include "Math3D/BoundingBox.hpp"
11 #include "Math3D/Matrix3x3.hpp"
12 #include "Templates/Array.hpp"
13 
14 #include "wx/wx.h"
15 
16 
17 class ViewWindow2DT;
18 
19 
20 /// This class implements the rendering into a 2D view.
21 /// Most methods are just simple wrappers around wxDC functionality, but it still makes rendering more convenient.
23 {
24  public:
25 
26  static const int LINE_THIN;
27  static const int LINE_THICK;
28 
29  /// The Constructor.
30  Renderer2DT(const ViewWindow2DT& ViewWin2D, wxDC& dc);
31 
32  /// Returns the ViewWindow2DT that this renderer renders into.
33  const ViewWindow2DT& GetViewWin2D() const { return m_ViewWin2D; }
34 
35  void SetFillColor(const wxColour& Color);
36  void SetLineColor(const wxColour& Color);
37  void SetLineType(wxPenStyle Style, int Width, const wxColour& Color);
38 
39  void DrawPoint(const wxPoint& Point, int Radius);
40  void DrawPoint(const Vector3fT& Point, int Radius);
41 
42  void DrawLine(const wxPoint& A, const wxPoint& B);
43  void DrawLine(const Vector3fT& A, const Vector3fT& B);
44  void DrawLine(int x1, int y1, int x2, int y2);
45  void DrawLineLoop(const ArrayT<Vector3fT>& Points, int Radius);
46 
47  void DrawEllipse(const wxPoint& Center, int RadiusX, int RadiusY, bool Fill);
48  void Rectangle(const wxRect& Rect, bool Fill);
49  void DrawBitmap(int x, int y, const wxBitmap& Bitmap);
50 
51  // void SetFont(...); // TODO!
52  // void GetTextExtent(...); // TODO!, this easily (1:1) implemented with wxDC::GetTextExtent().
53  void SetTextColor(const wxColour& FgColor, const wxColour& BkColor);
54  void DrawText(const wxString& Text, const wxPoint& Pos);
55 
56 
57  /// Renders the basis vectors (the "axes") of the given matrix at the given position with the given length.
58  void BasisVectors(const Vector3fT& Pos, const cf::math::Matrix3x3fT& Mat, float Length=24.0f);
59 
60  /// Renders an X-shaped handle at the given position with the given radius.
61  /// This is typically used for marking the center of map elements.
62  void XHandle(const wxPoint& Pos, int Radius=3);
63 
64  /// Renders the dimensions of the given bounding-box next to the box.
65  /// @param BB The bounding-box whose dimensions are printed.
66  /// @param Pos A combination of the flags wxTOP, wxBOTTOM, wxLEFT and wxRIGHT that determines where the dimensions are printed.
67  void DrawBoxDims(const BoundingBox3fT& BB, int Pos);
68 
69 
70  private:
71 
72  const ViewWindow2DT& m_ViewWin2D; ///< The 2D view that this renderer is rendering into.
73  wxDC& m_DC; ///< The 2D views device context.
74  wxPen m_Pen; ///< The pen that is currently being used for line drawing.
75  wxBrush m_Brush; ///< The brush that is currently being used for area filling.
76 };
77 
78 #endif
This class implements the rendering into a 2D view.
Definition: Renderer2D.hpp:22
void BasisVectors(const Vector3fT &Pos, const cf::math::Matrix3x3fT &Mat, float Length=24.0f)
Renders the basis vectors (the "axes") of the given matrix at the given position with the given lengt...
Definition: Renderer2D.cpp:133
void XHandle(const wxPoint &Pos, int Radius=3)
Renders an X-shaped handle at the given position with the given radius.
Definition: Renderer2D.cpp:146
Renderer2DT(const ViewWindow2DT &ViewWin2D, wxDC &dc)
The Constructor.
Definition: Renderer2D.cpp:15
void DrawBoxDims(const BoundingBox3fT &BB, int Pos)
Renders the dimensions of the given bounding-box next to the box.
Definition: Renderer2D.cpp:173
Definition: ChildFrameViewWin2D.hpp:24
Definition: Renderer.hpp:16
This class represents a generic 3x3 matrix.
Definition: Angles.hpp:17
This class represents an axis-aligned bounding-box ("AABB") in 3-dimensional space.
Definition: BoundingBox.hpp:23
const ViewWindow2DT & GetViewWin2D() const
Returns the ViewWindow2DT that this renderer renders into.
Definition: Renderer2D.hpp:33