OpenCPN Partial API docs
Loading...
Searching...
No Matches
pi_ocpndc.h
Go to the documentation of this file.
1/**************************************************************************
2 * Copyright (C) 2011 by Sean D'Epagnier *
3 * sean at depagnier dot com *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, see <https://www.gnu.org/licenses/>. *
17 **************************************************************************/
18
25#ifndef __PIOCPNDC_H__
26#define __PIOCPNDC_H__
27
28#include <vector>
29#include "linmath.h"
30
31#include "pi_tex_font.h"
32#include "ocpn_plugin.h"
33
34#ifdef ocpnUSE_GL
35#include <wx/glcanvas.h>
36#endif
37
38// class ViewPort;
39class GLUtesselator;
40
41void piDrawGLThickLine(float x1, float y1, float x2, float y2, wxPen pen,
42 bool b_hiqual);
43
44//----------------------------------------------------------------------------
45// pi_ocpnDC
46//----------------------------------------------------------------------------
47
48class wxGLCanvas;
49
50class pi_ocpnDC {
51public:
52 pi_ocpnDC(wxGLCanvas &canvas);
53 pi_ocpnDC(wxDC &pdc);
54 pi_ocpnDC();
55
56 ~pi_ocpnDC();
57
58 void SetBackground(const wxBrush &brush);
59 void SetPen(const wxPen &pen);
60 void SetBrush(const wxBrush &brush);
61 void SetTextForeground(const wxColour &colour);
62 void SetFont(const wxFont &font);
63 static void SetGLAttrs(bool highQuality);
64 void SetGLStipple() const;
65 void SetVP(PlugIn_ViewPort *vp);
66 void SetDC(wxDC *dc_in) { dc = dc_in; }
67
68 const wxPen &GetPen() const;
69 const wxBrush &GetBrush() const;
70 const wxFont &GetFont() const;
71
72 void GetSize(wxCoord *width, wxCoord *height) const;
73
74 void DrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2,
75 bool b_hiqual = true);
76 void DrawLines(int n, wxPoint points[], wxCoord xoffset = 0,
77 wxCoord yoffset = 0, bool b_hiqual = true);
78
79 void StrokeLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2);
80 void StrokeLine(wxPoint a, wxPoint b) { StrokeLine(a.x, a.y, b.x, b.y); }
81 void StrokeLines(int n, wxPoint *points);
82
83 void Clear();
84 void DrawRectangle(wxCoord x, wxCoord y, wxCoord w, wxCoord h);
85 void DrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord w, wxCoord h,
86 wxCoord rr);
87 void DrawCircle(wxCoord x, wxCoord y, wxCoord radius);
88 void DrawCircle(const wxPoint &pt, wxCoord radius) {
89 DrawCircle(pt.x, pt.y, radius);
90 }
91 void StrokeCircle(wxCoord x, wxCoord y, wxCoord radius);
92
93 void DrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
94 void DrawPolygon(int n, wxPoint points[], wxCoord xoffset = 0,
95 wxCoord yoffset = 0, float scale = 1.0, float angle = 0.0);
96 void DrawPolygonTessellated(int n, wxPoint points[], wxCoord xoffset = 0,
97 wxCoord yoffset = 0);
98 void StrokePolygon(int n, wxPoint points[], wxCoord xoffset = 0,
99 wxCoord yoffset = 0, float scale = 1.0);
100
101 void DrawBitmap(const wxBitmap &bitmap, wxCoord x, wxCoord y, bool usemask);
102
103 void DrawText(const wxString &text, wxCoord x, wxCoord y);
104 void GetTextExtent(const wxString &string, wxCoord *w, wxCoord *h,
105 wxCoord *descent = NULL, wxCoord *externalLeading = NULL,
106 wxFont *font = NULL);
107
108 void ResetBoundingBox();
109 void CalcBoundingBox(wxCoord x, wxCoord y);
110
111 void DestroyClippingRegion() {}
112
113 wxDC *GetDC() const { return dc; }
114
115 void DrawGLLineArray(int n, float *vertex_array, unsigned char *color_array,
116 bool b_hiqual);
117 void DrawGLLineArray(int n, float *vertex_array, float *color_array,
118 bool b_hiqual);
119
120#ifdef ocpnUSE_GL
121 GLfloat *s_odc_tess_work_buf;
122#endif
123
124#ifdef USE_ANDROID_GLES2
125 int s_odc_tess_vertex_idx;
126 int s_odc_tess_vertex_idx_this;
127 int s_odc_tess_buf_len;
128 GLenum s_odc_tess_mode;
129 int s_odc_nvertex;
130 vec4 s_odc_tess_color;
131 // ViewPort *s_odc_tessVP;
132 GLUtesselator *m_tobj;
133
134#endif
135
136protected:
137 bool ConfigurePen();
138 bool ConfigureBrush();
139
140 void GLDrawBlendData(wxCoord x, wxCoord y, wxCoord w, wxCoord h, int format,
141 const unsigned char *data);
142
143 void drawrrhelperGLES2(wxCoord x0, wxCoord y0, wxCoord r, int quadrant,
144 int steps);
145
146 wxGLCanvas *glcanvas;
147 wxDC *dc;
148 wxPen m_pen;
149 wxBrush m_brush;
150 wxColour m_textforegroundcolour;
151 wxFont m_font;
152
153#ifdef ocpnUSE_GL
154 TexFont m_texfont;
155#endif
156 bool m_buseTex;
157
158#if wxUSE_GRAPHICS_CONTEXT
159 wxGraphicsContext *pgc;
160#endif
161
162 float *workBuf;
163 size_t workBufSize;
164 unsigned int workBufIndex;
165
166 wxSize m_vpSize;
167};
168
169#endif
Contains view parameters and status information for a chart display viewport.
PlugIn Object Definition/API.
OpenGL text rendering.