From aefee5d63138d3c160ec869f1b0325f8c8085a70 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Wed, 31 Dec 2025 14:05:16 +0100 Subject: [PATCH] added some functions to Category. --- src/lib/aqdiagram/graph/category.t2d | 322 +++++++++++++++++++++++++++ 1 file changed, 322 insertions(+) diff --git a/src/lib/aqdiagram/graph/category.t2d b/src/lib/aqdiagram/graph/category.t2d index 8ddfa7a..d4aa376 100644 --- a/src/lib/aqdiagram/graph/category.t2d +++ b/src/lib/aqdiagram/graph/category.t2d @@ -18,9 +18,11 @@
aqdiagram/aqdg_api.h
aqdiagram/graph/datapair.h
+
gwenhywfar/path.h
+ $(api) void $(struct_prefix)_AddDataPair($(struct_type) *st, AQDG_GRAPH_DATAPAIR *dp); @@ -32,18 +34,324 @@ void $(struct_prefix)_AddDataPair($(struct_type) *st, AQDG_GRAPH_DATAPAIR *dp) \n { \n if (st && dp) { \n + double v; \n + \n + v=AQDG_Graph_DataPair_GetValueY(dp); \n if (st->dataPairList==NULL) \n st->dataPairList=AQDG_Graph_DataPair_List_new(); \n AQDG_Graph_DataPair_List_Add(dp, st->dataPairList); \n + st->totalAmount+=v; \n + if (v<0.0) \n + st->negAmount+=v; \n + else \n + st->posAmount+=v; \n } \n } \n + + + + $(api) void $(struct_prefix)_AddValue($(struct_type) *st, double v); + + + + + + void $(struct_prefix)_AddValue($(struct_type) *st, double v) \n + { \n + if (st) { \n + st->totalAmount+=v; \n + if (v<0.0) \n + st->negAmount+=v; \n + else \n + st->posAmount+=v; \n + } \n + } \n + + + + + + + $(api) int $(struct_prefix)_Tree2_AddDataPair($(struct_type) *st, AQDG_GRAPH_DATAPAIR *dp); + + + + + + int $(struct_prefix)_Tree2_AddDataPair($(struct_type) *st, AQDG_GRAPH_DATAPAIR *dp) \n + { \n + uint32_t categoryId; \n + \n + categoryId=AQDG_Graph_DataPair_GetCategoryId(dp); \n + if (categoryId) { \n + AQDG_GRAPH_CATEGORY *cat; \n + \n + cat=AQDG_Graph_Category_Tree2_GetByCategoryId(st, categoryId); \n + if (cat) { \n + AQDG_Graph_Category_AddDataPair(cat, dp); \n + return 0; \n + } \n + } \n + return GWEN_ERROR_NOT_FOUND; \n + } \n + + + + + + + $(api) int $(struct_prefix)_Tree2_AddValue($(struct_type) *st, uint32_t categoryId, double v); + + + + + + int $(struct_prefix)_Tree2_AddValue($(struct_type) *st, uint32_t categoryId, double v) \n + { \n + if (categoryId) { \n + AQDG_GRAPH_CATEGORY *cat; \n + \n + cat=AQDG_Graph_Category_Tree2_GetByCategoryId(st, categoryId); \n + if (cat) { \n + AQDG_Graph_Category_AddValue(cat, v); \n + return 0; \n + } \n + } \n + return GWEN_ERROR_NOT_FOUND; \n + } \n + + + + + + + $(api) void $(struct_prefix)_Tree2_SumUpChildren($(struct_type) *st); + + + + + + void $(struct_prefix)_Tree2_SumUpChildren($(struct_type) *st) \n + { \n + if (st) { \n + $(struct_type) *child; \n + \n + child=$(struct_prefix)_Tree2_GetFirstChild(st); \n + while (child) { \n + $(struct_prefix)_Tree2_SumUpChildren(child); \n + st->totalAmount+=child->totalAmount; \n + st->negAmount+=child->negAmount; \n + st->posAmount+=child->posAmount; \n + child=AQDG_Graph_Category_Tree2_GetNext(child); \n + } \n + } \n + } \n + + + + + + + $(api) void $(struct_prefix)_Tree2_MarkCategoriesWithDataPairs($(struct_type) *st); + + + + + + void $(struct_prefix)_Tree2_MarkCategoriesWithDataPairs($(struct_type) *st) \n + { \n + while (st) { \n + if (st->dataPairList && AQDG_Graph_DataPair_List_GetCount(st->dataPairList)) \n + st->flags|=$(struct_type)_FLAGS_SELECTED; \n + st=AQDG_Graph_Category_Tree2_GetBelow(st); \n + } \n + } \n + + + + + + + $(api) void $(struct_prefix)_Tree2_SubFlags($(struct_type) *st, uint32_t flags); + + + + + + void $(struct_prefix)_Tree2_SubFlags($(struct_type) *st, uint32_t flags) \n + { \n + while (st) { \n + st->flags&=~flags; \n + st=AQDG_Graph_Category_Tree2_GetBelow(st); \n + } \n + } \n + + + + + + + $(api) void $(struct_prefix)_Tree2_SubFlagsDown($(struct_type) *st, uint32_t flags); + + + + + + void $(struct_prefix)_Tree2_SubFlagsDown($(struct_type) *st, uint32_t flags) \n + { \n + if (st) { \n + st->flags&=~flags; \n + st=$(struct_prefix)_Tree2_GetFirstChild(st); \n + while (st) { \n + $(struct_prefix)_Tree2_SubFlagsDown(st, flags); \n + st=AQDG_Graph_Category_Tree2_GetNext(st); \n + } \n + } \n + } \n + + + + + + + $(api) void $(struct_prefix)_Tree2_AddFlagsDown($(struct_type) *st, uint32_t flags); + + + + + + void $(struct_prefix)_Tree2_AddFlagsDown($(struct_type) *st, uint32_t flags) \n + { \n + if (st) { \n + st->flags|=flags; \n + st=$(struct_prefix)_Tree2_GetFirstChild(st); \n + while (st) { \n + $(struct_prefix)_Tree2_AddFlagsDown(st, flags); \n + st=AQDG_Graph_Category_Tree2_GetNext(st); \n + } \n + } \n + } \n + + + + + + + $(api) void $(struct_prefix)_Tree2_AddFlagsUp($(struct_type) *st, uint32_t flags); + + + + + + void $(struct_prefix)_Tree2_AddFlagsUp($(struct_type) *st, uint32_t flags) \n + { \n + while (st) { \n + st->flags|=flags; \n + st=AQDG_Graph_Category_Tree2_GetParent(st); \n + } \n + } \n + + + + + + + static void* _handlePath(const char *aname, void *data, int idx, uint32_t flags) \n + { \n + $(struct_type) *st; \n + \n + st=($(struct_type)*) data; \n + if (st) { \n + if (flags & GWEN_PATH_FLAGS_ROOT) { \n + while($(struct_prefix)_Tree2_GetParent(st)) \n + st=$(struct_prefix)_Tree2_GetParent(st); \n + return st; \n + } \n + \n + if (strcasecmp(aname, "..")==0) \n + return $(struct_prefix)_Tree2_GetParent(st); \n + else if (strcasecmp(aname, ".")==0) \n + return st; \n + \n + st=$(struct_prefix)_Tree2_GetFirstChild(st); \n + while(st) { \n + const char *s; \n + \n + s=$(struct_prefix)_GetName(st); \n + if (s && strcasecmp(s, aname)==0) \n + return st; \n + st=$(struct_prefix)_Tree2_GetNext(st); \n + } \n + } \n + return NULL; \n + } \n + + + + + + + $(api) $(struct_type)* $(struct_prefix)_Tree2_GetByPath(const $(struct_type) *st, const char *path); + + + + + + $(struct_type)* $(struct_prefix)_Tree2_GetByPath(const $(struct_type) *st, const char *path) \n + { \n + return GWEN_Path_HandleWithIdx(path, (void*) st, GWEN_PATH_FLAGS_NAMEMUSTEXIST, _handlePath); \n + } \n + + + + + + + $(api) void $(struct_prefix)_Tree2_CollectChildrenDataPairs($(struct_type) *st); + + + + + + void $(struct_prefix)_Tree2_CollectChildrenDataPairs($(struct_type) *st) \n + { \n + if (st) { \n + $(struct_type) *child; \n + \n + child=$(struct_prefix)_Tree2_GetFirstChild(st); \n + while(child) { \n + $(struct_prefix)_Tree2_CollectChildrenDataPairs(child); \n + if (child->dataPairList) { \n + AQDG_GRAPH_DATAPAIR *dp; \n + \n + while( (dp=AQDG_Graph_DataPair_List_First(child->dataPairList)) ){ \n + AQDG_Graph_DataPair_List_Del(dp); \n + $(struct_prefix)_AddDataPair(st, dp); \n + } \n + } \n + child=$(struct_prefix)_Tree2_GetNext(child); \n + } \n + } \n + } \n + + + + + + + + + + + + @@ -60,6 +368,13 @@ public + + public + own with_getbymember + const dup + const + + public own with_getbymember @@ -67,6 +382,13 @@ const + + 0.0 + 0.0 + public + sortbymember + + 0.0 0.0