Logo ROOT  
Reference Guide
TStructNodeProperty.cxx
Go to the documentation of this file.
1 // @(#)root/gviz3d:$Id$
2 // Author: Tomasz Sosnicki 18/09/09
3 
4 /************************************************************************
5 * Copyright (C) 1995-2009, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11 
12 #include "TStructNodeProperty.h"
13 #include <TROOT.h>
14 #include <TClass.h>
15 
17 
18 //________________________________________________________________________
19 //////////////////////////////////////////////////////////////////////////
20 //
21 // TStructNodeProperty class keeps a color for type
22 //
23 //
24 //
25 //
26 //
27 //////////////////////////////////////////////////////////////////////////
28 
29 ////////////////////////////////////////////////////////////////////////////////
30 /// Contructs a TStructNodeProperty with p as parent window for class "name" with color "color".
31 
33 {
34  SetName(name);
35  SetColor(color);
36 }
37 
38 ////////////////////////////////////////////////////////////////////////////////
39 /// Contructs a TStructNodeProperty with p as parent window for class "name" with color "pixel".
40 
42 {
43  SetName(name);
44  SetColor(pixel);
45 }
46 
47 ////////////////////////////////////////////////////////////////////////////////
48 /// Destructor
49 
51 {
52 }
53 
54 ////////////////////////////////////////////////////////////////////////////////
55 /// Overrided method. Compare two objects of TStructNodeProperty class
56 
58 {
59 
60  // Default color "+" should be at the end.
61  if (fName == "+") {
62  return 1;
63  }
65  TString propName(prop->GetName());
66  if (propName == "+") {
67  return -1;
68  }
69 
70  TClass* cl1;
71  if (fName.EndsWith("+")) {
73  } else {
74  cl1 = TClass::GetClass(fName.Data());
75  }
76 
77  TClass* cl2;
78 
79  if (propName.EndsWith("+")) {
80  cl2 = TClass::GetClass(TString(propName.Data(), propName.Length()-1).Data());
81  } else {
82  cl2 = TClass::GetClass(prop->GetName());
83  }
84 
85  if(!cl1) {
86  return -1;
87  }
88  if(!cl2) {
89  return -1;
90  }
91 
92  if(cl1->InheritsFrom(cl2)) {
93  return -1;
94  }
95  if(cl2->InheritsFrom(cl1)) {
96  return 1;
97  }
98 
99  if(this > prop) {
100  return 1;
101  }
102  if(this < prop) {
103  return -1;
104  }
105 
106  return 0;
107 }
108 
109 ////////////////////////////////////////////////////////////////////////////////
110 /// Returns color of class
111 
113 {
114  return fColor;
115 }
116 
117 ////////////////////////////////////////////////////////////////////////////////
118 /// Return color in Pixel_t format
119 
121 {
122  return fColor.GetPixel();
123 }
124 
125 ////////////////////////////////////////////////////////////////////////////////
126 /// Retruns true, because we have overrided method Compare
127 
129 {
130  return true;
131 }
132 
133 ////////////////////////////////////////////////////////////////////////////////
134 /// Sets the color to "color"
135 
137 {
138  fColor = color;
139 }
140 
141 ////////////////////////////////////////////////////////////////////////////////
142 /// Sets the color to "color"
143 
145 {
146  fColor = *(gROOT->GetColor(color));
147 }
148 
149 ////////////////////////////////////////////////////////////////////////////////
150 /// Sets the color to "pixel"
151 
153 {
154  SetColor(TColor::GetColor(pixel));
155 }
TStructNodeProperty::SetColor
void SetColor(const TColor &color)
Sets the color to "color".
Definition: TStructNodeProperty.cxx:136
TNamed::SetName
virtual void SetName(const char *name)
Set the name of the TNamed.
Definition: TNamed.cxx:140
TStructNodeProperty::fColor
TColor fColor
Definition: TStructNodeProperty.h:22
TString::Data
const char * Data() const
Definition: TString.h:369
Pixel_t
ULong_t Pixel_t
Pixel value.
Definition: GuiTypes.h:40
ClassImp
#define ClassImp(name)
Definition: Rtypes.h:364
TStructNodeProperty::IsSortable
Bool_t IsSortable() const
Retruns true, because we have overrided method Compare.
Definition: TStructNodeProperty.cxx:128
TColor::GetPixel
ULong_t GetPixel() const
Return pixel value corresponding to this color.
Definition: TColor.cxx:1446
TStructNodeProperty.h
TNamed::fName
TString fName
Definition: TNamed.h:32
TString::EndsWith
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
Definition: TString.cxx:2199
TString::Length
Ssiz_t Length() const
Definition: TString.h:410
TClass.h
TString
Basic string class.
Definition: TString.h:136
bool
TROOT.h
TClass::InheritsFrom
Bool_t InheritsFrom(const char *cl) const
Return kTRUE if this class inherits from a class with name "classname".
Definition: TClass.cxx:4858
TColor
The color creation and management class.
Definition: TColor.h:19
TStructNodeProperty::GetPixel
Pixel_t GetPixel() const
Return color in Pixel_t format.
Definition: TStructNodeProperty.cxx:120
TStructNodeProperty::GetColor
TColor GetColor() const
Returns color of class.
Definition: TStructNodeProperty.cxx:112
TClass::GetClass
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
Definition: TClass.cxx:2946
TColor::GetColor
static Int_t GetColor(const char *hexcolor)
Static method returning color number for color specified by hex color string of form: "#rrggbb",...
Definition: TColor.cxx:1775
TStructNodeProperty
Definition: TStructNodeProperty.h:19
TClass
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition: TClass.h:80
TObject
Mother of all ROOT objects.
Definition: TObject.h:37
name
char name[80]
Definition: TGX11.cxx:110
TStructNodeProperty::TStructNodeProperty
TStructNodeProperty(const char *name, Int_t color)
Contructs a TStructNodeProperty with p as parent window for class "name" with color "color".
Definition: TStructNodeProperty.cxx:32
TNamed::GetName
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
TStructNodeProperty::Compare
Int_t Compare(const TObject *obj) const
Overrided method. Compare two objects of TStructNodeProperty class.
Definition: TStructNodeProperty.cxx:57
TStructNodeProperty::~TStructNodeProperty
~TStructNodeProperty()
Destructor.
Definition: TStructNodeProperty.cxx:50
gROOT
#define gROOT
Definition: TROOT.h:406
int