#include <vector>
#include <string>
#include <Rtypes.h>
Go to the source code of this file.
Functions | |
void | expand_node (TEveElement *element) |
const char * | get_name (const TEveElement *element) |
TGeoShape * | get_shape (TEveElement *element) |
const TGeoShape * | get_shape (const TEveElement *element) |
void | hide_tracker_endcap (TEveElement *tracker) |
bool | is_leaf_node (const TEveElement *element) |
void | set_children_visibility (TEveElement *element, const std::string &node_name, const std::vector< std::string > &children_name, bool visibility) |
void | set_color (TEveElement *element, Color_t color, float alpha=1.0, unsigned int levels=0) |
void | set_tracker_endcap_visibility (TEveElement *tracker, bool visibility) |
void | show_tracker_endcap (TEveElement *tracker) |
void expand_node | ( | TEveElement * | element | ) |
Definition at line 26 of file vis_macros.cc.
{ // force a TEveGeoNode to load all its children if (TEveGeoNode * node = dynamic_cast<TEveGeoNode *>( element )) { if (node->NumChildren() == 0 && node->GetNode()->GetVolume()->GetNdaughters() != 0) { TIter next(node->GetNode()->GetVolume()->GetNodes()); TGeoNode* dnode; while ((dnode = (TGeoNode*) next()) != 0) { TEveGeoNode* node_re = new TEveGeoNode(dnode); node->AddElement(node_re); } } return; } // a TEveGeoShape is always exanded //if (TEveGeoShape * shape __attribute__ ((unused)) = dynamic_cast<TEveGeoShape *>( element )) { // return; //} // a generic TEveElement has no knwledge on children expansion return; }
const char* get_name | ( | const TEveElement * | element | ) |
Definition at line 11 of file vis_macros.cc.
{ // try as a TEveGeoNode or TEveGeoShape if (const TEveGeoNode * node = dynamic_cast<const TEveGeoNode *>( element )) return node->GetName(); if (const TEveGeoShape * shape = dynamic_cast<const TEveGeoShape *>( element )) return shape->GetName(); // try to access the element as a named thingy if (const TNamed * named = dynamic_cast<const TNamed *>( element )) return named->GetName(); return 0; }
TGeoShape* get_shape | ( | TEveElement * | element | ) |
Definition at line 64 of file vis_macros.cc.
{ // a TEveGeoNode cannot modify its shape //if (const TEveGeoNode * node __attribute__ ((unused)) = dynamic_cast<const TEveGeoNode *>( element )) { // return 0; //} // a TEveGeoShape owns its shape, and can modifiy it if (TEveGeoShape * shape = dynamic_cast<TEveGeoShape *>( element )) { return shape->GetShape(); } // a TEveElement is too generic, no way to get a shape return 0; }
const TGeoShape* get_shape | ( | const TEveElement * | element | ) |
Definition at line 49 of file vis_macros.cc.
{ // a TEveGeoNode, can look into its TGeoNode and retrieve the shape if (const TEveGeoNode * node = dynamic_cast<const TEveGeoNode *>( element )) { return node->GetNode()->GetVolume()->GetShape(); } // a TEveGeoShape owns its shape if (const TEveGeoShape * shape = dynamic_cast<const TEveGeoShape *>( element )) { TEveGeoShape * nc_shape = const_cast<TEveGeoShape *>( shape ); return const_cast<const TGeoShape *>( nc_shape->GetShape() ); } // a TEveElement is too generic, no way to get a shape return 0; }
void hide_tracker_endcap | ( | TEveElement * | tracker | ) |
Definition at line 167 of file vis_macros.cc.
{ set_tracker_endcap_visibility( tracker, false ); }
bool is_leaf_node | ( | const TEveElement * | element | ) |
Definition at line 100 of file vis_macros.cc.
{ // a TEveGeoNode can have unaccounted-for children if (const TEveGeoNode * node = dynamic_cast<const TEveGeoNode *>( element )) { return ((node->NumChildren() == 0) and (node->GetNode()->GetVolume()->GetNdaughters() == 0)); } // a TEveGeoShape always knows its children if (const TEveGeoShape * shape = dynamic_cast<const TEveGeoShape *>( element )) { return (shape->NumChildren() == 0); } // default implementation return (element->NumChildren() == 0); }
void set_children_visibility | ( | TEveElement * | element, |
const std::string & | node_name, | ||
const std::vector< std::string > & | children_name, | ||
bool | visibility | ||
) |
Definition at line 116 of file vis_macros.cc.
{ // try to access the element as a named thingy const char * name = get_name( element ); if (not name or strncmp(name, node_name.c_str(), node_name.size())) // unnamed node, or wrong node return; for (std::list<TEveElement *>::iterator j = element->BeginChildren(); j != element->EndChildren(); ++j) { TEveElement * child = *j; name = get_name( child ); if (not name) // unnamed node, ignore it continue; for (unsigned int i = 0; i < children_name.size(); ++i) if (not strncmp(name, children_name[i].c_str(), children_name[i].size())) { // change this child visibility if (is_leaf_node( child )) { child->SetRnrSelf( visibility ); child->SetRnrChildren( false ); } else { child->SetRnrSelf( false ); child->SetRnrChildren( visibility ); } break; } } // notify the element that is had changed element->ElementChanged(true, true); }
void set_color | ( | TEveElement * | element, |
Color_t | color, | ||
float | alpha = 1.0 , |
||
unsigned int | levels = 0 |
||
) |
Definition at line 77 of file vis_macros.cc.
{ if (not element) return; // set this node's color element->SetMainColor( color ); if (alpha > 1.) alpha = 1.; if (alpha < 0.) alpha = 0.; unsigned char transparency = (unsigned char) roundf(100. - (alpha * 100.)); element->SetMainTransparency( transparency ); if (levels > 0) { // set the node's children's color expand_node( element ); for (std::list<TEveElement*>::iterator i = element->BeginChildren(); i != element->EndChildren(); ++i) set_color( *i, color, alpha, levels - 1); } // notify the element that it has changed element->ElementChanged(true, true); }
void set_tracker_endcap_visibility | ( | TEveElement * | tracker, |
bool | visibility | ||
) |
Definition at line 149 of file vis_macros.cc.
{ std::vector<std::string> endcap; endcap.push_back("tec:TEC"); endcap.push_back("tidf:TIDF"); endcap.push_back("tidb:TIDB"); endcap.push_back("pixfwd:PixelForwardZPlus"); endcap.push_back("pixfwd:PixelForwardZMinus"); set_children_visibility( tracker, "tracker:Tracker", endcap, visibility ); }
void show_tracker_endcap | ( | TEveElement * | tracker | ) |
Definition at line 161 of file vis_macros.cc.
{ set_tracker_endcap_visibility( tracker, true ); }