CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions
eve_macros.h File Reference
#include <vector>
#include <string>
#include <Rtypes.h>

Go to the source code of this file.

Functions

TEveGeoShape * clone (const TEveElement *element, TEveElement *parent=0)
 
void expand_node (TEveElement *element)
 
const char * get_name (const TEveElement *element)
 
const TGeoShape * get_shape (const TEveElement *element)
 
TGeoShape * get_shape (TEveElement *element)
 
const char * get_title (const TEveElement *element)
 
TGeoMatrix * get_transform (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)
 

Function Documentation

TEveGeoShape* clone ( const TEveElement *  element,
TEveElement *  parent = 0 
)

Definition at line 135 of file eve_macros.cc.

References clone(), extract(), get_name(), get_shape(), get_title(), and get_transform().

136 {
137  TEveGeoShape* shape = new TEveGeoShape( get_name(element), get_title(element) );
138 
139  std::auto_ptr<TGeoMatrix> matrix( get_transform(element) );
140  shape->SetTransMatrix( matrix.get() );
141  delete matrix;
142 
143  TEveGeoShapeExtract extract; // FIXME put name and title here...
144  extract.SetShape( (TGeoShape *) get_shape(element)->Clone() );
145  extract.SetTrans( trans.Array() );
146  extract.SetRnrSelf( true );
147  extract.SetRnrElements( true );
148 
149  TEveGeoShape * clone = TEveGeoShape::ImportShapeExtract( &extract, parent );
150  return clone;
151 }
list parent
Definition: dbtoconf.py:74
const char * get_title(const TEveElement *element)
Definition: eve_macros.cc:28
const char * get_name(const TEveElement *element)
Definition: vis_macros.cc:11
TGeoMatrix * get_transform(const TEveElement *element)
Definition: eve_macros.cc:95
int extract(std::vector< int > *output, const std::string &dati)
T * clone(const T *tp)
Definition: Ptr.h:42
const TGeoShape * get_shape(const TEveElement *element)
Definition: vis_macros.cc:49
void expand_node ( TEveElement *  element)

Definition at line 26 of file vis_macros.cc.

References python.Node::node.

Referenced by node_filter(), and set_color().

27 {
28  // force a TEveGeoNode to load all its children
29  if (TEveGeoNode * node = dynamic_cast<TEveGeoNode *>( element )) {
30  if (node->NumChildren() == 0 && node->GetNode()->GetVolume()->GetNdaughters() > 0) {
31  TIter next(node->GetNode()->GetVolume()->GetNodes());
32  TGeoNode* dnode;
33  while ((dnode = (TGeoNode*) next()) != 0) {
34  TEveGeoNode* node_re = new TEveGeoNode(dnode);
35  node->AddElement(node_re);
36  }
37  }
38  return;
39  }
40  // a TEveGeoShape is always exanded
41  //if (TEveGeoShape * shape __attribute__ ((unused)) = dynamic_cast<TEveGeoShape *>( element )) {
42  // return;
43  //}
44  // a generic TEveElement has no knwledge on children expansion
45  return;
46 }
tuple node
Definition: Node.py:50
const char* get_name ( const TEveElement *  element)

Definition at line 11 of file vis_macros.cc.

References python.Node::node.

Referenced by apply_filter(), clone(), get_root_object(), and set_children_visibility().

11  {
12  // try as a TEveGeoNode or TEveGeoShape
13  if (const TEveGeoNode * node = dynamic_cast<const TEveGeoNode *>( element ))
14  return node->GetName();
15  if (const TEveGeoShape * shape = dynamic_cast<const TEveGeoShape *>( element ))
16  return shape->GetName();
17 
18  // try to access the element as a named thingy
19  if (const TNamed * named = dynamic_cast<const TNamed *>( element ))
20  return named->GetName();
21 
22  return 0;
23 }
tuple node
Definition: Node.py:50
const TGeoShape* get_shape ( const TEveElement *  element)

Definition at line 49 of file vis_macros.cc.

References python.Node::node.

Referenced by clone().

49  {
50  // a TEveGeoNode, can look into its TGeoNode and retrieve the shape
51  if (const TEveGeoNode * node = dynamic_cast<const TEveGeoNode *>( element )) {
52  return node->GetNode()->GetVolume()->GetShape();
53  }
54  // a TEveGeoShape owns its shape
55  if (const TEveGeoShape * shape = dynamic_cast<const TEveGeoShape *>( element )) {
56  TEveGeoShape * nc_shape = const_cast<TEveGeoShape *>( shape );
57  return const_cast<const TGeoShape *>( nc_shape->GetShape() );
58  }
59  // a TEveElement is too generic, no way to get a shape
60  return 0;
61 }
tuple node
Definition: Node.py:50
TGeoShape* get_shape ( TEveElement *  element)

Definition at line 64 of file vis_macros.cc.

64  {
65  // a TEveGeoNode cannot modify its shape
66  //if (const TEveGeoNode * node __attribute__ ((unused)) = dynamic_cast<const TEveGeoNode *>( element )) {
67  // return 0;
68  //}
69  // a TEveGeoShape owns its shape, and can modifiy it
70  if (TEveGeoShape * shape = dynamic_cast<TEveGeoShape *>( element )) {
71  return shape->GetShape();
72  }
73  // a TEveElement is too generic, no way to get a shape
74  return 0;
75 }
const char* get_title ( const TEveElement *  element)

Definition at line 28 of file eve_macros.cc.

References python.Node::node.

Referenced by clone().

28  {
29  // try as a TEveGeoNode or TEveGeoShape
30  if (const TEveGeoNode * node = dynamic_cast<const TEveGeoNode *>( element ))
31  return node->GetTitle();
32  if (const TEveGeoShape * shape = dynamic_cast<const TEveGeoShape *>( element ))
33  return shape->GetTitle();
34 
35  // try to access the element as a generic named object
36  if (const TNamed * named = dynamic_cast<const TNamed *>( element ))
37  return named->GetTitle();
38 
39  return 0;
40 }
tuple node
Definition: Node.py:50
TGeoMatrix* get_transform ( const TEveElement *  element)

Definition at line 95 of file eve_macros.cc.

References i, and python.Node::node.

Referenced by clone().

95  {
96  if (const TEveGeoNode * node = dynamic_cast<const TEveGeoNode *>( element )) {
97  // a TEveGeoNode is a proxy to a TGeoNode, which knows its relative transformation wrt. its parent
98  // so we follow the TEveGeoNode hierarchy up to a TEveGeoTopNode, then jump to its TGeoManager, and go back down the branches to the TEveGeoNode's TGeoNode
99  std::vector< const TEveGeoNode * > nodes;
100  const TEveGeoTopNode * top = 0;
101 
102  while ((top = dynamic_cast<const TEveGeoTopNode *>( node )) == 0) {
103  // save the current node
104  nodes.push_back(node);
105 
106  // check that the node actually has any parents
107  TEveGeoNode * nc_node = const_cast<TEveGeoNode *>( node );
108  if (nc_node->BeginParents() == nc_node->EndParents())
109  return 0;
110 
111  // assume the firt parent is the good one, and check that the parent type is correct
112  node = dynamic_cast<const TEveGeoNode *>( * nc_node->BeginParents() );
113  if (node == 0)
114  return 0;
115  }
116  // reached the top level node, start from its (optional) global transormation
117  TGeoHMatrix * matrix = new TGeoHMatrix();
118  (const_cast<TEveGeoTopNode *>(top))->RefGlobalTrans().SetGeoHMatrix( *matrix );
119  for (unsigned int i = 0; i < nodes.size(); ++i)
120  *matrix *= *(nodes[i]->GetNode()->GetMatrix());
121  return matrix;
122  }
123 
124  if (const TEveGeoShape * shape = dynamic_cast<const TEveGeoShape *>( element )) {
125  // a TEveGeoShape knows the absolute transformation of its shape
126  TGeoHMatrix * matrix = new TGeoHMatrix();
127  (const_cast<TEveGeoShape *>(shape))->RefHMTrans().SetGeoHMatrix( *matrix );
128  return matrix;
129  }
130 
131  return 0;
132 }
int i
Definition: DBlmapReader.cc:9
tuple node
Definition: Node.py:50
void hide_tracker_endcap ( TEveElement *  tracker)

Definition at line 167 of file vis_macros.cc.

References set_tracker_endcap_visibility().

168 {
170 }
void set_tracker_endcap_visibility(TEveElement *tracker, bool visibility)
Definition: vis_macros.cc:149
bool is_leaf_node ( const TEveElement *  element)

Definition at line 100 of file vis_macros.cc.

References python.Node::node.

Referenced by set_children_visibility().

101 {
102  // a TEveGeoNode can have unaccounted-for children
103  if (const TEveGeoNode * node = dynamic_cast<const TEveGeoNode *>( element )) {
104  return ((node->NumChildren() == 0) and (node->GetNode()->GetVolume()->GetNdaughters() == 0));
105  }
106  // a TEveGeoShape always knows its children
107  if (const TEveGeoShape * shape = dynamic_cast<const TEveGeoShape *>( element )) {
108  return (shape->NumChildren() == 0);
109  }
110  // default implementation
111  return (element->NumChildren() == 0);
112 }
tuple node
Definition: Node.py:50
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.

References get_name(), i, is_leaf_node(), j, AlCaRecoCosmics_cfg::name, or, and findQualityFiles::size.

Referenced by set_tracker_endcap_visibility().

117 {
118  // try to access the element as a named thingy
119  const char * name = get_name( element );
120  if (not name or strncmp(name, node_name.c_str(), node_name.size()))
121  // unnamed node, or wrong node
122  return;
123 
124  for (std::list<TEveElement *>::iterator j = element->BeginChildren(); j != element->EndChildren(); ++j) {
125  TEveElement * child = *j;
126  name = get_name( child );
127  if (not name)
128  // unnamed node, ignore it
129  continue;
130 
131  for (unsigned int i = 0; i < children_name.size(); ++i)
132  if (not strncmp(name, children_name[i].c_str(), children_name[i].size())) {
133  // change this child visibility
134  if (is_leaf_node( child )) {
135  child->SetRnrSelf( visibility );
136  child->SetRnrChildren( false );
137  } else {
138  child->SetRnrSelf( false );
139  child->SetRnrChildren( visibility );
140  }
141  break;
142  }
143  }
144  // notify the element that is had changed
145  element->ElementChanged(true, true);
146 }
int i
Definition: DBlmapReader.cc:9
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventIDconst &, edm::Timestampconst & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
const char * get_name(const TEveElement *element)
Definition: vis_macros.cc:11
int j
Definition: DBlmapReader.cc:9
bool is_leaf_node(const TEveElement *element)
Definition: vis_macros.cc:100
tuple size
Write out results.
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.

References expand_node(), i, and set_color().

Referenced by set_color().

78 {
79  if (not element)
80  return;
81 
82  // set this node's color
83  element->SetMainColor( color );
84  if (alpha > 1.) alpha = 1.;
85  if (alpha < 0.) alpha = 0.;
86  unsigned char transparency = (unsigned char) roundf(100. - (alpha * 100.));
87  element->SetMainTransparency( transparency );
88 
89  if (levels > 0) {
90  // set the node's children's color
91  expand_node( element );
92  for (std::list<TEveElement*>::iterator i = element->BeginChildren(); i != element->EndChildren(); ++i)
93  set_color( *i, color, alpha, levels - 1);
94  }
95  // notify the element that it has changed
96  element->ElementChanged(true, true);
97 }
int i
Definition: DBlmapReader.cc:9
float alpha
Definition: AMPTWrapper.h:95
void expand_node(TEveElement *element)
Definition: vis_macros.cc:26
void set_color(TEveElement *element, Color_t color, float alpha, unsigned int levels)
Definition: vis_macros.cc:77
void set_tracker_endcap_visibility ( TEveElement *  tracker,
bool  visibility 
)

Definition at line 149 of file vis_macros.cc.

References Reference_intrackfit_cff::endcap, and set_children_visibility().

Referenced by hide_tracker_endcap(), and show_tracker_endcap().

150 {
151  std::vector<std::string> endcap;
152  endcap.push_back("tec:TEC");
153  endcap.push_back("tidf:TIDF");
154  endcap.push_back("tidb:TIDB");
155  endcap.push_back("pixfwd:PixelForwardZPlus");
156  endcap.push_back("pixfwd:PixelForwardZMinus");
157  set_children_visibility( tracker, "tracker:Tracker", endcap, visibility );
158 }
void set_children_visibility(TEveElement *element, const std::string &node_name, const std::vector< std::string > &children_name, bool visibility)
Definition: vis_macros.cc:116
void show_tracker_endcap ( TEveElement *  tracker)

Definition at line 161 of file vis_macros.cc.

References set_tracker_endcap_visibility().

162 {
164 }
void set_tracker_endcap_visibility(TEveElement *tracker, bool visibility)
Definition: vis_macros.cc:149