Warning, /include/Geant4/tools/sg/ecbk 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_ecbk
0005 #define tools_sg_ecbk
0006
0007 // A callback class to handle a response to some event
0008 // (viewer/window size, mouse button press, etc...).
0009 // It is typically used through the event_dispatcher node.
0010
0011 #include "bcbk"
0012 #include "event"
0013 #include "event_action"
0014 #include "../forit"
0015 #include "../HEADER"
0016
0017 #include <vector>
0018
0019 namespace tools {
0020 namespace sg {
0021 class node;
0022 }}
0023
0024 namespace tools {
0025 namespace sg {
0026
0027 class ecbk : public bcbk {
0028 TOOLS_HEADER(ecbk,tools::sg::ecbk,bcbk)
0029 public:
0030 ecbk(unsigned int a_action = 0)
0031 :parent()
0032 ,m_action(a_action)
0033 ,m_no_set_done(false)
0034 ,m_event(0)
0035 ,m_event_action(0)
0036 ,m_node(0)
0037 ,m_z(0)
0038 ,m_w(0)
0039 {}
0040 virtual ~ecbk(){delete m_event;}
0041 public:
0042 ecbk(const ecbk& a_from)
0043 :parent(a_from)
0044 ,m_action(a_from.m_action)
0045 ,m_no_set_done(a_from.m_no_set_done)
0046 ,m_event(0)
0047 ,m_event_action(a_from.m_event_action)
0048 ,m_node(a_from.m_node)
0049 ,m_z(a_from.m_z)
0050 ,m_w(a_from.m_w)
0051 {
0052 if(a_from.m_event) m_event = a_from.m_event->copy();
0053 }
0054 ecbk& operator=(const ecbk& a_from){
0055 parent::operator=(a_from);
0056
0057 m_action = a_from.m_action;
0058 m_no_set_done = a_from.m_no_set_done;
0059
0060 delete m_event;
0061 m_event = 0;
0062 if(a_from.m_event) m_event = a_from.m_event->copy();
0063
0064 m_event_action = a_from.m_event_action;
0065 m_node = a_from.m_node;
0066 m_z = a_from.m_z;
0067 m_w = a_from.m_w;
0068 return *this;
0069 }
0070 public:
0071 void set_action(unsigned int a_v){m_action = a_v;}
0072 void set_no_set_done(bool a_v) {m_no_set_done = a_v;}
0073 // for ArcheryTune :
0074 event& event_ref() const {return *m_event;}
0075 event_action& event_action_ref() const {return *m_event_action;}
0076 public:
0077 static void exec_event_cbks(const std::vector<bcbk*>& a_cbks,
0078 const event& a_evt,
0079 event_action* a_action,
0080 node* a_node,
0081 float a_z = 0,float a_w = 0) {
0082 tools_vforcit(bcbk*,a_cbks,it) {
0083 bcbk* _cbk = (*it)->copy();
0084
0085 if(ecbk* _ecbk = safe_cast<bcbk,ecbk>(*_cbk)){
0086 delete _ecbk->m_event;
0087 _ecbk->m_event = a_evt.copy();
0088
0089 _ecbk->m_event_action = a_action;
0090 _ecbk->m_node = a_node;
0091 _ecbk->m_z = a_z;
0092 _ecbk->m_w = a_w;
0093
0094 _ecbk->action();
0095
0096 if(a_action->done()) {
0097 delete _cbk;
0098 break;
0099 }
0100 }
0101
0102 delete _cbk;
0103 }
0104 }
0105
0106 public:
0107 unsigned int m_action;
0108 bool m_no_set_done; //to tell not doing m_event_action->set_done(true).
0109 event* m_event; //owner
0110 event_action* m_event_action; //not owner.
0111 node* m_node; //not owner.
0112 float m_z;
0113 float m_w;
0114 };
0115
0116 }}
0117
0118 #endif