![]() |
http://www.sim.no/ http://www.coin3d.org/ |
00001 #ifndef COIN_SOFIELD_H 00002 #define COIN_SOFIELD_H 00003 00004 /**************************************************************************\ 00005 * 00006 * This file is part of the Coin 3D visualization library. 00007 * Copyright (C) by Kongsberg Oil & Gas Technologies. 00008 * 00009 * This library is free software; you can redistribute it and/or 00010 * modify it under the terms of the GNU General Public License 00011 * ("GPL") version 2 as published by the Free Software Foundation. 00012 * See the file LICENSE.GPL at the root directory of this source 00013 * distribution for additional information about the GNU GPL. 00014 * 00015 * For using Coin with software that can not be combined with the GNU 00016 * GPL, and for taking advantage of the additional benefits of our 00017 * support services, please contact Kongsberg Oil & Gas Technologies 00018 * about acquiring a Coin Professional Edition License. 00019 * 00020 * See http://www.coin3d.org/ for more information. 00021 * 00022 * Kongsberg Oil & Gas Technologies, Bygdoy Alle 5, 0257 Oslo, NORWAY. 00023 * http://www.sim.no/ sales@sim.no coin-support@coin3d.org 00024 * 00025 \**************************************************************************/ 00026 00027 #include <Inventor/SoType.h> 00028 #include <Inventor/misc/SoNotification.h> 00029 00030 class SbString; 00031 class SoEngineOutput; 00032 class SoFieldContainer; 00033 class SoFieldConverter; 00034 class SoFieldList; 00035 class SoInput; 00036 class SoOutput; 00037 00038 class COIN_DLL_API SoField { 00039 00040 public: 00041 virtual ~SoField(); 00042 00043 static void initClass(void); 00044 static void initClasses(void); 00045 static void cleanupClass(void); 00046 00047 void setIgnored(SbBool ignore); 00048 SbBool isIgnored(void) const; 00049 00050 void setDefault(SbBool defaultVal); 00051 SbBool isDefault(void) const; 00052 00053 virtual SoType getTypeId(void) const = 0; 00054 00055 static SoType getClassTypeId(void); 00056 SbBool isOfType(const SoType type) const; 00057 00058 void enableConnection(SbBool flag); 00059 SbBool isConnectionEnabled(void) const; 00060 00061 // Field<-Engine connection stuff. 00062 SbBool connectFrom(SoEngineOutput * master, 00063 SbBool notnotify = FALSE, SbBool append = FALSE); 00064 SbBool appendConnection(SoEngineOutput * master, SbBool notnotify = FALSE); 00065 void disconnect(SoEngineOutput * engineoutput); 00066 SbBool isConnectedFromEngine(void) const; 00067 SbBool getConnectedEngine(SoEngineOutput *& master) const; 00068 00069 // Field<->Field connection stuff. 00070 SbBool connectFrom(SoField * master, 00071 SbBool notnotify = FALSE, SbBool append = FALSE); 00072 SbBool appendConnection(SoField * master, SbBool notnotify = FALSE); 00073 void disconnect(SoField * field); 00074 SbBool isConnectedFromField(void) const; 00075 SbBool getConnectedField(SoField *& master) const; 00076 int getNumConnections(void) const; 00077 int getForwardConnections(SoFieldList & slavelist) const; 00078 int getConnections(SoFieldList & masterlist) const; 00079 00080 void disconnect(void); 00081 SbBool isConnected(void) const; 00082 00083 void setContainer(SoFieldContainer * cont); 00084 SoFieldContainer * getContainer(void) const; 00085 00086 SbBool set(const char * valuestring); 00087 void get(SbString & valuestring); 00088 00089 SbBool shouldWrite(void) const; 00090 00091 virtual void touch(void); 00092 virtual void startNotify(void); 00093 virtual void notify(SoNotList * nlist); 00094 SbBool enableNotify(SbBool on); 00095 SbBool isNotifyEnabled(void) const; 00096 00097 void addAuditor(void * f, SoNotRec::Type type); 00098 void removeAuditor(void * f, SoNotRec::Type type); 00099 00100 int operator ==(const SoField & f) const; 00101 int operator !=(const SoField & f) const; 00102 00103 virtual void connectionStatusChanged(int numconnections); 00104 SbBool isReadOnly(void) const; 00105 virtual SbBool isSame(const SoField & f) const = 0; 00106 virtual void copyFrom(const SoField & f) = 0; 00107 00108 virtual void fixCopy(SbBool copyconnections); 00109 virtual SbBool referencesCopy(void) const; 00110 void copyConnection(const SoField * fromfield); 00111 00112 virtual SbBool read(SoInput * input, const SbName & name); 00113 virtual void write(SoOutput * out, const SbName & name) const; 00114 00115 virtual void countWriteRefs(SoOutput * out) const; 00116 00117 // enums for setFieldType()/getFieldType() 00118 enum FieldType { 00119 NORMAL_FIELD = 0, 00120 EVENTIN_FIELD, 00121 EVENTOUT_FIELD, 00122 EXPOSED_FIELD 00123 }; 00124 00125 void setFieldType(int type); 00126 int getFieldType(void) const; 00127 00128 SbBool getDirty(void) const; 00129 void setDirty(SbBool dirty); 00130 00131 void evaluate(void) const { 00132 if ((this->statusbits & (FLAG_EXTSTORAGE|FLAG_NEEDEVALUATION)) == 00133 (FLAG_EXTSTORAGE|FLAG_NEEDEVALUATION)) this->evaluateField(); 00134 } 00135 00136 protected: 00137 SoField(void); 00138 00139 void valueChanged(SbBool resetdefault = TRUE); 00140 virtual void evaluateConnection(void) const; 00141 virtual SbBool readValue(SoInput * in) = 0; 00142 virtual void writeValue(SoOutput * out) const = 0; 00143 virtual SbBool readConnection(SoInput * in); 00144 virtual void writeConnection(SoOutput * out) const; 00145 00146 SbBool isDestructing(void) const; 00147 00148 private: 00149 00150 enum FieldFlags { 00151 FLAG_TYPEMASK = 0x0007, // need 3 bits for values [0-5] 00152 FLAG_ISDEFAULT = 0x0008, 00153 FLAG_IGNORE = 0x0010, 00154 FLAG_EXTSTORAGE = 0x0020, 00155 FLAG_ENABLECONNECTS = 0x0040, 00156 FLAG_NEEDEVALUATION = 0x0080, 00157 FLAG_READONLY = 0x0100, 00158 FLAG_DONOTIFY = 0x0200, 00159 FLAG_ISDESTRUCTING = 0x0400, 00160 FLAG_ISEVALUATING = 0x0800, 00161 FLAG_ISNOTIFIED = 0x1000 00162 }; 00163 00164 void evaluateField(void) const; 00165 void extendStorageIfNecessary(void); 00166 SoFieldConverter * createConverter(SoType from) const; 00167 SoFieldContainer * resolveWriteConnection(SbName & mastername) const; 00168 00169 void notifyAuditors(SoNotList * l); 00170 00171 static SoType classTypeId; 00172 00173 // These are bit flags. 00174 enum FileFormatFlags { 00175 IGNORED = 0x01, 00176 CONNECTED = 0x02, 00177 DEFAULT = 0x04, 00178 ALLFILEFLAGS = IGNORED|CONNECTED|DEFAULT 00179 }; 00180 00181 SbBool changeStatusBits(const unsigned int bits, const SbBool onoff); 00182 void clearStatusBits(const unsigned int bits); 00183 void setStatusBits(const unsigned int bits); 00184 SbBool getStatus(const unsigned int bits) const; 00185 unsigned int statusbits; 00186 union { 00187 SoFieldContainer * container; 00188 class SoConnectStorage * storage; 00189 }; 00190 00191 SbBool hasExtendedStorage(void) const; 00192 }; 00193 00194 00195 #ifndef COIN_INTERNAL 00196 // Added to be Inventor compliant. 00197 #include <Inventor/fields/SoSField.h> 00198 #include <Inventor/fields/SoMField.h> 00199 #endif // !COIN_INTERNAL 00200 00201 #endif // !COIN_SOFIELD_H
Copyright © 1998-2010 by Kongsberg Oil & Gas Technologies. All rights reserved.
Generated on Fri Dec 11 2015 03:24:53 for Coin by Doxygen 1.7.6.1.