added some functions to Category.

This commit is contained in:
Martin Preuss
2025-12-31 14:05:16 +01:00
parent ba79f68819
commit aefee5d631

View File

@@ -18,9 +18,11 @@
<headers> <headers>
<header type="sys" loc="pre">aqdiagram/aqdg_api.h</header> <header type="sys" loc="pre">aqdiagram/aqdg_api.h</header>
<header type="sys" loc="pre">aqdiagram/graph/datapair.h</header> <header type="sys" loc="pre">aqdiagram/graph/datapair.h</header>
<header type="sys" loc="pre">gwenhywfar/path.h</header>
</headers> </headers>
<inlines> <inlines>
<inline loc="end" access="public"> <inline loc="end" access="public">
<content> <content>
$(api) void $(struct_prefix)_AddDataPair($(struct_type) *st, AQDG_GRAPH_DATAPAIR *dp); $(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 void $(struct_prefix)_AddDataPair($(struct_type) *st, AQDG_GRAPH_DATAPAIR *dp) \n
{ \n { \n
if (st &amp;&amp; dp) { \n if (st &amp;&amp; dp) { \n
double v; \n
\n
v=AQDG_Graph_DataPair_GetValueY(dp); \n
if (st-&gt;dataPairList==NULL) \n if (st-&gt;dataPairList==NULL) \n
st-&gt;dataPairList=AQDG_Graph_DataPair_List_new(); \n st-&gt;dataPairList=AQDG_Graph_DataPair_List_new(); \n
AQDG_Graph_DataPair_List_Add(dp, st-&gt;dataPairList); \n AQDG_Graph_DataPair_List_Add(dp, st-&gt;dataPairList); \n
st-&gt;totalAmount+=v; \n
if (v&lt;0.0) \n
st-&gt;negAmount+=v; \n
else \n
st-&gt;posAmount+=v; \n
} \n } \n
} \n } \n
</content> </content>
</inline> </inline>
<inline loc="end" access="public">
<content>
$(api) void $(struct_prefix)_AddValue($(struct_type) *st, double v);
</content>
</inline>
<inline loc="code">
<content>
void $(struct_prefix)_AddValue($(struct_type) *st, double v) \n
{ \n
if (st) { \n
st-&gt;totalAmount+=v; \n
if (v&lt;0.0) \n
st-&gt;negAmount+=v; \n
else \n
st-&gt;posAmount+=v; \n
} \n
} \n
</content>
</inline>
<inline loc="end" access="public">
<content>
$(api) int $(struct_prefix)_Tree2_AddDataPair($(struct_type) *st, AQDG_GRAPH_DATAPAIR *dp);
</content>
</inline>
<inline loc="code">
<content>
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
</content>
</inline>
<inline loc="end" access="public">
<content>
$(api) int $(struct_prefix)_Tree2_AddValue($(struct_type) *st, uint32_t categoryId, double v);
</content>
</inline>
<inline loc="code">
<content>
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
</content>
</inline>
<inline loc="end" access="public">
<content>
$(api) void $(struct_prefix)_Tree2_SumUpChildren($(struct_type) *st);
</content>
</inline>
<inline loc="code">
<content>
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-&gt;totalAmount+=child-&gt;totalAmount; \n
st-&gt;negAmount+=child-&gt;negAmount; \n
st-&gt;posAmount+=child-&gt;posAmount; \n
child=AQDG_Graph_Category_Tree2_GetNext(child); \n
} \n
} \n
} \n
</content>
</inline>
<inline loc="end" access="public">
<content>
$(api) void $(struct_prefix)_Tree2_MarkCategoriesWithDataPairs($(struct_type) *st);
</content>
</inline>
<inline loc="code">
<content>
void $(struct_prefix)_Tree2_MarkCategoriesWithDataPairs($(struct_type) *st) \n
{ \n
while (st) { \n
if (st-&gt;dataPairList &amp;&amp; AQDG_Graph_DataPair_List_GetCount(st-&gt;dataPairList)) \n
st-&gt;flags|=$(struct_type)_FLAGS_SELECTED; \n
st=AQDG_Graph_Category_Tree2_GetBelow(st); \n
} \n
} \n
</content>
</inline>
<inline loc="end" access="public">
<content>
$(api) void $(struct_prefix)_Tree2_SubFlags($(struct_type) *st, uint32_t flags);
</content>
</inline>
<inline loc="code">
<content>
void $(struct_prefix)_Tree2_SubFlags($(struct_type) *st, uint32_t flags) \n
{ \n
while (st) { \n
st-&gt;flags&amp;=~flags; \n
st=AQDG_Graph_Category_Tree2_GetBelow(st); \n
} \n
} \n
</content>
</inline>
<inline loc="end" access="public">
<content>
$(api) void $(struct_prefix)_Tree2_SubFlagsDown($(struct_type) *st, uint32_t flags);
</content>
</inline>
<inline loc="code">
<content>
void $(struct_prefix)_Tree2_SubFlagsDown($(struct_type) *st, uint32_t flags) \n
{ \n
if (st) { \n
st-&gt;flags&amp;=~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
</content>
</inline>
<inline loc="end" access="public">
<content>
$(api) void $(struct_prefix)_Tree2_AddFlagsDown($(struct_type) *st, uint32_t flags);
</content>
</inline>
<inline loc="code">
<content>
void $(struct_prefix)_Tree2_AddFlagsDown($(struct_type) *st, uint32_t flags) \n
{ \n
if (st) { \n
st-&gt;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
</content>
</inline>
<inline loc="end" access="public">
<content>
$(api) void $(struct_prefix)_Tree2_AddFlagsUp($(struct_type) *st, uint32_t flags);
</content>
</inline>
<inline loc="code">
<content>
void $(struct_prefix)_Tree2_AddFlagsUp($(struct_type) *st, uint32_t flags) \n
{ \n
while (st) { \n
st-&gt;flags|=flags; \n
st=AQDG_Graph_Category_Tree2_GetParent(st); \n
} \n
} \n
</content>
</inline>
<inline loc="code">
<content>
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 &amp; 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 &amp;&amp; strcasecmp(s, aname)==0) \n
return st; \n
st=$(struct_prefix)_Tree2_GetNext(st); \n
} \n
} \n
return NULL; \n
} \n
</content>
</inline>
<inline loc="end" access="public">
<content>
$(api) $(struct_type)* $(struct_prefix)_Tree2_GetByPath(const $(struct_type) *st, const char *path);
</content>
</inline>
<inline loc="code">
<content>
$(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
</content>
</inline>
<inline loc="end" access="public">
<content>
$(api) void $(struct_prefix)_Tree2_CollectChildrenDataPairs($(struct_type) *st);
</content>
</inline>
<inline loc="code">
<content>
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-&gt;dataPairList) { \n
AQDG_GRAPH_DATAPAIR *dp; \n
\n
while( (dp=AQDG_Graph_DataPair_List_First(child-&gt;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
</content>
</inline>
</inlines> </inlines>
</lang> </lang>
<defines>
<define id="$(struct_type)_FLAGS" prefix="AQDG_GRAPH_CATEGORY_FLAGS_">
<item name="MODIFIED" value="0x00000001" />
<item name="SELECTED" value="0x00000002" />
</define>
</defines>
<members> <members>
<member name="flags" type="uint32_t" maxlen="8"> <member name="flags" type="uint32_t" maxlen="8">
@@ -60,6 +368,13 @@
<access>public</access> <access>public</access>
</member> </member>
<member name="name" type="char_ptr" maxlen="256" >
<access>public</access>
<flags>own with_getbymember</flags>
<setflags>const dup</setflags>
<getflags>const</getflags>
</member>
<member name="label" type="char_ptr" maxlen="256" > <member name="label" type="char_ptr" maxlen="256" >
<access>public</access> <access>public</access>
<flags>own with_getbymember</flags> <flags>own with_getbymember</flags>
@@ -67,6 +382,13 @@
<getflags>const</getflags> <getflags>const</getflags>
</member> </member>
<member name="totalAmount" type="double" maxlen="8" >
<default>0.0</default>
<preset>0.0</preset>
<access>public</access>
<flags>sortbymember</flags>
</member>
<member name="negAmount" type="double" maxlen="8" > <member name="negAmount" type="double" maxlen="8" >
<default>0.0</default> <default>0.0</default>
<preset>0.0</preset> <preset>0.0</preset>