00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 #ifndef  _SO_MARKER_H_
00026 #define  _SO_MARKER_H_
00027 
00028 #include <Inventor/nodes/SoNode.h>
00029 #include <Inventor/fields/SoMFUInt32.h>
00030 #include <Inventor/fields/SoSFBool.h>
00031 #include <Inventor/fields/SoMFUByte.h>
00032 #include <Inventor/fields/SoSFVec2s.h>
00033 #include <Inventor/fields/SoSFInt32.h>
00034 
00035 class SoState;
00036 class SoGLObjectCache;
00037 
00038 #define MARKER_HASH_TAB_SIZE 151
00039 
00130 class  SoMarker : public SoNode
00131 {
00132   SO_NODE_HEADER(SoMarker);
00133 
00134 public:
00135 
00137   enum MarkerType {
00139     CROSS_5_5,
00141     PLUS_5_5,
00143     MINUS_5_5,
00145     SLASH_5_5,
00147     BACKSLASH_5_5,
00149     BAR_5_5,
00151     STAR_5_5,
00153     Y_5_5,
00155     LIGHTNING_5_5,
00157     WELL_5_5,
00158     
00160     CIRCLE_LINE_5_5,
00162     SQUARE_LINE_5_5,
00164     DIAMOND_LINE_5_5,
00166     TRIANGLE_LINE_5_5,
00168     RHOMBUS_LINE_5_5,
00170     HOURGLASS_LINE_5_5,
00172     SATELLITE_LINE_5_5,
00174     PINE_TREE_LINE_5_5,
00176     CAUTION_LINE_5_5,
00178     SHIP_LINE_5_5,
00179 
00181     CIRCLE_FILLED_5_5,
00183     SQUARE_FILLED_5_5,
00185     DIAMOND_FILLED_5_5,
00187     TRIANGLE_FILLED_5_5,
00189     RHOMBUS_FILLED_5_5,
00191     HOURGLASS_FILLED_5_5,
00193     SATELLITE_FILLED_5_5,
00195     PINE_TREE_FILLED_5_5,
00197     CAUTION_FILLED_5_5,
00199     SHIP_FILLED_5_5,
00200 
00202     CROSS_7_7,
00204     PLUS_7_7,
00206     MINUS_7_7,
00208     SLASH_7_7,
00210     BACKSLASH_7_7,
00212     BAR_7_7,
00214     STAR_7_7,
00216     Y_7_7,
00218     LIGHTNING_7_7,
00220     WELL_7_7,
00221 
00223     CIRCLE_LINE_7_7,
00225     SQUARE_LINE_7_7,
00227     DIAMOND_LINE_7_7,
00229     TRIANGLE_LINE_7_7,
00231     RHOMBUS_LINE_7_7,
00233     HOURGLASS_LINE_7_7,
00235     SATELLITE_LINE_7_7,
00237     PINE_TREE_LINE_7_7,
00239     CAUTION_LINE_7_7,
00241     SHIP_LINE_7_7,
00242     
00244     CIRCLE_FILLED_7_7,
00246     SQUARE_FILLED_7_7,
00248     DIAMOND_FILLED_7_7,
00250     TRIANGLE_FILLED_7_7,
00252     RHOMBUS_FILLED_7_7,
00254     HOURGLASS_FILLED_7_7,
00256     SATELLITE_FILLED_7_7,
00258     PINE_TREE_FILLED_7_7,
00260     CAUTION_FILLED_7_7,
00262     SHIP_FILLED_7_7,
00263 
00265     CROSS_9_9,
00267     PLUS_9_9,
00269     MINUS_9_9,
00271     SLASH_9_9,
00273     BACKSLASH_9_9,
00275     BAR_9_9,
00277     STAR_9_9,
00279     Y_9_9,
00281     LIGHTNING_9_9,
00283     WELL_9_9,
00284     
00286     CIRCLE_LINE_9_9,
00288     SQUARE_LINE_9_9,
00290     DIAMOND_LINE_9_9,
00292     TRIANGLE_LINE_9_9,
00294     RHOMBUS_LINE_9_9,
00296     HOURGLASS_LINE_9_9,
00298     SATELLITE_LINE_9_9,
00300     PINE_TREE_LINE_9_9,
00302     CAUTION_LINE_9_9,
00304     SHIP_LINE_9_9,
00305 
00307     CIRCLE_FILLED_9_9,
00309     SQUARE_FILLED_9_9,
00311     DIAMOND_FILLED_9_9,
00313     TRIANGLE_FILLED_9_9,
00315     RHOMBUS_FILLED_9_9,
00317     HOURGLASS_FILLED_9_9,
00319     SATELLITE_FILLED_9_9,
00321     PINE_TREE_FILLED_9_9,
00323     CAUTION_FILLED_9_9,
00325     SHIP_FILLED_9_9
00326   };
00327 
00331   SoMarker();
00332 
00340   SoMFUByte bitmap;
00341 
00345   SoMFUInt32 orderedRGBA;
00346 
00352   SoSFBool upToDown;
00353 
00358   SoSFBool isLSBFirst;
00359 
00363   SoSFVec2s size;
00364 
00368   SoSFInt32 index;
00369 
00370 private:
00371 
00372   static void initClass();
00373   static void exitClass();
00374 
00375   void render( SoState* state, int index = 0);
00376   virtual void notify( SoNotList* list );
00377   virtual SbBool readInstance(SoInput *in, unsigned short flags);
00378 
00382   int getMarkerIndex() 
00383   { return m_markerIndex; }
00384 
00388   void setMarkerIndex( const int tindex ) 
00389   { m_markerIndex = tindex; }
00390 
00394   static int getNumDefinedMarkers();
00395 
00399   static int getMaxIndexDefinedMarker();
00400 
00404   static void addMarker(int markerIndex,
00405                         const SbVec2s &size,
00406                         const unsigned char *bytes,
00407                         const uint32_t *orderedRGBA,
00408                         SbBool isLSBFirst = TRUE,
00409                         SbBool isUpToDown = TRUE);
00413   static void addMarker(int markerIndex, SoMarker* marker );
00414 
00418   static SbBool removeMarker(int markerIndex);
00419   
00420   static SoMarker* getMarkerDesc( int markerInd );
00421 
00422   static SbBool isMarkerBitSet(int markerIndex, int bitNumber) ;
00423 
00424   
00425   static void updateListInstanciedMarkerSet();
00426   static void addMarkerSetDependency(SoNode* );
00427   static void removeMarkerSetDependency(SoNode* );
00428 
00429 private:
00433   virtual ~SoMarker();
00434 
00435   SbBool useDL;
00436 
00437 private:
00438 
00439   
00440   int m_markerIndex;
00441 
00442   
00443   SoGLObjectCache* m_objCache;
00444 
00445   
00446   static SbPList m_markerHashTab[MARKER_HASH_TAB_SIZE];
00447 
00448   
00449   static void createListOfPreDefinedMarkers();
00450   static void destroyListOfPreDefinedMarkers();
00451   static bool m_isBuildingPredefinedMarkers;
00452 
00453   
00454   static inline int getMarkerHashTabIndex(int markerIndex);
00455 
00456   
00457   static SbPList m_listInstanciedMarkerSet;
00458 
00459   void setPredefined(bool b);
00460 
00461   bool m_predefined;
00462   bool m_prevUpToDown;
00463 
00464   
00465   static int s_cachedCurrentMarkerIndex;
00466 };
00467 
00468 #endif // !_SO_MARKER_H_
00469 
00470 
00471