home *** CD-ROM | disk | FTP | other *** search
/ Photo CD Demo 1 / Demo.bin / graphtal / linedevc.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-10-23  |  1.9 KB  |  92 lines

  1. /*
  2.  * LineDevice.C - simple line device driver.
  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. #include "LineDevice.h"
  19. #include "Polygon.h"
  20.  
  21. //___________________________________________________________ LineDevice
  22.  
  23. LineDevice::LineDevice(BaseWindow* window, Options* options)
  24. : DeviceDriver(options), w(window)
  25. {}
  26.  
  27. LineDevice::~LineDevice()
  28. {
  29.   delete w;
  30. }
  31.  
  32. void LineDevice::begin()
  33. {
  34.   if (!theOptions->autoscale) {
  35.     w->disableBuffering();
  36.     w->setView(theOptions->eye, theOptions->lookat, theOptions->up, 
  37.            theOptions->fov);
  38.   }
  39.   w->open(theOptions->resX, theOptions->resY, "L-System " + LSystemName);
  40.  
  41.   if (theOptions->autoscale)
  42.     w->writeText("Please wait ...", 
  43.          theOptions->resX/2-40, theOptions->resY/2-5);
  44. }
  45.  
  46. void LineDevice::end(const BoundingBox& b)
  47. {
  48.   char key;
  49.  
  50.   if (theOptions->verbose)
  51.     cerr << "primitives: "<< primitives << '\n';
  52.   if (theOptions->autoscale) {
  53.     w->setView(b, theOptions->up, theOptions->fov);
  54.     w->clear();
  55.   }
  56.  
  57.   w->flush();
  58.   do {
  59.     key = w->waitForKey();
  60.   } while(key != 'q' && key != 'Q');
  61.   w->close();
  62. }
  63.  
  64. void LineDevice::cylinder(const Vector& p1, const Vector& p2, real)
  65. {
  66.   if (definingMacro)
  67.     return;
  68.  
  69.   primitives++;
  70.   w->line(p1, p2);
  71. }
  72.  
  73. void LineDevice::cone(const Vector& p1, real, const Vector& p2, real)
  74. {
  75.   if (definingMacro)
  76.     return;
  77.  
  78.   primitives++;
  79.   w->line(p1, p2);
  80. }
  81.  
  82. void LineDevice::polygon(Polygon* p)
  83. {
  84.   if (definingMacro)
  85.     return;
  86.  
  87.   primitives++;
  88.   w->polygon(p);
  89. }
  90.  
  91. void LineDevice::sphere(const Vector&, real){}
  92.