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
41#ifndef PIOCPNDC_H__
42#define PIOCPNDC_H__
43
44#include <vector>
45#include "linmath.h"
46
47#include "pi_tex_font.h"
48#include "ocpn_plugin.h"
49
50#ifdef ocpnUSE_GL
51#include <wx/glcanvas.h>
52#endif
53
54// class ViewPort;
55class GLUtesselator;
56
57void DrawGLThickLine(float x1, float y1, float x2, float y2, wxPen pen,
58 bool b_hiqual);
59
60//----------------------------------------------------------------------------
61// pi_ocpnDC
62//----------------------------------------------------------------------------
63
64class wxGLCanvas;
65
66class pi_ocpnDC {
67public:
68 pi_ocpnDC(wxGLCanvas &canvas);
69 pi_ocpnDC(wxDC &pdc);
70 pi_ocpnDC();
71
72 ~pi_ocpnDC();
73
74 void SetBackground(const wxBrush &brush);
75 void SetPen(const wxPen &pen);
76 void SetBrush(const wxBrush &brush);
77 void SetTextForeground(const wxColour &colour);
78 void SetFont(const wxFont &font);
79 static void SetGLAttrs(bool highQuality);
80 void SetGLStipple() const;
81 void SetVP(PlugIn_ViewPort *vp);
82 void SetDC(wxDC *dc_in) { dc = dc_in; }
83
84 const wxPen &GetPen() const;
85 const wxBrush &GetBrush() const;
86 const wxFont &GetFont() const;
87
88 void GetSize(wxCoord *width, wxCoord *height) const;
89
90 void DrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2,
91 bool b_hiqual = true);
92 void DrawLines(int n, wxPoint points[], wxCoord xoffset = 0,
93 wxCoord yoffset = 0, bool b_hiqual = true);
94
95 void StrokeLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2);
96 void StrokeLine(wxPoint a, wxPoint b) { StrokeLine(a.x, a.y, b.x, b.y); }
97 void StrokeLines(int n, wxPoint *points);
98
99 void Clear();
100 void DrawRectangle(wxCoord x, wxCoord y, wxCoord w, wxCoord h);
101 void DrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord w, wxCoord h,
102 wxCoord rr);
103 void DrawCircle(wxCoord x, wxCoord y, wxCoord radius);
104 void DrawCircle(const wxPoint &pt, wxCoord radius) {
105 DrawCircle(pt.x, pt.y, radius);
106 }
107 void StrokeCircle(wxCoord x, wxCoord y, wxCoord radius);
108
109 void DrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
110 void DrawPolygon(int n, wxPoint points[], wxCoord xoffset = 0,
111 wxCoord yoffset = 0, float scale = 1.0, float angle = 0.0);
112 void DrawPolygonTessellated(int n, wxPoint points[], wxCoord xoffset = 0,
113 wxCoord yoffset = 0);
114 void StrokePolygon(int n, wxPoint points[], wxCoord xoffset = 0,
115 wxCoord yoffset = 0, float scale = 1.0);
116
117 void DrawBitmap(const wxBitmap &bitmap, wxCoord x, wxCoord y, bool usemask);
118
119 void DrawText(const wxString &text, wxCoord x, wxCoord y);
120 void GetTextExtent(const wxString &string, wxCoord *w, wxCoord *h,
121 wxCoord *descent = nullptr,
122 wxCoord *externalLeading = nullptr,
123 wxFont *font = nullptr);
124
125 void ResetBoundingBox();
126 void CalcBoundingBox(wxCoord x, wxCoord y);
127
128 void DestroyClippingRegion() {}
129
130 wxDC *GetDC() const { return dc; }
131
132 void DrawGLLineArray(int n, float *vertex_array, float *color_array,
133 unsigned char *color_array_ub, bool b_hiqual);
134
135#ifdef ocpnUSE_GL
136 GLfloat *s_odc_tess_work_buf;
137
138 int s_odc_tess_vertex_idx;
139 int s_odc_tess_vertex_idx_this;
140 int s_odc_tess_buf_len;
141 GLenum s_odc_tess_mode;
142 int s_odc_nvertex;
143 vec4 s_odc_tess_color;
144 GLUtesselator *m_tobj;
145
146#endif
147 bool UsesGL() { return m_buseGL; };
148
149protected:
150 bool ConfigurePen();
151 bool ConfigureBrush();
152
153 void GLDrawBlendData(wxCoord x, wxCoord y, wxCoord w, wxCoord h, int format,
154 const unsigned char *data);
155
156 void drawrrhelperGLES2(wxCoord x0, wxCoord y0, wxCoord r, int quadrant,
157 int steps);
158
159 wxGLCanvas *glcanvas;
160 wxDC *dc;
161 wxPen m_pen;
162 wxBrush m_brush;
163 wxColour m_textforegroundcolour;
164 wxFont m_font;
165
166#ifdef ocpnUSE_GL
167 TexFont m_texfont;
168#endif
169 bool m_buseTex;
170
171#if wxUSE_GRAPHICS_CONTEXT
172 wxGraphicsContext *pgc;
173#endif
174
175 float *workBuf;
176 size_t workBufSize;
177 unsigned int workBufIndex;
178
179 wxSize m_vpSize;
180 bool m_buseGL;
181};
182
183#endif // PIOCPNDC_H__
Contains view parameters and status information for a chart display viewport.
PlugIn Object Definition/API.
OpenGL text rendering.