32 #import <Foundation/Foundation.h>
33 #import <AquaTerm/AQTAdapter.h>
43 #define AQT_Default_X 720
44 #define AQT_Default_Y 540
47 #define MAX_STRING_LEN 1000
74 #define AQT_N_FontLookup 30
76 {
PL_FCI_MARK | 0x000, (
unsigned char *)
"Helvetica" },
77 {
PL_FCI_MARK | 0x001, (
unsigned char *)
"Times-Roman" },
78 {
PL_FCI_MARK | 0x002, (
unsigned char *)
"Courier" },
79 {
PL_FCI_MARK | 0x003, (
unsigned char *)
"Times-Roman" },
80 {
PL_FCI_MARK | 0x004, (
unsigned char *)
"LucidaGrande Regular" },
81 {
PL_FCI_MARK | 0x010, (
unsigned char *)
"Helvetica-Oblique" },
82 {
PL_FCI_MARK | 0x011, (
unsigned char *)
"Times-Italic" },
83 {
PL_FCI_MARK | 0x012, (
unsigned char *)
"Courier-Oblique" },
84 {
PL_FCI_MARK | 0x013, (
unsigned char *)
"Times-Italic" },
85 {
PL_FCI_MARK | 0x014, (
unsigned char *)
"LucidaGrande Regular" },
86 {
PL_FCI_MARK | 0x020, (
unsigned char *)
"Helvetica-Oblique" },
87 {
PL_FCI_MARK | 0x021, (
unsigned char *)
"Times-Italic" },
88 {
PL_FCI_MARK | 0x022, (
unsigned char *)
"Courier-Oblique" },
89 {
PL_FCI_MARK | 0x023, (
unsigned char *)
"Times-Italic" },
90 {
PL_FCI_MARK | 0x024, (
unsigned char *)
"LucidaGrande Regular" },
91 {
PL_FCI_MARK | 0x100, (
unsigned char *)
"Helvetica-Bold" },
92 {
PL_FCI_MARK | 0x101, (
unsigned char *)
"Times-Bold" },
93 {
PL_FCI_MARK | 0x102, (
unsigned char *)
"Courier-Bold" },
94 {
PL_FCI_MARK | 0x103, (
unsigned char *)
"Times-Bold" },
95 {
PL_FCI_MARK | 0x104, (
unsigned char *)
"LucidaGrande Regular" },
96 {
PL_FCI_MARK | 0x110, (
unsigned char *)
"Helvetica-BoldOblique" },
97 {
PL_FCI_MARK | 0x111, (
unsigned char *)
"Times-BoldItalic" },
98 {
PL_FCI_MARK | 0x112, (
unsigned char *)
"Courier-BoldOblique" },
99 {
PL_FCI_MARK | 0x113, (
unsigned char *)
"Times-BoldItalic" },
100 {
PL_FCI_MARK | 0x114, (
unsigned char *)
"LucidaGrande Regular" },
101 {
PL_FCI_MARK | 0x120, (
unsigned char *)
"Helvetica-BoldOblique" },
102 {
PL_FCI_MARK | 0x121, (
unsigned char *)
"Times-BoldItalic" },
103 {
PL_FCI_MARK | 0x122, (
unsigned char *)
"Courier-BoldOblique" },
104 {
PL_FCI_MARK | 0x123, (
unsigned char *)
"Times-BoldItalic" },
105 {
PL_FCI_MARK | 0x124, (
unsigned char *)
"LucidaGrande Regular" }
133 "PLPLOT_FREETYPE_SANS_FONT",
134 "PLPLOT_FREETYPE_SERIF_FONT",
135 "PLPLOT_FREETYPE_MONO_FONT",
136 "PLPLOT_FREETYPE_SCRIPT_FONT",
137 "PLPLOT_FREETYPE_SYMBOL_FONT",
138 "PLPLOT_FREETYPE_SANS_ITALIC_FONT",
139 "PLPLOT_FREETYPE_SERIF_ITALIC_FONT",
140 "PLPLOT_FREETYPE_MONO_ITALIC_FONT",
141 "PLPLOT_FREETYPE_SCRIPT_ITALIC_FONT",
142 "PLPLOT_FREETYPE_SYMBOL_ITALIC_FONT",
143 "PLPLOT_FREETYPE_SANS_OBLIQUE_FONT",
144 "PLPLOT_FREETYPE_SERIF_OBLIQUE_FONT",
145 "PLPLOT_FREETYPE_MONO_OBLIQUE_FONT",
146 "PLPLOT_FREETYPE_SCRIPT_OBLIQUE_FONT",
147 "PLPLOT_FREETYPE_SYMBOL_OBLIQUE_FONT",
148 "PLPLOT_FREETYPE_SANS_BOLD_FONT",
149 "PLPLOT_FREETYPE_SERIF_BOLD_FONT",
150 "PLPLOT_FREETYPE_MONO_BOLD_FONT",
151 "PLPLOT_FREETYPE_SCRIPT_BOLD_FONT",
152 "PLPLOT_FREETYPE_SYMBOL_BOLD_FONT",
153 "PLPLOT_FREETYPE_SANS_BOLD_ITALIC_FONT",
154 "PLPLOT_FREETYPE_SERIF_BOLD_ITALIC_FONT",
155 "PLPLOT_FREETYPE_MONO_BOLD_ITALIC_FONT",
156 "PLPLOT_FREETYPE_SCRIPT_BOLD_ITALIC_FONT",
157 "PLPLOT_FREETYPE_SYMBOL_BOLD_ITALIC_FONT",
158 "PLPLOT_FREETYPE_SANS_BOLD_OBLIQUE_FONT",
159 "PLPLOT_FREETYPE_SERIF_BOLD_OBLIQUE_FONT",
160 "PLPLOT_FREETYPE_MONO_BOLD_OBLIQUE_FONT",
161 "PLPLOT_FREETYPE_SCRIPT_BOLD_OBLIQUE_FONT",
162 "PLPLOT_FREETYPE_SYMBOL_BOLD_OBLIQUE_FONT"
167 static inline void NOOP_(
id x, ... )
210 #ifndef ENABLE_DYNDRIVERS
236 arpool = [[NSAutoreleasePool alloc] init];
237 adapter = [[AQTAdapter alloc] init];
239 [
adapter setBackgroundColorRed : 0.5 green : 0.5 blue : 0.5];
287 hasShear = [
adapter respondsToSelector:
@selector( addLabel:atPoint:angle:shearAngle:align: )];
288 hasAlpha = [
adapter respondsToSelector:
@selector( setColorRed:green:blue:alpha: )];
308 green : (float) ( pls->
curcolor.
g / 255. )
309 blue : (float) ( pls->
curcolor.
b / 255. )
315 green : (float) ( pls->
curcolor.
g / 255. )
316 blue : (float) ( pls->
curcolor.
b / 255. )];
330 [
adapter moveToPoint : NSMakePoint( (
float) x1a *
SCALE, (
float) y1a * SCALE )];
331 [
adapter addLineToPoint : NSMakePoint( (
float) x2a * SCALE, (
float) y2a * SCALE )];
344 for ( i = 0; i < npts - 1; i++ )
345 plD_line_aqt( pls, xa[i], ya[i], xa[i + 1], ya[i + 1] );
358 arpool = [[NSAutoreleasePool alloc] init];
393 [
adapter setBackgroundColorRed : (float) ( plsc->cmap0[0].r / 255.0 )
394 green : (float) ( plsc->cmap0[0].g / 255.0 )
395 blue : (float) ( plsc->cmap0[0].b / 255.0 )
396 alpha : (float) ( plsc->cmap0[0].a )];
400 [
adapter setBackgroundColorRed : (float) ( plsc->cmap0[0].r / 255.0 )
401 green : (float) ( plsc->cmap0[0].g / 255.0 )
402 blue : (float) ( plsc->cmap0[0].b / 255.0 )];
409 green : (float) ( pls->
curcolor.
g / 255. )
410 blue : (float) ( pls->
curcolor.
b / 255. )
416 green : (float) ( pls->
curcolor.
g / 255. )
417 blue : (float) ( pls->
curcolor.
b / 255. )];
462 for ( i = 1; i < pls->
dev_npts; i++ )
495 int scanned, x, y, button;
500 temp = [
adapter waitNextEvent];
501 scanned = sscanf([temp cString],
"1:{%d, %d}:%d", &x, &y, &button );
513 printf(
"AquaTerm did not return a valid mouse location!\n" );
531 PLFLT a1, ft_ht, angle, shear, stride;
532 PLINT clxmin, clxmax, clymin, clymax;
534 NSMutableAttributedString *str;
540 printf(
"Non unicode string passed to AquaTerm driver, ignoring\n" );
548 printf(
"Sorry, the AquaTerm driver only handles strings of length < %d\n",
MAX_STRING_LEN );
554 ft_ht = 1.2 * pls->
chrht *
DPI / 25.4;
559 shear *= -180.0 /
PI;
563 if ( args->
just < 0.33 )
565 else if ( args->
just > 0.66 )
568 jst = AQTAlignCenter;
574 if ( args->
base == 2 )
576 else if ( args->
base == 1 )
577 ref = AQTAlignMiddle;
579 ref = AQTAlignMiddle;
590 green : (float) ( pls->
curcolor.
g / 255. )
591 blue : (float) ( pls->
curcolor.
b / 255. )
597 green : (float) ( pls->
curcolor.
g / 255. )
598 blue : (float) ( pls->
curcolor.
b / 255. )];
604 atPoint : NSMakePoint( (
float) args->
x *
SCALE, (
float) args->
y * SCALE )
607 align : ( jst | ref )];
612 atPoint : NSMakePoint( (
float) args->
x *
SCALE, (
float) args->
y * SCALE )
614 align : ( jst | ref )];
644 NSMutableAttributedString *str;
653 str = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithCString:dummy]];
668 while ( i < ucs4_len )
675 [str replaceCharactersInRange : NSMakeRange( cur_loc, 1 )
676 withString :[NSString stringWithUTF8String : utf8]];
685 [str replaceCharactersInRange : NSMakeRange( cur_loc, 1 )
686 withString :[NSString stringWithUTF8String : utf8]];
696 printf(
"hmm, unicode string apparently not following fci convention...\n" );
701 [str addAttribute : @
"NSSuperScript"
702 value :[NSNumber numberWithInt : updown]
703 range : NSMakeRange( cur_loc, ( MAX_STRING_LEN - cur_loc ) )];
708 [str addAttribute : @
"NSSuperScript"
709 value :[NSNumber numberWithInt : updown]
710 range : NSMakeRange( cur_loc, ( MAX_STRING_LEN - cur_loc ) )];
724 [str deleteCharactersInRange : NSMakeRange( cur_loc, ( MAX_STRING_LEN - cur_loc ) )];
745 printf(
"AquaTerm : Warning, could not find font given by fci = 0x%x\n", fci );
751 [str addAttribute : @
"AQTFontname"
752 value :[NSString stringWithCString : font]
754 [str addAttribute : @
"AQTFontsize"
755 value :[NSNumber numberWithFloat : font_height]
778 if ( ( new_font = getenv( aqt_font_env_names[i] ) ) != NULL )
786 begin = strrchr( new_font,
'/' );
787 end = strrchr( new_font,
'.' );
791 printf(
"Aquaterm : Warning, removing extension from font name : %s\n", new_font );
796 printf(
"AquaTerm : Warning, removing path from font name : %s\n", new_font );
797 new_font = begin + 1;
802 AQT_FontLookup[i].
pfont = (
unsigned char *) new_font;
void(* plD_line_fp)(struct PLStream_struct *, short, short, short, short)
void(* plD_eop_fp)(struct PLStream_struct *)
static NSAutoreleasePool * arpool
void(* plD_state_fp)(struct PLStream_struct *, PLINT)
void(* plD_tidy_fp)(struct PLStream_struct *)
NSMutableAttributedString * create_string(const PLUNICODE *, int, PLFLT)
int ucs4_to_utf8(PLUNICODE unichar, char *ptr)
void plGinInit(PLGraphicsIn *gin)
void plD_dispatch_init_aqt(PLDispatchTable *pdt)
void plD_esc_aqt(PLStream *, PLINT, void *)
static void NOOP_(id x,...)
void plD_polyline_aqt(PLStream *, short *, short *, PLINT)
void(* plD_polyline_fp)(struct PLStream_struct *, short *, short *, PLINT)
void(* plD_esc_fp)(struct PLStream_struct *, PLINT, void *)
static FCI_to_FontName_Table AQT_FontLookup[AQT_N_FontLookup]
const unsigned char * pfont
void plD_state_aqt(PLStream *, PLINT)
void(* plD_bop_fp)(struct PLStream_struct *)
void plD_tidy_aqt(PLStream *)
void plD_eop_aqt(PLStream *)
void plP_setpxl(PLFLT xpmm, PLFLT ypmm)
#define PLDLLIMPEXP_DRIVER
static PLStream * pls[PL_NSTREAMS]
void plP_setphy(PLINT xmin, PLINT xmax, PLINT ymin, PLINT ymax)
static void check_font_environment_variables(void)
void plRotationShear(PLFLT *xFormMatrix, PLFLT *rotation, PLFLT *shear, PLFLT *stride)
static void proc_str(PLStream *, EscText *)
unsigned short unicode_array_len
static PLFLT value(double n1, double n2, double hue)
PLCHAR_VECTOR plP_FCI2FontName(PLUNICODE fci, const FCI_to_FontName_Table lookup[], const int nlookup)
void plD_init_aqt(PLStream *)
static void set_font_and_size(NSMutableAttributedString *, PLUNICODE, PLFLT, int)
static void get_cursor(PLStream *, PLGraphicsIn *)
void plD_bop_aqt(PLStream *)
const char * aqt_font_env_names[AQT_N_FontLookup]
PLDLLIMPEXP_DRIVER const char * plD_DEVICE_INFO_aqt
plD_polyline_fp pl_polyline
PLUNICODE * unicode_array
void plD_line_aqt(PLStream *, short, short, short, short)
void(* plD_init_fp)(struct PLStream_struct *)