GimmickDebugMessage(3,"AttributeDescriptor : '"<<key
<<"' ["<<flags<<"]"<<std::endl);
GimmickDebugMessage(3,"='"<<mName<<"'"<<std::endl);
- DecodeType();
}
//=====================================================================
{
mName = entry->GetName();
CleanName(mName);
- DecodeType();
GimmickDebugMessage(3,"='"<<mName<<"'"<<std::endl);
}
else
<<"Considering it as a user attribute"
<< std::endl);
mName = "UNKNOWN";
- mGroup = mElement = mType = 0;
- DecodeType();
+ mGroup = mElement = 0;
}
}
}
return;
}
+
//=====================================================================
- ///Decodes the type of attribute into the valid groups
- void AttributeDescriptor::DecodeType()
- {
- // Retrieve the name from gdcm dict
+ /// Decodes the type of the attribute
+ void AttributeDescriptor::DecodeType(unsigned int& typ) const
+ {
+
+
+ // Retrieve the name from gdcm dict
GDCM_NAME_SPACE::DictEntry* entry =
GDCM_NAME_SPACE::Global::GetDicts()
- ->GetDefaultPubDict()->GetEntry(mGroup,mElement);
+ ->GetDefaultPubDict()->GetEntry(GetGroup(),GetElement());
std::string type = entry->GetVR().str();
- CleanName(type);
GimmickDebugMessage(3,"VR Value is "<<type<<"!"<<std::endl);
if(type=="AS" ||
type=="DA" ||
type=="US" ||
type=="SH")
{
- mType=1;
+ type="1";
+ sscanf(type.c_str(),"%u",&typ);
}
else
{
- mType=2;
+ type="2";
+ sscanf(type.c_str(),"%u",&typ);
}
-
- }
+
+ }
+ //=====================================================================
} // EO namespace tree
/// Types
/// The attribute is of numeric type
- static const unsigned int NUMBER=1;
+ static const int NUMBER=1;
/// The attribute is of string type
- static const unsigned int STRING=2;
+ static const int STRING=2;
/// The attribute's type is unknown
- static const unsigned int UNKNOWN=0;
+ static const int UNKNOWN=0;
/// Default ctor
AttributeDescriptor()
unsigned short GetElement() const { return mElement; }
/// Returns the flags of the attribute
unsigned int GetFlags() const { return mFlags; }
- /// Returns the type of the attribute
- unsigned int GetType() const { return mType; }
-
+
/// Extracts group and element from a key of the form "Dgroup_elem"
static void GetDicomGroupElementFromKey(const std::string& key,
unsigned short& group,
/// Replace simple quote by double quotes
/// Cut string at NULL chars
void CleanName(std::string& str) const;
- ///Decodes the attribute into accepted types
- void DecodeType();
+ ///Decodes the type of attribute into the existing ones
+ void DecodeType(unsigned int& type) const;
+
private:
std::string mKey;
std::string mName;
unsigned short mGroup;
unsigned short mElement;
unsigned int mFlags;
- unsigned int mType;
};
// EO class AttributeDescriptor
//=====================================================================
a!= GetTree()->GetAttributeDescriptorList(GetLevel()).end();
++a)
{
- GimmickMessage(1,"Hello my type is"<<a->GetType()<<std::endl);
- GimmickMessage(1,"Hello my group is"<<a->GetGroup()<<std::endl);
- GimmickMessage(1,"Hello my element is"<<a->GetElement()<<std::endl);
-
+
if(a->GetKey()==k)
{
return *a;
#include <creaImageIOWxTreeView.h>
#include <creaImageIOSystem.h>
#include <wx/splitter.h>
-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]);
}
+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: "
+ <<val1
+ <<" STRING 2: "
+ <<val2
+ <<std::endl);
+ if(sortData==1)
+ {
+ // inverse the order
+ if (val1 < val2)
+ return 1;
+ if (val1 > val2)
+ return -1;
+
+ return 0;
+ }
+ else
+ {
+ if (val1 < val2)
+ return -1;
+ if (val1 > val2)
+ return 1;
+
+ return 0;
+
+ }
+
+}
+
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:"<<ty<<std::endl);
+
char* d= new char [att.size()+1];
strcpy (d, att.c_str());
//Sets it as the data
GetCtrl(level)->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