| 1 | /* |
| 2 | * |
| 3 | * Copyright (C) 2000 Silicon Graphics, Inc. All Rights Reserved. |
| 4 | * |
| 5 | * This library is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of the GNU Lesser General Public |
| 7 | * License as published by the Free Software Foundation; either |
| 8 | * version 2.1 of the License, or (at your option) any later version. |
| 9 | * |
| 10 | * This library is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | * Lesser General Public License for more details. |
| 14 | * |
| 15 | * Further, this software is distributed without any warranty that it is |
| 16 | * free of the rightful claim of any third person regarding infringement |
| 17 | * or the like. Any license provided herein, whether implied or |
| 18 | * otherwise, applies only to this software file. Patent licenses, if |
| 19 | * any, provided herein do not apply to combinations of this program with |
| 20 | * other software, or any other product whatsoever. |
| 21 | * |
| 22 | * You should have received a copy of the GNU Lesser General Public |
| 23 | * License along with this library; if not, write to the Free Software |
| 24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 25 | * |
| 26 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, |
| 27 | * Mountain View, CA 94043, or: |
| 28 | * |
| 29 | * http://www.sgi.com |
| 30 | * |
| 31 | * For further information regarding this notice, see: |
| 32 | * |
| 33 | * http://oss.sgi.com/projects/GenInfo/NoticeExplan/ |
| 34 | * |
| 35 | */ |
| 36 | |
| 37 | /* |
| 38 | * Copyright (C) 1990,91 Silicon Graphics, Inc. |
| 39 | * |
| 40 | _______________________________________________________________________ |
| 41 | ______________ S I L I C O N G R A P H I C S I N C . ____________ |
| 42 | | |
| 43 | | $Revision: 1.1.1.1 $ |
| 44 | | |
| 45 | | Classes: |
| 46 | | SoSFTrigger |
| 47 | | |
| 48 | | Author(s) : Ronen Barzel |
| 49 | | |
| 50 | ______________ S I L I C O N G R A P H I C S I N C . ____________ |
| 51 | _______________________________________________________________________ |
| 52 | */ |
| 53 | |
| 54 | #include <Inventor/fields/SoSFTrigger.h> |
| 55 | #include <Inventor/misc/SoNotification.h> |
| 56 | |
| 57 | ////////////////////////////////////////////////////////////////////////////// |
| 58 | // |
| 59 | // SoSFTrigger class |
| 60 | // |
| 61 | ////////////////////////////////////////////////////////////////////////////// |
| 62 | |
| 63 | // Use most of the standard stuff: |
| 64 | SO__FIELD_ID_SOURCE(SoSFTrigger); |
| 65 | SO__FIELD_EQ_SAME_SOURCE(SoSFTrigger); |
| 66 | SO_SFIELD_CONSTRUCTOR_SOURCE(SoSFTrigger); |
| 67 | |
| 68 | //////////////////////////////////////////////////////////////////////// |
| 69 | // |
| 70 | // Description: |
| 71 | // Comparison. Always returns TRUE. |
| 72 | // |
| 73 | // Use: internal |
| 74 | |
| 75 | int |
| 76 | SoSFTrigger::operator ==(const SoSFTrigger &) const |
| 77 | // |
| 78 | //////////////////////////////////////////////////////////////////////// |
| 79 | { |
| 80 | return TRUE; |
| 81 | } |
| 82 | |
| 83 | //////////////////////////////////////////////////////////////////////// |
| 84 | // |
| 85 | // Description: |
| 86 | // Comparison. Always returns FALSE. |
| 87 | // |
| 88 | // Use: internal |
| 89 | |
| 90 | int |
| 91 | SoSFTrigger::operator !=(const SoSFTrigger &) const |
| 92 | // |
| 93 | //////////////////////////////////////////////////////////////////////// |
| 94 | { |
| 95 | return FALSE; |
| 96 | } |
| 97 | |
| 98 | //////////////////////////////////////////////////////////////////////// |
| 99 | // |
| 100 | // Description: |
| 101 | // Method required to copy a field. For triggers, just touches the |
| 102 | // destination, ignoring the source |
| 103 | // |
| 104 | // Use: internal |
| 105 | |
| 106 | const SoSFTrigger & |
| 107 | SoSFTrigger::operator =(const SoSFTrigger &) |
| 108 | // |
| 109 | //////////////////////////////////////////////////////////////////////// |
| 110 | { |
| 111 | touch(); |
| 112 | return *this; |
| 113 | } |
| 114 | |
| 115 | //////////////////////////////////////////////////////////////////////// |
| 116 | // |
| 117 | // Description: |
| 118 | // "Reads value from file." Doesn't bother reading anything, since |
| 119 | // write method is a no-op. Note that trigger fields might get |
| 120 | // written/read for field connections to be written/read, so it's not |
| 121 | // an error for this routine to be called. |
| 122 | // |
| 123 | // Use: private |
| 124 | |
| 125 | SbBool |
| 126 | SoSFTrigger::readValue(SoInput *) |
| 127 | // |
| 128 | //////////////////////////////////////////////////////////////////////// |
| 129 | { |
| 130 | return TRUE; |
| 131 | } |
| 132 | |
| 133 | //////////////////////////////////////////////////////////////////////// |
| 134 | // |
| 135 | // Description: |
| 136 | // "Writes value of field to file." Doesn't bother writing anything. |
| 137 | // Note that trigger fields might get written/read for field connections |
| 138 | // to be written/read, so it's not an error for this routine to be |
| 139 | // called. |
| 140 | // |
| 141 | // Use: private |
| 142 | |
| 143 | void |
| 144 | SoSFTrigger::writeValue(SoOutput *) const |
| 145 | // |
| 146 | //////////////////////////////////////////////////////////////////////// |
| 147 | { |
| 148 | } |
| 149 | |
| 150 | //////////////////////////////////////////////////////////////////////// |
| 151 | // |
| 152 | // Description: |
| 153 | // Override startNotify to prevent notification from going any |
| 154 | // further than just this field. |
| 155 | // Temporarily sets container to NULL, which prevents notification |
| 156 | // from going to downstream connections. Relies on the dirty bit |
| 157 | // being set and evaluate getting called to clear it (in notify()). |
| 158 | // |
| 159 | // Use: internal |
| 160 | |
| 161 | void |
| 162 | SoSFTrigger::startNotify() |
| 163 | // |
| 164 | //////////////////////////////////////////////////////////////////////// |
| 165 | { |
| 166 | SoFieldContainer *container = getContainer(); |
| 167 | setContainer(NULL); |
| 168 | |
| 169 | SoField::startNotify(); |
| 170 | |
| 171 | setContainer(container); |
| 172 | } |
| 173 | |
| 174 | //////////////////////////////////////////////////////////////////////// |
| 175 | // |
| 176 | // Description: |
| 177 | // Override notification to always evaluate, clearing upstream dirty |
| 178 | // bits. |
| 179 | // |
| 180 | // Use: internal |
| 181 | |
| 182 | void |
| 183 | SoSFTrigger::notify(SoNotList *list) |
| 184 | // |
| 185 | //////////////////////////////////////////////////////////////////////// |
| 186 | { |
| 187 | SoField::notify(list); |
| 188 | evaluate(); |
| 189 | } |
| 190 | |
| 191 | //////////////////////////////////////////////////////////////////////// |
| 192 | // |
| 193 | // Description: |
| 194 | // Override touch to notify. |
| 195 | // |
| 196 | // Use: internal |
| 197 | |
| 198 | void |
| 199 | SoSFTrigger::touch() |
| 200 | // |
| 201 | //////////////////////////////////////////////////////////////////////// |
| 202 | { |
| 203 | SoField::startNotify(); // Use SoField method explicitly |
| 204 | } |
| 205 |