TStructNodeProperty.cxx

Go to the documentation of this file.
00001 // @(#)root/gviz3d:$Id: TStructNodeProperty.cxx 29940 2009-08-27 16:33:32Z brun $
00002 // Author: Tomasz Sosnicki   18/09/09
00003 
00004 /************************************************************************
00005 * Copyright (C) 1995-2009, Rene Brun and Fons Rademakers.               *
00006 * All rights reserved.                                                  *
00007 *                                                                       *
00008 * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010 *************************************************************************/
00011 
00012 #include "TStructNodeProperty.h"
00013 #include <TROOT.h>
00014 #include <TClass.h>
00015 
00016 ClassImp(TStructNodeProperty);
00017 
00018 //________________________________________________________________________
00019 //////////////////////////////////////////////////////////////////////////
00020 //
00021 // TStructNodeProperty class keeps a color for type
00022 // 
00023 // 
00024 // 
00025 // 
00026 // 
00027 //////////////////////////////////////////////////////////////////////////
00028 
00029 //________________________________________________________________________
00030 TStructNodeProperty::TStructNodeProperty(const char * name, Int_t color)
00031 {
00032    // Contructs a TStructNodeProperty with p as parent window for class "name" with color "color".
00033 
00034    SetName(name);
00035    SetColor(color);
00036 }
00037 
00038 //________________________________________________________________________
00039 TStructNodeProperty::TStructNodeProperty(const char * name, Pixel_t pixel)
00040 {
00041    // Contructs a TStructNodeProperty with p as parent window for class "name" with color "pixel".
00042 
00043    SetName(name);
00044    SetColor(pixel);
00045 }
00046 
00047 //________________________________________________________________________
00048 TStructNodeProperty::~TStructNodeProperty()
00049 {
00050    // Destructor
00051 
00052 }
00053 
00054 //________________________________________________________________________
00055 Int_t TStructNodeProperty::Compare(const TObject* obj) const
00056 {
00057    // Overrided method. Compare two objects of TStructNodeProperty class
00058 
00059 
00060    // Default color "+" should be at the end.
00061    if (fName == "+") {
00062       return 1;
00063    }
00064    TStructNodeProperty* prop = (TStructNodeProperty*)obj;
00065    TString propName(prop->GetName());
00066    if (propName == "+") {
00067       return -1;
00068    }
00069 
00070    TClass* cl1;
00071    if (fName.EndsWith("+")) {
00072       cl1 = TClass::GetClass(TString(fName.Data(), fName.Length()-1).Data());
00073    } else {
00074       cl1 = TClass::GetClass(fName.Data());
00075    }
00076 
00077    TClass* cl2;
00078 
00079    if (propName.EndsWith("+")) {
00080       cl2 = TClass::GetClass(TString(propName.Data(), propName.Length()-1).Data());
00081    } else {
00082       cl2 = TClass::GetClass(prop->GetName());
00083    }
00084 
00085    if(!cl1) {
00086       return -1;
00087    }
00088    if(!cl2) {
00089       return -1;
00090    }
00091 
00092    if(cl1->InheritsFrom(cl2)) {
00093       return -1;
00094    }
00095    if(cl2->InheritsFrom(cl1)) {
00096       return 1;   
00097    }
00098 
00099    if(this > prop) {
00100       return 1;
00101    }
00102    if(this < prop) {
00103       return -1;
00104    }
00105 
00106    return 0;
00107 }
00108 
00109 //________________________________________________________________________
00110 TColor TStructNodeProperty::GetColor() const
00111 {
00112    // Returns color of class
00113 
00114    return fColor;
00115 }
00116 
00117 //________________________________________________________________________
00118 Pixel_t TStructNodeProperty::GetPixel() const
00119 {
00120    // Return color in Pixel_t format
00121 
00122    return fColor.GetPixel();
00123 }
00124 
00125 //________________________________________________________________________
00126 Bool_t TStructNodeProperty::IsSortable() const
00127 {
00128    // Retruns true, because we have overrided method Compare
00129 
00130    return true;
00131 }
00132 
00133 //________________________________________________________________________
00134 void TStructNodeProperty::SetColor(const TColor & color)
00135 {
00136    // Sets the color to "color"
00137 
00138    fColor = color;
00139 }
00140 
00141 //________________________________________________________________________
00142 void TStructNodeProperty::SetColor(Int_t color)
00143 {
00144    // Sets  the color to "color"
00145 
00146    fColor = *(gROOT->GetColor(color));
00147 }
00148 
00149 //________________________________________________________________________
00150 void TStructNodeProperty::SetColor(Pixel_t pixel)
00151 {
00152    // Sets the color to "pixel"
00153 
00154    SetColor(TColor::GetColor(pixel));
00155 }

Generated on Tue Jul 5 14:19:17 2011 for ROOT_528-00b_version by  doxygen 1.5.1