3 #include "RenderElement.h"
4 #include "RGTopFrame.h"
8 #include <TGListTree.h>
14 //______________________________________________________________________
18 ClassImp(RenderElement)
20 RenderElement::RenderElement()
26 RenderElement::RenderElement(Color_t& main_color) : fMainColorPtr(&main_color)
31 /**************************************************************************/
33 TObject* RenderElement::GetObject(Exc_t eh)
35 TObject* obj = dynamic_cast<TObject*>(this);
37 throw(eh + "not a TObject.");
41 /**************************************************************************/
43 TGListTreeItem* RenderElement::AddIntoListTree(TGListTree* ltree,
44 TGListTreeItem* parent)
46 static const Exc_t eH("RenderElement::AddIntoListTree ");
48 TObject* tobj = GetObject(eH);
49 TGListTreeItem* item = ltree->AddItem(parent, tobj->GetName(), tobj,
51 item->CheckItem(GetRnrElement());
52 item->SetColor(GetMainColor());
53 // printf("%s setting title for %s, '%s'\n", eH.Data(), tobj->GetName(), tobj->GetTitle());
54 item->SetTipText(tobj->GetTitle());
56 fItems.insert(ListTreeInfo(ltree, item));
61 /**************************************************************************/
63 void RenderElement::FullUpdate()
65 for(sLTI_i i=fItems.begin(); i!=fItems.end(); ++i) {
66 // Setup name and title/tooltip? Need update calls from setname/title as well.
67 i->fItem->CheckItem(fRnrElement);
68 i->fItem->SetColor(GetMainColor());
71 gReve->NotifyBrowser();
74 /**************************************************************************/
76 void RenderElement::SpawnEditor()
78 // Here spawn a sub-class of TGedFrame with special UpdateMethod.
79 gReve->EditRenderElement(this);
82 void RenderElement::ExportToCINT(Text_t* var_name)
84 static const Exc_t eH("RenderElement::ExportToCINT ");
86 TObject* obj = GetObject(eH);
87 const char* cname = obj->IsA()->GetName();
88 gROOT->ProcessLine(Form("%s* %s = (%s*) %p;", cname, var_name, cname, obj));
91 /**************************************************************************/
93 void RenderElement::DumpSourceObject()
95 TObject* o = GetSourceObject();
97 printf("Source object not set.\n");
103 void RenderElement::InspectSourceObject()
105 TObject* o = GetSourceObject();
107 printf("Source object not set.\n");
113 /**************************************************************************/
115 void RenderElement::SetRnrElement(Bool_t rnr)
117 if(rnr != fRnrElement) {
122 /**************************************************************************/
124 void RenderElement::SetMainColor(Color_t color)
127 *fMainColorPtr = color;
132 void RenderElement::SetMainColorByPixel(Pixel_t pixel)
134 SetMainColor(Color_t(TColor::GetColor(pixel)));
137 /**************************************************************************/
138 /**************************************************************************/
140 ClassImp(RenderElementListBase)
142 Int_t RenderElementListBase::ExpandIntoListTree(TGListTree* ltree,
143 TGListTreeItem* parent)
145 // Populates parent with elements.
146 // parent must be an already existing representation of *this*.
147 // Returns number of inserted elements.
148 // If parent already has children, it does nothing.
150 // RnrEl can be inserted in a list-tree several times, thus we can not
151 // search through fItems to get parent here.
152 // Anyhow, it is probably known as it must have been selected by the user.
154 if(parent->GetFirstChild() != 0)
157 for(lpRE_i i=fList.begin(); i!=fList.end(); ++i) {
158 (*i)->AddIntoListTree(ltree, parent);
164 /**************************************************************************/
166 void RenderElementListBase::EnableListElements()
168 for(lpRE_i i=fList.begin(); i!=fList.end(); ++i)
169 (*i)->SetRnrElement(true);
172 void RenderElementListBase::DisableListElements()
174 for(lpRE_i i=fList.begin(); i!=fList.end(); ++i)
175 (*i)->SetRnrElement(false);
178 /**************************************************************************/
180 void RenderElementListBase::SetMainColor(Color_t col)
182 Color_t oldcol = GetMainColor();
183 for(lpRE_i i=fList.begin(); i!=fList.end(); ++i) {
184 if((*i)->GetMainColor() == oldcol) (*i)->SetMainColor(col);
186 RenderElement::SetMainColor(col);
189 void RenderElementListBase::SetMainColor(Pixel_t pixel)
191 // This one needed for proper calling via CINT (signals).
193 SetMainColor(Color_t(TColor::GetColor(pixel)));
196 /**************************************************************************/
198 void RenderElementListBase::PaintElements(Option_t* option)
201 for(lpRE_i i=fList.begin(); i!=fList.end(); ++i) {
202 if((*i)->GetRnrElement())
203 (*i)->GetObject()->Paint(option);
208 /**************************************************************************/
209 /**************************************************************************/
211 ClassImp(RenderElementList)