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