home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / oct93 / graphics / graphtal.lha / Graphtal / LineDevice.C < prev    next >
C/C++ Source or Header  |  1992-11-17  |  2KB  |  93 lines

  1. /*
  2.  * LineDevice.C - simple line device driver.
  3.  *
  4.  * Copyright (C) 1992, Christoph Streit (streit@iam.unibe.ch)
  5.  *                     University of Berne, Switzerland
  6.  * All rights reserved.
  7.  *
  8.  * This software may be freely copied, modified, and redistributed
  9.  * provided that this copyright notice is preserved on all copies.
  10.  *
  11.  * You may not distribute this software, in whole or in part, as part of
  12.  * any commercial product without the express consent of the authors.
  13.  *
  14.  * There is no warranty or other guarantee of fitness of this software
  15.  * for any purpose.  It is provided solely "as is".
  16.  *
  17.  */
  18.  
  19. #include "LineDevice.h"
  20. #include "Polygon.h"
  21.  
  22. //___________________________________________________________ LineDevice
  23.  
  24. LineDevice::LineDevice(BaseWindow* window, Options* options)
  25. : DeviceDriver(options), w(window)
  26. {}
  27.  
  28. LineDevice::~LineDevice()
  29. {
  30.   delete w;
  31. }
  32.  
  33. void LineDevice::begin()
  34. {
  35.   if (!theOptions->autoscale) {
  36.     w->disableBuffering();
  37.     w->setView(theOptions->eye, theOptions->lookat, theOptions->up, 
  38.            theOptions->fov);
  39.   }
  40.   w->open(theOptions->resX, theOptions->resY, "L-System " + LSystemName);
  41.  
  42.   if (theOptions->autoscale)
  43.     w->writeText("Please wait ...", 
  44.          theOptions->resX/2-40, theOptions->resY/2-5);
  45. }
  46.  
  47. void LineDevice::end(const BoundingBox& b)
  48. {
  49.   char key;
  50.  
  51.   if (theOptions->verbose)
  52.     cerr << "primitives: "<< primitives << '\n';
  53.   if (theOptions->autoscale) {
  54.     w->setView(b, theOptions->up, theOptions->fov);
  55.     w->clear();
  56.   }
  57.  
  58.   w->flush();
  59.   do {
  60.     key = w->waitForKey();
  61.   } while(key != 'q' && key != 'Q');
  62.   w->close();
  63. }
  64.  
  65. void LineDevice::cylinder(const Vector& p1, const Vector& p2, real)
  66. {
  67.   if (definingMacro)
  68.     return;
  69.  
  70.   primitives++;
  71.   w->line(p1, p2);
  72. }
  73.  
  74. void LineDevice::cone(const Vector& p1, real, const Vector& p2, real)
  75. {
  76.   if (definingMacro)
  77.     return;
  78.  
  79.   primitives++;
  80.   w->line(p1, p2);
  81. }
  82.  
  83. void LineDevice::polygon(Polygon* p)
  84. {
  85.   if (definingMacro)
  86.     return;
  87.  
  88.   primitives++;
  89.   w->polygon(p);
  90. }
  91.  
  92. void LineDevice::sphere(const Vector&, real){}
  93.