// @(#)root/gviz3d:$Id$
// Author: Tomasz Sosnicki   18/09/09

/************************************************************************
* Copyright (C) 1995-2009, Rene Brun and Fons Rademakers.               *
* All rights reserved.                                                  *
*                                                                       *
* For the licensing terms see $ROOTSYS/LICENSE.                         *
* For the list of contributors see $ROOTSYS/README/CREDITS.             *
*************************************************************************/

#include "TStructNodeProperty.h"
#include <TROOT.h>
#include <TClass.h>

ClassImp(TStructNodeProperty);

//________________________________________________________________________
//////////////////////////////////////////////////////////////////////////
//
// TStructNodeProperty class keeps a color for type
//
//
//
//
//
//////////////////////////////////////////////////////////////////////////

//________________________________________________________________________
TStructNodeProperty::TStructNodeProperty(const char * name, Int_t color)
{
   // Contructs a TStructNodeProperty with p as parent window for class "name" with color "color".

   SetName(name);
   SetColor(color);
}

//________________________________________________________________________
TStructNodeProperty::TStructNodeProperty(const char * name, Pixel_t pixel)
{
   // Contructs a TStructNodeProperty with p as parent window for class "name" with color "pixel".

   SetName(name);
   SetColor(pixel);
}

//________________________________________________________________________
TStructNodeProperty::~TStructNodeProperty()
{
   // Destructor

}

//________________________________________________________________________
Int_t TStructNodeProperty::Compare(const TObject* obj) const
{
   // Overrided method. Compare two objects of TStructNodeProperty class


   // Default color "+" should be at the end.
   if (fName == "+") {
      return 1;
   }
   TStructNodeProperty* prop = (TStructNodeProperty*)obj;
   TString propName(prop->GetName());
   if (propName == "+") {
      return -1;
   }

   TClass* cl1;
   if (fName.EndsWith("+")) {
      cl1 = TClass::GetClass(TString(fName.Data(), fName.Length()-1).Data());
   } else {
      cl1 = TClass::GetClass(fName.Data());
   }

   TClass* cl2;

   if (propName.EndsWith("+")) {
      cl2 = TClass::GetClass(TString(propName.Data(), propName.Length()-1).Data());
   } else {
      cl2 = TClass::GetClass(prop->GetName());
   }

   if(!cl1) {
      return -1;
   }
   if(!cl2) {
      return -1;
   }

   if(cl1->InheritsFrom(cl2)) {
      return -1;
   }
   if(cl2->InheritsFrom(cl1)) {
      return 1;
   }

   if(this > prop) {
      return 1;
   }
   if(this < prop) {
      return -1;
   }

   return 0;
}

//________________________________________________________________________
TColor TStructNodeProperty::GetColor() const
{
   // Returns color of class

   return fColor;
}

//________________________________________________________________________
Pixel_t TStructNodeProperty::GetPixel() const
{
   // Return color in Pixel_t format

   return fColor.GetPixel();
}

//________________________________________________________________________
Bool_t TStructNodeProperty::IsSortable() const
{
   // Retruns true, because we have overrided method Compare

   return true;
}

//________________________________________________________________________
void TStructNodeProperty::SetColor(const TColor & color)
{
   // Sets the color to "color"

   fColor = color;
}

//________________________________________________________________________
void TStructNodeProperty::SetColor(Int_t color)
{
   // Sets  the color to "color"

   fColor = *(gROOT->GetColor(color));
}

//________________________________________________________________________
void TStructNodeProperty::SetColor(Pixel_t pixel)
{
   // Sets the color to "pixel"

   SetColor(TColor::GetColor(pixel));
}
 TStructNodeProperty.cxx:1
 TStructNodeProperty.cxx:2
 TStructNodeProperty.cxx:3
 TStructNodeProperty.cxx:4
 TStructNodeProperty.cxx:5
 TStructNodeProperty.cxx:6
 TStructNodeProperty.cxx:7
 TStructNodeProperty.cxx:8
 TStructNodeProperty.cxx:9
 TStructNodeProperty.cxx:10
 TStructNodeProperty.cxx:11
 TStructNodeProperty.cxx:12
 TStructNodeProperty.cxx:13
 TStructNodeProperty.cxx:14
 TStructNodeProperty.cxx:15
 TStructNodeProperty.cxx:16
 TStructNodeProperty.cxx:17
 TStructNodeProperty.cxx:18
 TStructNodeProperty.cxx:19
 TStructNodeProperty.cxx:20
 TStructNodeProperty.cxx:21
 TStructNodeProperty.cxx:22
 TStructNodeProperty.cxx:23
 TStructNodeProperty.cxx:24
 TStructNodeProperty.cxx:25
 TStructNodeProperty.cxx:26
 TStructNodeProperty.cxx:27
 TStructNodeProperty.cxx:28
 TStructNodeProperty.cxx:29
 TStructNodeProperty.cxx:30
 TStructNodeProperty.cxx:31
 TStructNodeProperty.cxx:32
 TStructNodeProperty.cxx:33
 TStructNodeProperty.cxx:34
 TStructNodeProperty.cxx:35
 TStructNodeProperty.cxx:36
 TStructNodeProperty.cxx:37
 TStructNodeProperty.cxx:38
 TStructNodeProperty.cxx:39
 TStructNodeProperty.cxx:40
 TStructNodeProperty.cxx:41
 TStructNodeProperty.cxx:42
 TStructNodeProperty.cxx:43
 TStructNodeProperty.cxx:44
 TStructNodeProperty.cxx:45
 TStructNodeProperty.cxx:46
 TStructNodeProperty.cxx:47
 TStructNodeProperty.cxx:48
 TStructNodeProperty.cxx:49
 TStructNodeProperty.cxx:50
 TStructNodeProperty.cxx:51
 TStructNodeProperty.cxx:52
 TStructNodeProperty.cxx:53
 TStructNodeProperty.cxx:54
 TStructNodeProperty.cxx:55
 TStructNodeProperty.cxx:56
 TStructNodeProperty.cxx:57
 TStructNodeProperty.cxx:58
 TStructNodeProperty.cxx:59
 TStructNodeProperty.cxx:60
 TStructNodeProperty.cxx:61
 TStructNodeProperty.cxx:62
 TStructNodeProperty.cxx:63
 TStructNodeProperty.cxx:64
 TStructNodeProperty.cxx:65
 TStructNodeProperty.cxx:66
 TStructNodeProperty.cxx:67
 TStructNodeProperty.cxx:68
 TStructNodeProperty.cxx:69
 TStructNodeProperty.cxx:70
 TStructNodeProperty.cxx:71
 TStructNodeProperty.cxx:72
 TStructNodeProperty.cxx:73
 TStructNodeProperty.cxx:74
 TStructNodeProperty.cxx:75
 TStructNodeProperty.cxx:76
 TStructNodeProperty.cxx:77
 TStructNodeProperty.cxx:78
 TStructNodeProperty.cxx:79
 TStructNodeProperty.cxx:80
 TStructNodeProperty.cxx:81
 TStructNodeProperty.cxx:82
 TStructNodeProperty.cxx:83
 TStructNodeProperty.cxx:84
 TStructNodeProperty.cxx:85
 TStructNodeProperty.cxx:86
 TStructNodeProperty.cxx:87
 TStructNodeProperty.cxx:88
 TStructNodeProperty.cxx:89
 TStructNodeProperty.cxx:90
 TStructNodeProperty.cxx:91
 TStructNodeProperty.cxx:92
 TStructNodeProperty.cxx:93
 TStructNodeProperty.cxx:94
 TStructNodeProperty.cxx:95
 TStructNodeProperty.cxx:96
 TStructNodeProperty.cxx:97
 TStructNodeProperty.cxx:98
 TStructNodeProperty.cxx:99
 TStructNodeProperty.cxx:100
 TStructNodeProperty.cxx:101
 TStructNodeProperty.cxx:102
 TStructNodeProperty.cxx:103
 TStructNodeProperty.cxx:104
 TStructNodeProperty.cxx:105
 TStructNodeProperty.cxx:106
 TStructNodeProperty.cxx:107
 TStructNodeProperty.cxx:108
 TStructNodeProperty.cxx:109
 TStructNodeProperty.cxx:110
 TStructNodeProperty.cxx:111
 TStructNodeProperty.cxx:112
 TStructNodeProperty.cxx:113
 TStructNodeProperty.cxx:114
 TStructNodeProperty.cxx:115
 TStructNodeProperty.cxx:116
 TStructNodeProperty.cxx:117
 TStructNodeProperty.cxx:118
 TStructNodeProperty.cxx:119
 TStructNodeProperty.cxx:120
 TStructNodeProperty.cxx:121
 TStructNodeProperty.cxx:122
 TStructNodeProperty.cxx:123
 TStructNodeProperty.cxx:124
 TStructNodeProperty.cxx:125
 TStructNodeProperty.cxx:126
 TStructNodeProperty.cxx:127
 TStructNodeProperty.cxx:128
 TStructNodeProperty.cxx:129
 TStructNodeProperty.cxx:130
 TStructNodeProperty.cxx:131
 TStructNodeProperty.cxx:132
 TStructNodeProperty.cxx:133
 TStructNodeProperty.cxx:134
 TStructNodeProperty.cxx:135
 TStructNodeProperty.cxx:136
 TStructNodeProperty.cxx:137
 TStructNodeProperty.cxx:138
 TStructNodeProperty.cxx:139
 TStructNodeProperty.cxx:140
 TStructNodeProperty.cxx:141
 TStructNodeProperty.cxx:142
 TStructNodeProperty.cxx:143
 TStructNodeProperty.cxx:144
 TStructNodeProperty.cxx:145
 TStructNodeProperty.cxx:146
 TStructNodeProperty.cxx:147
 TStructNodeProperty.cxx:148
 TStructNodeProperty.cxx:149
 TStructNodeProperty.cxx:150
 TStructNodeProperty.cxx:151
 TStructNodeProperty.cxx:152
 TStructNodeProperty.cxx:153
 TStructNodeProperty.cxx:154
 TStructNodeProperty.cxx:155