home *** CD-ROM | disk | FTP | other *** search
/ Photo CD Demo 1 / Demo.bin / graphtal / devcdrvr.h < prev    next >
C/C++ Source or Header  |  1992-10-23  |  3KB  |  96 lines

  1. /*
  2.  * DeviceDriver.h - abstract class definition for device drivers.
  3.  *
  4.  * Copyright (C) 1992, Christoph Streit (streit@iam.unibe.ch)
  5.  * All rights reserved.
  6.  *
  7.  * This software may be freely copied, modified, and redistributed
  8.  * provided that this copyright notice is preserved on all copies.
  9.  *
  10.  * You may not distribute this software, in whole or in part, as part of
  11.  * any commercial product without the express consent of the authors.
  12.  *
  13.  * There is no warranty or other guarantee of fitness of this software
  14.  * for any purpose.  It is provided solely "as is".
  15.  *
  16.  */
  17.  
  18. #ifndef DeviceDriver_H
  19. # define DeviceDriver_H
  20.  
  21. #include "list.h"
  22. #include "table.h"
  23.  
  24. #include "Vector.h"
  25. #include "TransMatrix.h"
  26. #include "BoundingBox.h"
  27. #include "Color.h"
  28. #include "Options.h"
  29.  
  30. /*___________________________________________________________ DeviceDriver
  31.  *
  32.  * Abstract base class for any device driver. The following function
  33.  * must be supplied by a new driver:
  34.  *
  35.  * - void begin() : called before any other graphic commands to
  36.  *                  set up whatever you need.
  37.  * - void end()   : end of interpretation (close the file, ...)
  38.  * - void cylinder(..), cone(..), sphere(..), polygon(..)
  39.  *                : geometric primitives to be supported.
  40.  * - void color(Color) 
  41.  *                : set a new color (better you check if the new
  42.  *                  color is different from the old one!)
  43.  * - void beginMacro(..), endMacro(..), executeMacro(..) 
  44.  *                : member functions for macro support. Within a 
  45.  *                  macro definition you have to store the geometric
  46.  *                  primitives for later use (see WireDevice), or just 
  47.  *                  ignore them (see LineDevice).
  48.  * - void libraryObject(..)
  49.  *                : include a predefinied object at the current position
  50.  *                  (it's done in the RayshadeDevice, but for others we 
  51.  *                  would need a general object format).
  52.  */
  53.  
  54. class Polygon;
  55. declareTable(StringTable, rcString, anyPtr);
  56.  
  57. class DeviceDriver
  58. {
  59. public:
  60.   DeviceDriver();
  61.   virtual ~DeviceDriver();
  62.  
  63.   virtual void begin()=0;
  64.   virtual void end(const BoundingBox&)=0;
  65.   virtual void cylinder(const Vector&, const Vector&, real)=0;
  66.   virtual void cone(const Vector&, real, const Vector&, real)=0;
  67.   virtual void sphere(const Vector&, real)=0;
  68.   virtual void polygon(Polygon*)=0;
  69.   virtual void color(const Color&);
  70.   virtual void texture(const rcString&);
  71.   virtual void beginMacro(const rcString&);
  72.   virtual void endMacro();
  73.   virtual void executeMacro(const rcString&, const TransMatrix&);
  74.   virtual void libraryObject(const rcString&, const TransMatrix&);
  75.  
  76.   virtual int addMacroName(const rcString&);
  77.   virtual void addLibraryObjectName(const rcString&);
  78.  
  79.   void setName(const rcString&);
  80.  
  81. protected:
  82.   DeviceDriver(Options*);
  83.  
  84. protected:
  85.   rcString LSystemName;
  86.   Options* theOptions;
  87.  
  88.   long primitives;
  89.   int definingMacro;
  90.   StringTable macroNames;
  91.   StringTable libraryNames;
  92. };
  93.  
  94. #endif // DeviceDriver_H
  95.  
  96.