OpenCPN Partial API docs
Loading...
Searching...
No Matches
ocpn_region.cpp File Reference

Implement ocpn_region.h – Opencpn region handling. More...

#include <wx/wxprec.h>
#include <wx/region.h>
#include "ocpn_region.h"
#include <wx/log.h>

Go to the source code of this file.

Classes

struct  _OGdkPoint
 
struct  _OGdkRectangle
 
struct  _OGdkSegment
 
struct  _OGdkRegion
 
struct  _OPOINTBLOCK
 
struct  OBRESINFO
 
struct  _OEdgeTableEntry
 
struct  _OScanLineList
 
struct  OEdgeTable
 
struct  _OScanLineListBlock
 
class  OCPNRegionRefData
 

Macros

#define EMPTY_REGION(pReg)   pReg->numRects = 0
 
#define REGION_NOT_EMPTY(pReg)   pReg->numRects
 
#define NUMPTSTOBUFFER   200
 
#define INBOX(r, x, y)    ((((r).x2 > x)) && (((r).x1 <= x)) && (((r).y2 > y)) && (((r).y1 <= y)))
 
#define EXTENTCHECK(r1, r2)
 
#define OGROWREGION(reg, nRects)
 
#define OMEMCHECK(reg, rect, firstrect)
 
#define MIN(a, b)   wxMin(a, b)
 
#define MAX(a, b)   wxMax(a, b)
 
#define OBRESINITPGON(dy, x1, x2, xStart, d, m, m1, incr1, incr2)
 
#define OBRESINCRPGON(d, minval, m, m1, incr1, incr2)
 
#define OBRESINITPGONSTRUCT(dmaj, min1, min2, bres)
 
#define OBRESINCRPGONSTRUCT(bres)
 
#define CLOCKWISE   1
 
#define COUNTERCLOCKWISE   -1
 
#define SLLSPERBLOCK   25
 
#define OEVALUATEEDGEWINDING(pAET, pPrevAET, y, fixWAET)
 
#define OEVALUATEEDGEEVENODD(pAET, pPrevAET, y)
 
#define M_REGIONDATA   ((OCPNRegionRefData *)m_refData)
 
#define M_REGIONDATA_OF(rgn)   ((OCPNRegionRefData *)(rgn.m_refData))
 
#define M_REGIONDATA   ((OCPNRegionRefData *)m_refData)
 

Typedefs

typedef struct _OGdkPoint OGdkPoint
 
typedef struct _OGdkRectangle OGdkRectangle
 
typedef struct _OGdkSegment OGdkSegment
 
typedef OGdkSegment OGdkRegionBox
 
typedef struct _OGdkRegion OGdkRegion
 
typedef struct _OPOINTBLOCK OPOINTBLOCK
 
typedef struct _OEdgeTableEntry OEdgeTableEntry
 
typedef struct _OScanLineList OScanLineList
 
typedef struct _OScanLineListBlock OScanLineListBlock
 

Enumerations

enum  OGdkFillRule { OGDK_EVEN_ODD_RULE , OGDK_WINDING_RULE }
 
enum  OGdkOverlapType { OGDK_OVERLAP_RECTANGLE_IN , OGDK_OVERLAP_RECTANGLE_OUT , OGDK_OVERLAP_RECTANGLE_PART }
 

Functions

OGdkRegiongdk_region_copy (const OGdkRegion *region)
 
void gdk_region_destroy (OGdkRegion *region)
 
OGdkRegiongdk_region_rectangle (const OGdkRectangle *rectangle)
 
bool ogdk_region_equal (const OGdkRegion *region1, const OGdkRegion *region2)
 
bool gdk_region_point_in (const OGdkRegion *region, int x, int y)
 
OGdkOverlapType gdk_region_rect_in (const OGdkRegion *region, const OGdkRectangle *rectangle)
 
void gdk_region_offset (OGdkRegion *region, int dx, int dy)
 
void gdk_region_union_with_rect (OGdkRegion *region, const OGdkRectangle *rect)
 
void gdk_region_union (OGdkRegion *source1, const OGdkRegion *source2)
 
void gdk_region_intersect (OGdkRegion *source1, const OGdkRegion *source2)
 
OGdkRegiongdk_region_polygon (const OGdkPoint *points, int n_points, OGdkFillRule fill_rule)
 
OGdkRegiongdk_region_new ()
 
void gdk_region_subtract (OGdkRegion *source1, const OGdkRegion *source2)
 
bool gdk_region_empty (const OGdkRegion *region)
 
void gdk_region_get_rectangles (const OGdkRegion *region, OGdkRectangle **rectangles, int *n_rectangles)
 
void gdk_region_get_clipbox (const OGdkRegion *region, OGdkRectangle *rectangle)
 

Detailed Description

Implement ocpn_region.h – Opencpn region handling.

Definition in file ocpn_region.cpp.

Macro Definition Documentation

◆ CLOCKWISE

#define CLOCKWISE   1

Definition at line 235 of file ocpn_region.cpp.

◆ COUNTERCLOCKWISE

#define COUNTERCLOCKWISE   -1

Definition at line 236 of file ocpn_region.cpp.

◆ EMPTY_REGION

#define EMPTY_REGION (   pReg)    pReg->numRects = 0

Definition at line 37 of file ocpn_region.cpp.

◆ EXTENTCHECK

#define EXTENTCHECK (   r1,
  r2 
)
Value:
((r1)->x2 > (r2)->x1 && (r1)->x1 < (r2)->x2 && (r1)->y2 > (r2)->y1 && \
(r1)->y1 < (r2)->y2)

Definition at line 96 of file ocpn_region.cpp.

◆ INBOX

#define INBOX (   r,
  x,
 
)     ((((r).x2 > x)) && (((r).x1 <= x)) && (((r).y2 > y)) && (((r).y1 <= y)))

Definition at line 89 of file ocpn_region.cpp.

◆ M_REGIONDATA [1/2]

#define M_REGIONDATA   ((OCPNRegionRefData *)m_refData)

Definition at line 364 of file ocpn_region.cpp.

◆ M_REGIONDATA [2/2]

#define M_REGIONDATA   ((OCPNRegionRefData *)m_refData)

Definition at line 364 of file ocpn_region.cpp.

◆ M_REGIONDATA_OF

#define M_REGIONDATA_OF (   rgn)    ((OCPNRegionRefData *)(rgn.m_refData))

Definition at line 365 of file ocpn_region.cpp.

◆ MAX

#define MAX (   a,
 
)    wxMax(a, b)

Definition at line 143 of file ocpn_region.cpp.

◆ MIN

#define MIN (   a,
 
)    wxMin(a, b)

Definition at line 139 of file ocpn_region.cpp.

◆ NUMPTSTOBUFFER

#define NUMPTSTOBUFFER   200

Definition at line 78 of file ocpn_region.cpp.

◆ OBRESINCRPGON

#define OBRESINCRPGON (   d,
  minval,
  m,
  m1,
  incr1,
  incr2 
)
Value:
{ \
if (m1 > 0) { \
if (d > 0) { \
minval += m1; \
d += incr1; \
} else { \
minval += m; \
d += incr2; \
} \
} else { \
if (d >= 0) { \
minval += m1; \
d += incr1; \
} else { \
minval += m; \
d += incr2; \
} \
} \
}

Definition at line 189 of file ocpn_region.cpp.

◆ OBRESINCRPGONSTRUCT

#define OBRESINCRPGONSTRUCT (   bres)
Value:
OBRESINCRPGON(bres.d, bres.minor_axis, bres.m, bres.m1, bres.incr1, \
bres.incr2)

Definition at line 228 of file ocpn_region.cpp.

◆ OBRESINITPGON

#define OBRESINITPGON (   dy,
  x1,
  x2,
  xStart,
  d,
  m,
  m1,
  incr1,
  incr2 
)
Value:
{ \
int dx; /* local storage */ \
\
/* \
* if the edge is horizontal, then it is ignored \
* and assumed not to be processed. Otherwise, do this stuff. \
*/ \
if ((dy) != 0) { \
xStart = (x1); \
dx = (x2) - xStart; \
if (dx < 0) { \
m = dx / (dy); \
m1 = m - 1; \
incr1 = -2 * dx + 2 * (dy) * m1; \
incr2 = -2 * dx + 2 * (dy) * m; \
d = 2 * m * (dy) - 2 * dx - 2 * (dy); \
} else { \
m = dx / (dy); \
m1 = m + 1; \
incr1 = 2 * dx - 2 * (dy) * m1; \
incr2 = 2 * dx - 2 * (dy) * m; \
d = -2 * m * (dy) + 2 * dx; \
} \
} \
}

Definition at line 165 of file ocpn_region.cpp.

◆ OBRESINITPGONSTRUCT

#define OBRESINITPGONSTRUCT (   dmaj,
  min1,
  min2,
  bres 
)
Value:
OBRESINITPGON(dmaj, min1, min2, bres.minor_axis, bres.d, bres.m, bres.m1, \
bres.incr1, bres.incr2)

Definition at line 224 of file ocpn_region.cpp.

◆ OEVALUATEEDGEEVENODD

#define OEVALUATEEDGEEVENODD (   pAET,
  pPrevAET,
 
)
Value:
{ \
if (pAET->ymax == y) { /* leaving this edge */ \
pPrevAET->next = pAET->next; \
pAET = pPrevAET->next; \
if (pAET) pAET->back = pPrevAET; \
} else { \
OBRESINCRPGONSTRUCT(pAET->bres); \
pPrevAET = pAET; \
pAET = pAET->next; \
} \
}

Definition at line 305 of file ocpn_region.cpp.

◆ OEVALUATEEDGEWINDING

#define OEVALUATEEDGEWINDING (   pAET,
  pPrevAET,
  y,
  fixWAET 
)
Value:
{ \
if (pAET->ymax == y) { /* leaving this edge */ \
pPrevAET->next = pAET->next; \
pAET = pPrevAET->next; \
fixWAET = 1; \
if (pAET) pAET->back = pPrevAET; \
} else { \
OBRESINCRPGONSTRUCT(pAET->bres); \
pPrevAET = pAET; \
pAET = pAET->next; \
} \
}

Definition at line 284 of file ocpn_region.cpp.

◆ OGROWREGION

#define OGROWREGION (   reg,
  nRects 
)
Value:
{ \
if ((nRects) == 0) { \
if ((reg)->rects != &(reg)->extents) { \
free((reg)->rects); \
(reg)->rects = &(reg)->extents; \
} \
} else if ((reg)->rects == &(reg)->extents) { \
(reg)->rects = (OGdkRegionBox *)malloc(nRects * sizeof(OGdkRegionBox)); \
(reg)->rects[0] = (reg)->extents; \
} else \
(reg)->rects = (OGdkRegionBox *)realloc((reg)->rects, \
sizeof(OGdkRegionBox) * nRects); \
(reg)->size = (nRects); \
}

Definition at line 111 of file ocpn_region.cpp.

◆ OMEMCHECK

#define OMEMCHECK (   reg,
  rect,
  firstrect 
)
Value:
{ \
if ((reg)->numRects >= ((reg)->size - 1)) { \
OGROWREGION(reg, 2 * (reg)->size); \
(rect) = &(firstrect)[(reg)->numRects]; \
} \
}

Definition at line 130 of file ocpn_region.cpp.

◆ REGION_NOT_EMPTY

#define REGION_NOT_EMPTY (   pReg)    pReg->numRects

Definition at line 38 of file ocpn_region.cpp.

◆ SLLSPERBLOCK

#define SLLSPERBLOCK   25

Definition at line 264 of file ocpn_region.cpp.

Typedef Documentation

◆ OGdkPoint

typedef struct _OGdkPoint OGdkPoint

Definition at line 40 of file ocpn_region.cpp.

◆ OGdkRectangle

typedef struct _OGdkRectangle OGdkRectangle

Definition at line 46 of file ocpn_region.cpp.

◆ OGdkRegion

typedef struct _OGdkRegion OGdkRegion

Definition at line 66 of file ocpn_region.cpp.

◆ OGdkRegionBox

Definition at line 64 of file ocpn_region.cpp.

◆ OGdkSegment

typedef struct _OGdkSegment OGdkSegment

Definition at line 56 of file ocpn_region.cpp.

Enumeration Type Documentation

◆ OGdkFillRule

enum OGdkFillRule

Definition at line 29 of file ocpn_region.cpp.

◆ OGdkOverlapType

enum OGdkOverlapType

Definition at line 31 of file ocpn_region.cpp.