<commit_before>/* March 12, 2005

	PLplot driver for AquaTerm and Mac OS X.

	Copyright (C) <NAME>
	Copyright (C) 2005 <NAME>

	This file is part of PLplot.

	PLplot is free software; you can redistribute it and/or modify
	it under the terms of the GNU General Library Public License as published
	by the Free Software Foundation; either version 2 of the License, or
	(at your option) any later version.

	PLplot is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU Library General Public License for more details.

	You should have received a copy of the GNU Library General Public License
	along with PLplot; if not, write to the Free Software
	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
   	
*/

#import <Foundation/Foundation.h>
#import <aquaterm/AQTAdapter.h>

/* Debugging extras */
static inline void NOOP_(id x, ...) {;}

#ifdef LOGGING
#define LOG  NSLog
#else
#define LOG  NOOP_
#endif  /* LOGGING */

static NSAutoreleasePool *arpool;   // Objective-C autorelease pool
static id adapter;					// Adapter object

// ----------------------------------------------------------------
// --- Start of PlPlot function aqtrm()
// ----------------------------------------------------------------

#include "plplotP.h"
#include "drivers.h"

char* plD_DEVICE_INFO_aqt = "aqt:AquaTerm (Mac OS X):1:aqt:50:aqt";

/* declarations for functions local to aqt.c */

void get_cursor(PLGraphicsIn *);
void proc_str (PLStream *, EscText *);
NSMutableAttributedString * create_string(const PLUNICODE *, int, PLFLT);
void set_font_and_size(NSMutableAttributedString *, PLUNICODE, PLFLT, int);
char * UCS4_to_UTF8(const PLUNICODE);

/* Driver entry and dispatch setup */

void plD_dispatch_init_aqt      ( PLDispatchTable *pdt );

void plD_init_aqt               (PLStream *);
void plD_line_aqt               (PLStream *, short, short, short, short);
void plD_polyline_aqt   		(PLStream *, short *, short *, PLINT);
void plD_eop_aqt                (PLStream *);
void plD_bop_aqt                (PLStream *);
void plD_tidy_aqt               (PLStream *);
void plD_state_aqt              (PLStream *, PLINT);
void plD_esc_aqt                (PLStream *, PLINT, void *);

void plD_dispatch_init_aqt( PLDispatchTable *pdt )
{
   pdt->pl_MenuStr  = "AquaTerm - Mac OS X";
   pdt->pl_DevName  = "aqt";
   pdt->pl_type     = plDevType_Interactive;
   pdt->pl_seq      = 1;
   pdt->pl_init     = (plD_init_fp)     plD_init_aqt;
   pdt->pl_line     = (plD_line_fp)     plD_line_aqt;
   pdt->pl_polyline = (plD_polyline_fp) plD_polyline_aqt;
   pdt->pl_eop      = (plD_eop_fp)      plD_eop_aqt;
   pdt->pl_bop      = (plD_bop_fp)      plD_bop_aqt;
   pdt->pl_tidy     = (plD_tidy_fp)     plD_tidy_aqt;
   pdt->pl_state    = (plD_state_fp)    plD_state_aqt;
   pdt->pl_esc      = (plD_esc_fp)      plD_esc_aqt;
}

/* global variables & defines */

static int currentPlot = 0;
static int maxWindows = 30;
static int windowXSize = 0;
static int windowYSize = 0;

#define SCALE			0.1
#define AQT_Max_X       720
#define AQT_Max_Y       720
#define DPI             72.0

#define MAX_STRING_LEN	1000
#define FCI 			0x10000000

/* AquaTerm font look-up table */

#define AQT_N_Type1Lookup 5
const FCI_to_FontName_Table AQT_Type1Lookup[AQT_N_Type1Lookup] = {
     {0x10000000, "Helvetica"},
     {0x10000001, "Times-Roman"},
     {0x10000002, "Courier"},
     {0x10000003, "Times-Roman"},
     {0x10000004, "Symbol"},
};

//---------------------------------------------------------------------
//   aqt_init()
//
//   Initialize device
//----------------------------------------------------------------------

void plD_init_aqt(PLStream *pls)
{
	
   if (arpool == NULL)   /* Make sure we don't leak mem by allocating every time */
   {
      arpool = [[NSAutoreleasePool alloc] init];
      adapter = [[AQTAdapter alloc] init];
   }
   [adapter setBackgroundColorRed:0.5 green:0.5 blue:0.5];

   pls->termin = 1;		// If interactive terminal, set true.
   pls->color = 1;		// aqt is color terminal
   pls->width = 1;
   pls->verbose = 1;
   pls->bytecnt = 0;
   pls->debug = 1;
   pls->dev_text = 1;
   pls->dev_unicode = 1; 	/* want unicode */
   pls->page = 0;
   pls->dev_fill0 = 1;		/* supports hardware solid fills */
   pls->dev_fill1 = 1;

   pls->graphx = GRAPHICS_MODE;

   if (!pls->colorset)
      pls->color = 1; 
   //
   // Set up device parameters
   //
   plP_setpxl(DPI/25.4/SCALE, DPI/25.4/SCALE);           /* Pixels/mm. */
   //
   // Set the bounds for plotting.  default is AQT_Max_X x AQT_Max_Y unless otherwise specified.
   //
   if (pls->xlength <= 0 || pls->ylength <= 0){
      windowXSize = AQT_Max_X;
      windowYSize = AQT_Max_Y;
      plP_setphy((PLINT) 0, (PLINT) (AQT_Max_X/SCALE), (PLINT) 0, (PLINT) (AQT_Max_Y/SCALE));
   } else {<commit_msg>Changed default aspect ratio to be the normal 3/4 ratio<commit_after>/* March 12, 2005

	PLplot driver for AquaTerm and Mac OS X.

	Copyright (C) <NAME>
	Copyright (C) 2005 <NAME>

	This file is part of PLplot.

	PLplot is free software; you can redistribute it and/or modify
	it under the terms of the GNU General Library Public License as published
	by the Free Software Foundation; either version 2 of the License, or
	(at your option) any later version.

	PLplot is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU Library General Public License for more details.

	You should have received a copy of the GNU Library General Public License
	along with PLplot; if not, write to the Free Software
	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
   	
*/

#import <Foundation/Foundation.h>
#import <aquaterm/AQTAdapter.h>

/* Debugging extras */
static inline void NOOP_(id x, ...) {;}

#ifdef LOGGING
#define LOG  NSLog
#else
#define LOG  NOOP_
#endif  /* LOGGING */

static NSAutoreleasePool *arpool;   // Objective-C autorelease pool
static id adapter;					// Adapter object

// ----------------------------------------------------------------
// --- Start of PlPlot function aqtrm()
// ----------------------------------------------------------------

#include "plplotP.h"
#include "drivers.h"

char* plD_DEVICE_INFO_aqt = "aqt:AquaTerm (Mac OS X):1:aqt:50:aqt";

/* declarations for functions local to aqt.c */

void get_cursor(PLGraphicsIn *);
void proc_str (PLStream *, EscText *);
NSMutableAttributedString * create_string(const PLUNICODE *, int, PLFLT);
void set_font_and_size(NSMutableAttributedString *, PLUNICODE, PLFLT, int);
char * UCS4_to_UTF8(const PLUNICODE);

/* Driver entry and dispatch setup */

void plD_dispatch_init_aqt      ( PLDispatchTable *pdt );

void plD_init_aqt               (PLStream *);
void plD_line_aqt               (PLStream *, short, short, short, short);
void plD_polyline_aqt   		(PLStream *, short *, short *, PLINT);
void plD_eop_aqt                (PLStream *);
void plD_bop_aqt                (PLStream *);
void plD_tidy_aqt               (PLStream *);
void plD_state_aqt              (PLStream *, PLINT);
void plD_esc_aqt                (PLStream *, PLINT, void *);

void plD_dispatch_init_aqt( PLDispatchTable *pdt )
{
   pdt->pl_MenuStr  = "AquaTerm - Mac OS X";
   pdt->pl_DevName  = "aqt";
   pdt->pl_type     = plDevType_Interactive;
   pdt->pl_seq      = 1;
   pdt->pl_init     = (plD_init_fp)     plD_init_aqt;
   pdt->pl_line     = (plD_line_fp)     plD_line_aqt;
   pdt->pl_polyline = (plD_polyline_fp) plD_polyline_aqt;
   pdt->pl_eop      = (plD_eop_fp)      plD_eop_aqt;
   pdt->pl_bop      = (plD_bop_fp)      plD_bop_aqt;
   pdt->pl_tidy     = (plD_tidy_fp)     plD_tidy_aqt;
   pdt->pl_state    = (plD_state_fp)    plD_state_aqt;
   pdt->pl_esc      = (plD_esc_fp)      plD_esc_aqt;
}

/* global variables & defines */

static int currentPlot = 0;
static int maxWindows = 30;
static int windowXSize = 0;
static int windowYSize = 0;

#define SCALE			0.1
#define AQT_Default_X	720
#define AQT_Default_Y	540
#define DPI             72.0

#define MAX_STRING_LEN	1000
#define FCI 			0x10000000

/* AquaTerm font look-up table */

#define AQT_N_Type1Lookup 5
const FCI_to_FontName_Table AQT_Type1Lookup[AQT_N_Type1Lookup] = {
     {0x10000000, "Helvetica"},
     {0x10000001, "Times-Roman"},
     {0x10000002, "Courier"},
     {0x10000003, "Times-Roman"},
     {0x10000004, "Symbol"},
};

//---------------------------------------------------------------------
//   aqt_init()
//
//   Initialize device
//----------------------------------------------------------------------

void plD_init_aqt(PLStream *pls)
{
	
   if (arpool == NULL)   /* Make sure we don't leak mem by allocating every time */
   {
      arpool = [[NSAutoreleasePool alloc] init];
      adapter = [[AQTAdapter alloc] init];
   }
   [adapter setBackgroundColorRed:0.5 green:0.5 blue:0.5];

   pls->termin = 1;		// If interactive terminal, set true.
   pls->color = 1;		// aqt is color terminal
   pls->width = 1;
   pls->verbose = 1;
   pls->bytecnt = 0;
   pls->debug = 1;
   pls->dev_text = 1;
   pls->dev_unicode = 1; 	/* want unicode */
   pls->page = 0;
   pls->dev_fill0 = 1;		/* supports hardware solid fills */
   pls->dev_fill1 = 1;

   pls->graphx = GRAPHICS_MODE;

   if (!pls->colorset)
      pls->color = 1; 
   //
   // Set up device parameters
   //
   plP_setpxl(DPI/25.4/SCALE, DPI/25.4/SCALE);           /* Pixels/mm. */
   //
   // Set the bounds for plotting.  default is AQT_Default_X x AQT_Default_Y unless otherwise specified.
   //
   if (pls->xlength <= 0 || pls->ylength <= 0){
      windowXSize = AQT_Default_X;
      windowYSize = AQT_Default_Y;
      plP_setphy((PLINT) 0, (PLINT) (AQT_Default_X/SCALE), (PLINT) 0, (PLINT) (AQT_Default_Y/SCALE));
   } else {
{'fraction_non_alphanumeric': 0.1598825435398947, 'fraction_numerical': 0.028351559335763468, 'mean_word_length': 2.428323498785144, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 67, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 4, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1011798', 'n_tokens_mistral': 3745, 'n_tokens_neox': 3427, 'n_words': 933}