Main Page Class Hierarchy Compound List File List Compound Members File Members

EPSRenderer.cc

Go to the documentation of this file.
00001 /*
00002 File: EPSRenderer.cc
00003 
00004 Function: Implements EPSRenderer.h
00005 
00006 Author(s): Andrew Willmott
00007 
00008 Copyright: (c) 1997-2000, Andrew Willmott
00009 
00010 */
00011 
00012 #include <iostream.h>
00013 #include "gcl/EPSRenderer.h"
00014 
00015  EPSRenderer::EPSRenderer() : 
00016 Renderer(),
00017 matrixStack(1, 32),
00018 start(true),
00019 style(renNone),
00020 itsFilename("out.eps")
00021 {
00022 matrixStack.Top() = vl_I;
00023 itsPlot.SetOutputSize(192); 
00024 // 192 points: this gets us same size as 400x400 picture at 150dpi in frame
00025 }
00026 
00027  Void EPSRenderer::ViewPoint(const HPoint &hp, Bool draw)
00028 {
00029 Point p = proj(hp);
00030 
00031 if (draw)
00032 itsPlot.LineTo(p[0], p[1]);
00033 else
00034 itsPlot.MoveTo(p[0], p[1]);
00035 }
00036 
00037  Void EPSRenderer::Attach(StrConst epsFilename)
00038 {
00039 itsFilename = epsFilename;
00040 }
00041 
00042  Void EPSRenderer::MakeCurrent()
00043 {
00044 }
00045 
00046  Void EPSRenderer::Show()
00047 {
00048 itsPlot.Close();
00049 }
00050 
00051 
00052 // --- Renderer Drawing Operators ---------------------------------------------
00053 
00054 
00055  Renderer &EPSRenderer::SetColour(const Colour &c)
00056 {
00057 itsPlot.SetColour(c);
00058 return(SELF);
00059 }
00060 
00061  Renderer &EPSRenderer::SetPoint(const Point &p)
00062 {
00063 HPoint hp(p, 1.0);
00064 
00065 hp = xform(matrixStack.Top(), hp);
00066 
00067 ClipPoint(hp, !start);
00068 
00069 if (start)
00070 {
00071 firstPoint = p;
00072 start = false;
00073 }
00074 
00075 return(SELF);
00076 }
00077 
00078  Renderer &EPSRenderer::SetCoord(const Coord &c)
00079 {
00080 return(SetPoint(Vector(c, 0.0)));
00081 }
00082 
00083  Renderer &EPSRenderer::SetNormal(const Vector &n)
00084 {
00085 return(SELF);
00086 }
00087 
00088  Renderer &EPSRenderer::SetTransform(const Transform &t)
00089 {
00090 matrixStack.Top() *= t; 
00091 return(SELF);
00092 }
00093 
00094  Renderer &EPSRenderer::SetCamera(const Camera &c)
00095 {
00096 matrixStack.Clear();
00097 matrixStack.Push(c.ProjMatrix() * c.ModelMatrix());
00098 return(SELF);
00099 }
00100 
00101  Renderer &EPSRenderer::Pop()
00102 {
00103 matrixStack.Pop();
00104 return(SELF);
00105 }
00106 
00107  Renderer &EPSRenderer::Push()
00108 {
00109 matrixStack.Push(matrixStack.Top()); 
00110 return(SELF);
00111 }
00112 
00113  Renderer &EPSRenderer::Clear()
00114 {
00115 itsPlot.Open(itsFilename); 
00116 itsPlot.SetPort(-1, -1, 1, 1, true);
00117 itsPlot.SetWidth(0.0005);
00118 
00119 return(SELF);
00120 }
00121 
00122  Renderer &EPSRenderer::Begin(RenderStyle newStyle)
00123 {
00124 Assert(style == renNone, "Unmatched EPSRenderer::Begin().");
00125 style = newStyle;
00126 start = true;
00127 return(SELF);
00128 }
00129 
00130  Renderer &EPSRenderer::End()
00131 {
00132 Assert(style != renNone, "Unmatched EPSRenderer::End().");
00133 
00134 if (style == renPoly || style == renLineLoop)
00135 // close loop
00136 SetPoint(firstPoint);
00137 
00138 style = renNone;
00139 return(SELF);
00140 }
00141 
00142  Void EPSRenderer::Print(ostream &s)
00143 {
00144 #ifdef BROKEN 
00145 s << "EPS Renderer\n style = " << (int) style
00146 << " matrix = " << matrixStack.Top()
00147 << " start = " << start << endl; 
00148 #endif
00149 }
00150 

Generated at Sat Aug 5 00:16:58 2000 for Graphics Class Library by doxygen 1.1.0 written by Dimitri van Heesch, © 1997-2000

AltStyle によって変換されたページ (->オリジナル) /