Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/visualization/OpenInventor/src/SbPainterPS.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /visualization/OpenInventor/src/SbPainterPS.cc (Version 11.3.0) and /visualization/OpenInventor/src/SbPainterPS.cc (Version 11.0)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 /*----------------------------HEPVis----------     26 /*----------------------------HEPVis----------------------------------------*/
 27 /*                                                 27 /*                                                                          */
 28 /* Node:             SbPainterPS                   28 /* Node:             SbPainterPS                                            */
 29 /* Author:           Guy Barrand                   29 /* Author:           Guy Barrand                                            */
 30 /*                                                 30 /*                                                                          */
 31 /*--------------------------------------------     31 /*--------------------------------------------------------------------------*/
 32 // this :                                          32 // this :
 33 #include <HEPVis/SbPainterPS.h>                    33 #include <HEPVis/SbPainterPS.h>
 34                                                    34 
 35 //#include <HEPVis/SbString.h>                     35 //#include <HEPVis/SbString.h>
 36 #define STRDUP(str)  ((str) != NULL ? (::strcp     36 #define STRDUP(str)  ((str) != NULL ? (::strcpy((char*)::malloc((unsigned)::strlen(str) + 1), str)) : (char*)NULL)
 37 #define STRDEL(str) {if((str)!=NULL) {::free(s     37 #define STRDEL(str) {if((str)!=NULL) {::free(str);str=NULL;}}
 38                                                    38 
 39 //#define DEBUG                                    39 //#define DEBUG
 40 #include <stdlib.h>                                40 #include <stdlib.h>
 41 #include <string.h>                                41 #include <string.h>
 42 #include <stdio.h>                                 42 #include <stdio.h>
 43 #include <stdarg.h>                                43 #include <stdarg.h>
 44 #include <time.h>                                  44 #include <time.h>
 45 #include <locale.h>                                45 #include <locale.h>
 46                                                    46 
 47 #define METAFILE_DEFAULT "out.ps"                  47 #define METAFILE_DEFAULT "out.ps"
 48 #define METAFILE_SCALE 1.                          48 #define METAFILE_SCALE 1.
 49                                                    49 
 50 static char* GetDate();                            50 static char* GetDate();
 51 static double ConvertRGB_ToGrey(double,double,     51 static double ConvertRGB_ToGrey(double,double,double);
 52 //////////////////////////////////////////////     52 //////////////////////////////////////////////////////////////////////////////
 53 SbPainterPS::SbPainterPS(                          53 SbPainterPS::SbPainterPS(
 54 )                                                  54 )
 55 :fDeviceWidth((8.5-1.) * 72. * METAFILE_SCALE)     55 :fDeviceWidth((8.5-1.) * 72. * METAFILE_SCALE) /* 540. * METAFILE_SCALE */
 56 ,fDeviceHeight(11.     * 72. * METAFILE_SCALE)     56 ,fDeviceHeight(11.     * 72. * METAFILE_SCALE) /* 792. * METAFILE_SCALE */
 57 ,fPageNumber(0)                                    57 ,fPageNumber(0)
 58 ,fMarkerSize(2.)                                   58 ,fMarkerSize(2.)
 59 ,fFile(NULL)                                       59 ,fFile(NULL)
 60 ,fFileName(NULL)                                   60 ,fFileName(NULL)
 61 ,fGSave(0)                                         61 ,fGSave(0)
 62 ,fBufferCount(0)                                   62 ,fBufferCount(0)
 63 ,fBufferString(NULL)                               63 ,fBufferString(NULL)
 64 //////////////////////////////////////////////     64 //////////////////////////////////////////////////////////////////////////////
 65 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!     65 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
 66 {                                                  66 {
 67   fParams.shade = Color;                           67   fParams.shade = Color;
 68   fParams.portrait = 1;                            68   fParams.portrait = 1;
 69   fParams.nbit = 2;                                69   fParams.nbit = 2;
 70   fParams.doBack = 1;                              70   fParams.doBack = 1;
 71   fParams.lineWidth = -1.;                         71   fParams.lineWidth = -1.;
 72   fBufferPointer[0] = '\0';                        72   fBufferPointer[0] = '\0';
 73 #ifdef WIN32                                       73 #ifdef WIN32
 74   ::setlocale(LC_NUMERIC,"USA");                   74   ::setlocale(LC_NUMERIC,"USA");
 75 #endif                                             75 #endif
 76 }                                                  76 }
 77 //////////////////////////////////////////////     77 //////////////////////////////////////////////////////////////////////////////
 78 SbPainterPS::~SbPainterPS(                         78 SbPainterPS::~SbPainterPS(
 79 )                                                  79 )
 80 //////////////////////////////////////////////     80 //////////////////////////////////////////////////////////////////////////////
 81 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!     81 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
 82 {                                                  82 {
 83   if(fFile!=NULL) closeStream ();                  83   if(fFile!=NULL) closeStream ();
 84   if(fBufferString!=NULL) ::free(fBufferString     84   if(fBufferString!=NULL) ::free(fBufferString);
 85   fBufferString = NULL;                            85   fBufferString = NULL;
 86   if(fGSave!=0) {                                  86   if(fGSave!=0) {
 87     ::printf("SbPainterPS : bad gsave/grestore     87     ::printf("SbPainterPS : bad gsave/grestore balance : %d.\n",fGSave);
 88   }                                                88   }
 89 }                                                  89 }
 90 //////////////////////////////////////////////     90 //////////////////////////////////////////////////////////////////////////////
 91 //////////////////////////////////////////////     91 //////////////////////////////////////////////////////////////////////////////
 92 //////////////////////////////////////////////     92 //////////////////////////////////////////////////////////////////////////////
 93 void SbPainterPS::beginTraversal (                 93 void SbPainterPS::beginTraversal (
 94 )                                                  94 )
 95 //////////////////////////////////////////////     95 //////////////////////////////////////////////////////////////////////////////
 96 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!     96 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
 97 {                                                  97 {
 98   if(fFile==NULL) openFileForWriting(NULL);        98   if(fFile==NULL) openFileForWriting(NULL);
 99   if(fFile==NULL) return;                          99   if(fFile==NULL) return;
100   putBeginPageInStream();                         100   putBeginPageInStream();
101   putPageScaleInStream((float)fWindowWidth,(fl    101   putPageScaleInStream((float)fWindowWidth,(float)fWindowHeight);
102   putSaveStateInStream();                         102   putSaveStateInStream();
103 }                                                 103 }
104 //////////////////////////////////////////////    104 //////////////////////////////////////////////////////////////////////////////
105 void SbPainterPS::endTraversal(                   105 void SbPainterPS::endTraversal(
106 )                                                 106 )
107 //////////////////////////////////////////////    107 //////////////////////////////////////////////////////////////////////////////
108 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    108 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
109 {                                                 109 {
110   if(fFile==NULL) return;                         110   if(fFile==NULL) return;
111   putFrameInStream(0.0,0.0,0.0,(float)fWindowW    111   putFrameInStream(0.0,0.0,0.0,(float)fWindowWidth,(float)fWindowHeight);
112   putRestoreStateInStream();                      112   putRestoreStateInStream();
113   putEndPageInStream();                           113   putEndPageInStream();
114 }                                                 114 }
115 //////////////////////////////////////////////    115 //////////////////////////////////////////////////////////////////////////////
116 void SbPainterPS::clearColorBuffer(               116 void SbPainterPS::clearColorBuffer(
117  float aRed                                       117  float aRed
118 ,float aGreen                                     118 ,float aGreen
119 ,float aBlue                                      119 ,float aBlue
120 )                                                 120 )
121 //////////////////////////////////////////////    121 //////////////////////////////////////////////////////////////////////////////
122 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    122 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
123 {                                                 123 {
124   if(fFile==NULL) return;                         124   if(fFile==NULL) return;
125   putBackgroundInStream(aRed,aGreen,aBlue,        125   putBackgroundInStream(aRed,aGreen,aBlue,
126                            (float)fWindowWidth    126                            (float)fWindowWidth,(float)fWindowHeight);
127 }                                                 127 }
128 /*                                                128 /*
129 //////////////////////////////////////////////    129 //////////////////////////////////////////////////////////////////////////////
130 void SbPainterPS::drawPrimitive (                 130 void SbPainterPS::drawPrimitive (
131  SbPrimitiveType aType                            131  SbPrimitiveType aType
132 ,int aPointn                                      132 ,int aPointn
133 ,float* aXs                                       133 ,float* aXs
134 ,float* aYs                                       134 ,float* aYs
135 ,float* //aZs                                     135 ,float* //aZs
136 ,const SbPainterContext& aAtb                     136 ,const SbPainterContext& aAtb
137 )                                                 137 )
138 //////////////////////////////////////////////    138 //////////////////////////////////////////////////////////////////////////////
139 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    139 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
140 {                                                 140 {
141   if(fFile==NULL) return;                         141   if(fFile==NULL) return;
142   switch(aType) {                                 142   switch(aType) {
143   case SbPrimitivePoints:                         143   case SbPrimitivePoints:
144     drawMarkers(aPointn,                          144     drawMarkers(aPointn,
145                 aXs,aYs,                          145                 aXs,aYs,
146                 aAtb.fRed,aAtb.fGreen,aAtb.fBl    146                 aAtb.fRed,aAtb.fGreen,aAtb.fBlue,
147                 aAtb.fMarkerStyle,aAtb.fMarker    147                 aAtb.fMarkerStyle,aAtb.fMarkerSize);
148     break;                                        148     break;
149   case SbPrimitiveLineStrip:                      149   case SbPrimitiveLineStrip:
150   case SbPrimitiveLineLoop:                       150   case SbPrimitiveLineLoop:
151     drawLines(aPointn,                            151     drawLines(aPointn,
152               aXs,aYs,                            152               aXs,aYs,
153               aAtb.fRed,aAtb.fGreen,aAtb.fBlue    153               aAtb.fRed,aAtb.fGreen,aAtb.fBlue,
154               aAtb.fLineStyle,aAtb.fLineWidth)    154               aAtb.fLineStyle,aAtb.fLineWidth);
155     break;                                        155     break;
156   case SbPrimitivePolygon:                        156   case SbPrimitivePolygon:
157     drawPolygon(aPointn,                          157     drawPolygon(aPointn,
158                 aXs,aYs,                          158                 aXs,aYs,
159                 aAtb.fRed,aAtb.fGreen,aAtb.fBl    159                 aAtb.fRed,aAtb.fGreen,aAtb.fBlue,
160                 aAtb.fAreaStyle);                 160                 aAtb.fAreaStyle);
161     break;                                        161     break;
162   default:                                        162   default:
163     break;                                        163     break;
164   }                                               164   }
165 }                                                 165 }
166 //////////////////////////////////////////////    166 //////////////////////////////////////////////////////////////////////////////
167 void SbPainterPS::drawPolygon(                    167 void SbPainterPS::drawPolygon(
168  int aPointn                                      168  int aPointn
169 ,float* aXs                                       169 ,float* aXs
170 ,float* aYs                                       170 ,float* aYs
171 ,float aRed                                       171 ,float aRed
172 ,float aGreen                                     172 ,float aGreen
173 ,float aBlue                                      173 ,float aBlue
174 ,const SbAreaStyle& //aStyle                      174 ,const SbAreaStyle& //aStyle
175 )                                                 175 )
176 //////////////////////////////////////////////    176 //////////////////////////////////////////////////////////////////////////////
177 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    177 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
178 {                                                 178 {
179   if(fFile==NULL) return;                         179   if(fFile==NULL) return;
180   if(aPointn<=0) return;                          180   if(aPointn<=0) return;
181   putNewPathInStream();                           181   putNewPathInStream(); 
182   putMoveInStream(aXs[0],aYs[0]);                 182   putMoveInStream(aXs[0],aYs[0]);
183   for(int count=1;count<aPointn;count++) {        183   for(int count=1;count<aPointn;count++) {
184     putLineToInStream(aXs[count] - aXs[count-1    184     putLineToInStream(aXs[count] - aXs[count-1],
185                       aYs[count] - aYs[count-1    185                       aYs[count] - aYs[count-1]);
186   }                                               186   }
187   if ( (aXs[0]==aXs[aPointn-1]) &&                187   if ( (aXs[0]==aXs[aPointn-1]) &&
188        (aYs[0]==aYs[aPointn-1]) )                 188        (aYs[0]==aYs[aPointn-1]) ) 
189     putClosePathInStream();                       189     putClosePathInStream();
190   putRGB_InStream(aRed,aGreen,aBlue);             190   putRGB_InStream(aRed,aGreen,aBlue);
191   putFillInStream();                              191   putFillInStream();
192 }                                                 192 }
193 //////////////////////////////////////////////    193 //////////////////////////////////////////////////////////////////////////////
194 void SbPainterPS::drawLines(                      194 void SbPainterPS::drawLines(
195  int aPointn                                      195  int aPointn
196 ,float* aXs                                       196 ,float* aXs
197 ,float* aYs                                       197 ,float* aYs
198 ,float aRed                                       198 ,float aRed
199 ,float aGreen                                     199 ,float aGreen
200 ,float aBlue                                      200 ,float aBlue
201 ,const SbLineStyle& aStyle                        201 ,const SbLineStyle& aStyle
202 ,int aWidth                                       202 ,int aWidth
203 )                                                 203 )
204 //////////////////////////////////////////////    204 //////////////////////////////////////////////////////////////////////////////
205 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    205 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
206 {                                                 206 {
207   if(fFile==NULL) return;                         207   if(fFile==NULL) return;
208   if(aPointn<=0) return;                          208   if(aPointn<=0) return;
209   putMoveInStream(aXs[0],aYs[0]);                 209   putMoveInStream(aXs[0],aYs[0]);
210   for(int count=1;count<aPointn;count++) {        210   for(int count=1;count<aPointn;count++) {
211     putLineToInStream(aXs[count] - aXs[count-1    211     putLineToInStream(aXs[count] - aXs[count-1],
212                       aYs[count] - aYs[count-1    212                       aYs[count] - aYs[count-1]);
213   }                                               213   }
214   if ( (aXs[0]==aXs[aPointn-1]) &&                214   if ( (aXs[0]==aXs[aPointn-1]) &&
215        (aYs[0]==aYs[aPointn-1]) )                 215        (aYs[0]==aYs[aPointn-1]) ) 
216     putClosePathInStream();                       216     putClosePathInStream();
217   putRGB_InStream(aRed,aGreen,aBlue);             217   putRGB_InStream(aRed,aGreen,aBlue);
218   putLineWidthInStream(aWidth);                   218   putLineWidthInStream(aWidth);
219   putCapInStream(1);                              219   putCapInStream(1);
220   putLineStyleInStream(aStyle);                   220   putLineStyleInStream(aStyle);
221   putStrokeInStream();                            221   putStrokeInStream();
222 }                                                 222 }
223 //////////////////////////////////////////////    223 //////////////////////////////////////////////////////////////////////////////
224 void SbPainterPS::drawMarkers (                   224 void SbPainterPS::drawMarkers (
225  int aPointn                                      225  int aPointn
226 ,float* aXs                                       226 ,float* aXs
227 ,float* aYs                                       227 ,float* aYs
228 ,float aRed                                       228 ,float aRed
229 ,float aGreen                                     229 ,float aGreen
230 ,float aBlue                                      230 ,float aBlue
231 ,const SbMarkerStyle& aStyle                      231 ,const SbMarkerStyle& aStyle 
232 ,int aSize                                        232 ,int aSize
233 )                                                 233 )
234 //////////////////////////////////////////////    234 //////////////////////////////////////////////////////////////////////////////
235 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    235 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
236 {                                                 236 {
237   if(fFile==NULL) return;                         237   if(fFile==NULL) return;
238   float mark_size  = (float)(aSize <=0 ? 1. :     238   float mark_size  = (float)(aSize <=0 ? 1. : aSize);   
239   mark_size *= 0.6F;                              239   mark_size *= 0.6F;
240   if(aStyle==SbMarkerCircleLine) {                240   if(aStyle==SbMarkerCircleLine) {
241     putNewPathInStream();                         241     putNewPathInStream();
242     int icount = 1;                               242     int icount = 1;
243     for(int count=0;count<aPointn;count++) {      243     for(int count=0;count<aPointn;count++) {
244       putCircleInStream(aXs[count],aYs[count],    244       putCircleInStream(aXs[count],aYs[count],mark_size);
245 #define MAX_PATH_POINT 100                        245 #define MAX_PATH_POINT 100
246       if(icount==MAX_PATH_POINT) {                246       if(icount==MAX_PATH_POINT) {
247         putRGB_InStream(aRed,aGreen,aBlue);       247         putRGB_InStream(aRed,aGreen,aBlue);
248         putLineWidthInStream(1);                  248         putLineWidthInStream(1);
249         putCapInStream(1);                        249         putCapInStream(1);
250         putStrokeInStream();                      250         putStrokeInStream();
251         icount = 1;                               251         icount = 1;
252         if(count!=aPointn-1) putNewPathInStrea    252         if(count!=aPointn-1) putNewPathInStream();
253       } else {                                    253       } else {
254         icount++;                                 254         icount++;
255       }                                           255       }
256     }                                             256     }
257     putRGB_InStream(aRed,aGreen,aBlue);           257     putRGB_InStream(aRed,aGreen,aBlue);
258     putLineWidthInStream(1);                      258     putLineWidthInStream(1);
259     putCapInStream(1);                            259     putCapInStream(1);
260     putStrokeInStream();                          260     putStrokeInStream();
261   } else {                                        261   } else {
262     putNewPathInStream();                         262     putNewPathInStream();
263     int icount = 1;                               263     int icount = 1;
264     for(int count=0;count<aPointn;count++) {      264     for(int count=0;count<aPointn;count++) {
265       putMoveInStream(aXs[count],aYs[count]);     265       putMoveInStream(aXs[count],aYs[count]);
266       putMarkerSizeInStream(mark_size);           266       putMarkerSizeInStream(mark_size);
267       putMarkerStyleInStream(aStyle);             267       putMarkerStyleInStream(aStyle);
268       if(icount==MAX_PATH_POINT) {                268       if(icount==MAX_PATH_POINT) {
269         putRGB_InStream(aRed,aGreen,aBlue);       269         putRGB_InStream(aRed,aGreen,aBlue);
270         putLineWidthInStream(1);                  270         putLineWidthInStream(1);
271         putCapInStream(1);                        271         putCapInStream(1);
272         putStrokeInStream();                      272         putStrokeInStream();
273         icount = 1;                               273         icount = 1;
274         if(count!=aPointn-1) putNewPathInStrea    274         if(count!=aPointn-1) putNewPathInStream();
275       } else {                                    275       } else {
276         icount++;                                 276         icount++;
277       }                                           277       }
278     }                                             278     }
279     putRGB_InStream(aRed,aGreen,aBlue);           279     putRGB_InStream(aRed,aGreen,aBlue);
280     putLineWidthInStream(1);                      280     putLineWidthInStream(1);
281     putCapInStream(1);                            281     putCapInStream(1);
282     putStrokeInStream();                          282     putStrokeInStream();
283   }                                               283   }
284 }                                                 284 }
285 */                                                285 */
286 //////////////////////////////////////////////    286 //////////////////////////////////////////////////////////////////////////////
287 //////////////////////////////////////////////    287 //////////////////////////////////////////////////////////////////////////////
288 //////////////////////////////////////////////    288 //////////////////////////////////////////////////////////////////////////////
289 //////////////////////////////////////////////    289 //////////////////////////////////////////////////////////////////////////////
290 void SbPainterPS::setColorScheme(                 290 void SbPainterPS::setColorScheme(
291  int aShade                                       291  int aShade
292 )                                                 292 )
293 //////////////////////////////////////////////    293 //////////////////////////////////////////////////////////////////////////////
294 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    294 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
295 {                                                 295 {
296   fParams.shade = aShade;                         296   fParams.shade = aShade;
297 }                                                 297 }
298 //////////////////////////////////////////////    298 //////////////////////////////////////////////////////////////////////////////
299 void SbPainterPS::setOrientation(                 299 void SbPainterPS::setOrientation(
300  int aPortrait                                    300  int aPortrait
301 )                                                 301 )
302 //////////////////////////////////////////////    302 //////////////////////////////////////////////////////////////////////////////
303 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    303 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
304 {                                                 304 {
305   fParams.portrait = aPortrait;                   305   fParams.portrait = aPortrait;
306 }                                                 306 }
307 //////////////////////////////////////////////    307 //////////////////////////////////////////////////////////////////////////////
308 void SbPainterPS::setBackgroundDrawn(             308 void SbPainterPS::setBackgroundDrawn(
309  int aDoback                                      309  int aDoback
310 )                                                 310 )
311 //////////////////////////////////////////////    311 //////////////////////////////////////////////////////////////////////////////
312 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    312 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
313 {                                                 313 {
314   fParams.doBack = aDoback;                       314   fParams.doBack = aDoback;
315 }                                                 315 }
316 //////////////////////////////////////////////    316 //////////////////////////////////////////////////////////////////////////////
317 void SbPainterPS::setBitsPerPixel(                317 void SbPainterPS::setBitsPerPixel(
318  int aNbit                                        318  int aNbit
319 )                                                 319 )
320 //////////////////////////////////////////////    320 //////////////////////////////////////////////////////////////////////////////
321 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    321 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
322 {                                                 322 {
323   if( (aNbit==2) || (aNbit==4) || (aNbit==8) )    323   if( (aNbit==2) || (aNbit==4) || (aNbit==8) )
324     fParams.nbit = aNbit;                         324     fParams.nbit = aNbit;
325   else                                            325   else 
326     fParams.nbit = 2;                             326     fParams.nbit = 2;
327 }                                                 327 }
328 //////////////////////////////////////////////    328 //////////////////////////////////////////////////////////////////////////////
329 void SbPainterPS::setLineWidth(                   329 void SbPainterPS::setLineWidth(
330  int aWidth                                       330  int aWidth
331 )                                                 331 )
332 //////////////////////////////////////////////    332 //////////////////////////////////////////////////////////////////////////////
333 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    333 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
334 {                                                 334 {
335   fParams.lineWidth = (float)aWidth;              335   fParams.lineWidth = (float)aWidth;
336 }                                                 336 }
337 //////////////////////////////////////////////    337 //////////////////////////////////////////////////////////////////////////////
338 //////////////////////////////////////////////    338 //////////////////////////////////////////////////////////////////////////////
339 //////////////////////////////////////////////    339 //////////////////////////////////////////////////////////////////////////////
340 void SbPainterPS::setFileName(                    340 void SbPainterPS::setFileName(
341  const char* aString                              341  const char* aString
342 )                                                 342 )
343 //////////////////////////////////////////////    343 //////////////////////////////////////////////////////////////////////////////
344 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    344 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
345 {                                                 345 {
346   STRDEL(fFileName);                              346   STRDEL(fFileName);
347   fFileName = STRDUP(aString);                    347   fFileName = STRDUP(aString);
348 }                                                 348 }
349 //////////////////////////////////////////////    349 //////////////////////////////////////////////////////////////////////////////
350 const char* SbPainterPS::getFileName(             350 const char* SbPainterPS::getFileName(
351 ) const                                           351 ) const
352 //////////////////////////////////////////////    352 //////////////////////////////////////////////////////////////////////////////
353 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    353 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
354 {                                                 354 {
355   return fFileName;                               355   return fFileName;
356 }                                                 356 }
357 //////////////////////////////////////////////    357 //////////////////////////////////////////////////////////////////////////////
358 void* SbPainterPS::getStream(                     358 void* SbPainterPS::getStream(
359 )                                                 359 )
360 //////////////////////////////////////////////    360 //////////////////////////////////////////////////////////////////////////////
361 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    361 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
362 {                                                 362 {
363   return fFile;                                   363   return fFile;
364 }                                                 364 }
365 //////////////////////////////////////////////    365 //////////////////////////////////////////////////////////////////////////////
366 void SbPainterPS::openFileForWriting(             366 void SbPainterPS::openFileForWriting(
367  const char* aString                              367  const char* aString
368 )                                                 368 )
369 //////////////////////////////////////////////    369 //////////////////////////////////////////////////////////////////////////////
370 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    370 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
371 {                                                 371 {
372   if(fFile!=NULL) closeStream ();                 372   if(fFile!=NULL) closeStream ();
373   if( (aString==NULL) || (*aString=='\0') ) {     373   if( (aString==NULL) || (*aString=='\0') ) {
374     if( (fFileName==NULL) || (*fFileName=='\0'    374     if( (fFileName==NULL) || (*fFileName=='\0') ) { // Take default name :
375       fFile = ::fopen(METAFILE_DEFAULT,"wb");     375       fFile = ::fopen(METAFILE_DEFAULT,"wb");
376       STRDEL(fFileName);                          376       STRDEL(fFileName);
377       fFileName = STRDUP(METAFILE_DEFAULT);       377       fFileName = STRDUP(METAFILE_DEFAULT);
378     } else {                                      378     } else {
379       fFile = ::fopen(fFileName,"wb");            379       fFile = ::fopen(fFileName,"wb");
380     }                                             380     }
381   } else {                                        381   } else {
382     fFile = ::fopen(aString,"wb");                382     fFile = ::fopen(aString,"wb");
383     STRDEL(fFileName);                            383     STRDEL(fFileName);
384     fFileName = STRDUP(aString);                  384     fFileName = STRDUP(aString);
385   }                                               385   }
386   if(fFile==NULL) return;                         386   if(fFile==NULL) return;
387                                                   387 
388   fBufferCount = 0;                               388   fBufferCount = 0;
389   fBufferPointer[METAFILE_RECORD_LENGTH] = '\0    389   fBufferPointer[METAFILE_RECORD_LENGTH] = '\0';
390   fPageNumber = 0;                                390   fPageNumber = 0;
391   // Header :                                     391   // Header :
392   printFLN   ("%%!PS-Adobe-2.0");                 392   printFLN   ("%%!PS-Adobe-2.0");
393   printFLN   ("%%%%Creator: HEPVis::SbPainterP    393   printFLN   ("%%%%Creator: HEPVis::SbPainterPS.");
394   printFLN("%%%%CreationDate: %s",GetDate());     394   printFLN("%%%%CreationDate: %s",GetDate());
395   printFLN("%%%%Title: %s",fFileName);            395   printFLN("%%%%Title: %s",fFileName);
396   printFLN("%%%%Pages: (atend)");                 396   printFLN("%%%%Pages: (atend)");
397   printFLN("%%%%BoundingBox: 0 0 %d %d",          397   printFLN("%%%%BoundingBox: 0 0 %d %d",
398            (int)fDeviceWidth,(int)fDeviceHeigh    398            (int)fDeviceWidth,(int)fDeviceHeight);
399   printFLN("%%%%DocumentFonts: Courier-Bold");    399   printFLN("%%%%DocumentFonts: Courier-Bold");
400   printFLN("%%%%DocumentPaperSizes: a4");         400   printFLN("%%%%DocumentPaperSizes: a4");
401   printFLN("%%%%EndComments");                    401   printFLN("%%%%EndComments");
402   // PostScript :                                 402   // PostScript :
403   putSaveStateInStream      ();                   403   putSaveStateInStream      ();
404   // General :                                    404   // General :
405   putInStreamF("/n {newpath} def ");              405   putInStreamF("/n {newpath} def ");
406   putInStreamF("/cl {closepath} def ");           406   putInStreamF("/cl {closepath} def ");
407   putInStreamF("/s {stroke} def ");               407   putInStreamF("/s {stroke} def ");
408   putInStreamF("/f {fill} def ");                 408   putInStreamF("/f {fill} def ");
409   // Move :                                       409   // Move :
410   putInStreamF("/m  {moveto} def ");              410   putInStreamF("/m  {moveto} def ");
411   putInStreamF("/rm {rmoveto} def ");             411   putInStreamF("/rm {rmoveto} def ");
412   putInStreamF("/rl {rlineto} def ");             412   putInStreamF("/rl {rlineto} def ");
413   // Line :                                       413   // Line :
414   putInStreamF("/lc {setlinecap} def ");          414   putInStreamF("/lc {setlinecap} def ");
415   putInStreamF("/lw {setlinewidth} def ");        415   putInStreamF("/lw {setlinewidth} def ");
416   putInStreamF("/rgb {setrgbcolor} def ");        416   putInStreamF("/rgb {setrgbcolor} def ");
417   putInStreamF("/ss {[] 0 setdash} def ") ;       417   putInStreamF("/ss {[] 0 setdash} def ") ;            /* style solid       */
418   putInStreamF("/sd {[12 6] 0 setdash} def ");    418   putInStreamF("/sd {[12 6] 0 setdash} def ");         /* style dashed      */
419   putInStreamF("/so {[6 12] 0 setdash} def ");    419   putInStreamF("/so {[6 12] 0 setdash} def ");         /* style dotted      */
420   putInStreamF("/sdo {[18 12 6 12] 0 setdash}     420   putInStreamF("/sdo {[18 12 6 12] 0 setdash} def ");  /* style dash dotted */
421   // Mark :                                       421   // Mark :
422   fMarkerSize = 2.;                               422   fMarkerSize = 2.;
423   putInStreamF("/ms 2. def /msi .5 def ");        423   putInStreamF("/ms 2. def /msi .5 def ");        /* mark size */
424   putInStreamF("/cross {ms ms scale -1. -1. rm    424   putInStreamF("/cross {ms ms scale -1. -1. rm  ");
425   putInStreamF("2. 2. rl 0. -2. rm -2. 2. rl m    425   putInStreamF("2. 2. rl 0. -2. rm -2. 2. rl msi msi scale} def ");
426   putInStreamF("/plus  {ms ms scale -1. 0. rm     426   putInStreamF("/plus  {ms ms scale -1. 0. rm 2. 0. rl ");
427   putInStreamF("-1. 1. rm 0. -2. rl msi msi sc    427   putInStreamF("-1. 1. rm 0. -2. rl msi msi scale} def ");
428   putInStreamF("/asterisk {ms ms scale -1. 0.     428   putInStreamF("/asterisk {ms ms scale -1. 0. rm 2. 0. rl -1. 1. rm ");
429   putInStreamF("0. -2. rl 0. 1. rm -0.707 -0.7    429   putInStreamF("0. -2. rl 0. 1. rm -0.707 -0.707 rm 1.414 1.414 rl ");
430   putInStreamF("0. -1.414 rm -1.414 1.414 rl m    430   putInStreamF("0. -1.414 rm -1.414 1.414 rl msi msi scale} def ");
431   putInStreamF("/triangle {ms ms scale 0. 1. r    431   putInStreamF("/triangle {ms ms scale 0. 1. rm -0.6 -1.5 rl ");
432   putInStreamF("1.2 0. rl -0.6 1.5 rl msi msi     432   putInStreamF("1.2 0. rl -0.6 1.5 rl msi msi scale} def ");
433   // Text :                                       433   // Text :
434   putInStreamF("/sh {show} def ");                434   putInStreamF("/sh {show} def ");
435   putInStreamF("/df {/Courier-Bold findfont} d    435   putInStreamF("/df {/Courier-Bold findfont} def ");
436   putInStreamF("/mf {makefont setfont} def ");    436   putInStreamF("/mf {makefont setfont} def ");
437   printFLN("%%%%EndProlog");                      437   printFLN("%%%%EndProlog");
438 }                                                 438 }
439 //////////////////////////////////////////////    439 //////////////////////////////////////////////////////////////////////////////
440 void SbPainterPS::closeStream(                    440 void SbPainterPS::closeStream(
441 )                                                 441 )
442 //////////////////////////////////////////////    442 //////////////////////////////////////////////////////////////////////////////
443 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    443 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
444 {                                                 444 {
445   if(fFile==NULL) return;                         445   if(fFile==NULL) return;
446   putRestoreStateInStream    ();                  446   putRestoreStateInStream    ();
447   printFLN("%%%%Trailer");                        447   printFLN("%%%%Trailer");
448   printFLN("%%%%Pages: %d",fPageNumber);          448   printFLN("%%%%Pages: %d",fPageNumber);
449   printFLN("%%%%EOF");                            449   printFLN("%%%%EOF");
450   if(fFile!=NULL) ::fclose(fFile);                450   if(fFile!=NULL) ::fclose(fFile);
451   fFile = NULL;                                   451   fFile = NULL;
452   STRDEL(fFileName);                              452   STRDEL(fFileName);
453   fFileName = NULL;                               453   fFileName = NULL;
454 }                                                 454 }
455 //////////////////////////////////////////////    455 //////////////////////////////////////////////////////////////////////////////
456 void SbPainterPS::putInStreamF(                   456 void SbPainterPS::putInStreamF(
457  const char* aFormat                              457  const char* aFormat 
458 ,...                                              458 ,...
459 )                                                 459 )
460 //////////////////////////////////////////////    460 //////////////////////////////////////////////////////////////////////////////
461 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    461 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
462 {                                                 462 {
463   if(fFile==NULL) return;                         463   if(fFile==NULL) return;
464   va_list  args;                                  464   va_list  args;
465   va_start(args,aFormat);                         465   va_start(args,aFormat);
466   printV(aFormat,args);                           466   printV(aFormat,args);
467   va_end(args);                                   467   va_end(args);
468   int length = (int)strlen(fBufferString);     << 468   int length = ::strlen(fBufferString);
469   if(length>METAFILE_RECORD_LENGTH) {             469   if(length>METAFILE_RECORD_LENGTH) {
470     ::printf("SoPostScript::putInStreamF overf    470     ::printf("SoPostScript::putInStreamF overflow\n");
471     return;                                       471     return;
472   }                                               472   }
473   int nlength = fBufferCount + length;            473   int nlength = fBufferCount + length;
474   if(nlength>METAFILE_RECORD_LENGTH) {            474   if(nlength>METAFILE_RECORD_LENGTH) {
475       fBufferPointer[fBufferCount] = '\0';        475       fBufferPointer[fBufferCount] = '\0';
476       if(::fprintf(fFile,"%s\n",(char*)fBuffer    476       if(::fprintf(fFile,"%s\n",(char*)fBufferPointer)<0) {
477         ::printf("SoPostScript::putInStreamF f    477         ::printf("SoPostScript::putInStreamF fprintf error\n");
478       }                                           478       }
479       fBufferCount = 0;                           479       fBufferCount = 0;
480       nlength = length;                           480       nlength = length;
481     }                                             481     }
482   unsigned char* pointer = fBufferPointer + fB    482   unsigned char* pointer = fBufferPointer + fBufferCount;
483   ::strcpy((char*)pointer,fBufferString);         483   ::strcpy((char*)pointer,fBufferString);
484   fBufferCount = nlength;                         484   fBufferCount = nlength;
485 }                                                 485 }
486 //////////////////////////////////////////////    486 //////////////////////////////////////////////////////////////////////////////
487 void SbPainterPS::printFLN(                       487 void SbPainterPS::printFLN(
488  const char* aFormat                              488  const char* aFormat 
489 ,...                                              489 ,...
490 )                                                 490 )
491 //////////////////////////////////////////////    491 //////////////////////////////////////////////////////////////////////////////
492 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    492 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
493 {                                                 493 {
494   if(fFile==NULL) return;                         494   if(fFile==NULL) return;
495   va_list args;                                   495   va_list args;
496   va_start(args,aFormat);                         496   va_start(args,aFormat);
497   printV(aFormat,args);                           497   printV(aFormat,args);
498   va_end(args);                                   498   va_end(args);
499 /* put buffer in file */                          499 /* put buffer in file */
500   if(fBufferCount>0) {                            500   if(fBufferCount>0) {
501     fBufferPointer[fBufferCount] = '\0';          501     fBufferPointer[fBufferCount] = '\0';
502     if(::fprintf (fFile,"%s\n",(char*)fBufferP    502     if(::fprintf (fFile,"%s\n",(char*)fBufferPointer)<0) {
503       ::printf("SbPainterPS::printFLN fprintf     503       ::printf("SbPainterPS::printFLN fprintf error\n");
504     }                                             504     }
505     fBufferCount = 0;                             505     fBufferCount = 0;
506   }                                               506   }
507 /* put comment in file */                         507 /* put comment in file */
508   if(::fprintf (fFile,"%s\n",fBufferString)<0)    508   if(::fprintf (fFile,"%s\n",fBufferString)<0) {
509     ::printf("SbPainterPS::printFLN fprintf er    509     ::printf("SbPainterPS::printFLN fprintf error\n");
510   }                                               510   }
511 }                                                 511 }
512 //////////////////////////////////////////////    512 //////////////////////////////////////////////////////////////////////////////
513 void SbPainterPS::printV(                         513 void SbPainterPS::printV(
514  const char* This                                 514  const char* This 
515 ,va_list aArgs                                    515 ,va_list aArgs  
516 )                                                 516 )
517 //////////////////////////////////////////////    517 //////////////////////////////////////////////////////////////////////////////
518 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    518 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
519 {                                                 519 {
520 #define MAX_STR    2048                           520 #define MAX_STR    2048
521   if(fBufferString==NULL) {                       521   if(fBufferString==NULL) {
522     fBufferString = (char*)::malloc(MAX_STR *     522     fBufferString = (char*)::malloc(MAX_STR * sizeof(char));
523     if(fBufferString==NULL) return;               523     if(fBufferString==NULL) return;
524   }                                               524   }
525   fBufferString[MAX_STR-1]  = '\0';               525   fBufferString[MAX_STR-1]  = '\0';
526   ::vsnprintf(fBufferString,MAX_STR-1, This,aA << 526   ::vsprintf(fBufferString,This,aArgs);
527   if(fBufferString[MAX_STR-1]!='\0') {            527   if(fBufferString[MAX_STR-1]!='\0') {
528     ::printf("SbPainterPS::printV overflow\n")    528     ::printf("SbPainterPS::printV overflow\n");
529     fBufferString[0] = '\0';                      529     fBufferString[0] = '\0';
530   }                                               530   }
531 }                                                 531 }
532 //////////////////////////////////////////////    532 //////////////////////////////////////////////////////////////////////////////
533 //////////////////////////////////////////////    533 //////////////////////////////////////////////////////////////////////////////
534 //////////////////////////////////////////////    534 //////////////////////////////////////////////////////////////////////////////
535 //////////////////////////////////////////////    535 //////////////////////////////////////////////////////////////////////////////
536 void SbPainterPS::putPageScaleInStream(           536 void SbPainterPS::putPageScaleInStream(
537  float aWidth                                     537  float aWidth 
538 ,float aHeight                                    538 ,float aHeight 
539 )                                                 539 )
540 //////////////////////////////////////////////    540 //////////////////////////////////////////////////////////////////////////////
541 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    541 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
542 {                                                 542 {
543   if(aWidth <=0.) aWidth  = 100.;                 543   if(aWidth <=0.) aWidth  = 100.;
544   if(aHeight<=0.) aHeight = 100.;                 544   if(aHeight<=0.) aHeight = 100.;
545                                                   545 
546   putScaleInStream (1./METAFILE_SCALE,1./METAF    546   putScaleInStream (1./METAFILE_SCALE,1./METAFILE_SCALE);
547   putTranslationInStream ((float)(fDeviceWidth    547   putTranslationInStream ((float)(fDeviceWidth/20.),
548                           (float)(fDeviceHeigh    548                           (float)(fDeviceHeight/30.));
549                                                   549 
550   float scale;                                    550   float scale;
551   if(fDeviceWidth<=fDeviceHeight)                 551   if(fDeviceWidth<=fDeviceHeight)
552     scale = (aHeight<=aWidth ?                    552     scale = (aHeight<=aWidth ? 
553              fDeviceWidth /aWidth  : fDeviceWi    553              fDeviceWidth /aWidth  : fDeviceWidth /aHeight );
554   else                                            554   else 
555     scale = (aHeight<=aWidth ?                    555     scale = (aHeight<=aWidth ? 
556              fDeviceHeight /aWidth : fDeviceHe    556              fDeviceHeight /aWidth : fDeviceHeight /aHeight );
557                                                   557 
558   float xtra,ytra;                                558   float xtra,ytra;
559   if(fParams.portrait==1) {                       559   if(fParams.portrait==1) {
560     xtra = (fDeviceWidth  - scale * aWidth)/2;    560     xtra = (fDeviceWidth  - scale * aWidth)/2;
561     ytra = (fDeviceHeight - scale * aHeight)/2    561     ytra = (fDeviceHeight - scale * aHeight)/2;
562   } else {                                        562   } else {
563     putTranslationInStream(fDeviceWidth,0.);      563     putTranslationInStream(fDeviceWidth,0.);
564     putRotateInStream(90);                        564     putRotateInStream(90);
565     xtra = (fDeviceHeight  - scale * aWidth)/2    565     xtra = (fDeviceHeight  - scale * aWidth)/2;
566     ytra = (fDeviceWidth   - scale * aHeight)/    566     ytra = (fDeviceWidth   - scale * aHeight)/2;
567   }                                               567   }
568   putTranslationInStream (xtra,ytra);             568   putTranslationInStream (xtra,ytra);
569                                                   569 
570   putScaleInStream (scale,scale);                 570   putScaleInStream (scale,scale);
571 }                                                 571 }
572 //////////////////////////////////////////////    572 //////////////////////////////////////////////////////////////////////////////
573 //////////////////////////////////////////////    573 //////////////////////////////////////////////////////////////////////////////
574 //////////////////////////////////////////////    574 //////////////////////////////////////////////////////////////////////////////
575 //////////////////////////////////////////////    575 //////////////////////////////////////////////////////////////////////////////
576 void SbPainterPS::putSaveStateInStream(           576 void SbPainterPS::putSaveStateInStream(
577 )                                                 577 )
578 //////////////////////////////////////////////    578 //////////////////////////////////////////////////////////////////////////////
579 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    579 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
580 {                                                 580 {
581   putInStreamF("gsave ");                         581   putInStreamF("gsave ");
582   fGSave++;                                       582   fGSave++;
583 }                                                 583 }
584 //////////////////////////////////////////////    584 //////////////////////////////////////////////////////////////////////////////
585 void SbPainterPS::putRestoreStateInStream(        585 void SbPainterPS::putRestoreStateInStream(
586 )                                                 586 )
587 //////////////////////////////////////////////    587 //////////////////////////////////////////////////////////////////////////////
588 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    588 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
589 {                                                 589 {
590   putInStreamF("grestore ");                      590   putInStreamF("grestore ");
591   fGSave--;                                       591   fGSave--;
592 }                                                 592 }
593 //////////////////////////////////////////////    593 //////////////////////////////////////////////////////////////////////////////
594 void SbPainterPS::putTranslationInStream(         594 void SbPainterPS::putTranslationInStream(
595  float aX                                         595  float aX
596 ,float aY                                         596 ,float aY
597 )                                                 597 )
598 //////////////////////////////////////////////    598 //////////////////////////////////////////////////////////////////////////////
599 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    599 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
600 {                                                 600 {
601   putInStreamF("%.2f %.2f translate ",aX,aY);     601   putInStreamF("%.2f %.2f translate ",aX,aY);
602 }                                                 602 }
603 //////////////////////////////////////////////    603 //////////////////////////////////////////////////////////////////////////////
604 void SbPainterPS::putScaleInStream(               604 void SbPainterPS::putScaleInStream(
605  float aX                                         605  float aX
606 ,float aY                                         606 ,float aY
607 )                                                 607 )
608 //////////////////////////////////////////////    608 //////////////////////////////////////////////////////////////////////////////
609 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    609 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
610 {                                                 610 {
611   putInStreamF("%.2f %.2f scale ",aX,aY);         611   putInStreamF("%.2f %.2f scale ",aX,aY);
612 }                                                 612 }
613 //////////////////////////////////////////////    613 //////////////////////////////////////////////////////////////////////////////
614 void SbPainterPS::putBeginPageInStream(           614 void SbPainterPS::putBeginPageInStream(
615 )                                                 615 )
616 //////////////////////////////////////////////    616 //////////////////////////////////////////////////////////////////////////////
617 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    617 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
618 {                                                 618 {
619   fPageNumber++;                                  619   fPageNumber++;
620   printFLN("%%%%Page: %d %d",fPageNumber,fPage    620   printFLN("%%%%Page: %d %d",fPageNumber,fPageNumber);
621   putSaveStateInStream();                         621   putSaveStateInStream();
622 }                                                 622 }
623 //////////////////////////////////////////////    623 //////////////////////////////////////////////////////////////////////////////
624 void SbPainterPS::putEndPageInStream (            624 void SbPainterPS::putEndPageInStream (
625 )                                                 625 )
626 //////////////////////////////////////////////    626 //////////////////////////////////////////////////////////////////////////////
627 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    627 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
628 {                                                 628 {
629   putInStreamF("showpage ");                      629   putInStreamF("showpage ");
630   putRestoreStateInStream();                      630   putRestoreStateInStream();
631 }                                                 631 }
632 //////////////////////////////////////////////    632 //////////////////////////////////////////////////////////////////////////////
633 void SbPainterPS::putRGB_InStream (               633 void SbPainterPS::putRGB_InStream (
634  float aR                                         634  float aR 
635 ,float aG                                         635 ,float aG
636 ,float aB                                         636 ,float aB 
637 )                                                 637 )
638 //////////////////////////////////////////////    638 //////////////////////////////////////////////////////////////////////////////
639 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    639 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
640 {                                                 640 {
641   if(fParams.shade==Color)                        641   if(fParams.shade==Color)       
642     putInStreamF("%.2f %.2f %.2f rgb ",aR,aG,a    642     putInStreamF("%.2f %.2f %.2f rgb ",aR,aG,aB);
643   else if(fParams.shade==Grey)                    643   else if(fParams.shade==Grey)
644     putInStreamF("%.2f setgray ",convertRGB_To    644     putInStreamF("%.2f setgray ",convertRGB_ToGrey(aR,aG,aB));
645   else if(fParams.shade==BlackWhite)              645   else if(fParams.shade==BlackWhite)  
646     putInStreamF("0. setgray ",convertRGB_ToGr    646     putInStreamF("0. setgray ",convertRGB_ToGrey(aR,aG,aB));
647 }                                                 647 }
648 //////////////////////////////////////////////    648 //////////////////////////////////////////////////////////////////////////////
649 void SbPainterPS::putLineWidthInStream(           649 void SbPainterPS::putLineWidthInStream(
650  int aWidth                                       650  int aWidth
651 )                                                 651 )
652 //////////////////////////////////////////////    652 //////////////////////////////////////////////////////////////////////////////
653 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    653 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
654 {                                                 654 {
655   if(fParams.lineWidth<0.) {                      655   if(fParams.lineWidth<0.) {
656     if(aWidth==1) {                               656     if(aWidth==1) {
657       putInStreamF("%.1f lw ",0.5); // For a b    657       putInStreamF("%.1f lw ",0.5); // For a better rendering.
658     } else {                                      658     } else {
659       putInStreamF("%.1f lw ",(float)(aWidth))    659       putInStreamF("%.1f lw ",(float)(aWidth));
660     }                                             660     }
661   } else {                                        661   } else {
662     putInStreamF("%.1f lw ",fParams.lineWidth)    662     putInStreamF("%.1f lw ",fParams.lineWidth); 
663   }                                               663   }
664 }                                                 664 }
665 //////////////////////////////////////////////    665 //////////////////////////////////////////////////////////////////////////////
666 void SbPainterPS::putMarkerSizeInStream (         666 void SbPainterPS::putMarkerSizeInStream (
667  float aSize                                      667  float aSize
668 )                                                 668 )
669 //////////////////////////////////////////////    669 //////////////////////////////////////////////////////////////////////////////
670 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    670 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
671 {                                                 671 {
672   if(aSize==fMarkerSize) return;                  672   if(aSize==fMarkerSize) return;
673   fMarkerSize = aSize;                            673   fMarkerSize = aSize;
674   putInStreamF("/ms %g def /msi %g def ",aSize    674   putInStreamF("/ms %g def /msi %g def ",aSize,1./aSize);
675 }                                                 675 }
676 /*                                                676 /*
677 //////////////////////////////////////////////    677 //////////////////////////////////////////////////////////////////////////////
678 void SbPainterPS::putMarkerStyleInStream (        678 void SbPainterPS::putMarkerStyleInStream (
679  SbMarkerStyle aStyle                             679  SbMarkerStyle aStyle 
680 )                                                 680 )
681 //////////////////////////////////////////////    681 //////////////////////////////////////////////////////////////////////////////
682 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    682 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
683 {                                                 683 {
684   switch (aStyle) {                               684   switch (aStyle) {
685   case SbMarkerPlus:                              685   case SbMarkerPlus:
686     putInStreamF("plus ");                        686     putInStreamF("plus ");
687     break;                                        687     break;
688   case SbMarkerAsterisk:                          688   case SbMarkerAsterisk:
689   case SbMarkerStar:                              689   case SbMarkerStar:
690     putInStreamF("asterisk ");                    690     putInStreamF("asterisk ");
691     break;                                        691     break;
692   case SbMarkerCross:                             692   case SbMarkerCross:
693     putInStreamF("cross ");                       693     putInStreamF("cross ");
694     break;                                        694     break;
695   case SbMarkerTriangleUpLine:                    695   case SbMarkerTriangleUpLine:
696     putInStreamF("triangle ");                    696     putInStreamF("triangle ");
697     break;                                        697     break;
698   default:                                        698   default:
699     putLineToInStream(0.,0.);                     699     putLineToInStream(0.,0.);
700     break;                                        700     break;
701   }                                               701   }
702 }                                                 702 }
703 */                                                703 */
704 //////////////////////////////////////////////    704 //////////////////////////////////////////////////////////////////////////////
705 void SbPainterPS::putBackgroundInStream (         705 void SbPainterPS::putBackgroundInStream (
706  float aR                                         706  float aR
707 ,float aG                                         707 ,float aG
708 ,float aB                                         708 ,float aB
709 ,float aWidth                                     709 ,float aWidth 
710 ,float aHeight                                    710 ,float aHeight 
711 )                                                 711 )
712 //////////////////////////////////////////////    712 //////////////////////////////////////////////////////////////////////////////
713 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    713 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
714 {                                                 714 {
715   putNewPathInStream();                           715   putNewPathInStream(); 
716   putMoveInStream(0.,0.);                         716   putMoveInStream(0.,0.);
717   putLineToInStream(aWidth,0.);                   717   putLineToInStream(aWidth,0.);
718   putLineToInStream(0.,aHeight);                  718   putLineToInStream(0.,aHeight);
719   putLineToInStream(-aWidth,0.);                  719   putLineToInStream(-aWidth,0.);
720   putLineToInStream(0.,-aHeight);                 720   putLineToInStream(0.,-aHeight);
721   putClosePathInStream();                         721   putClosePathInStream();
722   if(fParams.doBack==1) {                         722   if(fParams.doBack==1) {
723     // Back :                                     723     // Back :
724     putSaveStateInStream();                       724     putSaveStateInStream();
725     putRGB_InStream(aR,aG,aB);                    725     putRGB_InStream(aR,aG,aB);
726     putFillInStream();                            726     putFillInStream();       
727     putRestoreStateInStream();                    727     putRestoreStateInStream();
728   }                                               728   }
729   // Clip :                                       729   // Clip :
730   putInStreamF("clip ");                          730   putInStreamF("clip ");
731 }                                                 731 }
732 //////////////////////////////////////////////    732 //////////////////////////////////////////////////////////////////////////////
733 void SbPainterPS::putFrameInStream (              733 void SbPainterPS::putFrameInStream (
734  float aR                                         734  float aR
735 ,float aG                                         735 ,float aG
736 ,float aB                                         736 ,float aB
737 ,float aWidth                                     737 ,float aWidth 
738 ,float aHeight                                    738 ,float aHeight 
739 )                                                 739 )
740 //////////////////////////////////////////////    740 //////////////////////////////////////////////////////////////////////////////
741 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    741 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
742 {                                                 742 {
743   putNewPathInStream();                           743   putNewPathInStream(); 
744   putMoveInStream(0.,0.);                         744   putMoveInStream(0.,0.);
745   putLineToInStream(aWidth,0.);                   745   putLineToInStream(aWidth,0.);
746   putLineToInStream(0.,aHeight);                  746   putLineToInStream(0.,aHeight);
747   putLineToInStream(-aWidth,0.);                  747   putLineToInStream(-aWidth,0.);
748   putLineToInStream(0.,-aHeight);                 748   putLineToInStream(0.,-aHeight);
749   putClosePathInStream();                         749   putClosePathInStream();
750   putRGB_InStream(aR,aG,aB);                      750   putRGB_InStream(aR,aG,aB);
751   putLineWidthInStream(1);                        751   putLineWidthInStream(1);
752   putCapInStream(1);                              752   putCapInStream(1);
753   putInStreamF("ss ");                            753   putInStreamF("ss ");
754   putStrokeInStream();                            754   putStrokeInStream();
755 }                                                 755 }
756 //////////////////////////////////////////////    756 //////////////////////////////////////////////////////////////////////////////
757 float SbPainterPS::convertRGB_ToGrey (            757 float SbPainterPS::convertRGB_ToGrey (
758  float aRed                                       758  float aRed
759 ,float aGreen                                     759 ,float aGreen
760 ,float aBlue                                      760 ,float aBlue
761 )                                                 761 )
762 //////////////////////////////////////////////    762 //////////////////////////////////////////////////////////////////////////////
763 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    763 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
764 {                                                 764 {
765   return (0.3F * aRed + 0.59F * aGreen + 0.11F    765   return (0.3F * aRed + 0.59F * aGreen + 0.11F * aBlue);
766 }                                                 766 }
767 //////////////////////////////////////////////    767 //////////////////////////////////////////////////////////////////////////////
768 void SbPainterPS::putRotateInStream(              768 void SbPainterPS::putRotateInStream(
769  float aX                                         769  float aX                  
770 )                                                 770 )
771 //////////////////////////////////////////////    771 //////////////////////////////////////////////////////////////////////////////
772 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    772 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
773 {                                                 773 {
774   putInStreamF("%.2f  rotate ",aX);               774   putInStreamF("%.2f  rotate ",aX);
775 }                                                 775 }
776 //////////////////////////////////////////////    776 //////////////////////////////////////////////////////////////////////////////
777 void SbPainterPS::putNewPathInStream(             777 void SbPainterPS::putNewPathInStream(
778 )                                                 778 )
779 //////////////////////////////////////////////    779 //////////////////////////////////////////////////////////////////////////////
780 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    780 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
781 {                                                 781 {
782   putInStreamF("n ");                             782   putInStreamF("n ");
783 }                                                 783 }
784 //////////////////////////////////////////////    784 //////////////////////////////////////////////////////////////////////////////
785 void SbPainterPS::putStrokeInStream(              785 void SbPainterPS::putStrokeInStream(
786 )                                                 786 )
787 //////////////////////////////////////////////    787 //////////////////////////////////////////////////////////////////////////////
788 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    788 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
789 {                                                 789 {
790   putInStreamF("s ");                             790   putInStreamF("s ");
791 }                                                 791 }
792 //////////////////////////////////////////////    792 //////////////////////////////////////////////////////////////////////////////
793 void SbPainterPS::putFillInStream(                793 void SbPainterPS::putFillInStream(
794 )                                                 794 )
795 //////////////////////////////////////////////    795 //////////////////////////////////////////////////////////////////////////////
796 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    796 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
797 {                                                 797 {
798   putInStreamF("f ");                             798   putInStreamF("f ");
799 }                                                 799 }
800 //////////////////////////////////////////////    800 //////////////////////////////////////////////////////////////////////////////
801 void SbPainterPS::putClosePathInStream(           801 void SbPainterPS::putClosePathInStream(
802 )                                                 802 )
803 //////////////////////////////////////////////    803 //////////////////////////////////////////////////////////////////////////////
804 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    804 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
805 {                                                 805 {
806   putInStreamF("cl ");                            806   putInStreamF("cl ");
807 }                                                 807 }
808 //////////////////////////////////////////////    808 //////////////////////////////////////////////////////////////////////////////
809 void SbPainterPS::putCapInStream(                 809 void SbPainterPS::putCapInStream(
810  int aX                                           810  int aX
811 )                                                 811 )
812 //////////////////////////////////////////////    812 //////////////////////////////////////////////////////////////////////////////
813 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    813 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
814 {                                                 814 {
815   putInStreamF("%1d lc ",aX);                     815   putInStreamF("%1d lc ",aX);
816 }                                                 816 }
817 //////////////////////////////////////////////    817 //////////////////////////////////////////////////////////////////////////////
818 void SbPainterPS::putLineToInStream(              818 void SbPainterPS::putLineToInStream(
819  float aX                                         819  float aX
820 ,float aY                                         820 ,float aY
821 )                                                 821 )
822 //////////////////////////////////////////////    822 //////////////////////////////////////////////////////////////////////////////
823 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    823 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
824 {                                                 824 {
825   putInStreamF ("%.2f %.2f rl ",aX,aY);           825   putInStreamF ("%.2f %.2f rl ",aX,aY);
826 }                                                 826 }
827 //////////////////////////////////////////////    827 //////////////////////////////////////////////////////////////////////////////
828 void SbPainterPS::putMoveInStream(                828 void SbPainterPS::putMoveInStream(
829  float aX                                         829  float aX
830 ,float aY                                         830 ,float aY
831 )                                                 831 )
832 //////////////////////////////////////////////    832 //////////////////////////////////////////////////////////////////////////////
833 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    833 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
834 {                                                 834 {
835   putInStreamF ("%.2f %.2f m ",aX,aY);            835   putInStreamF ("%.2f %.2f m ",aX,aY);
836 }                                                 836 }
837 //////////////////////////////////////////////    837 //////////////////////////////////////////////////////////////////////////////
838 void SbPainterPS::putCircleInStream(              838 void SbPainterPS::putCircleInStream(
839  float aX                                         839  float aX                            
840 ,float aY                                         840 ,float aY                            
841 ,float aR                                         841 ,float aR                            
842 )                                                 842 )
843 //////////////////////////////////////////////    843 //////////////////////////////////////////////////////////////////////////////
844 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    844 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
845 {                                                 845 {
846   putInStreamF("%.2f %.2f %.2f 0 360 arc s ",a    846   putInStreamF("%.2f %.2f %.2f 0 360 arc s ",aX,aY,aR);
847 }                                                 847 }
848 /*                                                848 /*
849 //////////////////////////////////////////////    849 //////////////////////////////////////////////////////////////////////////////
850 void SbPainterPS::putLineStyleInStream(           850 void SbPainterPS::putLineStyleInStream(
851  SbLineStyle aStyle                               851  SbLineStyle aStyle
852 )                                                 852 )
853 //////////////////////////////////////////////    853 //////////////////////////////////////////////////////////////////////////////
854 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    854 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
855 {                                                 855 {
856   switch(aStyle) {                                856   switch(aStyle) {
857   case SbLineSolid:putInStreamF("ss ") ;break;    857   case SbLineSolid:putInStreamF("ss ") ;break;
858   case SbLineDashed:putInStreamF("sd ") ;break    858   case SbLineDashed:putInStreamF("sd ") ;break;
859   case SbLineDotted:putInStreamF("so ") ;break    859   case SbLineDotted:putInStreamF("so ") ;break;
860   case SbLineDashDotted:putInStreamF("sdo ");b    860   case SbLineDashDotted:putInStreamF("sdo ");break;
861   }                                               861   }
862 }                                                 862 }
863 */                                                863 */
864 //////////////////////////////////////////////    864 //////////////////////////////////////////////////////////////////////////////
865 //////////////////////////////////////////////    865 //////////////////////////////////////////////////////////////////////////////
866 /////// Image ////////////////////////////////    866 /////// Image ////////////////////////////////////////////////////////////////
867 //////////////////////////////////////////////    867 //////////////////////////////////////////////////////////////////////////////
868 //////////////////////////////////////////////    868 //////////////////////////////////////////////////////////////////////////////
869 void SbPainterPS::putImageInStream (              869 void SbPainterPS::putImageInStream (
870  unsigned int aWidth                              870  unsigned int aWidth
871 ,unsigned int aHeight                             871 ,unsigned int aHeight
872 ,GetRGB_Function aProc                            872 ,GetRGB_Function aProc
873 )                                                 873 )
874 //////////////////////////////////////////////    874 //////////////////////////////////////////////////////////////////////////////
875 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    875 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
876 {                                                 876 {
877   if((aWidth<=0)||(aHeight<=0)) return;           877   if((aWidth<=0)||(aHeight<=0)) return;
878   if(!aProc) return;                              878   if(!aProc) return;
879                                                   879 
880   putSaveStateInStream      ();                   880   putSaveStateInStream      ();
881   putInStreamF     ("%d %d scale ", aWidth, aH    881   putInStreamF     ("%d %d scale ", aWidth, aHeight ); 
882   int status = 1;                                 882   int status = 1;
883   int      nbhex;                                 883   int      nbhex;
884   unsigned int row,col,col_max;                   884   unsigned int row,col,col_max;
885   double   dr,dg,db;                              885   double   dr,dg,db;
886   typedef unsigned char Uchar;                    886   typedef unsigned char Uchar;
887   Uchar    red,green,blue,b;                      887   Uchar    red,green,blue,b;
888   if(fParams.shade!=0) { /*grey*/                 888   if(fParams.shade!=0) { /*grey*/
889     putInStreamF   ("/picstr %d string def ",a    889     putInStreamF   ("/picstr %d string def ",aWidth); 
890     putInStreamF   ("%d %d %d ",aWidth,aHeight    890     putInStreamF   ("%d %d %d ",aWidth,aHeight,8); 
891     putInStreamF   ("[ %d 0 0 -%d 0 %d ] ",aWi    891     putInStreamF   ("[ %d 0 0 -%d 0 %d ] ",aWidth,aHeight,aHeight); 
892     putInStreamF   ("{ currentfile picstr read    892     putInStreamF   ("{ currentfile picstr readhexstring pop } " );
893     printFLN ("image " );                         893     printFLN ("image " );
894     for ( row = 0; row < aHeight; row++ ){        894     for ( row = 0; row < aHeight; row++ ){
895       for ( col = 0; col < aWidth; col++){        895       for ( col = 0; col < aWidth; col++){ 
896         double    fgrey;                          896         double    fgrey;
897         Uchar     grey;                           897         Uchar     grey;
898         status    = aProc(col,row,dr,dg,db)==0    898         status    = aProc(col,row,dr,dg,db)==0 ? 0 : status;
899         fgrey     = ConvertRGB_ToGrey(dr,dg,db    899         fgrey     = ConvertRGB_ToGrey(dr,dg,db);
900         grey      = (Uchar) ( 255. * fgrey);      900         grey      = (Uchar) ( 255. * fgrey);
901         writeByte (grey);                         901         writeByte (grey);
902       }                                           902       }
903     }                                             903     }
904     nbhex     = aWidth * aHeight * 2;             904     nbhex     = aWidth * aHeight * 2; 
905     printFLN ("%%%% nbhex digit          :%d "    905     printFLN ("%%%% nbhex digit          :%d ",nbhex); 
906     printFLN ("%%%% nbhex/record_length  :%d "    906     printFLN ("%%%% nbhex/record_length  :%d ",nbhex/METAFILE_RECORD_LENGTH); 
907     printFLN ("%%%% nbhex%%record_length :%d "    907     printFLN ("%%%% nbhex%%record_length :%d ",nbhex%METAFILE_RECORD_LENGTH); 
908   }else if(fParams.nbit==2){                      908   }else if(fParams.nbit==2){ 
909     int       nbyte2;                             909     int       nbyte2;
910     nbyte2    = (aWidth   *  3)/4;                910     nbyte2    = (aWidth   *  3)/4;
911     nbyte2   /=3;                                 911     nbyte2   /=3;
912     nbyte2   *=3;                                 912     nbyte2   *=3;
913     col_max   = (nbyte2  *  4)/3;                 913     col_max   = (nbyte2  *  4)/3;
914     /* 2 bit for r and g and b   */               914     /* 2 bit for r and g and b   */
915     /* rgbs following each other */               915     /* rgbs following each other */
916     putInStreamF   ("/rgbstr %d string def ",n    916     putInStreamF   ("/rgbstr %d string def ",nbyte2); 
917     putInStreamF   ("%d %d %d ",col_max,aHeigh    917     putInStreamF   ("%d %d %d ",col_max,aHeight,2); 
918     putInStreamF   ("[ %d 0 0 -%d 0 %d ] ",col    918     putInStreamF   ("[ %d 0 0 -%d 0 %d ] ",col_max,aHeight,aHeight); 
919     putInStreamF   ("{ currentfile rgbstr read    919     putInStreamF   ("{ currentfile rgbstr readhexstring pop } " );
920     putInStreamF   ("false 3 " );                 920     putInStreamF   ("false 3 " );
921     printFLN ("colorimage " );                    921     printFLN ("colorimage " );
922     for ( row = 0; row < aHeight; row++ ){        922     for ( row = 0; row < aHeight; row++ ){
923       for ( col = 0; col < col_max; col+=4){      923       for ( col = 0; col < col_max; col+=4){
924         status  = aProc(col,row,dr,dg,db)==0 ?    924         status  = aProc(col,row,dr,dg,db)==0 ? 0 : status;
925         red     = (Uchar) ( 3. * dr);             925         red     = (Uchar) ( 3. * dr);
926         green   = (Uchar) ( 3. * dg);             926         green   = (Uchar) ( 3. * dg);
927         blue    = (Uchar) ( 3. * db);             927         blue    = (Uchar) ( 3. * db);
928         b       = red;                            928         b       = red;
929         b       = (b<<2)+green;                   929         b       = (b<<2)+green;
930         b       = (b<<2)+blue;                    930         b       = (b<<2)+blue;
931         status  = aProc(col+1,row,dr,dg,db)==0    931         status  = aProc(col+1,row,dr,dg,db)==0 ? 0 : status;
932         red     = (Uchar) ( 3. * dr);             932         red     = (Uchar) ( 3. * dr);
933         green   = (Uchar) ( 3. * dg);             933         green   = (Uchar) ( 3. * dg);
934         blue    = (Uchar) ( 3. * db);             934         blue    = (Uchar) ( 3. * db);
935         b     = (b<<2)+red;                       935         b     = (b<<2)+red;
936         writeByte (b);                            936         writeByte (b);
937                                                   937         
938         b       = green;                          938         b       = green;
939         b       = (b<<2)+blue;                    939         b       = (b<<2)+blue;
940         status  = aProc(col+2,row,dr,dg,db)==0    940         status  = aProc(col+2,row,dr,dg,db)==0 ? 0 : status;
941         red     = (Uchar) ( 3. * dr);             941         red     = (Uchar) ( 3. * dr);
942         green   = (Uchar) ( 3. * dg);             942         green   = (Uchar) ( 3. * dg);
943         blue    = (Uchar) ( 3. * db);             943         blue    = (Uchar) ( 3. * db);
944         b     = (b<<2)+red;                       944         b     = (b<<2)+red;
945         b     = (b<<2)+green;                     945         b     = (b<<2)+green;
946         writeByte (b);                            946         writeByte (b);
947                                                   947         
948         b       = blue;                           948         b       = blue;
949         status  = aProc(col+3,row,dr,dg,db)==0    949         status  = aProc(col+3,row,dr,dg,db)==0 ? 0 : status;
950         red     = (Uchar) ( 3. * dr);             950         red     = (Uchar) ( 3. * dr);
951         green   = (Uchar) ( 3. * dg);             951         green   = (Uchar) ( 3. * dg);
952         blue    = (Uchar) ( 3. * db);             952         blue    = (Uchar) ( 3. * db);
953         b     = (b<<2)+red;                       953         b     = (b<<2)+red;
954         b     = (b<<2)+green;                     954         b     = (b<<2)+green;
955         b     = (b<<2)+blue;                      955         b     = (b<<2)+blue;
956         writeByte (b);                            956         writeByte (b);
957       }                                           957       }
958     }                                             958     }
959   }else if(fParams.nbit==4){                      959   }else if(fParams.nbit==4){ 
960     int       nbyte4;                             960     int       nbyte4;
961     nbyte4    = (aWidth  * 3)/2;                  961     nbyte4    = (aWidth  * 3)/2;
962     nbyte4   /=3;                                 962     nbyte4   /=3;
963     nbyte4   *=3;                                 963     nbyte4   *=3;
964     col_max   = (nbyte4 * 2)/3;                   964     col_max   = (nbyte4 * 2)/3;
965     /* 4 bit for r and g and b   */               965     /* 4 bit for r and g and b   */
966     /* rgbs following each other */               966     /* rgbs following each other */
967     putInStreamF   ("/rgbstr %d string def ",n    967     putInStreamF   ("/rgbstr %d string def ",nbyte4); 
968     putInStreamF   ("%d %d %d ",col_max,aHeigh    968     putInStreamF   ("%d %d %d ",col_max,aHeight,4); 
969     putInStreamF   ("[ %d 0 0 -%d 0 %d ] ",col    969     putInStreamF   ("[ %d 0 0 -%d 0 %d ] ",col_max,aHeight,aHeight); 
970     putInStreamF   ("{ currentfile rgbstr read    970     putInStreamF   ("{ currentfile rgbstr readhexstring pop } " );
971     putInStreamF   ("false 3 " );                 971     putInStreamF   ("false 3 " );
972     printFLN ("colorimage " );                    972     printFLN ("colorimage " );
973     for ( row = 0; row < aHeight; row++ ){        973     for ( row = 0; row < aHeight; row++ ){
974       for ( col = 0; col < col_max; col+=2){      974       for ( col = 0; col < col_max; col+=2){
975         status  = aProc(col,row,dr,dg,db)==0 ?    975         status  = aProc(col,row,dr,dg,db)==0 ? 0 : status;
976         red     = (Uchar) ( 15. * dr);            976         red     = (Uchar) ( 15. * dr);
977         green   = (Uchar) ( 15. * dg);            977         green   = (Uchar) ( 15. * dg);
978         putInStreamF ("%x%x",red,green);          978         putInStreamF ("%x%x",red,green);
979         blue    = (Uchar) ( 15. * db);            979         blue    = (Uchar) ( 15. * db);
980                                                   980         
981         status  = aProc(col+1,row,dr,dg,db)==0    981         status  = aProc(col+1,row,dr,dg,db)==0 ? 0 : status;
982         red     = (Uchar) ( 15. * dr);            982         red     = (Uchar) ( 15. * dr);
983         putInStreamF ("%x%x",blue,red);           983         putInStreamF ("%x%x",blue,red);
984         green   = (Uchar) ( 15. * dg);            984         green   = (Uchar) ( 15. * dg);
985         blue    = (Uchar) ( 15. * db);            985         blue    = (Uchar) ( 15. * db);
986         putInStreamF ("%x%x",green,blue);         986         putInStreamF ("%x%x",green,blue);
987       }                                           987       }
988     }                                             988     }
989   }else{                                          989   }else{ 
990     int       nbyte8;                             990     int       nbyte8;
991     nbyte8    = aWidth   * 3;                     991     nbyte8    = aWidth   * 3;
992     /* 8 bit for r and g and b   */               992     /* 8 bit for r and g and b   */
993     putInStreamF   ("/rgbstr %d string def ",n    993     putInStreamF   ("/rgbstr %d string def ",nbyte8); 
994     putInStreamF   ("%d %d %d ",aWidth,aHeight    994     putInStreamF   ("%d %d %d ",aWidth,aHeight,8); 
995     putInStreamF   ("[ %d 0 0 -%d 0 %d ] ",aWi    995     putInStreamF   ("[ %d 0 0 -%d 0 %d ] ",aWidth,aHeight,aHeight); 
996     putInStreamF   ("{ currentfile rgbstr read    996     putInStreamF   ("{ currentfile rgbstr readhexstring pop } " );
997     putInStreamF   ("false 3 " );                 997     putInStreamF   ("false 3 " );
998     printFLN   ("colorimage " );                  998     printFLN   ("colorimage " );
999     for ( row = 0; row < aHeight; row++ ){        999     for ( row = 0; row < aHeight; row++ ){
1000       for ( col = 0; col < aWidth; col++){       1000       for ( col = 0; col < aWidth; col++){
1001         status     = aProc(col,row,dr,dg,db)=    1001         status     = aProc(col,row,dr,dg,db)==0 ? 0 : status;
1002         red        = (Uchar) ( 255. * dr);       1002         red        = (Uchar) ( 255. * dr);
1003         writeByte (red);                         1003         writeByte (red);
1004         green      = (Uchar) ( 255. * dg);       1004         green      = (Uchar) ( 255. * dg);
1005         writeByte (green);                       1005         writeByte (green);
1006         blue       = (Uchar) ( 255. * db);       1006         blue       = (Uchar) ( 255. * db);
1007         writeByte (blue);                        1007         writeByte (blue);
1008       }                                          1008       }
1009     }                                            1009     }
1010   }                                              1010   }
1011   if(status==0)                                  1011   if(status==0) 
1012     ::printf("SbPainterPS::putImageInStream:     1012     ::printf("SbPainterPS::putImageInStream: problem to retrieve some pixel rgb.\n");
1013   putRestoreStateInStream();                     1013   putRestoreStateInStream();
1014 }                                                1014 }
1015 /////////////////////////////////////////////    1015 //////////////////////////////////////////////////////////////////////////////
1016 void SbPainterPS::writeByte (                    1016 void SbPainterPS::writeByte (
1017  unsigned char a_byte                            1017  unsigned char a_byte
1018 )                                                1018 )
1019 /////////////////////////////////////////////    1019 //////////////////////////////////////////////////////////////////////////////
1020 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    1020 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
1021 {                                                1021 {
1022   unsigned char h = a_byte / 16;                 1022   unsigned char h = a_byte / 16;
1023   unsigned char l = a_byte % 16;                 1023   unsigned char l = a_byte % 16;
1024   putInStreamF ("%x%x",h,l);                     1024   putInStreamF ("%x%x",h,l);
1025 }                                                1025 }
1026 /////////////////////////////////////////////    1026 //////////////////////////////////////////////////////////////////////////////
1027 /////////////////////////////////////////////    1027 //////////////////////////////////////////////////////////////////////////////
1028 /////////////////////////////////////////////    1028 //////////////////////////////////////////////////////////////////////////////
1029 char* GetDate (                                  1029 char* GetDate (
1030 )                                                1030 )
1031 /////////////////////////////////////////////    1031 //////////////////////////////////////////////////////////////////////////////
1032 // Return local date.                            1032 // Return local date.
1033 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    1033 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
1034 {                                                1034 {
1035   time_t d;                                      1035   time_t d;
1036   time(&d);                                      1036   time(&d);
1037   char* string = ctime(&d);                      1037   char* string = ctime(&d);
1038   string[24] = '\0';                             1038   string[24] = '\0';
1039   return string;                                 1039   return string;
1040 }                                                1040 }
1041 /////////////////////////////////////////////    1041 //////////////////////////////////////////////////////////////////////////////
1042 double ConvertRGB_ToGrey(                        1042 double ConvertRGB_ToGrey(
1043  double a_red                                    1043  double a_red
1044 ,double a_green                                  1044 ,double a_green
1045 ,double a_blue                                   1045 ,double a_blue
1046 )                                                1046 )
1047 /////////////////////////////////////////////    1047 //////////////////////////////////////////////////////////////////////////////
1048 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    1048 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
1049 {                                                1049 {
1050   return (0.30 * a_red + 0.59 * a_green + 0.1    1050   return (0.30 * a_red + 0.59 * a_green + 0.11 * a_blue);
1051 }                                                1051 }
1052                                                  1052