g4tools  5.4.0
Public Member Functions | Public Attributes | List of all members
tools::sg::_switch Class Reference
Inheritance diagram for tools::sg::_switch:
Inheritance graph
[legend]
Collaboration diagram for tools::sg::_switch:
Collaboration graph
[legend]

Public Member Functions

virtual const desc_fieldsnode_desc_fields () const
 
virtual void render (render_action &a_action)
 
virtual void pick (pick_action &a_action)
 
virtual void bbox (bbox_action &a_action)
 
virtual void search (search_action &a_action)
 
virtual void event (event_action &a_action)
 
virtual bool write (write_action &a_action)
 
 _switch ()
 
virtual ~_switch ()
 
 _switch (const _switch &a_from)
 
_switchoperator= (const _switch &a_from)
 
nodewhich_node () const
 
- Public Member Functions inherited from tools::sg::group
virtual void get_matrix (get_matrix_action &a_action)
 
virtual void is_visible (visible_action &a_action)
 
 group ()
 
virtual ~group ()
 
 group (const group &a_from)
 
groupoperator= (const group &a_from)
 
void add (node *a_node)
 
void add_front (node *a_node)
 
void set (unsigned int a_index, node *a_node)
 
bool replace (const node *a_from, node *a_to, bool a_del)
 
void swap (unsigned int a_1, unsigned int a_2)
 
template<class T >
T * search () const
 
void * rsearch_from (const node *a_node, const std::string &a_class, bool a_inc_a_node=true) const
 
bool remove (const node *a_node)
 
bool remove_index (unsigned int a_index)
 
bool delete_from (const node *a_node, bool a_inc_a_node=true)
 
void transfer (group &a_from)
 
void transfer (std::vector< node * > &a_to)
 
void clear ()
 
void raw_clear ()
 
size_t size () const
 
bool empty () const
 
nodeoperator[] (size_t a_index) const
 
const std::vector< node * > & children () const
 
std::vector< node * > & children ()
 
bool insert (unsigned int a_index, node *a_new)
 
template<class T >
T * rsearch () const
 
bool position (const node *a_node, unsigned int &a_index) const
 
nodenode_at (unsigned int a_index) const
 
template<class T >
T * child (unsigned int a_index) const
 
- Public Member Functions inherited from tools::sg::node
virtual void * cast (const std::string &a_class) const
 
virtual const std::string & s_cls () const =0
 
virtual nodecopy () const =0
 
virtual unsigned int cls_version () const
 
virtual bool read (read_action &a_action)
 
virtual void protocol_one_fields (std::vector< field * > &a_fields) const
 
virtual bool draw_in_frame_buffer () const
 
virtual bool touched ()
 
virtual void reset_touched ()
 
 node ()
 
virtual ~node ()
 
void touch ()
 
fieldfield_from_desc (const field_desc &a_desc) const
 
void dump_field_descs (std::ostream &a_out) const
 
fieldfind_field_by_name (const std::string &a_name) const
 

Public Attributes

sf< int > which
 

Additional Inherited Members

- Protected Member Functions inherited from tools::sg::group
bool write_children (write_action &a_action)
 
- Protected Member Functions inherited from tools::sg::node
 node (const node &)
 
nodeoperator= (const node &)
 
void add_field (field *a_field)
 
bool write_fields (write_action &a_action)
 
bool read_fields (read_action &a_action)
 
field_desc::offset_t field_offset (const field *a_field) const
 
fieldfind_field (const field_desc &a_rdesc) const
 
void check_fields (std::ostream &a_out) const
 
- Protected Attributes inherited from tools::sg::group
std::vector< node * > m_children
 

Detailed Description

Definition at line 15 of file _switch.

Constructor & Destructor Documentation

◆ _switch() [1/2]

tools::sg::_switch::_switch ( )
inline

Definition at line 97 of file _switch.

98  :group()
99  ,which(-1)
100  {
101  add_fields();
102  }

◆ ~_switch()

virtual tools::sg::_switch::~_switch ( )
inlinevirtual

Definition at line 103 of file _switch.

103 {}

◆ _switch() [2/2]

tools::sg::_switch::_switch ( const _switch a_from)
inline

Definition at line 105 of file _switch.

106  :group(a_from)
107  ,which(a_from.which)
108  {
109  add_fields();
110  }

Member Function Documentation

◆ bbox()

virtual void tools::sg::_switch::bbox ( bbox_action a_action)
inlinevirtual

Reimplemented from tools::sg::group.

Definition at line 48 of file _switch.

48  {
49  int index = which.value();
50  if(index==(-1)) {
51  group::bbox(a_action);
52  } else if((index>=0)&&(index<(int)m_children.size())) {
53  m_children[index]->bbox(a_action);
54  }
55  }

◆ event()

virtual void tools::sg::_switch::event ( event_action a_action)
inlinevirtual

Reimplemented from tools::sg::group.

Definition at line 67 of file _switch.

67  {
68  if(a_action.do_switch_children()) {
69  group::event(a_action);
70  } else {
71  int index = which.value();
72  if(index==(-1)){
73  group::event(a_action);
74  } else if((index>=0)&&(index<(int)m_children.size())) {
75  m_children[index]->event(a_action);
76  }
77  }
78  }

◆ node_desc_fields()

virtual const desc_fields& tools::sg::_switch::node_desc_fields ( ) const
inlinevirtual

Reimplemented from tools::sg::node.

Definition at line 20 of file _switch.

20  {
22  static const desc_fields s_v(parent::node_desc_fields(),1, //WARNING : take care of count.
24  );
25  return s_v;
26  }

◆ operator=()

_switch& tools::sg::_switch::operator= ( const _switch a_from)
inline

Definition at line 111 of file _switch.

111  {
112  group::operator=(a_from);
113  which = a_from.which;
114  return *this;
115  }

◆ pick()

virtual void tools::sg::_switch::pick ( pick_action a_action)
inlinevirtual

Reimplemented from tools::sg::group.

Definition at line 40 of file _switch.

40  {
41  int index = which.value();
42  if(index==(-1)) {
43  group::pick(a_action);
44  } else if((index>=0)&&(index<(int)m_children.size())) {
45  m_children[index]->pick(a_action);
46  }
47  }

◆ render()

virtual void tools::sg::_switch::render ( render_action a_action)
inlinevirtual

Reimplemented from tools::sg::group.

Definition at line 32 of file _switch.

32  {
33  int index = which.value();
34  if(index==(-1)) {
35  group::render(a_action);
36  } else if((index>=0)&&(index<(int)m_children.size())) {
37  m_children[index]->render(a_action);
38  }
39  }

◆ search()

virtual void tools::sg::_switch::search ( search_action a_action)
inlinevirtual

Reimplemented from tools::sg::group.

Definition at line 56 of file _switch.

56  {
57  int index = which.value();
58  if(index==(-1)) {
59  group::search(a_action);
60  } else if((index>=0)&&(index<(int)m_children.size())) {
61  if(a_action.do_path()) a_action.path_push(this);
62  m_children[index]->search(a_action);
63  if(a_action.done()) return;
64  if(a_action.do_path()) a_action.path_pop();
65  }
66  }

◆ which_node()

node* tools::sg::_switch::which_node ( ) const
inline

Definition at line 117 of file _switch.

117  {
118  int index = which.value();
119  if(index<0) return 0;
120  if(index>=(int)m_children.size()) return 0;
121  return m_children[index];
122  }

◆ write()

virtual bool tools::sg::_switch::write ( write_action a_action)
inlinevirtual

Reimplemented from tools::sg::group.

Definition at line 79 of file _switch.

79  {
80  if(!a_action.beg_node(*this)) return false;
81  if(!write_fields(a_action)) return false;
82 
83  if(a_action.switch_do_all_children()) { //for exam write_exsg
84  if(!write_children(a_action)) return false;
85  } else { //for exa write_gl2ps
86  int index = which.value();
87  if(index==(-1)) {
88  if(!write_children(a_action)) return false;
89  } else if((index>=0)&&(index<(int)m_children.size())) {
90  m_children[index]->write(a_action);
91  }
92  }
93  if(!a_action.end_node(*this)) return false;
94  return true;
95  }

Member Data Documentation

◆ which

sf<int> tools::sg::_switch::which

Definition at line 18 of file _switch.


The documentation for this class was generated from the following file:
tools::sg::group::bbox
virtual void bbox(bbox_action &a_action)
Definition: group:42
tools::sg::group::event
virtual void event(event_action &a_action)
Definition: group:45
tools::sg::group::group
group()
Definition: group:80
tools::sg::group::m_children
std::vector< node * > m_children
Definition: group:318
tools::sg::group::operator=
group & operator=(const group &a_from)
Definition: group:88
tools::sg::group::render
virtual void render(render_action &a_action)
Definition: group:24
tools::sg::group::pick
virtual void pick(pick_action &a_action)
Definition: group:36
tools::sg::_switch
Definition: _switch:15
TOOLS_FIELD_DESC_NODE_CLASS
#define TOOLS_FIELD_DESC_NODE_CLASS(a__class)
Definition: field:68
tools::sg::group::search
T * search() const
Definition: group:130
tools::sg::bsf::value
T & value()
Definition: bsf:98
tools::sg::node::write_fields
bool write_fields(write_action &a_action)
Definition: node:132
tools::sg::_switch::which
sf< int > which
Definition: _switch:18
TOOLS_ARG_FIELD_DESC
#define TOOLS_ARG_FIELD_DESC(a__field)
Definition: field:71
tools::sg::group::write_children
bool write_children(write_action &a_action)
Definition: group:311