Open Inventor Reference
|
00001 /* 00002 * 00003 * Copyright (C) 2000 Silicon Graphics, Inc. All Rights Reserved. 00004 * 00005 * This library is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU Lesser General Public 00007 * License as published by the Free Software Foundation; either 00008 * version 2.1 of the License, or (at your option) any later version. 00009 * 00010 * This library is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * Lesser General Public License for more details. 00014 * 00015 * Further, this software is distributed without any warranty that it is 00016 * free of the rightful claim of any third person regarding infringement 00017 * or the like. Any license provided herein, whether implied or 00018 * otherwise, applies only to this software file. Patent licenses, if 00019 * any, provided herein do not apply to combinations of this program with 00020 * other software, or any other product whatsoever. 00021 * 00022 * You should have received a copy of the GNU Lesser General Public 00023 * License along with this library; if not, write to the Free Software 00024 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00025 * 00026 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, 00027 * Mountain View, CA 94043, or: 00028 * 00029 * http://www.sgi.com 00030 * 00031 * For further information regarding this notice, see: 00032 * 00033 * http://oss.sgi.com/projects/GenInfo/NoticeExplan/ 00034 * 00035 */ 00036 00037 00038 /* 00039 * Copyright (C) 1990,91,92 Silicon Graphics, Inc. 00040 * 00041 _______________________________________________________________________ 00042 ______________ S I L I C O N G R A P H I C S I N C . ____________ 00043 | 00044 | $Revision: 1.1.1.1 $ 00045 | 00046 | Description: 00047 | This file contains the implementation of the TimeCounter engine 00048 | 00049 | Classes: 00050 | SoTimeCounter 00051 | 00052 | Author(s) : Ronen Barzel 00053 | 00054 ______________ S I L I C O N G R A P H I C S I N C . ____________ 00055 _______________________________________________________________________ 00056 */ 00057 00058 #ifndef _SO_TIME_COUNTER_ 00059 #define _SO_TIME_COUNTER_ 00060 00061 #include <Inventor/system/SbSystem.h> 00062 #include <Inventor/engines/SoSubEngine.h> 00063 #include <Inventor/fields/SoSFShort.h> 00064 #include <Inventor/fields/SoSFFloat.h> 00065 #include <Inventor/fields/SoMFFloat.h> 00066 #include <Inventor/fields/SoSFTime.h> 00067 #include <Inventor/fields/SoSFBool.h> 00068 #include <Inventor/fields/SoSFTrigger.h> 00069 00072 00146 00147 00148 class INVENTOR_API SoTimeCounter : public SoEngine { 00149 00150 SO_ENGINE_HEADER(SoTimeCounter); 00151 00152 public: 00154 00155 00157 SoSFShort min; 00158 00160 SoSFShort max; 00161 00163 SoSFShort step; 00164 00166 SoSFBool on; 00167 00169 SoSFFloat frequency; 00170 00172 SoMFFloat duty; 00173 00175 SoSFTime timeIn; 00176 00178 SoSFTrigger syncIn; 00179 00181 SoSFShort reset; 00182 00184 00186 00187 00189 SoEngineOutput output; 00190 00192 SoEngineOutput syncOut; 00193 00195 00197 SoTimeCounter(); 00198 00199 SoINTERNAL public: 00200 00201 static void initClass(); 00202 00203 protected: 00204 virtual void inputChanged(SoField *whichInput); 00205 00208 virtual void writeInstance(SoOutput *out); 00209 00213 virtual SbBool readInstance(SoInput *in, unsigned short flags); 00214 00215 private: 00216 enum State { 00217 ON, 00218 PAUSED 00219 } state; 00220 enum Todo { 00221 RECALC = (1<<0), 00222 RESET = (1<<1), 00223 SYNC = (1<<2), 00224 PAUSE = (1<<3), 00225 UNPAUSE = (1<<4) 00226 }; 00227 unsigned int todo; 00228 SbTime period; 00229 int nStages; 00230 int curStage; 00231 int prevStage; 00232 struct Stage { 00233 int val; 00234 float duty; 00235 SbTime offset; 00236 } *stages; 00237 SbTime baseTime; 00238 SbTime pauseOffset; 00239 00241 ~SoTimeCounter(); 00242 00244 virtual void evaluate(); 00245 }; 00246 00247 #endif /* _SO_TIME_COUNTER_ */