36#define STRDUP(str) ((str) != NULL ? (::strcpy((char*)::malloc((unsigned)::strlen(str) + 1), str)) : (char*)NULL)
37#define STRDEL(str) {if((str)!=NULL) {::free(str);str=NULL;}}
47#define METAFILE_DEFAULT "out.ps"
48#define METAFILE_SCALE 1.
74 ::setlocale(LC_NUMERIC,
"USA");
87 ::printf(
"SbPainterPS : bad gsave/grestore balance : %d.\n",
fGSave);
99 if(
fFile==NULL)
return;
110 if(
fFile==NULL)
return;
124 if(
fFile==NULL)
return;
323 if( (aNbit==2) || (aNbit==4) || (aNbit==8) )
335 fParams.lineWidth = (float)aWidth;
373 if( (aString==NULL) || (*aString==
'\0') ) {
382 fFile = ::fopen(aString,
"wb");
386 if(
fFile==NULL)
return;
393 printFLN (
"%%%%Creator: HEPVis::SbPainterPS.");
397 printFLN(
"%%%%BoundingBox: 0 0 %d %d",
399 printFLN(
"%%%%DocumentFonts: Courier-Bold");
400 printFLN(
"%%%%DocumentPaperSizes: a4");
425 putInStreamF(
"2. 2. rl 0. -2. rm -2. 2. rl msi msi scale} def ");
427 putInStreamF(
"-1. 1. rm 0. -2. rl msi msi scale} def ");
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.707 rm 1.414 1.414 rl ");
430 putInStreamF(
"0. -1.414 rm -1.414 1.414 rl msi msi scale} def ");
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 scale} def ");
445 if(
fFile==NULL)
return;
463 if(
fFile==NULL)
return;
465 va_start(
args,aFormat);
470 ::printf(
"SoPostScript::putInStreamF overflow\n");
477 ::printf(
"SoPostScript::putInStreamF fprintf error\n");
494 if(
fFile==NULL)
return;
496 va_start(
args,aFormat);
503 ::printf(
"SbPainterPS::printFLN fprintf error\n");
509 ::printf(
"SbPainterPS::printFLN fprintf error\n");
528 ::printf(
"SbPainterPS::printV overflow\n");
543 if(aWidth <=0.) aWidth = 100.;
544 if(aHeight<=0.) aHeight = 100.;
552 scale = (aHeight<=aWidth ?
555 scale = (aHeight<=aWidth ?
765 return (0.3F * aRed + 0.59F * aGreen + 0.11F * aBlue);
872,GetRGB_Function aProc
877 if((aWidth<=0)||(aHeight<=0))
return;
884 unsigned int row,col,col_max;
886 typedef unsigned char Uchar;
887 Uchar red,green,blue,b;
891 putInStreamF (
"[ %d 0 0 -%d 0 %d ] ",aWidth,aHeight,aHeight);
892 putInStreamF (
"{ currentfile picstr readhexstring pop } " );
894 for ( row = 0; row < aHeight; row++ ){
895 for ( col = 0; col < aWidth; col++){
898 status = aProc(col,row,dr,dg,db)==0 ? 0 : status;
900 grey = (
Uchar) ( 255. * fgrey);
904 nbhex = aWidth * aHeight * 2;
905 printFLN (
"%%%% nbhex digit :%d ",nbhex);
910 nbyte2 = (aWidth * 3)/4;
913 col_max = (nbyte2 * 4)/3;
918 putInStreamF (
"[ %d 0 0 -%d 0 %d ] ",col_max,aHeight,aHeight);
919 putInStreamF (
"{ currentfile rgbstr readhexstring pop } " );
922 for ( row = 0; row < aHeight; row++ ){
923 for ( col = 0; col < col_max; col+=4){
924 status = aProc(col,row,dr,dg,db)==0 ? 0 : status;
925 red = (
Uchar) ( 3. * dr);
926 green = (
Uchar) ( 3. * dg);
927 blue = (
Uchar) ( 3. * db);
931 status = aProc(col+1,row,dr,dg,db)==0 ? 0 : status;
932 red = (
Uchar) ( 3. * dr);
933 green = (
Uchar) ( 3. * dg);
934 blue = (
Uchar) ( 3. * db);
940 status = aProc(col+2,row,dr,dg,db)==0 ? 0 : status;
941 red = (
Uchar) ( 3. * dr);
942 green = (
Uchar) ( 3. * dg);
943 blue = (
Uchar) ( 3. * db);
949 status = aProc(col+3,row,dr,dg,db)==0 ? 0 : status;
950 red = (
Uchar) ( 3. * dr);
951 green = (
Uchar) ( 3. * dg);
952 blue = (
Uchar) ( 3. * db);
961 nbyte4 = (aWidth * 3)/2;
964 col_max = (nbyte4 * 2)/3;
969 putInStreamF (
"[ %d 0 0 -%d 0 %d ] ",col_max,aHeight,aHeight);
970 putInStreamF (
"{ currentfile rgbstr readhexstring pop } " );
973 for ( row = 0; row < aHeight; row++ ){
974 for ( col = 0; col < col_max; col+=2){
975 status = aProc(col,row,dr,dg,db)==0 ? 0 : status;
976 red = (
Uchar) ( 15. * dr);
977 green = (
Uchar) ( 15. * dg);
979 blue = (
Uchar) ( 15. * db);
981 status = aProc(col+1,row,dr,dg,db)==0 ? 0 : status;
982 red = (
Uchar) ( 15. * dr);
984 green = (
Uchar) ( 15. * dg);
985 blue = (
Uchar) ( 15. * db);
995 putInStreamF (
"[ %d 0 0 -%d 0 %d ] ",aWidth,aHeight,aHeight);
996 putInStreamF (
"{ currentfile rgbstr readhexstring pop } " );
999 for ( row = 0; row < aHeight; row++ ){
1000 for ( col = 0; col < aWidth; col++){
1001 status = aProc(col,row,dr,dg,db)==0 ? 0 : status;
1002 red = (
Uchar) ( 255. * dr);
1004 green = (
Uchar) ( 255. * dg);
1006 blue = (
Uchar) ( 255. * db);
1012 ::printf(
"SbPainterPS::putImageInStream: problem to retrieve some pixel rgb.\n");
1017 unsigned char a_byte
1022 unsigned char h = a_byte / 16;
1023 unsigned char l = a_byte % 16;
1037 char*
string = ctime(&d);
1050 return (0.30 * a_red + 0.59 * a_green + 0.11 * a_blue);
static double ConvertRGB_ToGrey(double, double, double)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
static char * GetDate()
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
#define METAFILE_RECORD_LENGTH
void putMoveInStream(float, float)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
void endTraversal()
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
void putStrokeInStream()
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
void putCircleInStream(float, float, float)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
void putBeginPageInStream()
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
void putClosePathInStream()
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
void setOrientation(int)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
void beginTraversal()
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
void putSaveStateInStream()
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
void putImageInStream(unsigned int, unsigned int, GetRGB_Function)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
void setBackgroundDrawn(int)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
unsigned char fBufferPointer[METAFILE_RECORD_LENGTH+1]
void putNewPathInStream()
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
void setFileName(const char *)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
void putCapInStream(int)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
void setBitsPerPixel(int)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
void writeByte(unsigned char)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
void clearColorBuffer(float, float, float)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
void setColorScheme(int)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
float convertRGB_ToGrey(float, float, float)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
void putPageScaleInStream(float, float)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
struct SbPainterPS::@111 fParams
void putInStreamF(const char *,...)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
void putLineToInStream(float, float)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
void openFileForWriting(const char *)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
void printV(const char *, va_list)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
~SbPainterPS()
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
void setLineWidth(int)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
void putRestoreStateInStream()
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
void putEndPageInStream()
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
void * getStream()
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
void printFLN(const char *,...)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
void putRotateInStream(float)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
void putLineWidthInStream(int)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
void putMarkerSizeInStream(float)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
void putRGB_InStream(float, float, float)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
void putFillInStream()
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
void putBackgroundInStream(float, float, float, float, float)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
void putFrameInStream(float, float, float, float, float)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
const char * getFileName() const
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
void putScaleInStream(float, float)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
void putTranslationInStream(float, float)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
void closeStream()
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//