g4tools  5.4.0
nodekit
Go to the documentation of this file.
1 // Copyright (C) 2010, Guy Barrand. All rights reserved.
2 // See the file tools.license for terms.
3 
4 #ifndef tools_sg_nodekit
5 #define tools_sg_nodekit
6 
7 #include "pick_action"
8 #include "group"
9 
10 namespace tools {
11 namespace sg {
12 
13 inline void nodekit_pick(pick_action& a_action,node& a_sg,node* a_node) {
14  if(a_action.stop_at_first()){
15  a_sg.pick(a_action);
16  if(a_action.done()) {
17  a_action.set_node(a_node);
18  a_action.save_state(a_action.state());
19  }
20  } else {
21  // have a local pick_action to override node in the found pick list.
22  pick_action action(a_action);
23  a_sg.pick(action);
24  typedef pick_action::pick_t pick_t;
25  const std::vector<pick_t>& pks = action.picks();
26  std::vector<pick_t>::const_iterator it;
27  for(it=pks.begin();it!=pks.end();++it) {
28  a_action.add_pick(*a_node,(*it).zs(),(*it).ws(),(*it).state());
29  }
30  }
31 }
32 
33 }}
34 
35 #include "render_action"
36 #include "bbox_action"
37 
38 namespace tools {
39 namespace sg {
40 
41 class nodekit : public node {
43 public:
44  virtual void update_sg(std::ostream&) = 0;
45 public:
46  virtual void render(render_action& a_action) {
47  update_if_touched(a_action.out());
48  m_group.render(a_action);
49  }
50  virtual void search(search_action& a_action) {
51  update_if_touched(a_action.out());
52  parent::search(a_action);
53  if(a_action.done()) return;
54  m_group.search(a_action);
55  }
56  virtual void bbox(bbox_action& a_action) {
57  update_if_touched(a_action.out());
58  m_group.bbox(a_action);
59  }
60 /*
61  virtual void pick(pick_action& a_action) {
62  update_if_touched(a_action.out());
63  nodekit_pick(a_action,m_group,this);
64  }
65  virtual bool write(write_action& a_action) {
66  update_if_touched(a_action.out());
67  //if(!write_fields(a_action)) return false;
68  return m_group.write(a_action);
69  }
70 */
71 public:
73  :parent()
74  {}
75  virtual ~nodekit(){}
76 public:
77  nodekit(const nodekit& a_from)
78  :parent(a_from)
79  {}
80  nodekit& operator=(const nodekit& a_from){
81  parent::operator=(a_from);
82  return *this;
83  }
84 protected:
85  void update_if_touched(std::ostream& a_out) {
86  if(touched()) {
87  update_sg(a_out);
88  reset_touched();
89  }
90  }
91 protected:
93 };
94 
95 }}
96 
97 #endif
tools::sg::nodekit::search
virtual void search(search_action &a_action)
Definition: nodekit:50
tools::sg::group::search
virtual void search(search_action &a_action)
Definition: group:51
tools::sg::action
Definition: action:19
tools::sg::nodekit::operator=
nodekit & operator=(const nodekit &a_from)
Definition: nodekit:80
tools::sg::nodekit::bbox
virtual void bbox(bbox_action &a_action)
Definition: nodekit:56
tools::sg::group::bbox
virtual void bbox(bbox_action &a_action)
Definition: group:42
pick_action
render_action
tools::sg::nodekit::~nodekit
virtual ~nodekit()
Definition: nodekit:75
tools::sg::pick_action::set_node
void set_node(sg::node *a_node)
Definition: pick_action:257
tools::sg::node
Definition: node:28
tools::sg::nodekit::render
virtual void render(render_action &a_action)
Definition: nodekit:46
tools::sg::bbox_action
Definition: bbox_action:15
tools::sg::search_action::done
bool done() const
Definition: search_action:68
tools::sg::group
Definition: group:21
tools::sg::pick_action::add_pick
void add_pick(sg::node &a_node, const std::vector< float > &a_zs, const std::vector< float > &a_ws, const sg::state &a_state)
Definition: pick_action:265
group
tools::sg::pick_action::stop_at_first
bool stop_at_first() const
Definition: pick_action:252
tools::sg::pick_action
Definition: pick_action:59
tools::sg::nodekit_pick
void nodekit_pick(pick_action &a_action, node &a_sg, node *a_node)
Definition: nodekit:13
tools::sg::group::render
virtual void render(render_action &a_action)
Definition: group:24
TOOLS_HEADER
#define TOOLS_HEADER(a__class, a__sclass, a__parent)
Definition: HEADER:10
tools::sg::search_action
Definition: search_action:19
tools::sg::render_action
Definition: render_action:24
tools
inlined C code : ///////////////////////////////////
Definition: aida_ntuple:26
tools::sg::nodekit::nodekit
nodekit()
Definition: nodekit:72
tools::sg::node::pick
virtual void pick(pick_action &)
Definition: node:54
tools::sg::nodekit::m_group
group m_group
Definition: nodekit:92
tools::sg::pick_action::done
bool done() const
Definition: pick_action:255
tools::sg::states::save_state
void save_state(const sg::state &a_state)
Definition: states:86
tools::sg::nodekit::nodekit
nodekit(const nodekit &a_from)
Definition: nodekit:77
tools::sg::action::out
std::ostream & out() const
Definition: action:51
tools::sg::nodekit::update_sg
virtual void update_sg(std::ostream &)=0
tools::sg::states::state
const sg::state & state() const
Definition: states:76
tools::sg::nodekit::update_if_touched
void update_if_touched(std::ostream &a_out)
Definition: nodekit:85
tools::sg::pick_element
Definition: pick_action:18
tools::sg::node::touched
virtual bool touched()
Definition: node:96
tools::sg::node::reset_touched
virtual void reset_touched()
Definition: node:102
bbox_action
tools::sg::nodekit
Definition: nodekit:41