/* Copyright (C) 2019-2020, Dirk Krause SPDX-License-Identifier: BSD-3-Clause */ /* WARNING: This file was generated by the dkct program (see http://dktools.sourceforge.net/ for details). Changes you make here will be lost if dkct is run again! You should modify the original source and run dkct on it. Original source: WxdkdrawComp.cpt */ /** @file WxdkdrawComp.cpp The WxdkdrawComp module. */ #line 92 "WxdkdrawComp.cpt" #include "wxdkdraw.h" #line 98 "WxdkdrawComp.cpt" int drawobj_object_category(int8_t ot) { int back = WXD_OC_CONTROL; #line 106 "WxdkdrawComp.cpt" switch (ot) { case WXD_OT_TEXT : { back = WXD_OC_TEXT ; } break; case WXD_OT_POLYLINE : case WXD_OT_O_SPLINE : case WXD_OT_O_ARC : { back = WXD_OC_OPEN ; } break; case WXD_OT_POLYGON : case WXD_OT_C_SPLINE : case WXD_OT_C_ARC : case WXD_OT_CIRCLE : case WXD_OT_ELLIPSE : case WXD_OT_BOX : { back = WXD_OC_CLOSED ; } break; case WXD_OT_IMAGE : { back = WXD_OC_IMAGE ; } break; } #line 122 "WxdkdrawComp.cpt" return back; } static int cmp_u8(uint8_t a, uint8_t b) { return ((a > b) ? (1) : ((a < b) ? (-1) : (0))); } #if 0 static int cmp_i8(int8_t a, int8_t b) { return ((a > b) ? (1) : ((a < b) ? (-1) : (0))); } #endif #if 0 static int cmp_u16(uint16_t a, uint16_t b) { return ((a > b) ? (1) : ((a < b) ? (-1) : (0))); } #endif static int cmp_i16(int16_t a, int16_t b) { return ((a > b) ? (1) : ((a < b) ? (-1) : (0))); } #if 0 static int cmp_int(int a, int b) { return ((a > b) ? (1) : ((a < b) ? (-1) : (0))); } #endif int drawobj_compare_object(const void *l, const void *r, int DK4_ARG_UNUSED(cr)) { const Wxd_object_t *pl; /* Left object */ const Wxd_object_t *pr; /* Right object */ #if 0 int cal; /* Left object category */ int car; /* Right object category */ #endif int back = 0; /* Comparison result */ DK4_UNUSED_ARG(cr) #line 187 "WxdkdrawComp.cpt" if (NULL != l) { if (NULL != r) { pl = (const Wxd_object_t *)l; pr = (const Wxd_object_t *)r; back = cmp_i16(pl->lay, pr->lay); /* 2019-05-10 Modification Objects in the flat storage are compared by layer number only. Otherwise we would need to change object order on each style modification. */ #if 0 if (0 == back) { cal = drawobj_object_category(pl->ot); car = drawobj_object_category(pr->ot); back = cmp_int(cal, car); if (0 == back) { back = cmp_u16(pl->lw, pr->lw); if (0 == back) { back = cmp_u8(pl->ls, pr->ls); if (0 == back) { back = cmp_u8(pl->sl, pr->sl); if (0 == back) { back = cmp_u8(pl->js, pr->js); if (0 == back) { back = cmp_u8(pl->cs, pr->cs); if (0 == back) { back = cmp_u8(pl->fs, pr->fs); if (0 == back) { back = cmp_u8(pl->ml, pr->ml); if (0 == back) { back = cmp_u8(pl->sc[0], pr->sc[0]); if (0 == back) { back = cmp_u8(pl->sc[1], pr->sc[1]); if (0 == back) { back = cmp_u8(pl->sc[2], pr->sc[2]); if (0 == back) { back = cmp_u8(pl->fc[0], pr->fc[0]); if (0 == back) { back = cmp_u8(pl->fc[1], pr->fc[1]); if (0 == back) { back = cmp_u8(pl->fc[2], pr->fc[2]); if (0 == back) { back = cmp_i8(pl->ot, pr->ot); } } } } } } } } } } } } } } } #endif } else { back = 1; } } else { if (NULL != r) { back = -1; } } #line 258 "WxdkdrawComp.cpt" return back; } int drawobj_compare_stipples(const void *l, const void *r, int DK4_ARG_UNUSED(cr)) { Wxd_stipple_t const *pl; /* Left stipple */ Wxd_stipple_t const *pr; /* Right stipple */ int back = 0; /* Comparison result */ DK4_UNUSED_ARG(cr) if (NULL != l) { if (NULL != r) { pl = (Wxd_stipple_t const *)l; pr = (Wxd_stipple_t const *)r; for (size_t i = 0; ((0 == back) && (i < 7)); i++) { back = cmp_u8(pl->cd[i], pr->cd[i]); } } else { back = 1; } } else { if (NULL != r) { back = -1; } } return back; } int drawobj_compare_layers(const void *l, const void *r, int cr) { const Wxd_layer_t *pl; /* Left layer structure */ const Wxd_layer_t *pr; /* Right layer structure */ const int16_t *pnum; /* Address of layer number variable */ int back = 0; /* Comparison result */ if (NULL != l) { if (NULL != r) { pl = (const Wxd_layer_t *)l; switch (cr) { case 1: { pnum = (const int16_t *)r; if (pl->lay > *pnum) { back = 1; } else { if (pl->lay < *pnum) { back = -1; } } } break; default: { pr = (const Wxd_layer_t *)r; if (pl->lay > pr->lay) { back = 1; } else { if (pl->lay < pr->lay) { back = -1; } } } break; } } else { back = 1; } } else { if (NULL != r) { back = -1; } } return back; } /* vim: set ai sw=4 ts=4 : */