/*
 * Grace - GRaphing, Advanced Computation and Exploration of data
 * 
 * Home page: http://plasma-gate.weizmann.ac.il/Grace/
 * 
 * Copyright (c) 1991-1995 Paul J Turner, Portland, OR
 * Copyright (c) 1996-2002 Grace Development Team
 * 
 * Maintained by Evgeny Stambulchik
 * 
 * 
 *                           All Rights Reserved
 * 
 *    This program is free software; you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation; either version 2 of the License, or
 *    (at your option) any later version.
 * 
 *    This program 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 General Public License for more details.
 * 
 *    You should have received a copy of the GNU General Public License
 *    along with this program; if not, write to the Free Software
 *    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

/*
 *
 * Global variables of Grace - should be empty :-(
 *
 */

#ifndef __GLOBALS_H_
#define __GLOBALS_H_

#include <stdlib.h>
#include <stdio.h>

#ifdef WITH_GTK
#  include <gdk/gdk.h>
#endif   /* WITH_GTK */

#include "defines.h"
#include "graphs.h"
#include "draw.h"

#ifdef MAIN
#  define GLOBAL(var, type, val) type var = val
#  define GLOBALARR(arr, type, dim, val) type arr[dim] = val

/* target set */
target target_set;

/* default properties */
defaults grdefaults;

/* parameters for non-linear fit */
nonlparms nonl_parms[MAXPARM];
nonlopts  nonl_opts;

/* region definition */
region rg[MAXREGION];

/* Must correspond to Qtype enum in defines.h 50 */
char *Qtype_name[Q_Last] = {"Compound"
				  ,"Line"
				  ,"Polyline"
				  ,"Arc"
				  ,"String"
				  ,"Box"
				  ,"Colorbar"
				  ,"TimeStamp"
				  ,"Q_Last_objs"
				  ,"Leg.Box"
				  ,"Function,"
				  ,"Set"
				  ,"Axis"
				  ,"Graph"
				  ,"Project"
};

char *axis_name[] = {"xaxis"
		     ,"yaxis"
		     ,"altxaxis"
		     ,"altyaxis"
};

#else

#  define GLOBAL(var, type, val) extern type var
#  define GLOBALARR(arr, type, dim, val) extern type arr[]

extern target target_set;
extern defaults grdefaults;
extern char *Qtype_name[];
extern char *axis_name[];

extern nonlparms nonl_parms[];
extern nonlopts nonl_opts;

extern region rg[];

#endif

/* real-time input delay (prevents getting stuck reading) */
GLOBAL(timer_delay, int, 200);

/* linked scroll */
GLOBAL(scrolling_islinked, int, FALSE);
/* scroll fraction */
GLOBAL(scrollper, double, 0.05);
/* expand/shrink fraction */
GLOBAL(shexper, double, 0.05);

/* terminal device */
GLOBAL(tdevice, int, 0);
/* hardcopy device */
GLOBAL(hdevice, int, 0);

/* set mono mode */
GLOBAL(monomode, int, FALSE);
/* use GXxor or GXinvert for xor'ing */
GLOBAL(invert, int, TRUE);
/* if true, redraw graph each time action is performed */
GLOBAL(auto_redraw, int, TRUE);
/* if true, Apply is not needed to act the change in explorer rpane */
GLOBAL(instant_update, int, TRUE);
/* allow double click ops */
GLOBAL(allow_dc, int, TRUE);
/* if TRUE, assume yes for everything */
GLOBAL(noask, int, FALSE);

/* true if running X */
GLOBAL(inwin, int, FALSE);

/* autoscale after reading in data sets */
GLOBAL(autoscale_onread, int, AUTOSCALE_XY);

GLOBAL(focus_policy, int, FOCUS_CLICK);
GLOBAL(draw_focus_flag, int, TRUE);


/* The universal array of struct */
GLOBAL (objs      ,QDobject * ,NULL);
GLOBAL (clipboard ,QDobject * ,NULL);
/* to retrieve the current obj */
GLOBAL (cur_obj_typ   ,Qtype  ,Q_Undef);
GLOBAL (cur_obj_id    ,int    ,-1);
GLOBAL (cur_parent_typ,Qtype  ,Q_Undef);
GLOBAL (cur_parent_id ,int    ,-1);
GLOBAL (cur_obj_num   ,int    ,-1);

GLOBAL (obj_rot       ,int    ,0);
GLOBAL (obj_color     ,int    ,1);
GLOBAL (obj_lines     ,int    ,1);
GLOBAL (obj_linew     ,double ,1.0);
GLOBAL (obj_fillpat   ,int    ,0);
GLOBAL (obj_fillcolor ,int    ,1);
GLOBAL (obj_loctyp    ,int    ,COORD_VIEW);

GLOBAL (follow_me_on  ,int    ,0);    
GLOBAL (follow_gno    ,int    ,-2);    
GLOBAL (legend_for_new_set ,int ,TRUE);    

/* used in the parser */
GLOBAL(curtype, int, SET_XY);
GLOBAL(cursource, int, SOURCE_DISK);

/* the current region */
GLOBAL(nr, int, 0);

/* file for results */
GLOBAL(resfp, FILE *, NULL);

/* format for saving data sets */
GLOBALARR(sformat, char, 128, "%.8g");

#ifdef HAVE_NETCDF
GLOBALARR(netcdf_name, char, 512, "");
GLOBALARR(xvar_name, char, 128, "");
GLOBALARR(yvar_name, char, 128, "");
#endif

/* SELXY   :  A REVOIR  */
GLOBALARR(sel_cols_str ,char ,MAX_STRING_LENGTH ,"");
GLOBAL (revflag ,int ,FALSE);

/* the safe mode flag */
GLOBAL(safe_mode, int, TRUE);


#endif /* __GLOBALS_H_ */
