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