home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / msdos / plotting / pcgplots / cgm.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-04-24  |  35.5 KB  |  1,451 lines

  1. // C++ .h file for gplot, CGM-specific classes  -*-c++-*-
  2. // copyright Phil Andrews, Pittsburgh Supercomputing Center, 1992
  3. // all rights reserved
  4. #ifndef cgm_h
  5. #define cgm_h
  6. #include <stdio.h>
  7. #if __MSDOS__
  8. #include <windows.h>
  9.   typedef unsigned char huge * HugePt;
  10. #endif
  11.  
  12. ////
  13. // how to get the options from the X server
  14. ////
  15. enum {useScale = 0, PSWidth, PSHeight, PSRotation, PSColrs,
  16.       PSXOffset, PSYOffset, debugOutput, cgmOptionSize};
  17. ////
  18. // class to hold the overall option settings
  19. class cgmOptions {
  20. public:
  21.   cgmOptions() // default constructor
  22.     {useScale=0; PSWidth=8*72; PSHeight=10*72; PSRotation=0; PSColrs=0;
  23.    debugOutput=0; PSXOffset=20; PSYOffset=20;}
  24.   int useScale;
  25.   int PSWidth;
  26.   int PSHeight;
  27.   int PSColrs;
  28.   int debugOutput;
  29.   int PSRotation;
  30.   int PSXOffset;
  31.   int PSYOffset;
  32. };
  33. ////
  34. // forward declarations
  35. ////
  36. class cgmInput;
  37. class cgmOutput;
  38. class baseDisplay;
  39. class cgmContainer;
  40. class cgmMetafile;
  41. class colrValueExtent;
  42. #ifndef _XLIB_H_
  43. class XImage; // X classes 
  44. class XPoint; // for cell arrays
  45. #endif
  46. struct xlDisplay;
  47. class mPoint;      // for macintosh cell arrays
  48. class macDisplay;  // for macintosh
  49. //typedef POINT;      // for Windows pc
  50. ////
  51. // typedef for file positioning
  52. ////
  53. typedef long filePos;
  54. ////
  55. // basic CGM class
  56. ////
  57. class baseCGM { 
  58. public:
  59.    // constructor
  60.   baseCGM(cgmContainer*, baseCGM *inPrev = NULL, baseCGM *inNext = NULL);
  61.   virtual ~baseCGM(); // destructor
  62.   baseCGM *next, *prev; // pointers for linked list
  63.   virtual int cgmClass() = 0; // class
  64.   virtual int cgmElement() = 0; // element
  65.   virtual const char *cgmName() = 0; // clear text name
  66.   virtual int cgmOut(cgmOutput*);
  67.   virtual int display(baseDisplay*);
  68. protected:
  69.   cgmContainer *owner;
  70.   cgmMetafile *mfOwner(); // find the metafile owner 
  71. };
  72. ////
  73. // necessary types for cgm classes
  74. ////
  75. // real or integer vdc's ?
  76. ////
  77. typedef char vdcType; 
  78. ////
  79. // type for direct colours (R,G,B) format
  80. ////
  81. class dColr {
  82. public:
  83.   dColr() {values[0] = values[1] = values[2] = 0;} // default constructor
  84.   dColr(int, int, int); // constructor
  85. //int& operator[](int index) const {return values[index];} // simulate array ref      ********
  86.      int getValue(int i) const {return ((i>=0) && (i<3)) ? values[i] : 0;}
  87.     void setValue(int i, int j) {if ((i>=0) && (i<3)) values[i] = j;}
  88.   void set(int r, int g, int b) {values[0]=r;values[1]=g;values[2]=b;}
  89. private:
  90.   int values[3]; // store values here
  91. };
  92. ////
  93. // the extent of colour values
  94. ////
  95. class colrValueExtent {
  96. public:
  97.   colrValueExtent() {white = dColr(255, 255, 255);}
  98.   dColr black, white;
  99. };
  100. ////
  101. // colour table
  102. ////
  103. class colrTable {
  104. public:
  105.   // constructor
  106.   colrTable(unsigned int, const colrValueExtent*, unsigned int = 0); 
  107.   ~colrTable() {delete values;} // destructor
  108.   // legitimate const functions
  109.   int size() const {return mySize;} // max no of entries
  110.   int no() const {return myNo;} // actual no of entries
  111.   int start() const {return myStart;} // starting index
  112.   dColr val(unsigned i) const {return (i<mySize) ? values[i] : values[0];}
  113.   const colrValueExtent *extent() const {return myExtent;}
  114.   // now the modifier functions
  115.   void addTable(colrTable*); // insert another table
  116.   void extendTable(int); // extend the table
  117.   void setSize(int); // set the size
  118.   void addColr(dColr&);
  119.   const float *r(unsigned int) const;
  120. protected:
  121.   int mySize, myNo, myStart;
  122.   dColr *values;
  123.   void initialize(dColr*, int); // initialize values
  124.   const colrValueExtent *myExtent;
  125.   float rvalues[3];
  126. };
  127. ////
  128. // general colour, indexed or direct
  129. ////
  130. class genColr { 
  131. public:
  132.   genColr(int, const colrValueExtent*, const colrTable* = NULL);
  133.   genColr(int, int, int, const colrValueExtent*, const colrTable* = NULL);
  134.   genColr(const dColr&, const colrValueExtent*, const colrTable* = NULL);
  135.   int i() const {return myIndex;}
  136.   int i(unsigned int index) // ****** const {return myDC[index];}
  137.       const{return myDC.getValue(index); }
  138.   int type() const {return myType;}
  139.   float r(unsigned i) const; // get the actual colours
  140. private:
  141.   int myIndex, myType;
  142.   dColr myDC; // keep rgb values here
  143.   // classes required to work out actual colour values
  144.   const colrValueExtent *myExtent;
  145.   const colrTable *myTable;
  146. };
  147. ////
  148. // class for a single vdc dimension
  149. ////
  150. class vdc {
  151. public:
  152.   vdc(float inFloat) {myInt = 0; myFloat = inFloat; myType = 1;}
  153.   vdc(int inInt) {myInt = inInt; myFloat = 0; myType = 0;}
  154.   int i() const {return (myType) ? (int) myFloat : myInt;}
  155.   float f() const {return (myType) ? myFloat : (float) myInt;}
  156.   const vdcType type() const {return myType;}
  157. protected:
  158.   int myInt;
  159.   float myFloat;
  160.   vdcType myType;
  161. };
  162. ////
  163. // class to hold either a vdc or a real, for line width, etc.
  164. ////
  165. class vdcR {
  166. public:
  167.   vdcR(float inFloat) {myFloat = inFloat; myType = 1; myVdc = NULL;}
  168.   vdcR(vdc *inVdc) {myFloat = 0; myType = 0; myVdc = inVdc;}
  169.   ~vdcR() {if (myType == 0) delete myVdc;}
  170.   float f() const {return myFloat;}
  171.   int type() const {return myType;}
  172.   const vdc *v() const {return (const vdc*) myVdc;}
  173. protected:
  174.   float myFloat;
  175.   vdc *myVdc;
  176.   int myType;
  177. };    
  178. ////
  179. // class to hold an arbitrary number of vdc points
  180. ////
  181. class vdcPts { 
  182. public:
  183.   // default constructor
  184.   vdcPts(unsigned int inNoPts = 0, vdcType inType = 0)
  185.     {myPtr = NULL; noPts = inNoPts; myType = inType; next=NULL;}
  186.   // constructor for an integer set of points
  187.   vdcPts(int *inPtr, unsigned int inNoPts=0)
  188.     {myPtr = inPtr; noPts = inNoPts; myType = 0; next=NULL;}
  189.   // constructor for a float set of points
  190.   vdcPts(float *inPtr, unsigned int inNoPts=0)
  191.     {myPtr = inPtr; noPts = inNoPts; myType = 1; next=NULL;}
  192.   // constructor for an integer rectangle
  193.   vdcPts(int, int, int, int); 
  194.   // constructor for a float rectangle
  195.   vdcPts(double, double, double, double);
  196.   // destructor
  197.   ~vdcPts() { if (myPtr) delete myPtr;} 
  198.   // max width and height of the points
  199.   float width() const, height() const, maxY() const, minY() const,
  200.   maxX() const, minX() const;
  201.   // values for calculations (may need to be precise)
  202.   float x(int i) const {return (i>=noPts) ? 0 : (myType) ?
  203.               ((float *) myPtr)[2 * i] :
  204.             ((int *) myPtr)[2 * i]; }
  205.   float y(int i) const {return (i>=noPts) ? 0 : (myType) ?
  206.               ((float *) myPtr)[2 * i + 1] :
  207.             ((int *) myPtr)[2 * i + 1]; }
  208.   // now the squared versions
  209.   float x2(int i) const
  210.     {return (i>=noPts) ? 0 :(myType) ?
  211.        ((float *) myPtr)[2 * i] * ((float *) myPtr)[2 * i] :
  212.      ((int *) myPtr)[2 * i] * ((int *) myPtr)[2 * i]; }
  213.   float y2(int i) const
  214.     {return (i>=noPts) ? 0 : (myType) ?
  215.        ((float *) myPtr)[2 * i + 1] * ((float *) myPtr)[2 * i + 1]:
  216.      ((int *) myPtr)[2 * i + 1] * ((int *) myPtr)[2 * i + 1]; }
  217.   // how many points do we have ?
  218.   int no() const {return noPts;}
  219.   // the vdcType of these points
  220.   vdcType type() const {return myType;}
  221.   // i'th x and y components in float
  222.   float fx(int i) const {return ((float *)myPtr)[2*i];}
  223.   float fy(int i) const {return ((float *)myPtr)[2*i+1];}
  224.   // i'th x and y components in integer
  225.   int ix(int i) const {return ((int *)myPtr)[2*i];}
  226.   int iy(int i) const {return ((int *)myPtr)[2*i+1];}
  227.   // i'th component in integer
  228.   int i(int i) const {return ((int *)myPtr)[i];}
  229.   // i'th component in float
  230.   float f(int i) const {return ((float *)myPtr)[i];}
  231.   vdcPts *next; // for utility use
  232.   void shift(float, float); // shift of origin
  233.   void scale(float); // scale the points
  234.   vdc *newVdc(int i) const {return (myType) ? new vdc(((float *)myPtr)[i]) :
  235.                 new vdc(((int *)myPtr)[i]);}
  236. protected:
  237.   unsigned int noPts; // no. of points
  238.   vdcType myType; // real or integer ?
  239.   void *myPtr; // pointer to memory
  240. };
  241. ////
  242. // cell arrays, tricky class need both speed and compactness
  243. ////
  244. class cellArray {
  245. public:
  246.   cellArray(int inColMode, const colrValueExtent *inExtent,
  247.          vdcPts *inCorners, int inNx, int inNy,
  248.         int inPrec, int inRepMode,
  249.         const colrTable *inTable = NULL); // constructor
  250.   ~cellArray();// {delete myCorners; delete myContents;} // destructor
  251.   ////
  252.   // constant functions
  253.   const vdcPts *corners() const {return myCorners;} // 3 corners
  254.   unsigned int nx() const {return myNx;} // cells in x direction
  255.   unsigned int ny() const {return myNy;} // cells in y direction
  256.   unsigned int prec() const {return myPrec;} // local colour precision
  257.   unsigned int repMode() const {return myRepMode;} // representation mode
  258.   unsigned int colMode() const {return myColMode;} // colour mode
  259. #if __MSDOS__
  260. //  const HugePt contents() const { return myContents; }
  261.  // for pc [PLA, moved]
  262.   void fill(POINT *offScreen, unsigned int width, unsigned int height, unsigned int hdc) const;
  263. #else
  264. //  const unsigned char *contents() const {return myContents;} // the colours
  265. #endif
  266.   void fill(XImage*, XPoint*, unsigned int, unsigned int, xlDisplay*) const;
  267.  // for macintosh
  268.   void fill(mPoint *offScreen, unsigned int width, unsigned int height) const;
  269.   void fillGrey(unsigned char*&) const; // fill with a grey scale
  270.   void fillColr(unsigned char*&) const; // fill with colours
  271.   unsigned int getValue(unsigned long) const; // get a single integer
  272.   float *getFloats(unsigned long) const; // get a set of float values
  273.   float *getFloats(unsigned int ix, unsigned int iy)
  274.      const {return getFloats((unsigned long)iy * myNx + ix);} // convenience function
  275.   ////
  276.   // modifiers
  277.   int addValue(unsigned int); // add one value
  278. #if __MSDOS__
  279.   int addValues(HugePt, int, int); // add values from pointer
  280. #else
  281.   int addValues(unsigned char*, int, int); // add values from pointer
  282. #endif
  283.   void decompress(); // decompress, if necessary
  284. protected:
  285.   vdcPts *myCorners;
  286.   unsigned int myNx, myNy, myPrec, myRepMode, myColMode;
  287. #if __MSDOS__
  288.   HugePt myContents;
  289.   unsigned int hContentsBuffer;
  290.  
  291. #else
  292.   unsigned char *myContents;
  293. #endif
  294.   unsigned long bitsAdded;
  295.   unsigned long totalBits, totalBytes;
  296.   // classes required to work out actual colour values
  297.   const colrValueExtent *myExtent;
  298.   const colrTable *myTable;
  299.   float rvalues[3];
  300. };
  301. ////
  302. // set of defaults created by a metafile defaults replacement element
  303. ////
  304. class cgmDefaults {
  305. public:
  306.   cgmDefaults(baseCGM *inStart) // constructor
  307.      {myContents=inStart; myNext=NULL;}
  308.   void display(baseDisplay *inDisplay); // display the elements
  309. //     {for (baseCGM *myPtr=contents(); myPtr; myPtr=myPtr->next)
  310. //         myPtr->display(inDisplay);}
  311.   void addNext(cgmDefaults *inNext) {myNext=inNext;}
  312.   cgmDefaults *next() {return myNext;}
  313.   baseCGM *contents() {return myContents;}
  314. protected:
  315.   baseCGM *myContents; // the elements
  316.   cgmDefaults *myNext;
  317. };
  318. ////
  319. // class for text alignment
  320. ////
  321. class alignment {
  322. public:
  323.   alignment(int inH=0, int inV=0, float inCH=0, float inCV=0)
  324.     {myH = inH; myV = inV; myCH = inCH; myCV = inCV;}
  325.   int h() const {return myH;} // horizontal alignment
  326.   int v() const {return myV;} // vertical alignment
  327.   float cH() const {return myCH;} // continuous horizontal alignment
  328.   float cV() const {return myCV;} // continuous vertical alignment
  329. protected:
  330.   int myH, myV;
  331.   float myCH, myCV;
  332. };
  333. ////
  334. // text info (size, etc)
  335. ////
  336. class textInfo {
  337. public:
  338.   textInfo() // default constructor
  339.     {myIndex=1; myFont=0; myPrec=0; myExpan=1; myHeight=0; mySpace=0;
  340.    myColr=NULL; myAlign=NULL; myPath=0; myOrientation=NULL;}
  341.   int index() const {return myIndex;}
  342.   void setIndex(int inIndex) {myIndex = inIndex;}
  343.   int font() const {return myFont;}
  344.   void setFont(int inFont) {myFont = inFont;}
  345.   int prec() const {return myPrec;}
  346.   void setPrec(int inPrec) {myPrec = inPrec;}
  347.   float expan() const {return myExpan;}
  348.   void setExpan(float inExpan) {myExpan = inExpan;}
  349.   float height() const {return myHeight;}
  350.   void setHeight(float inHeight) {myHeight = inHeight;}
  351.   float space() const {return mySpace;}
  352.   void setSpace(float inSpace) {mySpace = inSpace;}
  353.   const genColr *colr() const {return myColr;}
  354.   void setColr(genColr *inColr) {myColr = inColr;}
  355.   const alignment *align() const {return myAlign;}
  356.   void setAlign(alignment *inAlign) {myAlign = inAlign;}
  357.   int path() const {return myPath;}
  358.   void setPath(int inPath) {myPath = inPath;}
  359.   const vdcPts *orientation() const {return myOrientation;}
  360.   void setOrientation(const vdcPts *inOrient) {myOrientation = inOrient;}
  361. protected:
  362.   int myIndex; // bundle index
  363.   int myFont; // font number
  364.   int myPrec; // precision
  365.   float myExpan; // character expansion factor
  366.   float myHeight; // character height
  367.   float mySpace; // spacing
  368.   genColr *myColr;
  369.   int myPath;
  370.   alignment *myAlign;
  371.   const vdcPts *myOrientation;
  372. };
  373. ////
  374. // general text class
  375. ////
  376. class genText {
  377. public:
  378.   genText(const textInfo *inTextInfo, int inFinal, char *inText, int inSize,
  379.       vdcPts *inPos = NULL, 
  380.       int inAppend=0, vdc *inHeight=NULL, vdc *inWidth=NULL) // constructor
  381.     {myPos=inPos; flag = (inFinal) ? finalFlag : 0; myContents=inText;
  382.      mySize=inSize; myHeight=inHeight; myWidth=inWidth;
  383.      if (inAppend) flag |= appendFlag; myInfo = inTextInfo;}
  384.   ~genText() {if (size()) delete myContents; delete myPos; delete myHeight;
  385.      delete myWidth;}
  386.   int restricted() const {return flag & restrictedFlag;}
  387.   int final() const {return flag & finalFlag;}
  388.   int size() const {return mySize;}
  389.   const vdcPts *pos() const {return myPos;}
  390.   const char *contents() const {return myContents;}
  391.   const vdc *height() const {return myHeight;}
  392.   const vdc *width() const {return myWidth;}
  393.   const textInfo *info() const {return myInfo;}
  394. protected:
  395.   int flag;
  396.   vdcPts *myPos; // position
  397.   vdc *myWidth, *myHeight; // if restricted
  398.   static const int finalFlag, restrictedFlag, appendFlag;
  399.   char *myContents;
  400.   int mySize;
  401.   const textInfo *myInfo;
  402. };
  403. // now individual CGM classes
  404. ////
  405. // define macro to handle CGM class declarations
  406. // after this macro add any other public parts and any privates
  407. ////
  408. #define CGMCLASS(className) \
  409. class className : public baseCGM { \
  410. public: \
  411.   className(cgmContainer *inOwner, baseCGM *inPrev = NULL, \
  412.         baseCGM *inNext = NULL) \
  413.     : baseCGM(inOwner, inPrev, inNext) {} \
  414.   int cgmClass() {return myClass;} \
  415.   virtual int cgmElement() = 0; \
  416.   virtual const char *cgmName() = 0; \
  417.   static const int myClass;
  418.  
  419. ////
  420. // define macro to help handle declaration of CGM elements
  421. // after this macro add any other public parts and any privates
  422. ////
  423. #define CGMELEMENT(element, className) \
  424. class element : public className { \
  425. public: \
  426.   element(cgmContainer*, cgmInput*, baseCGM *inPrev = NULL, \
  427.       baseCGM *inNext = NULL); \
  428.     int cgmElement() {return myElement;} \
  429.     const char *cgmName() {return myName;} \
  430.     static baseCGM *getNew(cgmContainer *inOwner, cgmInput *cgmIn, \
  431.     baseCGM *inPrev) \
  432.     { return new element(inOwner, cgmIn, inPrev);} \
  433.       static const int myElement; \
  434.     static const char *myName; \
  435.       virtual int cgmOut(cgmOutput*); 
  436. ////
  437. // the Delimiter elements
  438. ////
  439. CGMCLASS(cgmDelimiter)
  440. };
  441. ////
  442. // begin metafile
  443. ////
  444. CGMELEMENT(cgmBeginMetafile, cgmDelimiter)
  445.   ~cgmBeginMetafile();
  446.   void setOwner(cgmMetafile *inOwner);
  447.   virtual int display(baseDisplay*);
  448. private:
  449.   char *mfName;
  450.   int mfNameSize;
  451. };
  452. ////
  453. // end metafile
  454. ////
  455. CGMELEMENT(cgmEndMetafile, cgmDelimiter)
  456.      cgmEndMetafile(cgmContainer *inOwner=NULL)
  457.   : cgmDelimiter(inOwner) {} // alternate constructor
  458.   virtual int display(baseDisplay *inDisplay);
  459. };
  460.  
  461. ////
  462. // begin picture
  463. ////
  464. CGMELEMENT(cgmBeginPicture, cgmDelimiter)
  465.   // alternate constructor
  466.   cgmBeginPicture(cgmContainer*, const char*, int,
  467.     baseCGM* = NULL, baseCGM* = NULL);
  468.   ~cgmBeginPicture();
  469.   virtual int display(baseDisplay*);
  470.   const char *name() {return (picName) ? picName : "";}
  471.   int nameSize() {return picNameSize;}
  472. private:
  473.   char *picName;
  474.   int picNameSize;
  475. };
  476. ////
  477. // begin picture body
  478. ////
  479. CGMELEMENT(cgmBeginPictureBody, cgmDelimiter)
  480.   virtual int display(baseDisplay*);
  481. };
  482. ////
  483. // end picture
  484. CGMELEMENT(cgmEndPicture, cgmDelimiter)
  485.   virtual int display(baseDisplay *inDisplay);
  486. };
  487. ////
  488. // metafile descrptors
  489. ////
  490. CGMCLASS(cgmMetafileDescriptor)
  491. };
  492. ////
  493. // metafile version
  494. ////
  495. CGMELEMENT(cgmMetafileVersion, cgmMetafileDescriptor)
  496.   int versionNumber;
  497. };
  498. ////
  499. // metafile description
  500. ////
  501. CGMELEMENT(cgmMetafileDescription, cgmMetafileDescriptor)
  502.   ~cgmMetafileDescription();
  503.   char *mfDescription;
  504. private:
  505.   int mfDescriptionSize;
  506. };
  507. ////
  508. // VDC Type
  509. ////
  510. CGMELEMENT(cgmVdcType, cgmMetafileDescriptor)
  511. public:
  512.   vdcType myType;
  513. private:
  514.   static const char **typeList;
  515.   static const int typeListSize;
  516. };
  517. ////
  518. // class for unsigned integer precisions
  519. ////
  520. class uIntPrec {
  521. public:
  522.   uIntPrec(unsigned int inMax = 1<<16 - 1, int inBytes = 2)
  523.     {maxInt = inMax; noBytes = inBytes;}
  524.   unsigned int maxInt;
  525.   int noBytes;
  526. };
  527. ////
  528. // class for signed integer precisions
  529. ////
  530. class intPrec : public uIntPrec {
  531. public:
  532.   intPrec(int inMin = - (1<<15), int inMax = 1<<15 - 1, int inBytes = 2)
  533.     : uIntPrec(inMax, inBytes) {minInt = inMin;}
  534.   int minInt;
  535. };
  536. ////
  537. // Integer Precision
  538. ////
  539. CGMELEMENT(cgmIntegerPrec, cgmMetafileDescriptor)
  540.   intPrec thisPrec;
  541. };
  542. ////
  543. // class for real precisions
  544. ////
  545. class realPrec {
  546. public:
  547.   realPrec(float inMin = -33000, float inMax = 33000, int inDigits = 7,
  548.        int inFormat = 1, int inExp = 16, int inFract = 16) {
  549.     minReal = inMin; maxReal = inMax; noDigits = inDigits;
  550.     format = inFormat; expPart = inExp; fractPart = inFract;
  551.   }
  552.   float minReal;
  553.   float maxReal;
  554.   int noDigits;
  555.   int format;
  556.   int expPart;
  557.   int fractPart;
  558. };
  559. ////
  560. // Real Precision
  561. ////
  562. CGMELEMENT(cgmRealPrec, cgmMetafileDescriptor)
  563.   realPrec thisPrec;
  564. };
  565. ////
  566. // index precision
  567. ////
  568. CGMELEMENT(cgmIndexPrec, cgmMetafileDescriptor)
  569.   intPrec thisPrec;
  570. };
  571. ////
  572. // Colour precision
  573. ////
  574. CGMELEMENT(cgmColrPrec, cgmMetafileDescriptor)
  575.   uIntPrec thisPrec;
  576. };
  577. ////
  578. // Colour index precision
  579. ////
  580. CGMELEMENT(cgmColrIndexPrec, cgmMetafileDescriptor)
  581.   uIntPrec thisPrec;
  582. };
  583. ////
  584. // Maximum Colour index
  585. ////
  586. CGMELEMENT(cgmMaxColrIndex, cgmMetafileDescriptor)
  587.   int maxIndexValue;
  588. };
  589. ////
  590. // Colour Value Extent
  591. ////
  592. CGMELEMENT(cgmColrValueExtent, cgmMetafileDescriptor)
  593.   colrValueExtent myExtent;
  594. };
  595. ////
  596. // type to hold element list
  597. ////
  598. typedef int classElement[2];
  599. ////
  600. // metafile element list
  601. ////
  602. CGMELEMENT(cgmMetafileElementList, cgmMetafileDescriptor)
  603. private:
  604.   int noElements;
  605.   classElement *elements;
  606. };
  607. ////
  608. // metafile defaults replacement
  609. ////
  610. CGMELEMENT(cgmMetafileDefaultsReplacement, cgmMetafileDescriptor)
  611.   static const char *endName;
  612. private:
  613.   cgmDefaults *myDefaults;
  614. };
  615. ////
  616. // font list
  617. ////
  618. typedef char *fontName;
  619. CGMELEMENT(cgmFontList, cgmMetafileDescriptor)
  620. private:
  621.   int noFonts;
  622.   fontName *fontList;
  623. };
  624. ////
  625. // character set
  626. ////
  627. class characterSet
  628. {
  629. public:
  630.   int code;
  631.   char *tail;
  632. };
  633. ////
  634. // character set list
  635. ////
  636. CGMELEMENT(cgmCharacterSetList, cgmMetafileDescriptor)
  637. private:
  638.   int noSets;
  639.   characterSet *characterSetList;
  640. };
  641. ////
  642. // character coding announcer
  643. ////
  644. CGMELEMENT(cgmCharacterCodingAnnouncer, cgmMetafileDescriptor)
  645. private:
  646.   int announcer;
  647.   static const char **typeList;
  648.   static const int typeListSize;
  649. };
  650. ////
  651. // Picture descriptors
  652. ////
  653. CGMCLASS(cgmPictureDescriptor)
  654. };
  655. ////
  656. // scaling mode
  657. ////
  658. CGMELEMENT(cgmScalingMode, cgmPictureDescriptor)
  659.   int mode;
  660.   float factor;
  661. private:
  662.   static const char **typeList;
  663.   static const int typeListSize;
  664. };
  665. ////
  666. // colour mode
  667. ////
  668. CGMELEMENT(cgmColrMode, cgmPictureDescriptor)
  669.   int mode;
  670. private:
  671.   static const char **typeList;
  672.   static const int typeListSize;
  673. };
  674. ////
  675. // line width mode
  676. ////
  677. CGMELEMENT(cgmLineWidthMode, cgmPictureDescriptor)
  678.   int mode;
  679. private:
  680.   static const char **typeList;
  681.   static const int typeListSize;
  682. };
  683. ////
  684. // marker size mode
  685. ////
  686. CGMELEMENT(cgmMarkerSizeMode, cgmPictureDescriptor)
  687.   int mode;
  688. private:
  689.   static const char **typeList;
  690.   static const int typeListSize;
  691. };
  692. ////
  693. // edge width mode
  694. ////
  695. CGMELEMENT(cgmEdgeWidthMode, cgmPictureDescriptor)
  696.   int mode;
  697. private:
  698.   static const char **typeList;
  699.   static const int typeListSize;
  700. };
  701. ////
  702. // vdc extent
  703. ////
  704. CGMELEMENT(cgmVdcExtent, cgmPictureDescriptor)
  705.   ~cgmVdcExtent();
  706.   vdcPts *myPts;
  707. };
  708. ////
  709. // background colour
  710. ////
  711. CGMELEMENT(cgmBackgroundColr, cgmPictureDescriptor)
  712.   dColr background;
  713.   virtual int display(baseDisplay*);
  714. };
  715. ////
  716. // control elements
  717. ////
  718. CGMCLASS(cgmControl)
  719. };
  720. ////
  721. // vdc integer precision
  722. ////
  723. CGMELEMENT(cgmVdcInteger, cgmControl)
  724.   intPrec thisPrec;
  725. };
  726. ////
  727. // vdc real precision
  728. ////
  729. CGMELEMENT(cgmVdcReal, cgmControl)
  730.   realPrec thisPrec;
  731. };
  732. ////
  733. // auxiliary colour
  734. ////
  735. CGMELEMENT(cgmAuxColr, cgmControl)
  736.   ~cgmAuxColr() {delete myColr;}
  737. private:
  738.   genColr *myColr;
  739. };
  740. ////
  741. // transparency
  742. ////
  743. CGMELEMENT(cgmTransparency, cgmControl)
  744.   int myType;
  745.   virtual int display(baseDisplay*);
  746. private:
  747.   static const char **typeList;
  748.   static const int typeListSize;
  749. };
  750. ////
  751. // clip rectangle
  752. ////
  753. CGMELEMENT(cgmClipRect, cgmControl)
  754.   virtual int display(baseDisplay*);  
  755.   ~cgmClipRect() {delete myPts;}
  756. private:
  757.   vdcPts *myPts;
  758. };  
  759. ////
  760. // clip indicator
  761. ////
  762. CGMELEMENT(cgmClip, cgmControl)
  763.   int myType;
  764.   virtual int display(baseDisplay*);
  765. private:
  766.   static const char **typeList;
  767.   static const int typeListSize;
  768. };
  769. ////
  770. // graphical primitives
  771. ////
  772. CGMCLASS(cgmGraphicalPrimitive)
  773. };
  774. ////
  775. // polyline
  776. ////
  777. CGMELEMENT(cgmPolyline, cgmGraphicalPrimitive)
  778.   virtual int display(baseDisplay*);  
  779.   ~cgmPolyline();
  780. private:
  781.   vdcPts *myPts;
  782. };  
  783. ////
  784. // disjoint polyline
  785. ////
  786. CGMELEMENT(cgmDisPolyline, cgmGraphicalPrimitive)
  787.   virtual int display(baseDisplay*);  
  788.   ~cgmDisPolyline();
  789. private:
  790.   vdcPts *myPts;
  791. };  
  792. ////
  793. // polymarker
  794. ////
  795. CGMELEMENT(cgmPolymarker, cgmGraphicalPrimitive)
  796.   virtual int display(baseDisplay*);  
  797.   ~cgmPolymarker();
  798. private:
  799.   vdcPts *myPts;
  800. };  
  801. ////
  802. // text
  803. ////
  804. CGMELEMENT(cgmText, cgmGraphicalPrimitive)
  805.   virtual int display(baseDisplay*);  
  806.   ~cgmText() {delete myText;}
  807. protected:
  808.   genText *myText;
  809.   static const char **typeList;
  810.   static const int typeListSize;
  811. };  
  812. ////
  813. // restricted text
  814. ////
  815. CGMELEMENT(cgmRestrText, cgmGraphicalPrimitive)
  816.   virtual int display(baseDisplay*);  
  817.   ~cgmRestrText() {delete myText;}
  818. protected:
  819.   genText *myText;
  820.   vdc *maxWidth, *maxHeight;
  821.   static const char **typeList;
  822.   static const int typeListSize;
  823. };  
  824. ////
  825. // appended text
  826. ////
  827. CGMELEMENT(cgmApndText, cgmGraphicalPrimitive)
  828.   virtual int display(baseDisplay*);  
  829.   ~cgmApndText() {delete myText;}
  830. protected:
  831.   genText *myText;
  832.   static const char **typeList;
  833.   static const int typeListSize;
  834. };  
  835. ////
  836. // polygon
  837. ////
  838. CGMELEMENT(cgmPolygon, cgmGraphicalPrimitive)
  839.   virtual int display(baseDisplay*);  
  840.   ~cgmPolygon();
  841. private:
  842.   vdcPts *myPts;
  843. };  
  844. ////
  845. // polygon set
  846. ////
  847. CGMELEMENT(cgmPolygonSet, cgmGraphicalPrimitive)
  848.   virtual int display(baseDisplay*);  
  849.   static const char **typeList;
  850.   static const int typeListSize;
  851. private:
  852.   vdcPts *myPts;
  853.   int *myFlags;
  854. };  
  855. ////
  856. // generalized drawing primitive
  857. ////
  858. CGMELEMENT(cgmGDP, cgmGraphicalPrimitive)
  859.   virtual int display(baseDisplay*);  
  860. private:
  861.  // fill out later
  862. };  
  863. ////
  864. // cell array
  865. ////
  866. CGMELEMENT(cgmCellArray, cgmGraphicalPrimitive)
  867.   virtual int display(baseDisplay*);  
  868.   ~cgmCellArray();
  869. private:
  870.   cellArray *myCell;
  871. };  
  872. ////
  873. // rectangle
  874. ////
  875. CGMELEMENT(cgmRectangle, cgmGraphicalPrimitive)
  876.   virtual int display(baseDisplay*);  
  877.   ~cgmRectangle();
  878. private:
  879.   vdcPts *myPts;
  880. };  
  881. ////
  882. // circle
  883. ////
  884. CGMELEMENT(cgmCircle, cgmGraphicalPrimitive)
  885.   virtual int display(baseDisplay*);  
  886.   ~cgmCircle();
  887. private:
  888.   vdcPts *centre;
  889.   vdc *radius;
  890. };  
  891. ////
  892. // circular arc, designated by 3 points
  893. ////
  894. CGMELEMENT(cgmArc3Pt, cgmGraphicalPrimitive)
  895.   virtual int display(baseDisplay*);  
  896.   ~cgmArc3Pt() {delete myPts;}
  897. private:
  898.   vdcPts *myPts;
  899. };  
  900. ////
  901. // circular arc, designated by 3 points and closed
  902. ////
  903. CGMELEMENT(cgmArc3PtClose, cgmGraphicalPrimitive)
  904.   virtual int display(baseDisplay*);  
  905.   ~cgmArc3PtClose() {delete myPts;}
  906. private:
  907.   vdcPts *myPts;
  908.   static const char **typeList;
  909.   static const int typeListSize;
  910.   int myType;
  911. };  
  912. ////
  913. // circular arc, designated by a centre, 2 vectors and a radius
  914. ////
  915. CGMELEMENT(cgmArcCtr, cgmGraphicalPrimitive)
  916.   virtual int display(baseDisplay*);  
  917.   ~cgmArcCtr() {delete myPts; delete radius;}
  918. private:
  919.   vdcPts *myPts;
  920.   vdc *radius;
  921. };  
  922. ////
  923. // closed circular arc, designated by a centre, 2 vectors and a radius
  924. ////
  925. CGMELEMENT(cgmArcCtrClose, cgmGraphicalPrimitive)
  926.   virtual int display(baseDisplay*);  
  927.   ~cgmArcCtrClose() {delete myPts; delete radius;}
  928. private:
  929.   vdcPts *myPts;
  930.   vdc *radius;
  931.   static const char **typeList;
  932.   static const int typeListSize;
  933.   int myType;
  934. };  
  935. ////
  936. // ellipse, designated by 3 pts
  937. ////
  938. CGMELEMENT(cgmEllipse, cgmGraphicalPrimitive)
  939.   virtual int display(baseDisplay*);  
  940.   ~cgmEllipse() {delete myPts;}
  941. private:
  942.   vdcPts *myPts;
  943. };  
  944. ////
  945. // elliptical arc, designated by 5 pts
  946. ////
  947. CGMELEMENT(cgmEllipArc, cgmGraphicalPrimitive)
  948.   virtual int display(baseDisplay*);  
  949.   ~cgmEllipArc() {delete myPts;}
  950. private:
  951.   vdcPts *myPts;
  952. };  
  953. ////
  954. // elliptical arc, designated by 5 pts, closed
  955. ////
  956. CGMELEMENT(cgmEllipArcClose, cgmGraphicalPrimitive)
  957.   virtual int display(baseDisplay*);  
  958.   ~cgmEllipArcClose() {delete myPts;}
  959. private:
  960.   vdcPts *myPts;
  961.   static const char **typeList;
  962.   static const int typeListSize;
  963.   int myType;
  964. };  
  965. ////
  966. // attributes class
  967. ////
  968. class cgmPicture; // forward declaration
  969. CGMCLASS(cgmAttribute)
  970. };
  971. ////
  972. // line bundle index
  973. ////
  974. CGMELEMENT(cgmLineIndex, cgmAttribute)
  975.   virtual int display(baseDisplay*);  
  976. private:
  977.   int myIndex;
  978. };  
  979. ////
  980. // line type 
  981. ////
  982. CGMELEMENT(cgmLineType, cgmAttribute)
  983.   virtual int display(baseDisplay*);  
  984. private:
  985.   int myType;
  986. };  
  987. ////
  988. // line width
  989. ////
  990. CGMELEMENT(cgmLineWidth, cgmAttribute)
  991.   virtual int display(baseDisplay*);  
  992.   ~cgmLineWidth();
  993. private:
  994.   vdcR *myVdcR;
  995. };  
  996. ////
  997. // line colour
  998. ////
  999. CGMELEMENT(cgmLineColr, cgmAttribute)
  1000.   virtual int display(baseDisplay*);  
  1001.   ~cgmLineColr() {delete myColr;}
  1002. private:
  1003.   genColr *myColr;
  1004. };  
  1005. ////
  1006. // marker bundle index
  1007. ////
  1008. CGMELEMENT(cgmMarkerIndex, cgmAttribute)
  1009.   virtual int display(baseDisplay*);  
  1010. private:
  1011.   int myIndex;
  1012. };  
  1013. ////
  1014. // marker type 
  1015. ////
  1016. CGMELEMENT(cgmMarkerType, cgmAttribute)
  1017.   virtual int display(baseDisplay*);  
  1018. private:
  1019.   int myType;
  1020. };  
  1021. ////
  1022. // marker size
  1023. ////
  1024. CGMELEMENT(cgmMarkerSize, cgmAttribute)
  1025.   virtual int display(baseDisplay*);  
  1026.   ~cgmMarkerSize();
  1027. private:
  1028.   vdcR *myVdcR;
  1029. };  
  1030. ////
  1031. // marker colour
  1032. ////
  1033. CGMELEMENT(cgmMarkerColr, cgmAttribute)
  1034.   virtual int display(baseDisplay*);  
  1035.   ~cgmMarkerColr() {delete myColr;}
  1036. private:
  1037.   genColr *myColr;
  1038. };  
  1039. ////
  1040. // text bundle index
  1041. ////
  1042. CGMELEMENT(cgmTextIndex, cgmAttribute)
  1043.   virtual int display(baseDisplay*);  
  1044. private:
  1045.   int myIndex;
  1046. };  
  1047. ////
  1048. // text font index
  1049. ////
  1050. CGMELEMENT(cgmFontIndex, cgmAttribute)
  1051.   virtual int display(baseDisplay*);  
  1052. private:
  1053.   int myIndex;
  1054. };  
  1055. ////
  1056. // text precision
  1057. ////
  1058. CGMELEMENT(cgmTextPrec, cgmAttribute)
  1059.   virtual int display(baseDisplay*);  
  1060. private:
  1061.   int myType;
  1062.   static const char **typeList;
  1063.   static const int typeListSize;
  1064. };  
  1065. ////
  1066. // character expansion factor
  1067. ////
  1068. CGMELEMENT(cgmCharExpan, cgmAttribute)
  1069.   virtual int display(baseDisplay*);  
  1070. private:
  1071.   float factor;
  1072. };  
  1073. ////
  1074. // character spacing
  1075. ////
  1076. CGMELEMENT(cgmCharSpace, cgmAttribute)
  1077.   virtual int display(baseDisplay*);  
  1078. private:
  1079.   float spacing;
  1080. };  
  1081. ////
  1082. // text colour
  1083. ////
  1084. CGMELEMENT(cgmTextColr, cgmAttribute)
  1085.   virtual int display(baseDisplay*);  
  1086.   ~cgmTextColr() {delete myColr;}
  1087. private:
  1088.   genColr *myColr;
  1089. };  
  1090. ////
  1091. // character height
  1092. ////
  1093. CGMELEMENT(cgmCharHeight, cgmAttribute)
  1094.   virtual int display(baseDisplay*);  
  1095.   ~cgmCharHeight() {delete height;}
  1096. private:
  1097.   vdc *height;
  1098. };  
  1099. ////
  1100. // character orientation
  1101. ////
  1102. CGMELEMENT(cgmCharOri, cgmAttribute)
  1103.   virtual int display(baseDisplay*);  
  1104.   ~cgmCharOri() {delete orientation;}
  1105. private:
  1106.   vdcPts *orientation;
  1107. };  
  1108. ////
  1109. // text path
  1110. ////
  1111. CGMELEMENT(cgmTextPath, cgmAttribute)
  1112.   virtual int display(baseDisplay*);  
  1113. private:
  1114.   int myType;
  1115.   static const char **typeList;
  1116.   static const int typeListSize;
  1117. };  
  1118. ////
  1119. // text alignment
  1120. ////
  1121. CGMELEMENT(cgmTextAlign, cgmAttribute)
  1122.   virtual int display(baseDisplay*);  
  1123.   ~cgmTextAlign() {delete myAlign;} // destructor
  1124. private:
  1125.   alignment *myAlign;
  1126.   static const char **typeList1;
  1127.   static const int typeListSize1;
  1128.   static const char **typeList2;
  1129.   static const int typeListSize2;
  1130. };  
  1131. ////
  1132. // character set index
  1133. ////
  1134. CGMELEMENT(cgmCharSetIndex, cgmAttribute)
  1135.   virtual int display(baseDisplay*);  
  1136. private:
  1137.   int myIndex;
  1138. };  
  1139. ////
  1140. // alternate character set index
  1141. ////
  1142. CGMELEMENT(cgmAltCharSetIndex, cgmAttribute)
  1143.   virtual int display(baseDisplay*);  
  1144. private:
  1145.   int myIndex;
  1146. };  
  1147. ////
  1148. // fill bundle index
  1149. ////
  1150. CGMELEMENT(cgmFillIndex, cgmAttribute)
  1151.   virtual int display(baseDisplay*);  
  1152. private:
  1153.   int myIndex;
  1154. };  
  1155. ////
  1156. // interior style
  1157. ////
  1158. CGMELEMENT(cgmIntStyle, cgmAttribute)
  1159.   virtual int display(baseDisplay*);  
  1160. private:
  1161.   int myType;
  1162.   static const char **typeList;
  1163.   static const int typeListSize;
  1164. };  
  1165. ////
  1166. // fill colour
  1167. ////
  1168. CGMELEMENT(cgmFillColr, cgmAttribute)
  1169.   virtual int display(baseDisplay*);  
  1170.   ~cgmFillColr() {delete myColr;}
  1171. private:
  1172.   genColr *myColr;
  1173. };  
  1174. ////
  1175. // hatch index
  1176. ////
  1177. CGMELEMENT(cgmHatchIndex, cgmAttribute)
  1178.   virtual int display(baseDisplay*);  
  1179. private:
  1180.   int myIndex;
  1181. };  
  1182. ////
  1183. // pattern index
  1184. ////
  1185. CGMELEMENT(cgmPatIndex, cgmAttribute)
  1186.   virtual int display(baseDisplay*);  
  1187. private:
  1188.   int myIndex;
  1189. };  
  1190. ////
  1191. // edge bundle index
  1192. ////
  1193. CGMELEMENT(cgmEdgeIndex, cgmAttribute)
  1194.   virtual int display(baseDisplay*);  
  1195. private:
  1196.   int myIndex;
  1197. };  
  1198. ////
  1199. // edge type 
  1200. ////
  1201. CGMELEMENT(cgmEdgeType, cgmAttribute)
  1202.   virtual int display(baseDisplay*);  
  1203. private:
  1204.   int myType;
  1205. };  
  1206. ////
  1207. // edge width
  1208. ////
  1209. CGMELEMENT(cgmEdgeWidth, cgmAttribute)
  1210.   virtual int display(baseDisplay*);  
  1211.   ~cgmEdgeWidth();
  1212. private:
  1213.   vdcR *myVdcR;
  1214. };  
  1215. ////
  1216. // edge colour
  1217. ////
  1218. CGMELEMENT(cgmEdgeColr, cgmAttribute)
  1219.   virtual int display(baseDisplay*);  
  1220.   ~cgmEdgeColr() {delete myColr;}
  1221. private:
  1222.   genColr *myColr;
  1223. };  
  1224. ////
  1225. // edge visibility
  1226. ////
  1227. CGMELEMENT(cgmEdgeVis, cgmAttribute)
  1228.   virtual int display(baseDisplay*);  
  1229. private:
  1230.   int myType;
  1231.   static const char **typeList;
  1232.   static const int typeListSize;
  1233. };  
  1234. ////
  1235. // fill reference point
  1236. ////
  1237. CGMELEMENT(cgmFillRefPt, cgmAttribute)
  1238.   virtual int display(baseDisplay*);  
  1239.   ~cgmFillRefPt() {delete myPts;}
  1240. private:
  1241.   vdcPts *myPts;
  1242. };  
  1243. ////
  1244. // pattern size
  1245. ////
  1246. CGMELEMENT(cgmPatSize, cgmAttribute)
  1247.   virtual int display(baseDisplay*);  
  1248.   ~cgmPatSize() {delete myPts;}
  1249. private:
  1250.   vdcPts *myPts;
  1251. };  
  1252. ////
  1253. // pattern table
  1254. ////
  1255. CGMELEMENT(cgmPatTable, cgmAttribute)
  1256.   virtual int display(baseDisplay*);  
  1257. private:
  1258.   // fill out later
  1259. };  
  1260. ////
  1261. // colour table
  1262. ////
  1263. CGMELEMENT(cgmColrTable, cgmAttribute)
  1264.   virtual int display(baseDisplay*);  
  1265.   ~cgmColrTable() {delete myTable;}
  1266. private:
  1267.   colrTable *myTable;
  1268. };  
  1269. ////
  1270. // aspect source flags
  1271. ////
  1272. CGMELEMENT(cgmASF, cgmAttribute)
  1273.      // fill out later
  1274. };  
  1275. ////
  1276. // escape class
  1277. ////
  1278. CGMCLASS(cgmEscape)
  1279. };
  1280. ////
  1281. // escape element
  1282. ////
  1283. CGMELEMENT(cgmEscapeElement, cgmEscape)
  1284.   ~cgmEscapeElement() {if (dataSize) delete myData;}
  1285.   char *data() {return myData;}
  1286. private:
  1287.   int myId, dataSize;   
  1288.   char *myData;
  1289.   static const int indexFlag;
  1290.   void makeIndex(cgmMetafile*, cgmInput*);
  1291.   int haveNumber(char c) {return (c=='-') || (c=='+') || (('0'<=c)&&(c<='9'));}
  1292. };  
  1293. ////
  1294. // external class
  1295. ////
  1296. CGMCLASS(cgmExternal)
  1297. };
  1298. ////
  1299. // message element
  1300. ////
  1301. CGMELEMENT(cgmMessage, cgmExternal)
  1302.      // fill out later
  1303. };  
  1304. ////
  1305. // application data
  1306. ////
  1307. CGMELEMENT(cgmApplData, cgmExternal)
  1308.      // fill out later
  1309. };  
  1310. #undef CGMCLASS
  1311. #undef CGMELEMENT
  1312. ////
  1313. // classes that can contain cgm elements
  1314. ////
  1315. class cgmContainer { // container class, can be a picture or a metafile
  1316. public:
  1317.   cgmContainer() {
  1318.     scalingCmd = NULL;
  1319.     colrModeCmd = NULL;
  1320.     lineModeCmd = NULL;
  1321.     markerModeCmd = NULL;
  1322.     edgeModeCmd = NULL;
  1323.     vdcExtentCmd = NULL;
  1324.     myColrTable = NULL;
  1325.   }
  1326.   // colour table
  1327.   colrTable *myColrTable;
  1328.   virtual colrTable *colrs() {return myColrTable;} // default
  1329.   // metafile descriptors 
  1330.   virtual const colrValueExtent *colrExtent() = 0;
  1331.   // picture descriptors (may be in either picture or metafile)
  1332.   // come as a command marker and a function to access them
  1333.   cgmScalingMode *scalingCmd;
  1334.   virtual int scalingMode() = 0;
  1335.   virtual float scalingFactor() = 0;
  1336.   cgmColrMode *colrModeCmd;
  1337.   virtual int colrMode() = 0;
  1338.   cgmLineWidthMode *lineModeCmd;
  1339.   virtual int lineMode() = 0;
  1340.   cgmMarkerSizeMode *markerModeCmd;
  1341.   virtual int markerMode() = 0;
  1342.   cgmEdgeWidthMode *edgeModeCmd;
  1343.   virtual int edgeMode() = 0;
  1344.   cgmVdcExtent *vdcExtentCmd; 
  1345.   virtual const vdcPts* vdcExtent()const = 0;
  1346.   textInfo tInfo;
  1347.   // function to get top level metafile
  1348.   virtual cgmMetafile *mfOwner() = 0;
  1349.   // is this a metafile ?
  1350.   virtual int mf() {return 0;}
  1351. };
  1352. ////
  1353. // one picture
  1354. ////
  1355. class cgmPicture : public cgmContainer{
  1356. public:
  1357.   cgmPicture(cgmMetafile*, cgmInput*, cgmBeginPicture*, cgmPicture* = NULL,
  1358.          filePos=0);
  1359.   virtual ~cgmPicture();
  1360.   int cgmOut(cgmOutput*); // output to a cgm format
  1361.   cgmPicture *next; // next one
  1362.   cgmPicture *prev; // previous one
  1363.   void display(baseDisplay*);
  1364.   // state variables
  1365.   const colrValueExtent *colrExtent();
  1366.   int scalingMode();
  1367.   float scalingFactor();
  1368.   int colrMode();
  1369.   int lineMode();
  1370.   int markerMode();
  1371.   int edgeMode();
  1372.   const vdcPts* vdcExtent() const;
  1373.   filePos pos() {return myPos;}
  1374.   int readIn(); // read in the actual contents
  1375.   int inMem() const {return !!contents;}
  1376.   void setAside(); // store it until we need it
  1377.   cgmMetafile *mfOwner() {return metafile;}
  1378.   const char *name() {return (myBeginPicture) ? myBeginPicture->name() : NULL;}
  1379.   int nameSize() {return (myBeginPicture) ? myBeginPicture->nameSize() : 0;}
  1380.   int want() const {return myWant;}
  1381.   void setWant(int inWant) {myWant = inWant;}
  1382. private:
  1383.   int myWant;
  1384.   baseCGM *contents; // the contents of this picture
  1385.   filePos myPos; // position in file
  1386.   cgmInput *myInput; // input file handler
  1387.   cgmBeginPicture *myBeginPicture;  
  1388.   cgmMetafile *metafile; // the metafile it belongs to 
  1389. };
  1390. ////
  1391. // the file itself
  1392. ////
  1393. class cgmMetafile : public cgmContainer{
  1394. public:
  1395.   cgmMetafile(cgmBeginMetafile *inStart, cgmInput*); // constructor
  1396.   virtual ~cgmMetafile(); // destructor
  1397.   int cgmOut(cgmOutput*); // output to a cgm format
  1398.   // metafile state variables
  1399.   cgmMetafileVersion *versionCmd; // metafile version
  1400.   int version();
  1401.   cgmMetafileDescription *descriptionCmd; // metafile description
  1402.   const char *description();
  1403.   cgmVdcType *vdcTypeCmd; // VDC type
  1404.   vdcType myVdcType() const {return vdcTypeCmd ? vdcTypeCmd->myType : 0;}
  1405.   cgmMaxColrIndex *maxColrIndexCmd; // maximum colour index
  1406.   int maxColrIndex() const
  1407.     {return maxColrIndexCmd ? maxColrIndexCmd->maxIndexValue : 63;}
  1408.   cgmColrValueExtent *colrValueExtentCmd; // colour value extent
  1409.   colrValueExtent defExtent; // default colour value extent
  1410.   const colrValueExtent *colrExtent();
  1411.   // picture default state variables
  1412.   int scalingMode();
  1413.   float scalingFactor();
  1414.   int colrMode();
  1415.   int lineMode();
  1416.   int markerMode();
  1417.   int edgeMode();
  1418.   vdcPts *intDefVdcExtent; // integer default VDC extent
  1419.   vdcPts *floatDefVdcExtent; // float default VDC extent
  1420.   const vdcPts* vdcExtent() const; // VDC extent
  1421.  
  1422.   cgmPicture *firstPic; // first picture
  1423.   void addDefaults(cgmDefaults*); // add a set of defaults
  1424.   void displayDefaults(baseDisplay *inDisplay) const; // display the defaults
  1425. //     {for (cgmDefaults *myPtr=myDefaults; myPtr; myPtr=myPtr->next())
  1426. //         myPtr->display(inDisplay);}
  1427.   const cgmDefaults *defaults() const {return myDefaults;}
  1428.   cgmMetafile *mfOwner() {return this;}
  1429.   void display(baseDisplay *inDisplay);
  1430.   virtual int mf() {return 1;} // it's a metafile
  1431.   int indexed() {return myIndexed;}
  1432.   void setIndexed() {myIndexed = 1;}
  1433.   int makeIndex(); // try to index the file
  1434.   filePos start() {return myStart;}
  1435. protected:
  1436.   cgmBeginMetafile *contents; // leads to metafile discriptors, etc.
  1437.   cgmDefaults *myDefaults; // list of defaults
  1438.   cgmInput *myInput; // input file handler
  1439.   int myIndexed;
  1440.   filePos myStart; // actual start of the metafile
  1441. };
  1442. ////
  1443. // a couple of inline functions that couldn't be done earlier
  1444. inline cgmMetafile* baseCGM::mfOwner() {return owner->mfOwner();}
  1445. inline void cgmBeginMetafile::setOwner(cgmMetafile *inOwner) {owner = inOwner;}
  1446. #endif // end of file
  1447.  
  1448.  
  1449.  
  1450.  
  1451.