Back to home page

EIC code displayed by LXR

 
 

    


Warning, /include/Geant4/tools/sg/nodekit is written in an unsupported language. File is not indexed.

0001 // Copyright (C) 2010, Guy Barrand. All rights reserved.
0002 // See the file tools.license for terms.
0003 
0004 #ifndef tools_sg_nodekit
0005 #define tools_sg_nodekit
0006 
0007 #include "pick_action"
0008 #include "group"
0009 
0010 namespace tools {
0011 namespace sg {
0012 
0013 inline void nodekit_pick(pick_action& a_action,node& a_sg,node* a_node) {
0014   if(a_action.stop_at_first()){
0015     a_sg.pick(a_action);
0016     if(a_action.done()) {
0017       a_action.set_node(a_node);
0018       a_action.save_state(a_action.state());
0019     }
0020   } else {
0021     // have a local pick_action to override node in the found pick list.
0022     pick_action action(a_action);
0023     a_sg.pick(action);
0024     typedef pick_action::pick_t pick_t;
0025     const std::vector<pick_t>& pks = action.picks();
0026     std::vector<pick_t>::const_iterator it;
0027     for(it=pks.begin();it!=pks.end();++it) {
0028       a_action.add_pick(*a_node,(*it).zs(),(*it).ws(),(*it).state());
0029     }
0030   }
0031 }
0032 
0033 }}
0034 
0035 #include "render_action"
0036 #include "bbox_action"
0037 
0038 namespace tools {
0039 namespace sg {
0040 
0041 class nodekit : public node {
0042   TOOLS_HEADER(nodekit,tools::sg::nodekit,node)
0043 public:
0044   virtual void update_sg(std::ostream&) = 0;
0045 public:
0046   virtual void render(render_action& a_action) {
0047     update_if_touched(a_action.out());
0048     m_group.render(a_action);
0049   }
0050   virtual void search(search_action& a_action) {
0051     update_if_touched(a_action.out());
0052     parent::search(a_action);
0053     if(a_action.done()) return;
0054     m_group.search(a_action);
0055   }
0056   virtual void bbox(bbox_action& a_action) {
0057     update_if_touched(a_action.out());
0058     m_group.bbox(a_action);
0059   }
0060 /*
0061   virtual void pick(pick_action& a_action) {
0062     update_if_touched(a_action.out());
0063     nodekit_pick(a_action,m_group,this);
0064   }
0065   virtual bool write(write_action& a_action) {
0066     update_if_touched(a_action.out());
0067     //if(!write_fields(a_action)) return false;
0068     return m_group.write(a_action);
0069   }
0070 */
0071 public:
0072   nodekit()
0073   :parent()
0074   {}
0075   virtual ~nodekit(){}
0076 public:
0077   nodekit(const nodekit& a_from)
0078   :parent(a_from)
0079   {}
0080   nodekit& operator=(const nodekit& a_from){
0081     parent::operator=(a_from);
0082     return *this;
0083   }
0084 protected:
0085   void update_if_touched(std::ostream& a_out) {
0086     if(touched()) {
0087       update_sg(a_out);
0088       reset_touched();
0089     }
0090   }
0091 protected:
0092   group m_group;
0093 };
0094 
0095 }}
0096 
0097 #endif