home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / pstoedit.zip / source.zip / pstoedit.2.50 / src / drvrpl.cpp < prev    next >
C/C++ Source or Header  |  1996-10-29  |  4KB  |  130 lines

  1. /* 
  2.    drvrpl.cpp - Driver to output Real3D RPL polygons
  3.              - written by Glenn M. Lewis (glewis@c2.net) - 6/18/96
  4.            http://www.c2.net/~glewis/
  5.            Based on...
  6.  
  7.    drvSAMPL.cpp : This file is part of pstoedit
  8.    Skeleton for the implementation of new backends
  9.  
  10.    Copyright (C) 1993,1994,1995,1996 Wolfgang Glunz, Wolfgang.Glunz@zfe.siemens.de
  11.  
  12.     This program is free software; you can redistribute it and/or modify
  13.     it under the terms of the GNU General Public License as published by
  14.     the Free Software Foundation; either version 2 of the License, or
  15.     (at your option) any later version.
  16.  
  17.     This program is distributed in the hope that it will be useful,
  18.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  19.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20.     GNU General Public License for more details.
  21.  
  22.     You should have received a copy of the GNU General Public License
  23.     along with this program; if not, write to the Free Software
  24.     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  25.  
  26. */
  27.  
  28. #include <stdio.h>
  29. #include <string.h>
  30. #include <stdlib.h>
  31. #include "drvrpl.h"
  32.  
  33. drvRPL::drvRPL(const char * driveroptions_p,ostream & theoutStream,ostream & theerrStream): // Constructor
  34.   drvbase(driveroptions_p,theoutStream,theerrStream,
  35.       0, // if backend supports subpathes, else 0
  36.       // if subpathes are supported, the backend must deal with
  37.       // sequences of the following form
  38.       // moveto (start of subpath)
  39.       // lineto (a line segment)
  40.       // lineto 
  41.       // moveto (start of a new subpath)
  42.       // lineto (a line segment)
  43.       // lineto 
  44.       //
  45.       // If this argument is set to 0 each subpath is drawn 
  46.       // individually which might not necessarily represent
  47.       // the original drawing.
  48.  
  49.       0,  // if backend supports curves, else 0
  50.       0  // if backend supports elements with fill and edges
  51.       )
  52. {
  53.   // driver specific initializations
  54.   // and writing of header to output file
  55. }
  56.  
  57. drvRPL::~drvRPL()
  58. {
  59.   // driver specific deallocations
  60.   // and writing of trailer to output file
  61. }
  62.  
  63. void drvRPL::print_coords()
  64. {
  65.   for (unsigned int n = 0; n < numberOfElementsInPath(); n++) {
  66.     const basedrawingelement & elem = pathElement(n);
  67.     switch (elem.getType()) {
  68.     case moveto: {
  69.       const Point & p = elem.getPoint(0);
  70.       outf  << p.x_ + x_offset << " 0 " << p.y_ + y_offset << endl;
  71.     }                                  
  72.     break;                              
  73.     case lineto: {                          
  74.       const Point & p = elem.getPoint(0);              
  75.       outf  << p.x_ + x_offset << " 0 " << p.y_ + y_offset << endl;
  76.     }
  77.     break;
  78.     case closepath: // Not supported
  79.       break;
  80.     case curveto:{  // Not supported
  81.     }
  82.     break;
  83.     default:
  84.       errf << "\t\tFatal: unexpected case in drvpdf " << endl;
  85.       abort();
  86.       break;
  87.     }
  88.   }
  89.   outf << "0 1 0 ( dvect )" << endl;
  90.   outf << numberOfElementsInPath() << " ( count )" << endl;
  91.   outf << currentR() << " " << currentG() << " " << currentB() << " ( RGBA )" << endl;
  92.   outf << "\"polygon\" ( name )" << endl;
  93.   outf << "0 ( flags )" << endl;
  94.   outf << "\"CEND\"" << endl;
  95.   outf << "C_POLYGON DROP" << endl << endl;
  96. }
  97.  
  98.  
  99. void drvRPL::open_page()
  100. {
  101.   //  outf << "Opening page: " << currentPageNumber << endl;
  102. }
  103.  
  104. void drvRPL::close_page()
  105. {
  106.   //  outf << "Closing page: " << (currentPageNumber) << endl;
  107. }
  108.  
  109. void drvRPL::show_text(const TextInfo & textinfo)
  110. {
  111.   unused(&textinfo);
  112.   // Must use the -dt flag for this, since RenderMan doesn't support text
  113. }
  114.  
  115. void drvRPL::show_path()
  116. {
  117.   print_coords();
  118. };
  119.  
  120. void drvRPL::show_rectangle(const float llx, const float lly, const float urx, const float ury)
  121. {
  122.   // outf << "Rectangle ( " << llx << "," << lly << ") (" << urx << "," << ury << ")" << endl;
  123.   // just do show_path for a first guess
  124.   unused(&llx);
  125.   unused(&lly);
  126.   unused(&urx);
  127.   unused(&ury);
  128.   show_path();
  129. }
  130.