OpenCPN Partial API docs
Loading...
Searching...
No Matches
ocpnDC Class Reference

Device context class that can use either wxDC or OpenGL for drawing. More...

#include <ocpndc.h>

Public Member Functions

 ocpnDC (glChartCanvas &canvas)
 
 ocpnDC (wxGLCanvas &canvas)
 
 ocpnDC (wxDC &pdc)
 
void Init ()
 
void SetGLCanvas (glChartCanvas *canvas)
 
void SetBackground (const wxBrush &brush)
 
void SetPen (const wxPen &pen)
 
void SetBrush (const wxBrush &brush)
 
void SetTextForeground (const wxColour &colour)
 
void SetFont (const wxFont &font)
 
void SetGLStipple () const
 
const wxPen & GetPen () const
 
const wxBrush & GetBrush () const
 
const wxFont & GetFont () const
 
void GetSize (wxCoord *width, wxCoord *height) const
 
void DrawLine (wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, bool b_hiqual=true)
 Draw a line between two points using either wxDC or OpenGL.
 
void DrawLines (int n, wxPoint points[], wxCoord xoffset=0, wxCoord yoffset=0, bool b_hiqual=true)
 
void DrawGLThickLine (float x1, float y1, float x2, float y2, wxPen pen, bool b_hiqual)
 
void DrawGLThickLines (int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset, wxPen pen, bool b_hiqual)
 
void StrokeLine (wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
 
void StrokeLine (wxPoint a, wxPoint b)
 
void StrokeLines (int n, wxPoint *points)
 
void Clear ()
 
void DrawRectangle (wxCoord x, wxCoord y, wxCoord w, wxCoord h)
 
void DrawRoundedRectangle (wxCoord x, wxCoord y, wxCoord w, wxCoord h, wxCoord rr)
 
void DrawCircle (wxCoord x, wxCoord y, wxCoord radius)
 
void DrawCircle (const wxPoint &pt, wxCoord radius)
 
void StrokeCircle (wxCoord x, wxCoord y, wxCoord radius)
 
void DrawEllipse (wxCoord x, wxCoord y, wxCoord width, wxCoord height)
 
void DrawPolygon (int n, wxPoint points[], wxCoord xoffset=0, wxCoord yoffset=0, float scale=1.0, float angle=0.0)
 
void DrawPolygonTessellated (int n, wxPoint points[], wxCoord xoffset=0, wxCoord yoffset=0)
 
void StrokePolygon (int n, wxPoint points[], wxCoord xoffset=0, wxCoord yoffset=0, float scale=1.0)
 
void DrawBitmap (const wxBitmap &bitmap, wxCoord x, wxCoord y, bool usemask)
 
void DrawText (const wxString &text, wxCoord x, wxCoord y, float angle=0.0)
 
void GetTextExtent (const wxString &string, wxCoord *w, wxCoord *h, wxCoord *descent=NULL, wxCoord *externalLeading=NULL, wxFont *font=NULL)
 
void ResetBoundingBox ()
 
void CalcBoundingBox (wxCoord x, wxCoord y)
 
void DestroyClippingRegion ()
 
wxDC * GetDC () const
 
void SetDPIFactor (double factor)
 
void SetVP (ViewPort vp)
 

Static Public Member Functions

static void SetGLAttrs (bool highQuality)
 

Public Attributes

int m_canvasIndex
 

Protected Member Functions

bool ConfigurePen ()
 
bool ConfigureBrush ()
 
void GLDrawBlendData (wxCoord x, wxCoord y, wxCoord w, wxCoord h, int format, const unsigned char *data)
 
void drawrrhelperGLES2 (wxCoord x0, wxCoord y0, wxCoord r, int quadrant, int steps)
 
void BuildShaders ()
 

Protected Attributes

glChartCanvasm_glchartCanvas
 
wxGLCanvas * m_glcanvas
 
wxDC * dc
 
wxPen m_pen
 
wxBrush m_brush
 
wxColour m_textforegroundcolour
 
wxFont m_font
 
bool m_buseTex
 
float * workBuf
 
size_t workBufSize
 
unsigned int workBufIndex
 
double m_dpi_factor
 
ViewPort m_vp
 

Detailed Description

Device context class that can use either wxDC or OpenGL for drawing.

Provides a unified interface for drawing operations, abstracting the underlying context. Allows seamless switching between contexts and offers various drawing methods.

Definition at line 64 of file ocpndc.h.

Constructor & Destructor Documentation

◆ ocpnDC() [1/4]

ocpnDC::ocpnDC ( glChartCanvas canvas)

Definition at line 80 of file ocpndc.cpp.

◆ ocpnDC() [2/4]

ocpnDC::ocpnDC ( wxGLCanvas &  canvas)

Definition at line 95 of file ocpndc.cpp.

◆ ocpnDC() [3/4]

ocpnDC::ocpnDC ( wxDC &  pdc)

Definition at line 107 of file ocpndc.cpp.

◆ ocpnDC() [4/4]

ocpnDC::ocpnDC ( )

Definition at line 127 of file ocpndc.cpp.

◆ ~ocpnDC()

ocpnDC::~ocpnDC ( )

Definition at line 139 of file ocpndc.cpp.

Member Function Documentation

◆ CalcBoundingBox()

void ocpnDC::CalcBoundingBox ( wxCoord  x,
wxCoord  y 
)

Definition at line 1872 of file ocpndc.cpp.

◆ Clear()

void ocpnDC::Clear ( )

Definition at line 187 of file ocpndc.cpp.

◆ ConfigureBrush()

bool ocpnDC::ConfigureBrush ( )
protected

Definition at line 1891 of file ocpndc.cpp.

◆ ConfigurePen()

bool ocpnDC::ConfigurePen ( )
protected

Definition at line 1876 of file ocpndc.cpp.

◆ DestroyClippingRegion()

void ocpnDC::DestroyClippingRegion ( )
inline

Definition at line 147 of file ocpndc.h.

◆ DrawBitmap()

void ocpnDC::DrawBitmap ( const wxBitmap &  bitmap,
wxCoord  x,
wxCoord  y,
bool  usemask 
)

Definition at line 1562 of file ocpndc.cpp.

◆ DrawCircle() [1/2]

void ocpnDC::DrawCircle ( const wxPoint &  pt,
wxCoord  radius 
)
inline

Definition at line 124 of file ocpndc.h.

◆ DrawCircle() [2/2]

void ocpnDC::DrawCircle ( wxCoord  x,
wxCoord  y,
wxCoord  radius 
)

Definition at line 1047 of file ocpndc.cpp.

◆ DrawEllipse()

void ocpnDC::DrawEllipse ( wxCoord  x,
wxCoord  y,
wxCoord  width,
wxCoord  height 
)

Definition at line 1146 of file ocpndc.cpp.

◆ DrawGLThickLine()

void ocpnDC::DrawGLThickLine ( float  x1,
float  y1,
float  x2,
float  y2,
wxPen  pen,
bool  b_hiqual 
)

Definition at line 360 of file ocpndc.cpp.

◆ DrawGLThickLines()

void ocpnDC::DrawGLThickLines ( int  n,
wxPoint  points[],
wxCoord  xoffset,
wxCoord  yoffset,
wxPen  pen,
bool  b_hiqual 
)

Definition at line 698 of file ocpndc.cpp.

◆ DrawLine()

void ocpnDC::DrawLine ( wxCoord  x1,
wxCoord  y1,
wxCoord  x2,
wxCoord  y2,
bool  b_hiqual = true 
)

Draw a line between two points using either wxDC or OpenGL.

When using OpenGL, this function supports different line qualities and widths. For high quality lines (b_hiqual=true), it enables anti-aliasing and line smoothing. The function also handles dashed lines via line stippling in OpenGL mode.

Parameters
x1The x-coordinate of the starting point, in physical pixels.
y1The y-coordinate of the starting point, in physical pixels.
x2The x-coordinate of the ending point, in physical pixels.
y2The y-coordinate of the ending point, in physical pixels.
b_hiqualIf true, enables high quality rendering with anti-aliasing and line smoothing in OpenGL mode. Has no effect in wxDC mode.

Definition at line 476 of file ocpndc.cpp.

◆ DrawLines()

void ocpnDC::DrawLines ( int  n,
wxPoint  points[],
wxCoord  xoffset = 0,
wxCoord  yoffset = 0,
bool  b_hiqual = true 
)

Definition at line 713 of file ocpndc.cpp.

◆ DrawPolygon()

void ocpnDC::DrawPolygon ( int  n,
wxPoint  points[],
wxCoord  xoffset = 0,
wxCoord  yoffset = 0,
float  scale = 1.0,
float  angle = 0.0 
)

Definition at line 1167 of file ocpndc.cpp.

◆ DrawPolygonTessellated()

void ocpnDC::DrawPolygonTessellated ( int  n,
wxPoint  points[],
wxCoord  xoffset = 0,
wxCoord  yoffset = 0 
)

Definition at line 1460 of file ocpndc.cpp.

◆ DrawRectangle()

void ocpnDC::DrawRectangle ( wxCoord  x,
wxCoord  y,
wxCoord  w,
wxCoord  h 
)

Definition at line 883 of file ocpndc.cpp.

◆ DrawRoundedRectangle()

void ocpnDC::DrawRoundedRectangle ( wxCoord  x,
wxCoord  y,
wxCoord  w,
wxCoord  h,
wxCoord  rr 
)

Definition at line 963 of file ocpndc.cpp.

◆ drawrrhelperGLES2()

void ocpnDC::drawrrhelperGLES2 ( wxCoord  x0,
wxCoord  y0,
wxCoord  r,
int  quadrant,
int  steps 
)
protected

Definition at line 926 of file ocpndc.cpp.

◆ DrawText()

void ocpnDC::DrawText ( const wxString &  text,
wxCoord  x,
wxCoord  y,
float  angle = 0.0 
)

Definition at line 1639 of file ocpndc.cpp.

◆ GetBrush()

const wxBrush & ocpnDC::GetBrush ( ) const

Definition at line 260 of file ocpndc.cpp.

◆ GetDC()

wxDC * ocpnDC::GetDC ( ) const
inline

Definition at line 149 of file ocpndc.h.

◆ GetFont()

const wxFont & ocpnDC::GetFont ( ) const

Definition at line 265 of file ocpndc.cpp.

◆ GetPen()

const wxPen & ocpnDC::GetPen ( ) const

Definition at line 255 of file ocpndc.cpp.

◆ GetSize()

void ocpnDC::GetSize ( wxCoord *  width,
wxCoord *  height 
) const

Definition at line 270 of file ocpndc.cpp.

◆ GetTextExtent()

void ocpnDC::GetTextExtent ( const wxString &  string,
wxCoord *  w,
wxCoord *  h,
wxCoord *  descent = NULL,
wxCoord *  externalLeading = NULL,
wxFont *  font = NULL 
)

Definition at line 1834 of file ocpndc.cpp.

◆ GLDrawBlendData()

void ocpnDC::GLDrawBlendData ( wxCoord  x,
wxCoord  y,
wxCoord  w,
wxCoord  h,
int  format,
const unsigned char *  data 
)
protected

Definition at line 1903 of file ocpndc.cpp.

◆ Init()

void ocpnDC::Init ( )

Definition at line 155 of file ocpndc.cpp.

◆ ResetBoundingBox()

void ocpnDC::ResetBoundingBox ( )

Definition at line 1868 of file ocpndc.cpp.

◆ SetBackground()

void ocpnDC::SetBackground ( const wxBrush &  brush)

Definition at line 209 of file ocpndc.cpp.

◆ SetBrush()

void ocpnDC::SetBrush ( const wxBrush &  brush)

Definition at line 234 of file ocpndc.cpp.

◆ SetDPIFactor()

void ocpnDC::SetDPIFactor ( double  factor)
inline

Definition at line 150 of file ocpndc.h.

◆ SetFont()

void ocpnDC::SetFont ( const wxFont &  font)

Definition at line 248 of file ocpndc.cpp.

◆ SetGLAttrs()

void ocpnDC::SetGLAttrs ( bool  highQuality)
static

Definition at line 285 of file ocpndc.cpp.

◆ SetGLStipple()

void ocpnDC::SetGLStipple ( ) const

Definition at line 302 of file ocpndc.cpp.

◆ SetPen()

void ocpnDC::SetPen ( const wxPen &  pen)

Definition at line 224 of file ocpndc.cpp.

◆ SetTextForeground()

void ocpnDC::SetTextForeground ( const wxColour &  colour)

Definition at line 241 of file ocpndc.cpp.

◆ SetVP()

void ocpnDC::SetVP ( ViewPort  vp)

Definition at line 1917 of file ocpndc.cpp.

◆ StrokeCircle()

void ocpnDC::StrokeCircle ( wxCoord  x,
wxCoord  y,
wxCoord  radius 
)

Definition at line 1128 of file ocpndc.cpp.

◆ StrokeLine() [1/2]

void ocpnDC::StrokeLine ( wxCoord  x1,
wxCoord  y1,
wxCoord  x2,
wxCoord  y2 
)

Definition at line 850 of file ocpndc.cpp.

◆ StrokeLine() [2/2]

void ocpnDC::StrokeLine ( wxPoint  a,
wxPoint  b 
)
inline

Definition at line 116 of file ocpndc.h.

◆ StrokeLines()

void ocpnDC::StrokeLines ( int  n,
wxPoint *  points 
)

Definition at line 863 of file ocpndc.cpp.

◆ StrokePolygon()

void ocpnDC::StrokePolygon ( int  n,
wxPoint  points[],
wxCoord  xoffset = 0,
wxCoord  yoffset = 0,
float  scale = 1.0 
)

Definition at line 1537 of file ocpndc.cpp.

Member Data Documentation

◆ dc

wxDC* ocpnDC::dc
protected

Definition at line 188 of file ocpndc.h.

◆ m_brush

wxBrush ocpnDC::m_brush
protected

Definition at line 190 of file ocpndc.h.

◆ m_buseTex

bool ocpnDC::m_buseTex
protected

Definition at line 194 of file ocpndc.h.

◆ m_canvasIndex

int ocpnDC::m_canvasIndex

Definition at line 168 of file ocpndc.h.

◆ m_dpi_factor

double ocpnDC::m_dpi_factor
protected

Definition at line 203 of file ocpndc.h.

◆ m_font

wxFont ocpnDC::m_font
protected

Definition at line 192 of file ocpndc.h.

◆ m_glcanvas

wxGLCanvas* ocpnDC::m_glcanvas
protected

Definition at line 186 of file ocpndc.h.

◆ m_glchartCanvas

glChartCanvas* ocpnDC::m_glchartCanvas
protected

Definition at line 185 of file ocpndc.h.

◆ m_pen

wxPen ocpnDC::m_pen
protected

Definition at line 189 of file ocpndc.h.

◆ m_textforegroundcolour

wxColour ocpnDC::m_textforegroundcolour
protected

Definition at line 191 of file ocpndc.h.

◆ m_vp

ViewPort ocpnDC::m_vp
protected

Definition at line 204 of file ocpndc.h.

◆ workBuf

float* ocpnDC::workBuf
protected

Definition at line 200 of file ocpndc.h.

◆ workBufIndex

unsigned int ocpnDC::workBufIndex
protected

Definition at line 202 of file ocpndc.h.

◆ workBufSize

size_t ocpnDC::workBufSize
protected

Definition at line 201 of file ocpndc.h.


The documentation for this class was generated from the following files: