added some functions to Category.
This commit is contained in:
@@ -18,9 +18,11 @@
|
||||
<headers>
|
||||
<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">gwenhywfar/path.h</header>
|
||||
</headers>
|
||||
|
||||
<inlines>
|
||||
|
||||
<inline loc="end" access="public">
|
||||
<content>
|
||||
$(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
|
||||
</content>
|
||||
</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->totalAmount+=v; \n
|
||||
if (v<0.0) \n
|
||||
st->negAmount+=v; \n
|
||||
else \n
|
||||
st->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->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
|
||||
</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->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
|
||||
</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->flags&=~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->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
|
||||
</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->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->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 & 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
|
||||
</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->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
|
||||
</content>
|
||||
</inline>
|
||||
|
||||
|
||||
</inlines>
|
||||
|
||||
</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>
|
||||
|
||||
<member name="flags" type="uint32_t" maxlen="8">
|
||||
@@ -60,6 +368,13 @@
|
||||
<access>public</access>
|
||||
</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" >
|
||||
<access>public</access>
|
||||
<flags>own with_getbymember</flags>
|
||||
@@ -67,6 +382,13 @@
|
||||
<getflags>const</getflags>
|
||||
</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" >
|
||||
<default>0.0</default>
|
||||
<preset>0.0</preset>
|
||||
|
||||
Reference in New Issue
Block a user