H3D API  2.4.1
BooleanFilter.h
Go to the documentation of this file.
1 // Copyright 2004-2019, SenseGraphics AB
3 //
4 // This file is part of H3D API.
5 //
6 // H3D API is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
10 //
11 // H3D API is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with H3D API; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 //
20 // A commercial license is also available. Please contact us at
21 // www.sensegraphics.com for more information.
22 //
23 //
27 //
29 #ifndef __BOOLEANFILTER_H__
30 #define __BOOLEANFILTER_H__
31 
32 #include <H3D/X3DChildNode.h>
33 #include <H3D/SFBool.h>
34 
35 namespace H3D {
36 
54  class H3DAPI_API BooleanFilter : public X3DChildNode {
55  public:
58  class H3DAPI_API NegateSFBool: public SFBool {
59  virtual void update() {
60  BooleanFilter *bf =
61  static_cast< BooleanFilter * >( getOwner() );
62  value =
63  !static_cast< SFBool * >( event.ptr )->getValue( bf->id );
64  }
65  };
66 #ifdef __BORLANDC__
67  friend class NegateSFBool;
68 #endif
69 
73  class H3DAPI_API SetBoolean: public AutoUpdate< SFBool > {
74  public:
77  virtual void setValue( const bool &b, int _id = 0 ) {
78  SFBool::setValue( b, _id );
79  BooleanFilter *bf =
80  static_cast< BooleanFilter * >( getOwner() );
81  if( value )
82  bf->inputTrue->setValue( true, bf->id );
83  else
84  bf->inputFalse->setValue( false, bf->id );
85  }
86  protected:
89  virtual void update() {
91  BooleanFilter *bf =
92  static_cast< BooleanFilter * >( getOwner() );
93  if( value )
94  bf->inputTrue->setValue( true, bf->id );
95  else
96  bf->inputFalse->setValue( false, bf->id );
97  }
98  };
99 #ifdef __BORLANDC__
100  friend class SetBoolean;
101 #endif
102 
104  BooleanFilter( Inst< SFNode > _metadata = 0,
105  Inst< SetBoolean > _set_boolean = 0,
106  Inst< SFBool > _inputFalse = 0,
107  Inst< NegateSFBool > _inputNegate = 0,
108  Inst< SFBool > _inputTrue = 0 );
109 
115  H3DUniquePtr< SetBoolean > set_boolean;
116 
123  H3DUniquePtr< SFBool > inputFalse;
124 
130  H3DUniquePtr< NegateSFBool > inputNegate;
131 
138  H3DUniquePtr< SFBool > inputTrue;
139 
142  };
143 }
144 
145 #endif
Contains the SFBool field class.
Header file for X3DChildNode, X3D scene-graph node.
This field class takes as input SFBool fields and sets its value to the negated value of the input fi...
Definition: BooleanFilter.h:58
The SetBoolean class is specialize to set the value of either the inputTrue or inputFalse field in th...
Definition: BooleanFilter.h:73
virtual void update()
Sets either the inputTrue or inputFalse field depending on the new value.
Definition: BooleanFilter.h:89
virtual void setValue(const bool &b, int _id=0)
Sets either the inputTrue or inputFalse field depending on the new value.
Definition: BooleanFilter.h:77
BooleanFilter filters boolean events, allowing for selective routing of TRUE or FALSE values and nega...
Definition: BooleanFilter.h:54
H3DUniquePtr< SFBool > inputFalse
Generates an FALSE event if the set_boolean value is set to FALSE.
Definition: BooleanFilter.h:123
static H3DNodeDatabase database
The H3DNodedatabase for this node.
Definition: BooleanFilter.h:141
H3DUniquePtr< SetBoolean > set_boolean
The boolean field to filter.
Definition: BooleanFilter.h:115
H3DUniquePtr< SFBool > inputTrue
Generates an TRUE event if the set_boolean value is set to TRUE.
Definition: BooleanFilter.h:138
H3DUniquePtr< NegateSFBool > inputNegate
This field contains the negation of the set_boolean field.
Definition: BooleanFilter.h:130
The SFBool field contains a single boolean value.
Definition: SFBool.h:41
virtual void setValue(const bool &v, int id=0)
Set the value of the field.
Definition: SField.h:215
virtual void update()
Make the field up to date given that an event has occured.
Definition: SField.h:181
This abstract node type indicates that the concrete nodes which are instantiated based on it may be u...
Definition: X3DChildNode.h:42
Type getValue(const char *s, const char *&rest)
Function that reads characters from a char * and converts them to a given type.
Definition: X3DFieldConversion.h:134
H3D API namespace.
Definition: Anchor.h:38
The AutoUpdate field is a template to force the BaseField to update itself as soon as an event is rec...
Definition: FieldTemplates.h:130
The H3DNodeDatabase contains a mapping between a name of a Node and the constructor for the Node with...
Definition: H3DNodeDatabase.h:194