![]() |
VR-Forces 4.0.4 Class Documentation
|
00001 /******************************************************************************* 00002 ** Copyright (c) 2000 MAK Technologies, Inc. 00003 ** All rights reserved. 00004 *******************************************************************************/ 00005 /******************************************************************************* 00006 ** $RCSfile: controlObjSR.h,v $ $Revision: 1.23 $ $State: Exp $ 00007 *******************************************************************************/ 00008 00009 #ifndef CONTROLOBJSR_H 00010 #define CONTROLOBJSR_H 00011 00012 #include <vl/envProcessSR.h> 00013 #include <vrfExtObjects/vrfExtensions.h> 00014 #include <vlpi/appearance.h> 00015 00016 #include <vrfExtObjects/ittEnvProcRecs.h> 00017 #include <vrfExtObjects/ittEnvProcData.h> 00018 00019 class Dt3dBoundingVolume; 00020 00021 #include <vector> 00022 #include <map> 00023 00024 class DtSimEnvironmentalObjectStateRecord; 00025 class DtSimEnvironmentalModelType; 00026 class DtEnvironmentalBoundingSphereRecord; 00027 class DtEnvironmentalRectangularVolumeRecord; 00028 class DtVrfObjectDataEnvRec; 00029 class DtGlobalObjectDesignatorList; 00030 00031 enum DtControlObjectKind 00032 { 00033 DtControlObjectKindUnknown, 00034 DtControlObjectKindPoint, 00035 DtControlObjectKindLine, 00036 DtControlObjectKindArea, 00037 DtControlObjectKindCircle, 00038 DtControlObjectKindText, 00039 DtControlObjectKindPuff 00040 }; 00041 00042 enum DtControlObjectCategory 00043 { 00044 DtControlObjectCategoryUnknown, 00045 DtControlObjectCategoryPointOther, 00046 DtControlObjectCategoryControlPoint, 00047 DtControlObjectCategoryTargetPoint, 00048 DtControlObjectCategoryMarkerPoint, 00049 DtControlObjectCategoryLineOther, 00050 DtControlObjectCategoryPhaseLine, 00051 DtControlObjectCategoryRouteLine, 00052 DtControlObjectCategoryAreaOther, 00053 DtControlObjectCategoryControlArea, 00054 DtControlObjectCategoryObstacleArea, 00055 DtControlObjectCategoryPuff, 00056 DtControlObjectCategoryDisaggregationArea 00057 }; 00058 00059 class DtEnvironmentalPointRecord; 00060 00061 // class DtControlObjectRepository: 00062 // 00063 // Instances of DtControlObjectRepository are 00064 #include <vrfExtObjects/vrfExtObjectsDefines.h> 00065 class DT_DLL_vrfExtObjects DtControlObjectRepository : public DtEnvironmentProcessRepository, public DtVrfExtensions 00066 { 00067 public: 00068 typedef std::vector<DtVector> DtCOVertexList; 00069 typedef std::vector<DtIttEnvProcData*> DtGeometricDataList; 00070 typedef std::map<int, DtIttSourceDataCreator> DtIttSourceDataMap; 00071 00072 public: 00073 00074 // default constructor 00075 DtControlObjectRepository(); 00076 00077 // destructor 00078 virtual ~DtControlObjectRepository(); 00079 00080 // copy constructor 00081 DtControlObjectRepository(const DtControlObjectRepository& orig); 00082 00083 // assignment operator 00084 DtControlObjectRepository& operator=(const DtControlObjectRepository& orig); 00085 00086 // Return a copy/empty object of the same type as this. 00087 virtual DtStateRepository* clone(bool copy = false) const; 00088 00089 virtual const DtControlObjectKind& kind() const; 00090 virtual void setKind(const DtControlObjectKind& k); 00091 00092 virtual const DtControlObjectCategory& category() const; 00093 virtual void setCategory(const DtControlObjectCategory& c); 00094 00095 const std::vector<DtVector>& vertexList() const; 00096 00097 // updateExtensions() 00098 // extracts the extended environmental process state information, 00099 // if present, from the state repository 00100 virtual void updateExtensions(); 00101 00102 // Compares us against the supplied state repository and returns what's 00103 // changed. Since this is being called from a location where the vertex list 00104 // is already being checked, we don't need to do it. 00105 virtual int compare(const DtControlObjectRepository* rhs); 00106 00107 // Returns what has changed since the last time we called compare 00108 virtual int compareToMostRecent(); 00109 00110 // Returns true if our stashed location is different than our 00111 // current location 00112 virtual bool locationsDifferent(bool updateIfDifferent); 00113 virtual void emptyVertexList(); 00114 00115 // Adds mappings between environmental record types and the 00116 // type of information to read off of the network into local 00117 // environmental data structures 00118 static void initializePuffFactory(); 00119 static void addToPuffFactory(int iRecordType, DtIttSourceDataCreator fcn); 00120 static DtIttSourceData* createPuffRecord(DtNetEnvironmentalRecord* geometric, 00121 DtNetEnvironmentalRecord* source); 00122 static DtIttSourceData* createPuffRecord(DtNetEnvironmentalRecord* rec); 00123 00124 virtual void getBoundingVolume(DtVector& location, double& radius) const; 00125 00126 const DtGeometricDataList& geometricRecords() const; 00127 bool geometricRecordsChanged() const; 00128 void clearGeometricRecordsChanged(); 00129 00130 // If myNeedVrfObjectDataUpdate is true, update the vrf object data record. Also sets 00131 // all vrf specific data records into state repository. Called from publisher 00132 virtual void updateDataRecords(); 00133 00134 // Subordinate information. Not currently used by VRF 00135 virtual int numberOfSubordinates() const; 00136 virtual bool getSubordinate(int i, DtGlobalObjectDesignator& d); 00137 virtual const DtGlobalObjectDesignatorList& subordinates() const; 00138 virtual DtGlobalObjectDesignatorList& subordinates(); 00139 00140 public: 00141 // Sets the vertices to use in the publication of this object. Will create the environmental records (as needed), 00142 // put them into the state repository structure and also the vertex list. This routine assumes the DtList contains DtVectors 00143 virtual void setVertices(const DtList& pnt); 00144 virtual void appendVertex(const DtVector&); 00145 virtual void setVertex(int i, const DtVector&); 00146 virtual void removeVertex(int i); 00147 00148 public: 00149 // Environmental record settings 00150 00151 // Used to set in appearance value of env state record and vrf object data message 00152 virtual void setObjectType(const DtObjectType&); 00153 00154 00155 // Returns the force type from the environmental header record (if it exists), else 00156 // returns neutral by default 00157 virtual DtForceType forceType() const; 00158 virtual void setForceType(DtForceType i); 00159 00160 // Returns the color (rgb) value of this object 00161 virtual int color() const; 00162 virtual void setColor(int); 00163 00164 // Returns the parent of this object 00165 virtual const DtString& parent() const; 00166 virtual void setParent(const DtString&); 00167 00168 virtual const DtString& userData() const; 00169 virtual void setUserData(const DtString&); 00170 00171 virtual void setVrfObjectName(const DtString&); 00172 virtual const DtString& vrfObjectName(); 00173 00174 virtual DtAppearance appearance() const; 00175 virtual void setAppearance(const DtAppearance& app); 00176 00177 virtual void setNumberOfSubordinates(int); 00178 virtual void setSubordinate(int i, const DtGlobalObjectDesignator&); 00179 00180 // Returns the parent this object might be attached to 00181 virtual const DtGlobalObjectDesignator& hostGlobalId() const; 00182 virtual void setHostGlobalId(const DtGlobalObjectDesignator&); 00183 00185 virtual void clearHostGlobalId(); 00186 00187 public: 00195 00196 // In setting the bounding sphere radius, if a bounding sphere record does not exist, it 00197 // will be created 00198 virtual void setBoundingSphereRadius(double); 00199 virtual double boundingSphereRadius() const; 00200 00201 // Sets/gets the bounding sphere location. Will also create the record on set if it does not 00202 // exist 00203 virtual void setBoundingSphereLocation(const DtVector&); 00204 virtual const DtVector& boundingSphereLocation() const; 00205 00206 bool hasBoundingSphereRecord() const; 00207 00208 public: 00216 00217 bool hasBoundingRectRecord() const; 00218 00219 virtual void setBoundingExtent(const DtVector&); 00220 const DtVector& boundingExtent() const; 00221 00222 virtual void setBoundingCornerLocation(const DtVector&); 00223 virtual const DtVector& boundingCornerLocation() const; 00224 00225 virtual void setBoundingOrientation(const DtTaitBryan&); 00226 const DtTaitBryan& boundingOrientation() const; 00227 00228 public: 00231 virtual void setProjected(bool); 00232 virtual bool projected() const; 00233 00234 virtual void setClosedFigure(bool); 00235 virtual bool closedFigure() const; 00236 00237 virtual void setBound2D(bool); 00238 virtual bool bound2D() const; 00239 00241 virtual void setFillStyle(int); 00242 virtual int fillStyle() const; 00243 00244 virtual void setLineStyle(int); 00245 virtual int lineStyle() const; 00246 00247 virtual void setLineWidth(int); 00248 virtual int lineWidth() const; 00249 00250 public: 00254 virtual void setCachePoints(bool); 00255 bool cachePoints() const; 00256 00257 00258 protected: 00259 // createExtendedEnvironmentalStateRecord() 00260 // allocates myExtEnvStateRecord, a DtSimEnvironmentalObjectStateRecord 00261 // used by VR-Forces as extended environmental process state information: 00262 virtual bool createExtendedEnvironmentalStateRecord(); 00263 00264 // extendedEnvironmentalStateRecord() 00265 // returns the myExtEnvStateRecord for inspection by 00266 // the caller. If myExtEnvStateRecord is NULL, it is created. 00267 virtual DtSimEnvironmentalObjectStateRecord* extendedEnvironmentalStateRecord(); 00268 00269 // createVrfObjectStateRecord() 00270 // allocates myVrfObjectStateRecord, a DtVrfObjectDataEnvRec 00271 // used by VR-Forces as extended vrf object state information: 00272 virtual bool createVrfObjectStateRecord(); 00273 00274 // extendedVrfObjectStateRecord() 00275 // returns the myVrfObjectStateRecord for inspection by 00276 // the caller. If myVrfObjectStateRecord is NULL, it is created. 00277 virtual DtVrfObjectDataEnvRec* vrfObjectStateRecord(); 00278 00279 // createBoundingSphereRecord() 00280 // allocates myBoundingSphereRecord 00281 virtual bool createBoundingSphereRecord(); 00282 00283 // boundingSphereRecord() 00284 // returns the myBoundingSphereRecord for inspection by 00285 // the caller. If myBoundingSphereRecord is NULL, it is created. 00286 virtual DtEnvironmentalBoundingSphereRecord* boundingSphereRecord(); 00287 00288 // createBoundingRectRecord() 00289 // allocates myBoundingRectRecord 00290 virtual bool createBoundingRectRecord(); 00291 00292 // boundingRectRecord() 00293 // returns the myBoundingRectRecord for inspection by 00294 // the caller. If myBoundingRectRecord is NULL, it is created. 00295 virtual DtEnvironmentalRectangularVolumeRecord* boundingRectRecord(); 00296 00297 protected: 00298 // Sets up internal object kind and category from object type 00299 virtual void setupKindFromType(const DtEntityType& type); 00300 virtual void getBoundingVolume(EnvGeomSpheriod* rec); 00301 virtual void clearGeometricRecords(); 00302 00303 protected: 00304 // Override to set myNeedVrfObjectDataUpdate to true 00305 virtual void extensionModified(); 00306 00307 public: 00308 static DtEnvironmentProcessRepository* create(); 00309 00310 DtControlObjectKind myKind; 00311 DtControlObjectCategory myCategory; 00312 00313 // Keeps a list of all geometry point records to use to update internal 00314 // model datas from 00315 DtCOVertexList myVertexList; 00316 00317 // DtSimEnvironmentalObjectStateRecord is a special form 00318 // of DtEnvironmentalRecord, used to decode custom data 00319 // that might be published from a VR-Forces back end, such 00320 // as label, force type, appearance, etc. 00321 // see "envObjState.h" 00322 DtSimEnvironmentalObjectStateRecord* myExtEnvStateRecord; 00323 DtEnvironmentalBoundingSphereRecord* myBoundingSphereRecord; 00324 DtVrfObjectDataEnvRec* myVrfObjectStateRecord; 00325 DtControlObjectRepository* myLastCopy; 00326 DtEnvironmentalRectangularVolumeRecord* myBoundingRectRecord; 00327 DtSimEnvironmentalModelType* myEnvModelType; 00328 00329 // This information is needed for ITT puff clouds 00330 static DtIttSourceDataMap thePuffFactory; 00331 DtGeometricDataList myGeometricRecords; 00332 bool myGeometricRecordsChanged; 00333 bool myNeedVrfObjectDataUpdate; 00334 00335 bool myCachePoints; 00336 int myPointsSet; 00337 }; 00338 00339 inline const DtControlObjectRepository::DtGeometricDataList& DtControlObjectRepository::geometricRecords() const 00340 { 00341 return myGeometricRecords; 00342 } 00343 00344 inline bool DtControlObjectRepository::geometricRecordsChanged() const 00345 { 00346 return myGeometricRecordsChanged; 00347 } 00348 00349 inline void DtControlObjectRepository::clearGeometricRecordsChanged() 00350 { 00351 myGeometricRecordsChanged = false; 00352 } 00353 00354 inline bool DtControlObjectRepository::hasBoundingSphereRecord() const 00355 { 00356 return (myBoundingSphereRecord != NULL); 00357 } 00358 00359 inline bool DtControlObjectRepository::hasBoundingRectRecord() const 00360 { 00361 return (myBoundingRectRecord != NULL); 00362 } 00363 00364 inline bool DtControlObjectRepository::cachePoints() const 00365 { 00366 return myCachePoints; 00367 } 00368 00369 #endif