00001 /*======================================================================= 00002 * Copyright 1991-1996, Silicon Graphics, Inc. 00003 * ALL RIGHTS RESERVED 00004 * 00005 * UNPUBLISHED -- Rights reserved under the copyright laws of the United 00006 * States. Use of a copyright notice is precautionary only and does not 00007 * imply publication or disclosure. 00008 * 00009 * U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND: 00010 * Use, duplication or disclosure by the Government is subject to restrictions 00011 * as set forth in FAR 52.227.19(c)(2) or subparagraph (c)(1)(ii) of the Rights 00012 * in Technical Data and Computer Software clause at DFARS 252.227-7013 and/or 00013 * in similar or successor clauses in the FAR, or the DOD or NASA FAR 00014 * Supplement. Contractor/manufacturer is Silicon Graphics, Inc., 00015 * 2011 N. Shoreline Blvd. Mountain View, CA 94039-7311. 00016 * 00017 * THE CONTENT OF THIS WORK CONTAINS CONFIDENTIAL AND PROPRIETARY 00018 * INFORMATION OF SILICON GRAPHICS, INC. ANY DUPLICATION, MODIFICATION, 00019 * DISTRIBUTION, OR DISCLOSURE IN ANY FORM, IN WHOLE, OR IN PART, IS STRICTLY 00020 * PROHIBITED WITHOUT THE PRIOR EXPRESS WRITTEN PERMISSION OF SILICON 00021 * GRAPHICS, INC. 00022 **=======================================================================*/ 00023 /*======================================================================= 00024 ** Author : Gavin Bell (MMM yyyy) 00025 **=======================================================================*/ 00026 /*======================================================================= 00027 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), *** 00028 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. *** 00029 *** *** 00030 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS *** 00031 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR *** 00032 *** WRITTEN AUTHORIZATION OF FEI S.A.S. *** 00033 *** *** 00034 *** RESTRICTED RIGHTS LEGEND *** 00035 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS *** 00036 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN *** 00037 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT *** 00038 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN *** 00039 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. *** 00040 *** *** 00041 *** COPYRIGHT (C) 1996-2020 BY FEI S.A.S, *** 00042 *** BORDEAUX, FRANCE *** 00043 *** ALL RIGHTS RESERVED *** 00044 **=======================================================================*/ 00045 /*======================================================================= 00046 ** Modified by : VSG (MMM YYYY) 00047 **=======================================================================*/ 00048 00049 00050 #ifndef _SO_ENGINE_ 00051 #define _SO_ENGINE_ 00052 00053 #include <Inventor/SbBasic.h> 00054 #include <Inventor/fields/SoFieldContainer.h> 00055 #include <Inventor/SoLists.h> 00056 #include <Inventor/SbString.h> 00057 #include <Inventor/SoType.h> 00058 00060 // 00061 // Class: SoEngine 00062 // 00063 // Base SoEngine class (abstract). 00064 // 00066 00067 00068 class SoFieldData; 00069 class SoEngineList; 00070 class SoEngineOutput; 00071 class SoEngineOutputList; 00072 class SoEngineOutputData; 00073 class SoField; 00074 class SoOutput; 00075 class SoInput; 00076 00133 class SoEngine : public SoFieldContainer { 00134 00135 public: 00136 00140 static SoType getClassTypeId(); 00141 00147 virtual int getOutputs(SoEngineOutputList &list) const; 00148 00153 SoEngineOutput * getOutput(const SbName &outputName) const; 00154 00159 SbBool getOutputName(const SoEngineOutput *output, 00160 SbName &outputName) const; 00161 00166 SoEngine * copy() const; 00167 00171 static SoEngine * getByName(const SbName &name); 00175 static int getByName(const SbName &name, SoEngineList &list); 00176 00177 private: 00178 00182 virtual void evaluate() = 0; 00183 00184 private: 00185 00186 // wrapper for the user's evaluate() engine 00187 void evaluateWrapper(); 00188 00189 // Propagates modification notification through an instance. 00190 virtual void notify(SoNotList *list); 00191 00192 // Initializes base engine class 00193 static void initClass(); 00194 static void exitClass(); 00195 00196 // Info on outputs: 00197 virtual const SoEngineOutputData *getOutputData() const = 0; 00198 00199 // Initialize ALL Inventor engine classes 00200 static void initClasses(); 00201 static void exitClasses(); 00202 00203 // Writes instance to SoOutput. (Used only for last stage of writing) 00204 virtual void writeInstance(SoOutput *out); 00205 00206 // Copies an instance that is encountered through a field connection 00207 virtual SoFieldContainer * copyThroughConnection() const; 00208 00209 // Recursive procedure that determines if this engine should be 00210 // copied during a copy operation, or just referenced as is 00211 SbBool shouldCopy() const; 00212 00213 // A very annoying double notification occurs with engines 00214 // that enable their outputs during inputChanged; this flag 00215 // prevents that: 00216 SbBool isNotifying() const { return notifying; } 00217 00218 private: 00219 00220 // Constructor, destructor 00221 SoEngine(); 00222 virtual ~SoEngine(); 00223 00224 // Reads stuff into instance. Returns FALSE on error 00225 virtual SbBool readInstance(SoInput *in, unsigned short flags); 00226 00227 // This is called whenever the value of an input is changed. The 00228 // default method does nothing. Subclasses can override this to 00229 // detect when a specific field is changed. 00230 virtual void inputChanged(SoField *whichField); 00231 00232 // This is used by the input&output inheritence mechanism, hidden in 00233 // the SoSubEngine macros 00234 static const SoFieldData **getInputDataPtr() { return NULL; } 00235 static const SoEngineOutputData **getOutputDataPtr() { return NULL; } 00236 00237 // Write output type information for engines that are not built-in. 00238 void writeOutputTypes(SoOutput *out); 00239 00240 private: 00241 00242 // update forward connections 00243 void updateForwardConnections(); 00244 00245 static SoType classTypeId; 00246 SbBool needsEvaluation; // Dirty bit 00247 SbBool notifying; 00248 friend class SoEngineOutput; 00249 }; 00250 00252 // 00253 // Class: SoEngineOutput 00254 // 00255 // Engine outputs. They are lists of fields to be written into, 00256 // and a pointer back to the containing engine. 00257 // 00259 00283 class SoEngineOutput { 00284 00285 public: 00289 SoType getConnectionType() const; 00290 00295 int getForwardConnections(SoFieldList &list) const; 00296 00301 void enable(SbBool flag); 00305 SbBool isEnabled() const { return enabled; } 00306 00310 SoEngine * getContainer() const { return container; } 00311 00312 private: 00316 SoEngineOutput(); 00317 00318 virtual ~SoEngineOutput(); 00319 00320 void setContainer(SoEngine *eng) { container = eng; } 00321 00322 // Adds/removes connection to field 00323 void addConnection(SoField *); 00324 void removeConnection(SoField *); 00325 00326 // Number of connections this output currently has 00327 int getNumConnections() const 00328 { return connections.getLength(); } 00329 00330 // Returns the fields this output is writing into 00331 SoField * operator[](int i) const 00332 { return connections.get(i); } 00333 00334 // Before evaluating (which is done with the regular field API), 00335 // we must disable notification on all the fields we're about to 00336 // write into. After evaluating, the bits are restored: 00337 void prepareToWrite() const; 00338 void doneWriting() const; 00339 00340 // update connected object with cached value 00341 // Note only supported by SoImageVizEngineOutput class 00342 // Returns FALSE if failed, TRUE if OK 00343 virtual bool updateConnection() 00344 { return TRUE; } 00345 00346 private: 00347 SbBool enabled; 00348 SoFieldList connections; 00349 SoEngine *container; 00350 }; 00351 00352 #endif /* _SO_ENGINE_ */ 00353 00354 00355 00356