/
DDExpandedView.h
147 lines (112 loc) · 4.77 KB
/
DDExpandedView.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#ifndef DDExpandedView_h
#define DDExpandedView_h
#include <iosfwd>
#include <vector>
#include <string>
#include <map>
#include "DetectorDescription/Core/interface/DDTransform.h"
#include "DetectorDescription/Base/interface/DDTranslation.h"
#include "DetectorDescription/Core/interface/DDCompactView.h"
#include "DetectorDescription/Core/interface/DDLogicalPart.h"
#include "DetectorDescription/Core/interface/DDPosData.h"
#include "DetectorDescription/Core/interface/DDExpandedNode.h"
#include "DetectorDescription/Core/interface/DDsvalues.h"
class DDFilteredView;
/**
DDExpandedView provides a tree-walker (iterator) for the
expanded view of the detector description.
Further it provides a registration mechanism for call-backs
whenever a node in the expanded view becomes current and
fullfills the user-defined predicate.
FIXME: DDExpandedView: in the Prototype just one class -
FIXME: later seperation of interface & implementation!
*/
//! Provides an exploded view of the detector (tree-view)
/** Taking a DDCompactView the DDExpandedView expands the compact-view into
a detector tree. One instance of DDExpandedView corresponds to one node
in the tree. It is the 'current' node. By using tree navigation ( next(), nextSibling(),
parent(), firstChild() ) the DDExpandedView represents the new corresponding node.
*/
class DDExpandedView
{
friend class DDFilteredView;
public:
//! std::vector of sibling numbers
typedef std::vector<int> nav_type;
typedef std::pair<int const *, size_t> NavRange;
//! Constructs an expanded-view based on the compact-view
DDExpandedView(const DDCompactView &);
virtual ~DDExpandedView();
//! The logical-part of the current node in the expanded-view
const DDLogicalPart & logicalPart() const;
//! The absolute translation of the current node
const DDTranslation & translation() const;
//! The absolute rotation of the current node
const DDRotationMatrix & rotation() const;
//! The list of ancestors up to the root-node of the current node
const DDGeoHistory & geoHistory() const;
//! transversed the DDExpandedView according to the given stack of sibling numbers
bool goTo(const nav_type &);
bool goTo(NavRange);
bool goTo(int const * newpos, size_t sz);
//! return the stack of sibling numbers which indicates the current position in the DDExpandedView
nav_type navPos() const;
//! return the stack of copy numbers
nav_type copyNumbers() const;
//! User specific data attached to the current node
std::vector<const DDsvalues_type * > specifics() const;
void specificsV(std::vector<const DDsvalues_type * > & vc ) const;
DDsvalues_type mergedSpecifics() const;
void mergedSpecificsV(DDsvalues_type & res) const;
//! Copy number associated with the current node
int copyno() const;
// navigation
//! The scope of the expanded-view.
const DDGeoHistory & scope() const;
//! sets the scope of the expanded view
bool setScope(const DDGeoHistory & hist, int depth=0);
//! clears the scope; the full tree is available, depth=0
void clearScope();
//! depth of the scope. 0 means unrestricted depth.
int depth() const;
//! set current node to the next node in the expanded tree
bool next();
//! broad search order of next()
bool nextB();
//! set the current node to the next sibling ...
bool nextSibling();
//! set the current node to the first child ...
bool firstChild();
//! set the current node to the parent node ...
bool parent();
//! true, if a call to firstChild() would succeed (current node has at least one child)
//bool hasChildren() const;
//! clears the scope and sets the ExpandedView to its root-node
void reset();
/** NOT IN THE PROTOTYPE
\todo void addNodeAction(const DDNodeAction &);
\todo bool removeNodeAction(const DDNodeAction &);
*/
/* was protected, now public; was named goTo, now goToHistory*/
bool goToHistory(const DDGeoHistory & sc);
protected:
bool descend(const DDGeoHistory & sc);
protected:
DDCompactView::walker_type * walker_; //!< the tricky walker
DDCompactView::walker_type w2_;
const DDTranslation trans_;
const DDRotationMatrix rot_;
DDGeoHistory history_; //!< std::vector of DDExpandedNode
DDGeoHistory scope_; //!< scope of the expanded view
unsigned int depth_; //!< depth of the scope, 0==unrestricted depth
DDPosData * worldpos_ ; //!< ???
std::vector<nav_type> nextBStack_;
};
std::ostream & printNavType(std::ostream &, int const * n, size_t sz);
inline std::ostream & operator<<(std::ostream & os, const DDExpandedView::nav_type & n) {
return printNavType(os,&n.front(),n.size());
}
inline std::ostream & operator<<(std::ostream & os, const DDExpandedView::NavRange & n) {
return printNavType(os,n.first,n.second);
}
#endif