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[ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

  1 // Copyright (C) 2010, Guy Barrand. All rights reserved.
  2 // See the file tools.license for terms.
  3 
  4 #ifndef tools_sg_ecbk
  5 #define tools_sg_ecbk
  6 
  7 // A callback class to handle a response to some event
  8 // (viewer/window size, mouse button press, etc...).
  9 // It is typically used through the event_dispatcher node.
 10 
 11 #include "bcbk"
 12 #include "event"
 13 #include "event_action"
 14 #include "../forit"
 15 #include "../HEADER"
 16 
 17 #include <vector>
 18 
 19 namespace tools {
 20 namespace sg {
 21   class node;
 22 }}
 23 
 24 namespace tools {
 25 namespace sg {
 26 
 27 class ecbk : public bcbk {
 28   TOOLS_HEADER(ecbk,tools::sg::ecbk,bcbk)
 29 public:
 30   ecbk(unsigned int a_action = 0)
 31   :parent()
 32   ,m_action(a_action)
 33   ,m_no_set_done(false)
 34   ,m_event(0)
 35   ,m_event_action(0)
 36   ,m_node(0)
 37   ,m_z(0)
 38   ,m_w(0)
 39   {}
 40   virtual ~ecbk(){delete m_event;}
 41 public:
 42   ecbk(const ecbk& a_from)
 43   :parent(a_from)
 44   ,m_action(a_from.m_action)
 45   ,m_no_set_done(a_from.m_no_set_done)
 46   ,m_event(0)
 47   ,m_event_action(a_from.m_event_action)
 48   ,m_node(a_from.m_node)
 49   ,m_z(a_from.m_z)
 50   ,m_w(a_from.m_w)
 51   {
 52     if(a_from.m_event) m_event = a_from.m_event->copy();
 53   }
 54   ecbk& operator=(const ecbk& a_from){
 55     parent::operator=(a_from);
 56 
 57     m_action = a_from.m_action;
 58     m_no_set_done = a_from.m_no_set_done;
 59 
 60     delete m_event;
 61     m_event = 0;
 62     if(a_from.m_event) m_event = a_from.m_event->copy();
 63 
 64     m_event_action = a_from.m_event_action;
 65     m_node = a_from.m_node;
 66     m_z = a_from.m_z;
 67     m_w = a_from.m_w;
 68     return *this;
 69   }
 70 public:
 71   void set_action(unsigned int a_v){m_action = a_v;}
 72   void set_no_set_done(bool a_v) {m_no_set_done = a_v;}
 73   // for ArcheryTune :
 74   event& event_ref() const {return *m_event;}
 75   event_action& event_action_ref() const {return *m_event_action;}
 76 public:
 77   static void exec_event_cbks(const std::vector<bcbk*>& a_cbks,
 78                               const event& a_evt,
 79                               event_action* a_action,
 80                               node* a_node,
 81                               float a_z = 0,float a_w = 0) {
 82     tools_vforcit(bcbk*,a_cbks,it) {
 83       bcbk* _cbk = (*it)->copy();
 84 
 85       if(ecbk* _ecbk = safe_cast<bcbk,ecbk>(*_cbk)){
 86         delete _ecbk->m_event;
 87         _ecbk->m_event = a_evt.copy();
 88 
 89         _ecbk->m_event_action = a_action;
 90         _ecbk->m_node = a_node;
 91         _ecbk->m_z = a_z;
 92         _ecbk->m_w = a_w;
 93 
 94         _ecbk->action();
 95 
 96         if(a_action->done()) {
 97           delete _cbk;
 98           break;
 99         }
100       }
101 
102       delete _cbk;
103     }
104   }
105 
106 public:
107   unsigned int m_action;
108   bool m_no_set_done; //to tell not doing m_event_action->set_done(true).
109   event* m_event;         //owner
110   event_action* m_event_action; //not owner.
111   node* m_node;           //not owner.
112   float m_z;
113   float m_w;
114 };
115 
116 }}
117 
118 #endif