X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;ds=sidebyside;f=src2%2FcreaImageIOWxTreeView.cpp;h=1f3ccfeb1ff109fa35ba57ee90497ccb41cabd92;hb=384558d116ebb2ca264900f837c4a921d695515a;hp=cdf0c18dc35f450cb76e73e22b7f1bd92798527f;hpb=5f76a3752cd6e23874e8167f19c9ceb57223b390;p=creaImageIO.git diff --git a/src2/creaImageIOWxTreeView.cpp b/src2/creaImageIOWxTreeView.cpp index cdf0c18..1f3ccfe 100644 --- a/src2/creaImageIOWxTreeView.cpp +++ b/src2/creaImageIOWxTreeView.cpp @@ -1,7 +1,7 @@ #include #include #include -int wxCALLBACK MyCompareFunction(long item1, long item2, long sortData) +int wxCALLBACK CompareFunctionStrings(long item1, long item2, long sortData) { std::string s1((char*)((long*)item1)[1]); std::string s2((char*)((long*)item2)[1]); @@ -34,6 +34,39 @@ int wxCALLBACK MyCompareFunction(long item1, long item2, long sortData) } +int wxCALLBACK CompareFunctionInts(long item1, long item2, long sortData) +{ + int val1=atoi((char*)((long*)item1)[1]); + int val2=atoi((char*)((long*)item2)[1]); + GimmickMessage(1, + " Check: STRING 1: " + < val2) + return -1; + + return 0; + } + else + { + if (val1 < val2) + return -1; + if (val1 > val2) + return 1; + + return 0; + + } + +} + namespace creaImageIO { //===================================================================== @@ -395,18 +428,22 @@ namespace creaImageIO //Sets the data for the items to be sorted std::string att; - + unsigned int ty=0; int n = GetCtrl(level)->GetItemCount(); for (int i = 0; i < n; i++) { - //Gets current item data + + //Gets current item data long adr = GetCtrl(level)->GetItemData(i); - //Extracts the node + //Extracts the node and the type of attribute tree::Node* nod = ((ItemData*)adr)->node; + if(i==0) + { + (*nod).GetAttributeDescriptor(mLevelList[level].key[mColumnSelected-1]).DecodeType(ty); + } //Obtains the organizing attribute att=(*nod).GetAttribute(mLevelList[level].key[mColumnSelected-1]); - int ty=(*nod).GetAttributeDescriptor(mLevelList[level].key[mColumnSelected-1]).GetType(); - GimmickMessage(1,"Type:"<SetItemData(i,(long)lp); } - + + //int ty=GetAttributeDescriptor(mLevelList[level].key[mColumnSelected-1]).GetType(); if(mDirection) { - GetCtrl(level)->SortItems(MyCompareFunction, 0); + if(ty==1) + { + GetCtrl(level)->SortItems(CompareFunctionInts, 0); + } + else + { + GetCtrl(level)->SortItems(CompareFunctionStrings, 0); + } + mDirection=false; } else { - GetCtrl(level)->SortItems(MyCompareFunction, 1); - mDirection=true; + if(ty==1) + { + GetCtrl(level)->SortItems(CompareFunctionInts, 1); + } + else + { + GetCtrl(level)->SortItems(CompareFunctionStrings, 1); + } + mDirection=true; } //Resets original data