1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
|
#define PRO7689 //GG_300597
// La hauteur des caracteres avec CapsHeight TRUE doit etre
// relative a la hauteur de la lettre H et non pas
// la hauteur max de la police.
#define MFT //GG_MFT Etude G1343
// Utilisation du FontManager MFT permettant de traiter
// les chaines de caracteres EUCLID3 orientees et slantees.
//
#define PRO8709 //GG_170697
// Les textes encadres ou caches ne fonctionnent pas en mode
// NOIR & BLANC
#define CTS17946//GG_030797/GG_300698
// En mode NOIR et BLANC,ne pas remplir les polygones.
// dans la couleur du fond.
#define CTS18150//GG_210797
// Parametrer le format papier de maniere a reduire
// automatiquement l'echelle lorsque le format du dessin
// est plus grand.
#define PRO11339 //GG_260398
// Ne pas arrondir l'epaisseur du trait
#define JAP60166 //GG_180698
// Les polygones sont transparents alors qu'il devraient
// etres remplis.
// Traitement des niveaux de gris.
#define S3602 //SYL_170898
// Constructeur avec Format du papier en DX,DY ou FOSP
// Prise en compte de la marge papier
//#define PRO15090 //SYL_040998 annulle le 170998 suite a debug de GG (PRO15231)
// Utiliser toujours les polices MFT pour etre sur d'etre wysywig en ettendant de maitriser
// l'echelle
#define PRO15119 //SYL_040998
// En monochrome, on force les couleurs au noir tout en permettant le
// trace avec le fond blanc => le cache fonctionne
#define PRO15784 // SYL 19101998 les textes cachants ne doivent pas toujours etre encadres
#define PRO15786 // SYL 19101998 erreur setdash sur osf seulement !!
#define BUC60766 // GG 300399
// Ascendante compatibillity using OLD driver constructor
// must generates directly a file.
// Re Enable to draw PostScript string when it's requested
#define BUC60772 //GG_061100 Round off vectors intersection
// angle during MFT drawing with PostScript driver.
#define CSR862 // GG_101100
// Enable to draw full drawing after rotation and auto scaling.
#define MOVETO "M "
#define RMOVETO "RM "
#define LINETO "L "
#define CURVETO "CT "
#define RLINETO "RL "
#define ARC "A "
#define ARCN "AN "
#define STROKE "ST "
#define FILL "F "
#define SHOW "SH "
#define GSAVE "GS "
#define GRESTORE "GR "
#define ROTATE "R "
#define SCALE "SC "
#define CHARPATH "CHP "
#define CLOSEPATH "CLP "
#define NEWPATH "NP "
#define SHOWHIDINGTEXT "ShowHidingText "
#define SHOWFRAMEDTEXT "ShowFramedText "
#define SHOWUNDERLINEDTEXT "ShowUnderlinedText "
#define FILLRECTANGLE "FillRectangle "
#define DRAWRECTANGLE "DrawRectangle "
#define UNDERLINE "UnderLine "
#define SCALEDRAWING "ScaleDrawing "
#define SCALEFONT "ScaleFont "
static const char* MONTHS [] = {
"January", "February", "March",
"April", "May", "June", "July",
"August", "September", "October",
"November", "December"
};
#include <PS_Driver.ixx>
#include <MFT_FontManager.hxx>
#include <PlotMgt_TextManager.hxx>
#include <PlotMgt_HListOfMFTFonts.hxx>
#include <TShort_HArray1OfShortReal.hxx>
#include <Aspect.hxx>
#include <Aspect_RGBPixel.hxx>
#include <Quantity_Date.hxx>
#include <Aspect_Units.hxx>
#include <Aspect_ColorMapEntry.hxx>
#include <Aspect_TypeMapEntry.hxx>
#include <Aspect_WidthMapEntry.hxx>
#include <Aspect_FontMapEntry.hxx>
#include <Aspect_MarkMapEntry.hxx>
#include <OSD_Process.hxx>
#include <TColQuantity_Array1OfLength.hxx>
#include <TColStd_Array1OfBoolean.hxx>
#include <AlienImage.hxx>
#include <Image_Image.hxx>
#include <stdio.h>
static Handle(Image_Image) myImage;
#ifdef _MSC_VER
#pragma warning (disable : 4244 4018 4101)
#endif
#define MAXPOINT 1024
#define DRAD (3.1415927/180.)
#define PPI 72./(0.0254005 METER)
#define IMAGEBUFFERSIZE 48
#define DEFPLOTTER "DIRECT_PS"
#define PLOT_PCOLOR(aCol) \
if (myColorIndex != (aCol)) { \
myColorIndex = (aCol); \
if (myColorIndex > 0) \
(*Cout()) << " C" << myColorIndex << " "; \
else \
(*Cout()) << " CB "; \
}
//==========================================================================
PS_Driver::PS_Driver(const Handle(PlotMgt_Plotter)& aPlotter,
const Standard_CString aName,
const Quantity_Length aPaperX,
const Quantity_Length aPaperY,
const Aspect_TypeOfColorSpace aTypeOfColorSpace)
: PlotMgt_PlotterDriver (aPlotter, aName, Standard_True)
{
BeginFile( aPlotter,aName,aPaperX,aPaperY,aTypeOfColorSpace,aPaperX,aPaperY);
}
//==========================================================================
PS_Driver::PS_Driver(const Standard_CString aName,
const Quantity_Length aDX,
const Quantity_Length aDY,
const Aspect_TypeOfColorSpace aTypeOfColorSpace,
const Aspect_FormatOfSheetPaper aSheetFormat)
: PlotMgt_PlotterDriver (aName, Standard_True)
{
Quantity_Length thePaperWidth,thePaperHeight;
Aspect::ValuesOfFOSP(aSheetFormat,thePaperWidth,thePaperHeight);
#ifndef BUC60766
Handle(PlotMgt_Plotter) thePlotter = new PlotMgt_Plotter(TCollection_AsciiString(DEFPLOTTER));
#else
Handle(PlotMgt_Plotter) thePlotter = new PlotMgt_Plotter(TCollection_AsciiString(DEFPLOTTER),Standard_True);
#endif
SetPlotter (thePlotter);
BeginFile (thePlotter,aName,aDX,aDY,aTypeOfColorSpace,thePaperWidth,thePaperHeight);
}
//==========================================================================
void PS_Driver::BeginFile(const Handle(PlotMgt_Plotter)& aPlotter,
const Standard_CString aName,
const Quantity_Length aDX,
const Quantity_Length aDY,
const Aspect_TypeOfColorSpace aTypeOfColorSpace,
const Quantity_Length thePaperWidth,
const Quantity_Length thePaperHeight)
{
OSD_Process P;
Quantity_Date Date = P.SystemDate();
myTypeOfColorSpace = aTypeOfColorSpace;
// define the real workspace, usefull for mapping by the user of the driver
// before sending the objects to plot (V2d_View)
myWidth = Standard_ShortReal(aDX - 2*myPaperMargin);
myHeight = Standard_ShortReal(aDY - 2*myPaperMargin);
(*Cout()) << "%!PS-Adobe-" << endl;
(*Cout()) << "%%Title: " << aName << endl;
(*Cout()) << "%%Creator: " << P.UserName() << endl;
(*Cout()) << "%%CreationDate: " << MONTHS[Date.Month()-1] << " "
<< Date.Day() << " " << Date.Year() << " " << Date.Hour()
<< ":" << Date.Minute() << ":" << Date.Second() << endl;
(*Cout()) << "%%BeginProlog" << endl;
(*Cout()) << "%%EndProlog" << endl;
(*Cout()) << "%%BeginSetup" << endl;
(*Cout()) << "/Centimeter {" << PPI CENTIMETER << " mul} def" << endl;
(*Cout()) << "/Inch {72 mul} def" << endl;
(*Cout()) << "/PaperWidth " << TOCENTIMETER(thePaperHeight) << " Centimeter def" << endl;
(*Cout()) << "/PaperHeight " << TOCENTIMETER(thePaperWidth ) << " Centimeter def" << endl;
(*Cout()) << "/PaperMargin " << TOCENTIMETER(myPaperMargin ) << " Centimeter def" << endl;
(*Cout()) << "/PaperRotateIfPossible true def" << endl;
(*Cout()) << "/BD {bind def} bind def" << endl;
(*Cout()) << "/IB " << IMAGEBUFFERSIZE << " string def" << endl;
(*Cout()) << "/" << MOVETO << "{moveto} BD" << endl;
(*Cout()) << "/" << RMOVETO << "{rmoveto} BD" << endl;
(*Cout()) << "/" << LINETO << "{lineto} BD" << endl;
(*Cout()) << "/" << RLINETO << "{rlineto} BD" << endl;
(*Cout()) << "/" << CURVETO << "{curveto} BD" << endl;
(*Cout()) << "/" << ARC << "{arc} BD" << endl;
(*Cout()) << "/" << ARCN << "{arcn} BD" << endl;
(*Cout()) << "/" << STROKE << "{stroke} BD" << endl;
(*Cout()) << "/" << FILL << "{fill} BD" << endl;
(*Cout()) << "/" << SHOW << "{show} BD" << endl;
(*Cout()) << "/" << ROTATE << "{rotate} BD" << endl;
(*Cout()) << "/" << SCALE << "{scale} BD" << endl;
(*Cout()) << "/" << GSAVE << "{gsave} BD" << endl;
(*Cout()) << "/" << GRESTORE << "{grestore} BD" << endl;
(*Cout()) << "/" << CHARPATH << "{charpath} BD" << endl;
(*Cout()) << "/" << CLOSEPATH << "{closepath} BD" << endl;
(*Cout()) << "/" << NEWPATH << "{newpath} BD" << endl;
(*Cout()) << "/" << UNDERLINE << "{" << endl;
(*Cout()) << "% Compute underline position depending of the baseline position" << endl;
(*Cout()) << " /size exch def" << endl;
(*Cout()) << " currentfont /FontBBox known {" << endl;
(*Cout()) << " currentfont /FontBBox get dup" << endl;
(*Cout()) << " 1 get /ymin exch def" << endl;
(*Cout()) << " 3 get /ymax exch def" << endl;
(*Cout()) << " ymin ymax ymin sub div 0.6 mul size mul" << endl;
(*Cout()) << " } { " << endl;
(*Cout()) << " ymax ymin sub 8 div size mul neg" << endl;
(*Cout()) << " } ifelse" << endl;
(*Cout()) << "} bind def" << endl;
(*Cout()) << "/" << FILLRECTANGLE << "{" << endl;
(*Cout()) << " /rxmin exch def % lower-left corner" << endl;
(*Cout()) << " /rymin exch def % lower-left corner" << endl;
(*Cout()) << " /rwidth exch def % rect width" << endl;
(*Cout()) << " /rheight exch def % rect height" << endl;
(*Cout()) << " /orientation exch def % text angle" << endl;
(*Cout()) << " /framedattrib exch def % framed attrib" << endl;
(*Cout()) << " /hidingattrib exch def % hiding background attrib" << endl;
(*Cout()) << " gsave % get text bounding box" << endl;
(*Cout()) << " currentpoint /y exch def /x exch def % get current position" << endl;
(*Cout()) << " orientation rotate % rotate the text" << endl;
(*Cout()) << " hidingattrib cvx exec % draw hiding bounding box" << endl;
(*Cout()) << " rxmin rymin rmoveto 0 rheight rlineto rwidth 0 rlineto" << endl;
(*Cout()) << " 0 rheight neg rlineto rwidth neg 0 rlineto closepath fill" << endl;
(*Cout()) << " x y moveto framedattrib cvx exec % draw framed bounding box" << endl;
(*Cout()) << " rxmin rymin rmoveto 0 rheight rlineto rwidth 0 rlineto" << endl;
(*Cout()) << " 0 rheight neg rlineto rwidth neg 0 rlineto stroke" << endl;
(*Cout()) << " grestore" << endl;
(*Cout()) << "} bind def" << endl;
(*Cout()) << "/" << DRAWRECTANGLE << "{" << endl;
(*Cout()) << " /rxmin exch def % lower-left corner" << endl;
(*Cout()) << " /rymin exch def % lower-left corner" << endl;
(*Cout()) << " /rwidth exch def % rect width" << endl;
(*Cout()) << " /rheight exch def % rect height" << endl;
(*Cout()) << " /orientation exch def % text angle" << endl;
(*Cout()) << " /framedattrib exch def % framed attrib" << endl;
(*Cout()) << " gsave % get text bounding box" << endl;
(*Cout()) << " orientation rotate % rotate the text" << endl;
(*Cout()) << " framedattrib cvx exec % draw framed bounding box" << endl;
(*Cout()) << " rxmin rymin rmoveto 0 rheight rlineto rwidth 0 rlineto" << endl;
(*Cout()) << " 0 rheight neg rlineto rwidth neg 0 rlineto stroke" << endl;
(*Cout()) << " grestore" << endl;
(*Cout()) << "} bind def" << endl;
(*Cout()) << "/" << SHOWHIDINGTEXT << "{" << endl;
(*Cout()) << " /textstring exch def % text to edit" << endl;
(*Cout()) << " /isunderlined exch def % underline text flag" << endl;
(*Cout()) << " /textangle exch def % text angle" << endl;
(*Cout()) << " /textmargin exch def % text margin" << endl;
(*Cout()) << " /textattrib exch def % text attrib" << endl;
(*Cout()) << " /fontsize exch def % font size" << endl;
(*Cout()) << " /hidingattrib exch def % hiding background attrib" << endl;
(*Cout()) << " /framedattrib exch def % framed attrib" << endl;
(*Cout()) << " gsave" << endl;
(*Cout()) << " gsave % get text bounding box" << endl;
(*Cout()) << " 0 0 moveto" << endl;
(*Cout()) << " textstring false charpath pathbbox" << endl;
(*Cout()) << " /tymax exch def /txmax exch def /tymin exch def /txmin exch def" << endl;
(*Cout()) << " grestore" << endl;
(*Cout()) << " /twidth txmax txmin sub def % set text width" << endl;
(*Cout()) << " /theight tymax tymin sub def % set text height" << endl;
(*Cout()) << " isunderlined { % adjust underline space" << endl;
(*Cout()) << " /umargin fontsize UnderLine def" << endl;
(*Cout()) << " umargin tymin lt {" << endl;
(*Cout()) << " /tymin umargin def" << endl;
(*Cout()) << " /theight tymax tymin sub def" << endl;
(*Cout()) << " } if" << endl;
(*Cout()) << " } if" << endl;
(*Cout()) << " /hmargin textmargin theight mul def" << endl;
(*Cout()) << " /hxmin txmin hmargin sub def" << endl;
(*Cout()) << " /hymin tymin hmargin sub def" << endl;
(*Cout()) << " /hxmax txmax hmargin add def" << endl;
(*Cout()) << " /hymax tymax hmargin add def" << endl;
(*Cout()) << " /hwidth hxmax hxmin sub def % set hiding width" << endl;
(*Cout()) << " /hheight hymax hymin sub def % set hiding height" << endl;
(*Cout()) << " hidingattrib framedattrib textangle hheight hwidth hymin hxmin FillRectangle" << endl;
(*Cout()) << " textangle rotate % rotate the text" << endl;
(*Cout()) << " currentpoint /ytext exch def /xtext exch def % get text position" << endl;
(*Cout()) << " textstring textattrib cvx exec % draw text" << endl;
(*Cout()) << " isunderlined {" << endl;
(*Cout()) << " theight 32 div setlinewidth" << endl;
(*Cout()) << " xtext ytext moveto 0 umargin rmoveto twidth 0 rlineto stroke % draw underline" << endl;
(*Cout()) << " } if" << endl;
(*Cout()) << " grestore" << endl;
(*Cout()) << "} bind def" << endl;
(*Cout()) << "/" << SHOWFRAMEDTEXT << "{" << endl;
(*Cout()) << " /textstring exch def % text to edit" << endl;
(*Cout()) << " /isunderlined exch def % underline text flag" << endl;
(*Cout()) << " /textangle exch def % text angle" << endl;
(*Cout()) << " /textmargin exch def % text margin" << endl;
(*Cout()) << " /textattrib exch def % text attrib" << endl;
(*Cout()) << " /fontsize exch def % font size" << endl;
(*Cout()) << " /framedattrib exch def % framed attrib" << endl;
(*Cout()) << " gsave" << endl;
(*Cout()) << " gsave % get text bounding box" << endl;
(*Cout()) << " 0 0 moveto" << endl;
(*Cout()) << " textstring false charpath pathbbox" << endl;
(*Cout()) << " /tymax exch def /txmax exch def /tymin exch def /txmin exch def" << endl;
(*Cout()) << " grestore" << endl;
(*Cout()) << " /twidth txmax txmin sub def % set text width" << endl;
(*Cout()) << " /theight tymax tymin sub def % set text height" << endl;
(*Cout()) << " isunderlined { % adjust underline space" << endl;
(*Cout()) << " /umargin fontsize UnderLine def" << endl;
(*Cout()) << " umargin tymin lt {" << endl;
(*Cout()) << " /tymin umargin def" << endl;
(*Cout()) << " /theight tymax tymin sub def" << endl;
(*Cout()) << " } if" << endl;
(*Cout()) << " } if" << endl;
(*Cout()) << " /hmargin textmargin theight mul def" << endl;
(*Cout()) << " /hxmin txmin hmargin sub def" << endl;
(*Cout()) << " /hymin tymin hmargin sub def" << endl;
(*Cout()) << " /hxmax txmax hmargin add def" << endl;
(*Cout()) << " /hymax tymax hmargin add def" << endl;
(*Cout()) << " /hwidth hxmax hxmin sub def % set framed width" << endl;
(*Cout()) << " /hheight hymax hymin sub def % set framed height" << endl;
(*Cout()) << " framedattrib textangle hheight hwidth hymin hxmin DrawRectangle" << endl;
(*Cout()) << " currentpoint /ytext exch def /xtext exch def % get text position" << endl;
(*Cout()) << " textangle rotate % rotate the text" << endl;
(*Cout()) << " textstring textattrib cvx exec % draw text" << endl;
(*Cout()) << " isunderlined {" << endl;
(*Cout()) << " theight 32 div setlinewidth" << endl;
(*Cout()) << " xtext ytext moveto 0 umargin rmoveto twidth 0 rlineto stroke % draw underline" << endl;
(*Cout()) << " } if" << endl;
(*Cout()) << " grestore" << endl;
(*Cout()) << "} bind def" << endl;
(*Cout()) << "/" << SHOWUNDERLINEDTEXT << "{" << endl;
(*Cout()) << " /textstring exch def % text to edit" << endl;
(*Cout()) << " /textangle exch def % text angle" << endl;
(*Cout()) << " /textattrib exch def % text attrib" << endl;
(*Cout()) << " /fontsize exch def % font size" << endl;
(*Cout()) << " gsave" << endl;
(*Cout()) << " gsave % get text bounding box" << endl;
(*Cout()) << " 0 0 moveto" << endl;
(*Cout()) << " textstring false charpath pathbbox" << endl;
(*Cout()) << " /tymax exch def /txmax exch def /tymin exch def /txmin exch def" << endl;
(*Cout()) << " grestore" << endl;
(*Cout()) << " /twidth txmax txmin sub def % set text width" << endl;
(*Cout()) << " /theight tymax tymin sub def % set text height" << endl;
(*Cout()) << " /umargin fontsize UnderLine def" << endl;
(*Cout()) << " textangle rotate % rotate the text" << endl;
(*Cout()) << " currentpoint /ytext exch def /xtext exch def % get text position" << endl;
(*Cout()) << " theight 32 div setlinewidth" << endl;
(*Cout()) << " textstring textattrib cvx exec % draw text" << endl;
(*Cout()) << " xtext ytext moveto 0 umargin rmoveto twidth 0 rlineto stroke % draw underline" << endl;
(*Cout()) << " grestore" << endl;
(*Cout()) << "} bind def" << endl;
(*Cout()) << "/" << SCALEFONT << "{" << endl;
(*Cout()) << "% Adjust font scale depending of the baseline position" << endl;
(*Cout()) << " /size exch def" << endl;
(*Cout()) << " /ratio 1. def" << endl;
(*Cout()) << " currentfont /FontBBox known {" << endl;
(*Cout()) << " currentfont /FontBBox get dup" << endl;
(*Cout()) << " 1 get /ymin exch def" << endl;
(*Cout()) << " 3 get /ymax exch def" << endl;
(*Cout()) << " ymax ymin sub ymax div /ratio exch def" << endl;
(*Cout()) << " 0 0 moveto" << endl;
(*Cout()) << " (H) false charpath pathbbox /hmax exch def" << endl;
(*Cout()) << " 0 0 moveto" << endl;
(*Cout()) << " ($) false charpath pathbbox /dmax exch def" << endl;
(*Cout()) << " ratio hmax mul dmax div /ratio exch def" << endl;
(*Cout()) << " } if" << endl;
(*Cout()) << " currentfont ratio size mul scalefont setfont" << endl;
(*Cout()) << "} bind def" << endl;
(*Cout()) << "/" << SCALEDRAWING << "{" << endl;
(*Cout()) << "% Adjust drawing size depending of paper size" << endl;
(*Cout()) << " /DrawHeight exch Centimeter def" << endl;
(*Cout()) << " /DrawWidth exch Centimeter def" << endl;
(*Cout()) << " /DrawScale 1 def" << endl;
(*Cout()) << " /NewPaperMargin PaperMargin def" << endl;
#ifdef CSR862
(*Cout()) << " /NewDrawWidth DrawWidth def" << endl;
(*Cout()) << " /NewDrawHeight DrawHeight def" << endl;
#else
(*Cout()) << " /NewDrawWidth DrawHeight def" << endl;
(*Cout()) << " /NewDrawHeight DrawWidth def" << endl;
#endif
(*Cout()) << " /NewPaperWidth PaperWidth 2 PaperMargin mul sub def" << endl;
(*Cout()) << " /NewPaperHeight PaperHeight 2 PaperMargin mul sub def" << endl;
(*Cout()) << " /Helvetica-BoldOblique findfont 10 scalefont setfont" << endl ;
(*Cout()) << " /Tampon 20 string def" << endl;
(*Cout()) << " DrawWidth DrawHeight gt PaperRotateIfPossible and {" << endl;
(*Cout()) << " NewDrawWidth NewPaperWidth gt {" << endl;
(*Cout()) << " /DrawScale NewPaperWidth NewDrawWidth div def" << endl;
(*Cout()) << " /NewDrawWidth NewDrawWidth DrawScale mul def" << endl;
(*Cout()) << " /NewDrawHeight NewDrawHeight DrawScale mul def" << endl;
(*Cout()) << " } if" << endl;
(*Cout()) << " NewDrawHeight NewPaperHeight gt {" << endl;
(*Cout()) << " /DrawScale NewPaperHeight NewDrawHeight div DrawScale mul def" << endl;
(*Cout()) << " /NewDrawWidth NewDrawWidth DrawScale mul def" << endl;
(*Cout()) << " /NewDrawHeight NewDrawHeight DrawScale mul def" << endl;
(*Cout()) << " } if" << endl;
(*Cout()) << " DrawScale 1. lt {" << endl;
(*Cout()) << " NewPaperMargin 0 M (Scale : ) show DrawScale Tampon cvs show" << endl;
(*Cout()) << " } if" << endl;
#ifdef CSR862
(*Cout()) << " NewDrawWidth 2 div NewDrawHeight 2 div translate" << endl;
#else
(*Cout()) << " {" << endl;
(*Cout()) << " /NewPaperMargin PaperMargin def" << endl;
(*Cout()) << " /NewPaperWidth PaperWidth def" << endl;
(*Cout()) << " /NewPaperHeight PaperHeight def" << endl;
(*Cout()) << " } ifelse" << endl;
#endif
(*Cout()) << " 90 rotate" << endl;
#ifdef CSR862
(*Cout()) << " NewDrawHeight neg 2 div NewPaperMargin add NewDrawWidth 2 div NewPaperHeight sub NewPaperMargin sub translate" << endl;
#else
(*Cout()) << " PaperMargin NewDrawWidth PaperMargin add neg translate" << endl;
#endif
(*Cout()) << " }{" << endl;
#ifdef CSR862
(*Cout()) << " NewDrawWidth NewPaperHeight gt {" << endl;
(*Cout()) << " /DrawScale NewPaperHeight NewDrawWidth div def" << endl;
#else
(*Cout()) << " NewDrawHeight NewPaperHeight gt {" << endl;
(*Cout()) << " /DrawScale NewPaperHeight NewDrawHeight div def" << endl;
#endif
(*Cout()) << " /NewDrawWidth NewDrawWidth DrawScale mul def" << endl;
(*Cout()) << " /NewDrawHeight NewDrawHeight DrawScale mul def" << endl;
(*Cout()) << " } if" << endl;
#ifdef CSR862
(*Cout()) << " NewDrawHeight NewPaperWidth gt {" << endl;
(*Cout()) << " /DrawScale NewPaperWidth NewDrawHeight div DrawScale mul def" << endl;
#else
(*Cout()) << " NewDrawWidth NewPaperWidth gt {" << endl;
(*Cout()) << " /DrawScale NewPaperWidth NewDrawWidth div DrawScale mul def" << endl;
#endif
(*Cout()) << " /NewDrawWidth NewDrawWidth DrawScale mul def" << endl;
(*Cout()) << " /NewDrawHeight NewDrawHeight DrawScale mul def" << endl;
(*Cout()) << " } if" << endl;
(*Cout()) << " DrawScale 1. lt {" << endl;
(*Cout()) << " NewPaperMargin 0 M (Scale : ) show DrawScale Tampon cvs show" << endl;
(*Cout()) << " } {" << endl;
(*Cout()) << " /NewPaperMargin PaperMargin def" << endl;
(*Cout()) << " /NewPaperWidth PaperWidth def" << endl;
(*Cout()) << " /NewPaperHeight PaperHeight def" << endl;
(*Cout()) << " } ifelse" << endl;
(*Cout()) << " NewPaperMargin NewPaperMargin translate" << endl;
(*Cout()) << " } ifelse" << endl;
(*Cout()) << "% set scale" << endl;
(*Cout()) << " DrawScale DrawScale scale" << endl;
(*Cout()) << "% Draw frame and set clip path" << endl;
(*Cout()) << " 0 0 M 0 DrawHeight L DrawWidth DrawHeight L DrawWidth 0 L 0 0 L ST" << endl;
(*Cout()) << " NP 0 0 M 0 DrawHeight L DrawWidth DrawHeight L DrawWidth 0 L 0 0 L CLP clip NP" << endl;
#ifdef BUC60772
(*Cout()) << " 2 setlinejoin" << endl;
#endif
(*Cout()) << "} bind def" << endl;
myCurrentPage = 0;
}
//==========================================================================
void PS_Driver::BeginDraw ()
{
// Text management
myTextManager = new PlotMgt_TextManager(this);
if (myCurrentPage <= 0) {
(*Cout()) << "%%BeginSetup" << endl;
myCurrentPage = 1;
}
(*Cout()) << "%%Page: " << myCurrentPage << endl;
(*Cout()) << "GS " << TOCENTIMETER(myWidth) << " "
<< TOCENTIMETER(myHeight) << " " << SCALEDRAWING << endl;
}
//==========================================================================
void PS_Driver::EndDraw (const Standard_Boolean dontFlush)
{
(*Cout ()) << " showpage" << endl;
(*Cout ()) << " GR" << endl;
if (!dontFlush)
(*Cout ()) << flush;
myCurrentPage++;
myImage.Nullify ();
}
//==========================================================================
void PS_Driver::InitializeColorMap (const Handle(Aspect_ColorMap)& aColorMap)
{
Standard_Real r,g,b;
Standard_Integer index,Size = aColorMap->Size();
Aspect_ColorMapEntry entry ;
Quantity_Color color ;
if (myTypeOfColorSpace == Aspect_TOCS_GreyScale)
(*Cout()) << "/CB {1 setgray} BD" << endl;
else
(*Cout()) << "/CB {1 1 1 setrgbcolor} BD" << endl;
for (Standard_Integer i=1; i<= Size; i++) {
entry = aColorMap->Entry(i);
index = entry.Index();
color = entry.Color();
color.Values (r, g, b, Quantity_TOC_RGB);
if (myTypeOfColorSpace == Aspect_TOCS_GreyScale)
(*Cout()) << "/C" << index << " {" << (r + g + b)/3. << " setgray} BD" << endl;
else if (myTypeOfColorSpace == Aspect_TOCS_BlackAndWhite)
(*Cout()) << "/C" << index << " {0 0 0 setrgbcolor} BD" << endl;
else
(*Cout()) << "/C" << index << " {" << r << " " << g << " "
<< b << " setrgbcolor} BD" << endl;
}
if (myTypeOfColorSpace == Aspect_TOCS_BlackAndWhite)
myTypeOfColorSpace = Aspect_TOCS_RGB;
}
//==========================================================================
void PS_Driver::InitializeTypeMap (const Handle(Aspect_TypeMap)& aTypeMap)
{
Standard_Integer Size = aTypeMap->Size();
Aspect_LineStyle aStyle;
for (Standard_Integer i=1; i<= Size; i++) {
(*Cout()) << "/D" << aTypeMap->Entry(i).Index() << " {[";
aStyle = aTypeMap->Entry(i).Type();
for (Standard_Integer j = aStyle.Values().Lower(); j < aStyle.Values().Upper(); j += 2)
(*Cout()) << Standard_Real(Convert(aStyle.Values().Value(j ))) << " "
<< Standard_Real(Convert(aStyle.Values().Value(j+1))) << " ";
(*Cout()) << "] 0 setdash} BD" << endl;
}
}
//==========================================================================
void PS_Driver::InitializeWidthMap (const Handle(Aspect_WidthMap)& aWidthMap)
{
Standard_Integer Size = aWidthMap->Size();
for (Standard_Integer i=1; i<= Size; i++) {
Standard_Real w = aWidthMap->Entry(i).Width() / myPixelSize;
(*Cout()) << "/W" << aWidthMap->Entry(i).Index() << " {"
<< w << " setlinewidth} BD" << endl;
}
}
//==========================================================================
void PS_Driver::InitializeFontMap (const Handle(Aspect_FontMap)& aFontMap)
{
#ifdef BUC60766
PlotMgt_PlotterDriver::InitializeFontMap (aFontMap);
#else
if (UseMFT()) {
PlotMgt_PlotterDriver::InitializeFontMap (aFontMap);
} else
#endif
{
Aspect_FontMapEntry entry;
Standard_Integer index, iindex;
TCollection_AsciiString aname;
Aspect_FontStyle style;
Standard_Boolean theCapsHeight;
Quantity_Length theFontSize;
Standard_ShortReal fsize;
for (index = 1; index <= aFontMap->Size(); index++) {
entry = aFontMap->Entry(index);
iindex = entry.Index();
style = entry.Type();
theFontSize = TOMILLIMETER(style.Size());
aname = style.AliasName();
theCapsHeight = style.CapsHeight();
fsize = theFontSize;
if (fsize > 0.0001)
fsize = Convert(fsize);
else fsize = 1.;
(*Cout()) << "/F" << iindex;
(*Cout()) << " {/scf exch def /mat exch def" << endl;
if (!aname.Length() || (aname == "Default") || (aname == "Defaultfont"))
aname = "Courier";
(*Cout()) << "/" << aname << " findfont mat makefont ";
if (theCapsHeight) (*Cout()) << "setfont scf " << SCALEFONT << "} BD " << endl;
else (*Cout()) << "scf scalefont setfont} BD " << endl;
(*Cout()) << "/FSZ" << iindex << " " << Standard_Real(fsize) << " def" << endl;
}
}
}
//==========================================================================
void PS_Driver::InitializeMarkMap (const Handle(Aspect_MarkMap)& aMarkMap)
{
Standard_Integer i,j,n,sl,np,Size = aMarkMap->Size();
Standard_Real dx,dy,x,y;
Standard_Boolean fl;
for (i = 1; i <= Size; i++) {
const TShort_Array1OfShortReal& amx = aMarkMap->Entry(i).Style().XValues();
const TShort_Array1OfShortReal& amy = aMarkMap->Entry(i).Style().YValues();
const TColStd_Array1OfBoolean& ams = aMarkMap->Entry(i).Style().SValues();
(*Cout()) << "/MRK" << aMarkMap->Entry(i).Index() << " {" << endl;
x = y = 0.;
sl = amx.Lower();
np = 0;
fl = Standard_True;
for (n=1, j=sl; j <= amx.Upper(); j++, n++) {
dx = amx(j) - x;
dy = amy(j) - y;
x = amx(j);
y = amy(j);
(*Cout()) << dx << " " << dy << " ";
if (ams(j)) {
if (fl) np++;
(*Cout()) << RLINETO;
} else {
if (np) fl = Standard_False;
else sl = j;
(*Cout()) << RMOVETO;
}
if (!(n % 4)) (*Cout()) << endl;
}
(*Cout()) << "} BD" << endl;
(*Cout()) << "/FRMK" << aMarkMap->Entry(i).Index() << " {" << endl;
if (np > 1) {
x = y = 0.;
for (n=1, j=sl; j <= sl+np; j++, n++) {
dx = amx(j) - x;
dy = amy(j) - y;
x = amx(j);
y = amy(j);
(*Cout()) << dx << " " << dy << " ";
if( ams(j) ) {
(*Cout()) << RLINETO;
} else {
(*Cout()) << RMOVETO;
}
if (!(n % 4))
(*Cout()) << endl;
}
(*Cout()) << CLOSEPATH;
}
(*Cout()) << "} BD " << endl;
}
}
//==========================================================================
// Category: Methods to set the attributes
//==========================================================================
void PS_Driver::SetTextAttrib (const Standard_Integer ColorIndex,
const Standard_Integer FontIndex)
{
PlotMgt_PlotterDriver::SetTextAttrib (ColorIndex, FontIndex);
#ifndef BUC60766
if (!UseMFT())
#endif
(*Cout()) << " [1 0 0 1 0 0 ] FSZ" << FontIndex << " F" << FontIndex << " ";
}
//==========================================================================
void PS_Driver::SetTextAttrib (const Standard_Integer ColorIndex,
const Standard_Integer FontIndex,
const Quantity_PlaneAngle aSlant,
const Quantity_Factor aHScale,
const Standard_Real aWScale,
const Standard_Boolean isUnderlined)
{
PlotMgt_PlotterDriver::SetTextAttrib (
ColorIndex, FontIndex, aSlant, aHScale, aWScale, isUnderlined);
#ifndef BUC60766
if (!UseMFT())
#endif
(*Cout()) << " [" << myTextWScale << " 0 " << Sin(aSlant)*myTextHScale
<< " " << Cos(aSlant)*myTextHScale << " 0 0] FSZ" << FontIndex
<< " F" << FontIndex << " ";
}
//==========================================================================
// Image methods
//==========================================================================
Standard_Boolean PS_Driver::SizeOfImageFile(const Standard_CString anImageFile,
Standard_Integer &aWidth,
Standard_Integer &aHeight) const
{
return AlienImage::LoadImageFile (anImageFile, myImage, aWidth, aHeight);
}
//==========================================================================
Standard_Boolean PS_Driver::PlotImage (const Standard_ShortReal aX,
const Standard_ShortReal aY,
const Standard_ShortReal aWidth,
const Standard_ShortReal aHeight,
const Standard_ShortReal aScale,
const Standard_CString anImageFile,
const Standard_Address anArrayOfPixels,
const Standard_Integer aLineIndex)
{
Standard_Integer LowX = 0, LowY = 0;
Standard_Integer width = Standard_Integer(aWidth),
height = Standard_Integer(aHeight);
Standard_Boolean status;
Aspect_RGBPixel* g2dp = (Aspect_RGBPixel*) anArrayOfPixels;
// Load image if necessary
if (anImageFile) {
status = SizeOfImageFile (anImageFile, width, height);
if (status) {
LowX = myImage -> LowerX ();
LowY = myImage -> LowerY ();
}
} else {
status = Standard_True;
}
// Draw the image
if (status) {
Quantity_Color color;
Standard_Real r, g, b;
Standard_Integer n=0,x,y,red,green,blue;
Standard_ShortReal wscale, hscale;
wscale = hscale = aScale * myPixelSize * PPI;
if (aLineIndex == -1) {
(*Cout()) << " " << GSAVE << MapX(aX) - wscale*width/2. << " "
<< MapY(aY) - hscale*height/2.;
} else {
(*Cout()) << " " << GSAVE << MapX(aX) - wscale*width/2. << " "
<< MapY(aY) + hscale*(height/2. - aLineIndex);
height = 1;
}
(*Cout()) << " translate " << wscale*width << " " << hscale*height << " scale ";
(*Cout()) << width << " " << height << " 8 [" << width
<< " 0 0 " << -height << " 0 " << height
<< "] {currentfile IB readhexstring pop} false 3 colorimage " << endl;
Standard_Integer r1, r2, g1, g2, b1, b2;
char hstring[7];
for (y=0; y < height; y++) {
for (x=n=0; x < width; x++) {
if (anImageFile) {
color = myImage -> PixelColor (x + LowX, y + LowY);
color.Values (r, g, b, Quantity_TOC_RGB);
} else {
r = g2dp -> red;
g = g2dp -> green;
b = g2dp -> blue;
g2dp++;
}
red = (int)(r * 255.);
green = (int)(g * 255.);
blue = (int)(b * 255.);
if (anImageFile) {
r1 = (red >> 4) & 0xF; r2 = red & 0xF;
g1 = (green >> 4) & 0xF; g2 = green & 0xF;
b1 = (blue >> 4) & 0xF; b2 = blue & 0xF;
} else {
r1 = red >> 4; r2 = red & 0xF;
g1 = green >> 4; g2 = green & 0xF;
b1 = blue >> 4; b2 = blue & 0xF;
}
sprintf(hstring, "%X%X%X%X%X%X", r1, r2, g1, g2, b1, b2);
(*Cout()) << hstring;
n += 3;
if (n >= IMAGEBUFFERSIZE) {
n = 0;
(*Cout()) << endl;
}
}
}
if (n > 0) {
while (n < IMAGEBUFFERSIZE) {
(*Cout()) << "00"; n++;
}
}
(*Cout()) << endl;
(*Cout()) << " " << GRESTORE << endl;
return Standard_True;
}
return Standard_False;
}
//=============================================================
// Category: Methods to write attributes
//=============================================================
void PS_Driver::PlotLineAttrib (const Standard_Integer ColorIndex,
const Standard_Integer TypeIndex,
const Standard_Integer WidthIndex)
{
if ((myColorIndex != ColorIndex) &&
(myTypeOfColorSpace != Aspect_TOCS_BlackAndWhite)) {
myColorIndex = ColorIndex;
(*Cout()) << " C" << myColorIndex << " ";
}
if (myTypeIndex != TypeIndex) {
myTypeIndex = TypeIndex;
(*Cout()) << " D" << myTypeIndex << " ";
}
if (myWidthIndex != WidthIndex) {
myWidthIndex = WidthIndex;
(*Cout()) << " W" << myWidthIndex << " ";
}
}
//=============================================================
// Category: Methods to draw primitives
//=============================================================
//=============================================================
Standard_Boolean PS_Driver::PlotPoint (const Standard_ShortReal X,
const Standard_ShortReal Y)
{
(*Cout()) << X << " " << Y << " " << MOVETO << " "
<< X << " " << Y << " " << LINETO << " "
<< STROKE << endl;
return Standard_True;
}
//=============================================================
Standard_Boolean PS_Driver::PlotSegment (const Standard_ShortReal X1,
const Standard_ShortReal Y1,
const Standard_ShortReal X2,
const Standard_ShortReal Y2)
{
(*Cout()) << X1 << " " << Y1 << " " << MOVETO << " "
<< X2 << " " << Y2 << " " << LINETO << " "
<< STROKE << endl;
return Standard_True;
}
//=============================================================
#define _XP(idx) ((float*)xArray)[(idx)]
#define _YP(idx) ((float*)yArray)[(idx)]
//=============================================================
Standard_Boolean PS_Driver::PlotPolyline (const Standard_Address xArray,
const Standard_Address yArray,
const Standard_Address nPts,
const Standard_Integer nParts)
{
// Multipart drawing can only be used for text drawing
// (called from PlotMgt_TextManager::EndChar ()
int N, cpN, i, j;
for (N = 0, i = 0; i < nParts; i++) {
cpN = ((int*)nPts)[i];
(*Cout()) << _XP(N) << " " << _YP(N) << " " << MOVETO;
for (j = N + 1; j < N + cpN; j++)
(*Cout()) << _XP(j) << " " << _YP(j) << " " << LINETO;
(*Cout()) << " " << STROKE << endl;
N += cpN;
}
return Standard_True;
}
//=============================================================
Standard_Boolean PS_Driver::PlotPolygon (const Standard_Address xArray,
const Standard_Address yArray,
const Standard_Address nPts,
const Standard_Integer nParts)
{
Standard_Integer i;
if (nParts == 1) {
if (myPolyTileIndex >= 0) {
PLOT_PCOLOR (myPolyColorIndex);
(*Cout()) << _XP(0) << " " << _YP(0) << " " << MOVETO;
for (i = 1; i < ((int*)nPts)[0]; i++)
(*Cout()) << _XP(i) << " " << _YP(i) << " " << LINETO;
(*Cout()) << CLOSEPATH << FILL << endl;
if (myPolyEdgeFlag) {
POLYLN1:
PlotLineAttrib (myLineColorIndex, myLineTypeIndex, myLineWidthIndex);
PlotPolyline (xArray, yArray, nPts, nParts);
}
} else
goto POLYLN1;
} else {
// This can only be used for text drawing
// (called from PlotMgt_TextManager::EndChar ()
PLOT_PCOLOR (myPolyColorIndex);
int N, cpN, j;
for (N = 0, i = 0; i < nParts; i++) {
cpN = ((int*)nPts)[i];
(*Cout()) << _XP(N) << " " << _YP(N) << " " << MOVETO;
for (j = N + 1; j < N + cpN; j++)
(*Cout()) << _XP(j) << " " << _YP(j) << " " << LINETO;
(*Cout()) << CLOSEPATH << endl;
N += cpN;
}
if (myPolyTileIndex == -1) (*Cout()) << STROKE << endl;
else (*Cout()) << FILL << endl;
}
return Standard_True;
}
//=============================================================
#undef _XP
#undef _YP
//=============================================================
Standard_Boolean PS_Driver::PlotArc (const Standard_ShortReal Xpos,
const Standard_ShortReal Ypos,
const Standard_ShortReal aXradius,
const Standard_ShortReal aYradius,
const Standard_ShortReal sAngle,
const Standard_ShortReal oAngle)
{
Standard_Real san = sAngle;
Standard_Real fan = sAngle + oAngle;
if (Abs(aXradius-aYradius) <= 1.) {
(*Cout()) << Xpos + aXradius*Cos(san) << " "
<< Ypos + aYradius*Sin(san) << " " << MOVETO;
(*Cout()) << GSAVE << Xpos << " " << Ypos << " " << aXradius << " ";
if (Abs(fan)-Abs(san) >= 2.*PI) {
(*Cout()) << " 0 360 " << ARC << STROKE << GRESTORE << endl;
} else {
Standard_Real a1 = san/DRAD;
Standard_Real a2 = fan/DRAD;
(*Cout()) << a1 << " " << a2 << " " << ARC << STROKE << GRESTORE << endl;
}
return Standard_True;
}
return Standard_False;
}
//=============================================================
Standard_Boolean PS_Driver::PlotPolyArc (const Standard_ShortReal Xpos,
const Standard_ShortReal Ypos,
const Standard_ShortReal aXradius,
const Standard_ShortReal aYradius,
const Standard_ShortReal sAngle,
const Standard_ShortReal oAngle)
{
Standard_Real san = sAngle;
Standard_Real fan = sAngle + oAngle;
if (Abs(aXradius-aYradius) <= 1.) {
PLOT_PCOLOR (myPolyColorIndex);
if (Abs(oAngle) < 2.*PI)
(*Cout()) << Xpos << " " << Ypos << " " << MOVETO;
else
(*Cout()) << Xpos + aXradius*Cos(san) << " "
<< Ypos + aXradius*Sin(san) << " " << MOVETO;
(*Cout()) << GSAVE << Xpos << " " << Ypos << " " << aXradius << " ";
if (Abs(fan) - Abs(san) >= 2.*PI) {
(*Cout()) << " 0 360 " << ARC << FILL << GRESTORE << endl;
} else {
Standard_Real a1 = san/DRAD;
Standard_Real a2 = fan/DRAD;
(*Cout()) << a1 << " " << a2 << " " << ARC << FILL << GRESTORE << endl;
}
if (myPolyEdgeFlag) {
PlotLineAttrib (myLineColorIndex, myLineTypeIndex, myLineWidthIndex);
return PlotArc (Xpos, Ypos, aXradius, aYradius, sAngle, oAngle);
}
return Standard_True;
}
return Standard_False;
}
//=============================================================
Standard_Boolean PS_Driver::PlotMarker (const Standard_Integer aMarker,
const Standard_ShortReal Xpos,
const Standard_ShortReal Ypos,
const Standard_ShortReal Width,
const Standard_ShortReal Height,
const Standard_ShortReal Angle)
{
Standard_Real w = Convert(Width/2.);
Standard_Real h = Convert(Height/2.);
Standard_Real a = Angle/DRAD;
if (aMarker >= 0 && w > 0. && h > 0.) {
while (a > 360.) a -= 360.;
while (a < -360.) a += 360.;
if (myMarkerFillFlag) {
PlotLineAttrib (myPolyColorIndex, myLineTypeIndex, myLineWidthIndex);
(*Cout()) << GSAVE << Xpos << " " << Ypos << " " << MOVETO;
if (Angle != 0.)
(*Cout()) << a << " " << ROTATE;
(*Cout()) << w << " " << h << " " << SCALE << "FRMK"
<< aMarker << " " << FILL << GRESTORE << endl;
}
PlotLineAttrib (myMarkerColorIndex, 0, myMarkerWidthIndex);
(*Cout()) << GSAVE << Xpos << " " << Ypos << " " << MOVETO;
if (Angle != 0.)
(*Cout()) << a << " " << ROTATE;
(*Cout()) << w << " " << h << " " << SCALE << " MRK" << aMarker << " "
<< 1./w << " " << 1./h << " " << SCALE << STROKE << GRESTORE << endl;
} else {
DrawPoint (Xpos,Ypos);
}
return Standard_True;
}
//=============================================================
Standard_Boolean PS_Driver::PlotText (const TCollection_ExtendedString& aText,
const Standard_ShortReal Xpos,
const Standard_ShortReal Ypos,
const Standard_ShortReal Angle,
const Aspect_TypeOfText aType)
{
if( aText.IsAscii() ) {
TCollection_AsciiString atext(aText,'?');
PlotText(atext.ToCString(),Xpos,Ypos,Angle,aType);
} else {
#ifdef BUC60766
return Standard_False; // Use MFT fonts
#else
Standard_CString ptext = Aspect::ToCString(aText);
Standard_Real a = Angle/DRAD;
Standard_Integer i,h1,h2;
char hstring[3];
while (a > 360.) a -= 360.;
while (a < -360.) a += 360.;
PLOT_PCOLOR (myTextColorIndex);
if (myTextIsUnderlined) {
(*Cout()) << MapX(Xpos) << " " << MapY(Ypos) << " " << MOVETO;
(*Cout()) << "FSZ" << myFontIndex << " " << myTextHScale << " mul (";
(*Cout()) << "C" << myTextColorIndex;
if (aType == Aspect_TOT_OUTLINE) (*Cout()) << " true " << CHARPATH << STROKE << ") ";
else (*Cout()) << " " << SHOW << ") ";
(*Cout()) << a << "<";
for (i=0; i<strlen(ptext); i++) {
h1 = (ptext[i] >> 4) & 0xF; h2 = ptext[i] & 0xF;
sprintf(hstring,"%X%X",h1,h2);
(*Cout()) << hstring;
}
(*Cout()) << "> " << SHOWUNDERLINEDTEXT << endl;
} else {
if (Angle == 0.) (*Cout()) << MapX(Xpos) << " " << MapY(Ypos) << " " << MOVETO;
else (*Cout()) << GSAVE << MapX(Xpos) << " " << MapY(Ypos) << " " << MOVETO
<< a << " " << ROTATE;
(*Cout()) << "<";
for (i=0; i<strlen(ptext); i++) {
h1 = (ptext[i] >> 4) & 0xF; h2 = ptext[i] & 0xF;
sprintf(hstring,"%X%X",h1,h2);
(*Cout()) << hstring;
}
(*Cout()) << "> ";
if (aType == Aspect_TOT_OUTLINE) (*Cout()) << "true " << CHARPATH << STROKE;
else (*Cout()) << SHOW;
if (Angle == 0.) (*Cout()) << endl;
else (*Cout()) << GRESTORE << endl;
}
return Standard_True;
#endif
}
return Standard_False;
}
//=============================================================
Standard_Boolean PS_Driver::PlotText (const Standard_CString aText,
const Standard_ShortReal Xpos,
const Standard_ShortReal Ypos,
const Standard_ShortReal Angle,
const Aspect_TypeOfText aType)
{
#ifdef BUC60766
{
Standard_Real a = Angle/DRAD;
while (a > 360.) a -= 360.;
while (a < -360.) a += 360.;
PLOT_PCOLOR (myTextColorIndex);
if (myTextIsUnderlined) {
(*Cout()) << MapX(Xpos) << " " << MapY(Ypos) << " " << MOVETO;
(*Cout()) << "FSZ" << myFontIndex << " " << myTextHScale << " mul (";
(*Cout()) << "C" << myTextColorIndex;
if (aType == Aspect_TOT_OUTLINE) (*Cout()) << " true " << CHARPATH << STROKE << ") ";
else (*Cout()) << " " << SHOW << ") ";
(*Cout()) << a << " (" << aText << ") " << SHOWUNDERLINEDTEXT << endl;
} else {
if (Angle == 0.) (*Cout()) << MapX(Xpos) << " " << MapY(Ypos) << " " << MOVETO;
else (*Cout()) << GSAVE << MapX(Xpos) << " " << MapY(Ypos) << " " << MOVETO
<< a << " " << ROTATE;
(*Cout()) << "(" << aText << ") ";
if (aType == Aspect_TOT_OUTLINE) (*Cout()) << "true " << CHARPATH << STROKE;
else (*Cout()) << SHOW;
if (Angle == 0.) (*Cout()) << endl;
else (*Cout()) << GRESTORE << endl;
}
return Standard_True;
}
#else
return Standard_False;
#endif
}
//=============================================================
Standard_Boolean PS_Driver::PlotPolyText (const TCollection_ExtendedString& aText,
const Standard_ShortReal Xpos,
const Standard_ShortReal Ypos,
const Quantity_Factor aMargin,
const Standard_ShortReal Angle,
const Aspect_TypeOfText aType)
{
if( aText.IsAscii() ) {
TCollection_AsciiString atext(aText,'?');
PlotPolyText(atext.ToCString(),Xpos,Ypos,aMargin,Angle,aType);
} else {
#ifdef BUC60766
return Standard_False;
#else
Standard_Real a = Angle/DRAD;
while( a > 360. ) a -= 360.;
while( a < -360. ) a += 360.;
(*Cout()) << MapX(Xpos) << " " << MapY(Ypos) << " " << MOVETO;
{
Standard_CString ptext = Aspect::ToCString(aText);
Standard_Integer i,h1,h2;
char hstring[3];
if( myTypeOfColorSpace != Aspect_TOCS_BlackAndWhite ) {
if( myLineColorIndex > 0 && myPolyEdgeFlag) {
(*Cout()) << "(C" << myLineColorIndex;
} else {
(*Cout()) << "(CB";
}
(*Cout()) << " W" << myLineWidthIndex << ")";
if( myPolyTileIndex >= 0 ) {
if( myPolyColorIndex > 0 ) {
(*Cout()) << "(C" << myPolyColorIndex << ")";
} else {
(*Cout()) << "(CB)";
}
}
(*Cout()) << " FSZ" << myFontIndex << " " << myTextHScale << " mul ";
if( myTextColorIndex > 0 ) {
(*Cout()) << "(C" << myTextColorIndex;
} else {
(*Cout()) << "(CB";
}
} else {
if( myPolyTileIndex >= 0 ) {
(*Cout()) << "(W" << myLineWidthIndex << ") ()";
} else {
(*Cout()) << "(W" << myLineWidthIndex << ")";
}
(*Cout()) << " FSZ" << myFontIndex << " " << myTextHScale << " mul (";
}
if( aType == Aspect_TOT_OUTLINE ) {
(*Cout()) << " true " << CHARPATH << STROKE << ") ";
} else {
(*Cout()) << " " << SHOW << ") ";
}
(*Cout()) << aMargin << " " << a;
if( myTextIsUnderlined ) (*Cout()) << " true <";
else (*Cout()) << " false <";
for( i=0 ; i<strlen(ptext) ; i++ ) {
h1 = (ptext[i] >> 4) & 0xF; h2 = ptext[i] & 0xF;
sprintf(hstring,"%X%X",h1,h2);
(*Cout()) << hstring;
}
if( myPolyTileIndex >= 0 && myTypeOfColorSpace != Aspect_TOCS_BlackAndWhite ) {
(*Cout()) << "> " << SHOWHIDINGTEXT << endl;
} else {
(*Cout()) << "> " << SHOWFRAMEDTEXT << endl;
}
}
return Standard_True;
#endif
}
return Standard_False;
}
//=============================================================
Standard_Boolean PS_Driver::PlotPolyText (const Standard_CString aText,
const Standard_ShortReal Xpos,
const Standard_ShortReal Ypos,
const Quantity_Factor aMargin,
const Standard_ShortReal Angle,
const Aspect_TypeOfText aType)
{
#ifdef BUC60766
Standard_Real a = Angle/DRAD;
while( a > 360. ) a -= 360.;
while( a < -360. ) a += 360.;
(*Cout()) << MapX(Xpos) << " " << MapY(Ypos) << " " << MOVETO;
{
if( myTypeOfColorSpace != Aspect_TOCS_BlackAndWhite ) {
if( myLineColorIndex > 0 && myPolyEdgeFlag) {
(*Cout()) << "(C" << myLineColorIndex;
} else {
(*Cout()) << "(CB";
}
(*Cout()) << " W" << myLineWidthIndex << ")";
if( myPolyTileIndex >= 0 ) {
if( myPolyColorIndex > 0 ) {
(*Cout()) << "(C" << myPolyColorIndex << ")";
} else {
(*Cout()) << "(CB)";
}
}
(*Cout()) << " FSZ" << myFontIndex << " " << myTextHScale << " mul ";
if( myTextColorIndex > 0 ) {
(*Cout()) << "(C" << myTextColorIndex;
} else {
(*Cout()) << "(CB";
}
} else {
if( myPolyTileIndex >= 0 ) {
(*Cout()) << "(W" << myLineWidthIndex << ") ()";
} else {
(*Cout()) << "(W" << myLineWidthIndex << ")";
}
(*Cout()) << " FSZ" << myFontIndex << " " << myTextHScale << " mul (";
}
if( aType == Aspect_TOT_OUTLINE ) {
(*Cout()) << " true " << CHARPATH << STROKE << ") ";
} else {
(*Cout()) << " " << SHOW << ") ";
}
(*Cout()) << aMargin << " " << a;
if( myTextIsUnderlined ) (*Cout()) << " true";
else (*Cout()) << " false";
if( myPolyTileIndex >= 0 && myTypeOfColorSpace != Aspect_TOCS_BlackAndWhite ) {
(*Cout()) << " (" << aText << ") " << SHOWHIDINGTEXT << endl;
} else {
(*Cout()) << " (" << aText << ") " << SHOWFRAMEDTEXT << endl;
}
}
return Standard_True;
#else
return Standard_False;
#endif
}
//=============================================================
Standard_ShortReal PS_Driver::Convert(const Standard_ShortReal aShortreal) const
{
return aShortreal * PPI;
}
//===============================================================================
Standard_Boolean PS_Driver::DrawCurveCapable () const
{
return Standard_False;
}
//=============================================================
Standard_ShortReal PS_Driver::MapX (const Standard_ShortReal aShortreal) const
{
return aShortreal * PPI;
}
//=============================================================
Standard_ShortReal PS_Driver::MapY (const Standard_ShortReal aShortreal) const
{
return aShortreal * PPI;
}
|