/* -*- mode:C++ ; compile-command: "g++ -I.. -g -c plot.cc" -*- */
#ifndef _GIAC_PLOT_H
#define _GIAC_PLOT_H
/*
 *  Copyright (C) 2000 B. Parisse, Institut Fourier, 38402 St Martin d'Heres
 *
 *  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 3 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "first.h"
#include <stdexcept>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <sstream>
#include "gen.h"
#include "plot3d.h"
#ifdef HAVE_SIGNAL_H
#include <signal.h>
#endif
#include <stdio.h>
// #include <stdiostream.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#ifndef HAVE_NO_SYS_RESOURCE_WAIT_H
#include <sys/resource.h>
#include <sys/wait.h>
#endif

#ifdef HAVE_LIBFLTK
#include <FL/Enumerations.H>
#else
enum Fl_Color {	// standard colors
  FL_BLACK		= 0,
  FL_RED		= 1,
  FL_GREEN		= 2,
  FL_YELLOW		= 3,
  FL_BLUE		= 4,
  FL_MAGENTA		= 5,
  FL_CYAN		= 6,
  FL_WHITE		= 7,
  FL_INACTIVE_COLOR	= 8,
  FL_SELECTION_COLOR	= 15,

  FL_FREE_COLOR		= 16,
  FL_NUM_FREE_COLOR	= 16,

  FL_GRAY_RAMP		= 32,

  // boxtypes limit themselves to these colors so whole ramp is not allocated:
  FL_GRAY0		= 32,	// 'A'
  FL_DARK3		= 39,	// 'H'
  FL_DARK2		= 45,   // 'N'
  FL_DARK1		= 47,	// 'P'
  FL_GRAY		= 49,	// 'R' default color
  FL_LIGHT1		= 50,	// 'S'
  FL_LIGHT2		= 52,	// 'U'
  FL_LIGHT3		= 54,	// 'W'

  FL_COLOR_CUBE		= 56
};
#endif

#ifndef NO_NAMESPACE_GIAC
namespace giac {
#endif // ndef NO_NAMESPACE_GIAC

  std::string print_DOUBLE_(double d,unsigned ndigits);

  void local_sto_double(double value,const identificateur & i,GIAC_CONTEXT);
  void local_sto_double_increment(double value,const identificateur & i,GIAC_CONTEXT);
  vecteur quote_eval(const vecteur & v,const vecteur & quoted,GIAC_CONTEXT);

  // if v is the vector argument of pnt, get_style returns attributs and
  // set legende to the legende to be displayed
  vecteur get_style(const vecteur & v,std::string & legende);
  gen readvar(const gen & g);
  void read_tmintmaxtstep(vecteur & vargs,gen & t,int vstart,double &tmin,double & tmax,double &tstep,bool & tminmax_defined,bool & tstep_defined,GIAC_CONTEXT);
  int read_attributs(const vecteur & v,vecteur & attributs,GIAC_CONTEXT);
  void read_option(const vecteur & v,double xmin,double xmax,double ymin,double ymax,double zmin,double zmax,vecteur & attributs, int & nstep,int & jstep,int & kstep,GIAC_CONTEXT);
  gen curve_surface_apply(const gen & elem,const gen & b,gen (* func) (const gen &, const gen &,const context *),GIAC_CONTEXT);
  gen apply3d(const gen & e1, const gen & e2,const context * contextptr, gen (* f) (const gen &, const gen &,const context *) );

  gen mkrand2d3d(int dim,int nargs,gen (* f)(const gen &,const context *),GIAC_CONTEXT);
  gen droite_by_equation(const vecteur & v,bool est_plan,GIAC_CONTEXT);
  gen abs_norm(const gen & g,GIAC_CONTEXT);
  gen abs_norm2(const gen & g,GIAC_CONTEXT);
  gen dotvecteur(const gen & a,const gen & b,GIAC_CONTEXT);
  bool check3dpoint(const gen & g);
  vecteur remove_not_in_segment(const gen & a,const gen & b,int subtype,const vecteur & v,GIAC_CONTEXT);
  vecteur interpolygone(const vecteur & p,const gen & bb,GIAC_CONTEXT);

  bool set_turtle_state(const vecteur & v,GIAC_CONTEXT);
  gen turtle2gen(const logo_turtle & turtle);
  vecteur turtlevect2vecteur(const std::vector<logo_turtle> & v);
  std::vector<logo_turtle> vecteur2turtlevect(const vecteur & v);
  logo_turtle vecteur2turtle(const vecteur & v);

  // File "Out.txt" for gnuwince
#ifdef GNUWINCE
  extern std::ofstream * outptr;
#endif

  vecteur plotpreprocess(const gen & args,GIAC_CONTEXT);
  vecteur gen2vecteur(const gen & arg);
  bool chk_double_interval(const gen & g,double & inf,double & sup,GIAC_CONTEXT);
  bool readrange(const gen & g,double defaultxmin,double defaultxmax,gen & x, double & xmin, double & xmax,GIAC_CONTEXT);
  void ck_parameter_x(GIAC_CONTEXT);
  void ck_parameter_y(GIAC_CONTEXT);
  void ck_parameter_z(GIAC_CONTEXT);
  void ck_parameter_t(GIAC_CONTEXT);
  void ck_parameter_u(GIAC_CONTEXT);
  void ck_parameter_v(GIAC_CONTEXT);
  void ck_parameter(const gen & ,GIAC_CONTEXT);
  extern int LEGENDE_SIZE;
  extern int COORD_SIZE;
  extern int PARAM_STEP;

  void autoname_plus_plus(std::string & autoname);
  int erase3d();
  int erase_pos(GIAC_CONTEXT);
  int erase_pos(int current,GIAC_CONTEXT);
  bool is_segment(const gen & e);
  gen remove_at_pnt(const gen & e);
  gen remove_sto(const gen & e);
  vecteur selection2vecteur(const std::vector<int> & selected,GIAC_CONTEXT);
  vecteur selection2vecteureval(const std::vector<int> & selected,GIAC_CONTEXT);
  // find best int in selected (and modify selected)
  // p is the pointed mouse point, eps the precision
  // try_perp=-1 if no try of perp line, =an history_position otherwise
  bool find_best(std::vector<int> & selected,const gen & p,double eps,int try_perp_history_pos,int & pnt_pos,int & history_position,gen & res,GIAC_CONTEXT);
  int findfirstcercle(const vecteur & v);
  int findfirstpoint(const vecteur & v);

  extern bool run_modif;  // obsolete, used by make_child and co
  extern int run_modif_pos;
  extern bool fastcurveprint;
  void rewrite_with_t_real(gen & eq,const gen & t,GIAC_CONTEXT);
  extern int _GROUP__VECT_subtype[];
  extern const unary_function_ptr plot_sommets[];
  extern const unary_function_ptr not_point_sommets[];
  extern const unary_function_ptr notexprint_plot_sommets[];
  extern pid_t gnuplot_pid;
  int set_nonblock_flag (int desc, int value);
  extern std::string gnuplot_name; // name of the program gnuplot
  extern std::string gnuplot_filename; // name of files where we save plots
  extern int gnuplot_fileno; // current index in save plot files
  extern int gnuplot_pixels_per_eval;
  extern double gnuplot_xmin,gnuplot_xmax,gnuplot_ymin,gnuplot_ymax,gnuplot_zmin,gnuplot_zmax,gnuplot_tmin,gnuplot_tmax,gnuplot_tstep,global_window_xmin,global_window_xmax,global_window_ymin,global_window_ymax,x_tick,y_tick; // ranges
  extern double class_minimum,class_size; // histogram
  extern bool autoscale;
  extern bool has_gnuplot;
  extern bool win9x; // True for windows (win95/98/Me can not pipe to gnuplot)
  // runs gnuplot if necessary, returns the FD of the pipe to write to gnuplot
  int run_gnuplot(int & r);
  void gnuplot_wait(int handle,FILE * gnuplot_out_readstream,int ngwait=0);
  FILE * open_gnuplot(bool & clrplot,FILE * & gnuplot_out_readstream,int & r);
  // Plot a function or a set of functions
  void reset_gnuplot_hidden3d(FILE * stream);
  extern bool gnuplot_do_splot;
  std::string gnuplot_traduit(const gen & g);
  void win9x_gnuplot(FILE * stream);
  extern int gnuplot_wait_times;

  // return parametrization for a parametric curve and translate
  // ellipsis/hyperbola to a rational parametrization
  // m will contain the complex depending on gen_t 
  bool find_curve_parametrization(const gen & geo_obj,gen & m,const gen & gen_t,double T,gen & tmin,gen & tmax,gen & tstep,GIAC_CONTEXT);

  gen plotfunc(const gen & f,const gen & vars,const vecteur & attributs,bool clrplot,double function_xmin,double function_xmax,double function_ymin,double function_ymax,double function_zmin, double function_zmax,int nstep,int jstep,bool showeq,GIAC_CONTEXT);
  // return a vector of values with simple decimal representation
  // between xmin/xmax or including xmin/xmax (if bounds is true)
  vecteur ticks(double xmin,double xmax,bool bounds);
  gen plotcontour(const gen & f0,bool contour,GIAC_CONTEXT);
  gen plot_array(const std::vector< std::vector< double> > & fij,int imax,int jmax,double xmin,double xmax,double dx,double ymin,double ymax,double dy,const vecteur & lz,const vecteur & attributs,bool contour,GIAC_CONTEXT);
  symbolic symb_plotfunc(const gen & a,const gen & b);
  symbolic symb_plotfunc(const gen & a);
  bool latex_replot(FILE * stream,const std::string & s);
  bool png_replot(int i);
  bool png_replot(const std::string & s);
  bool terminal_replot(const char * terminal,int i,const char * file_extension);
  bool terminal_replot(const char * terminal,const std::string & s);
  gen _aire(const gen & args,GIAC_CONTEXT);
  gen funcplotfunc(const gen & args,bool densityplot,const context * contextptr);
  gen _plotfunc(const gen &,GIAC_CONTEXT);
  extern const unary_function_ptr at_plotfunc;
  extern const unary_function_ptr at_funcplot;
  // gen _plot(const gen &);
  extern const unary_function_ptr at_plot;
  void kill_gnuplot();
  gen remove_at_pnt(const gen & e);

  symbolic symb_erase(const gen & args);
  gen _erase(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_erase;

  gen _pixon(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_pixon;

  gen _pixoff(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_pixoff;

  gen _droite(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_droite;

  gen _demi_droite(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_demi_droite;

  gen _segment(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_segment;

  extern const unary_function_ptr at_inter_unique;
  extern const unary_function_ptr at_polygone_ouvert;

  // segment x->y with attributs c
  gen symb_segment(const gen & x,const gen & y,const vecteur & ,int ,GIAC_CONTEXT);
  // point x color c name nom
  gen symb_pnt_name(const gen & x,const gen & c,const gen & nom,GIAC_CONTEXT);
  // point x and color c
  gen symb_pnt(const gen & x,const gen & c,GIAC_CONTEXT);
  gen pnt_attrib(const gen & point,const vecteur & attributs,GIAC_CONTEXT);
  // point x with default color FL_BLACK
  gen symb_pnt(const gen & x,GIAC_CONTEXT);
  gen _pnt(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_pnt;
  extern const unary_function_ptr at_animation;
  int animations(const gen & g); // number of animations inside g
  gen get_animation_pnt(const gen & g,int pos);

  symbolic symb_point(const gen & x,const gen & y);
  gen _point(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_point;

  gen _affixe(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_affixe;

  gen _abscisse(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_abscisse;

  gen _ordonnee(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_ordonnee;

  gen _cercle(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_cercle;
  bool centre_rayon(const gen & cercle,gen & centre,gen & rayon,bool absrayon, GIAC_CONTEXT);
  gen _centre(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_centre;
  gen _rayon(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_rayon;

  symbolic symb_milieu(const gen & x,const gen & y);
  symbolic symb_milieu(const gen & x);
  gen _milieu(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_milieu;

  gen _mediatrice(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_mediatrice;

  gen bissectrice(const gen & args,bool interieur,GIAC_CONTEXT);
  gen _bissectrice(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_bissectrice;

  gen _exbissectrice(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_exbissectrice;

  gen _mediane(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_mediane;

  gen _circonscrit(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_circonscrit;

  gen _inscrit(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_inscrit;

  gen _exinscrit(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_exinscrit;

  gen _isobarycentre(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_isobarycentre;

  symbolic symb_perpendiculaire(const gen & a);
  gen _perpendiculaire(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_perpendiculaire;

  gen _parallele(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_parallele;

  gen distance2pp(const gen & ee,const gen & ff,GIAC_CONTEXT);
  gen distance2(const gen & f1,const gen & f2,GIAC_CONTEXT);
  gen _longueur2(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_longueur2;

  gen longueur(const gen & f1,const gen & f2,GIAC_CONTEXT);
  gen _longueur(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_longueur;

  gen angle(const gen & f1,const gen & f2,GIAC_CONTEXT);
  gen _angle(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_angle;

  gen scalar_product(const gen & a,const gen & b,GIAC_CONTEXT);
  // return t such that ta+(1-t)b is the projection of c on [a,b] 
  gen projection(const gen & a,const gen & b,const gen & c,GIAC_CONTEXT);
  // projection of p on a parametric curve
  // e=symb_cercle or line, returns t
  gen projection(const gen & e,const gen & p,GIAC_CONTEXT);
  gen parameter2point(const vecteur & v,GIAC_CONTEXT);
  
  std::vector<int> nearest_point(const vecteur & v,const gen & p,double eps,GIAC_CONTEXT);

  vecteur inter(const gen & a,const gen & b,GIAC_CONTEXT);

  gen _signal(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_signal;

  gen _click(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_click;
  class unary_function_eval;
  extern unary_function_eval __click;

  gen _element(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_element;

  gen _as_function_of(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_as_function_of;

  gen _lieu(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_lieu;

  gen _head(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_head;

  gen _tail(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_tail;

  gen _sommets(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_sommets;

  gen _symetrie(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_symetrie;

  gen _rotation(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_rotation;

  gen _projection(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_projection;

  gen _homothetie(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_homothetie;

  gen _est_aligne(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_est_aligne;

  gen _est_cocyclique(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_est_cocyclique;

  gen _est_parallele(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_est_parallele;

  gen _est_perpendiculaire(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_est_perpendiculaire;

  gen _est_element(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_est_element;

  gen _inversion(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_inversion;

  gen _similitude(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_similitude;

  gen translation(const gen & a,const gen & bb,GIAC_CONTEXT);
  gen _translation(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_translation;

  symbolic symb_curve(const gen & source,const gen & plot);
  gen _curve(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_curve;

  gen _plotparam(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_plotparam;
  extern const unary_function_ptr at_paramplot;
  gen paramplotparam(const gen & args,bool clrplot,const context * contextptr);

  gen _plotpolar(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_plotpolar;
  extern const unary_function_ptr at_polarplot;

  gen _parameq(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_parameq;

  gen _equation(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_equation;

  gen _tangent(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_tangent;

  gen _ellipse(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_ellipse;

  gen _hyperbole(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_hyperbole;

  gen _parabole(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_parabole;

  gen _legende(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_legende;
  extern const unary_function_ptr at_distanceat;
  extern const unary_function_ptr at_distanceatraw;
  extern const unary_function_ptr at_angleat;
  extern const unary_function_ptr at_angleatraw;
  extern const unary_function_ptr at_areaatraw;
  extern const unary_function_ptr at_areaat;
  extern const unary_function_ptr at_perimeteratraw;
  extern const unary_function_ptr at_perimeterat;
  extern const unary_function_ptr at_slopeatraw;
  extern const unary_function_ptr at_slopeat;
  extern const unary_function_ptr at_extract_measure;

  gen _couleur(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_couleur;
  extern const unary_function_ptr at_display ;

  gen _parameter(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_parameter;

  gen _hauteur(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_hauteur;

  gen _triangle(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_triangle;

  gen _triangle_rectangle(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_triangle_rectangle;

  gen _triangle_isocele(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_triangle_isocele;

  gen _triangle_equilateral(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_triangle_equilateral;

  gen _parallelogramme(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_parallelogramme;

  gen _carre(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_carre;

  gen _quadrilatere(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_quadrilatere;

  gen _rectangle(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_rectangle;

  gen _losange(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_losange;

  gen _polygone(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_polygone;

  gen _plotfield(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_plotfield;
  extern const unary_function_ptr at_fieldplot;

  gen _interactive_plotode(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_interactive_plotode;
  extern const unary_function_ptr at_interactive_odeplot;

  gen _plotode(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_plotode;
  extern const unary_function_ptr at_odeplot;

  std::ostream & archive(std::ostream & os,const gen & e,GIAC_CONTEXT);
  gen unarchive(std::istream & is,GIAC_CONTEXT);
  gen archive_session(bool save_history,std::ostream & os,GIAC_CONTEXT);
  gen archive_session(bool save_history,const std::string & s,GIAC_CONTEXT);
  std::string archive_session(bool save_history,GIAC_CONTEXT);
  gen unarchive_session(std::istream & is,int level, const gen & replace,GIAC_CONTEXT);
  gen unarchive_session(const std::string & s,int level, const gen & replace,GIAC_CONTEXT);
  gen unarchive_session_string(const std::string & s,int level, const gen & replace,GIAC_CONTEXT);

  gen _archive(bool save_history,const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_archive;

  gen _unarchive(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_unarchive;

  void geo_setup(const vecteur & w,GIAC_CONTEXT);
  gen xyztrange(double xmin,double xmax,double ymin,double ymax,double zmin,double zmax,double tmin,double tmax,double wxmin,double wxmax,double wymin, double wymax, int axes,double class_minimum,double class_size,bool gnuplot_hidden3d,bool gnuplot_pm3d);
  gen _xyztrange(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_xyztrange;
  extern unary_function_eval __xyztrange;

  gen _switch_axes(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_switch_axes;

  gen plotseq(const gen& f,const gen&x,double x0,double xmin,double xmax,int niter,GIAC_CONTEXT);
  gen _plotseq(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_plotseq;
  extern const unary_function_ptr at_seqplot;

  gen _plotimplicit(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_plotimplicit;
  extern const unary_function_ptr at_implicitplot;

  gen _plotcontour(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_plotcontour;
  extern const unary_function_ptr at_contourplot;

  gen _bitmap(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_bitmap;

  gen _Pictsize(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_Pictsize;

  extern const unary_function_ptr implicittex_plot_sommets[];

  gen _plot_style(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_plot_style ;

  gen _DrawInv(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_DrawInv ;

  extern const unary_function_ptr at_Graph;
  extern const unary_function_ptr at_DrawFunc;
  extern const unary_function_ptr at_DrawParm;
  extern const unary_function_ptr at_DrawPol;
  extern const unary_function_ptr at_DrwCtour;

  gen _est_isocele(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_est_isocele;

  gen _est_equilateral(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_est_equilateral;

  gen _est_carre(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_est_carre;

  gen _est_losange(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_est_losange;

  gen _est_parallelogramme(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_est_parallelogramme;

  gen _est_rectangle(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_est_rectangle;
 
  gen _est_harmonique(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_est_harmonique;
  
  gen _div_harmonique(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_div_harmonique;
  
  gen _point_div(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_point_div;
  
  gen _birapport(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_birapport;

  gen _est_harmonique(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_est_harmonique;

  gen _div_harmonique(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_div_harmonique;

  gen _conj_harmonique(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_conj_harmonique;

  gen _conj_harmoniques(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_conj_harmoniques;

  gen _point_div(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_point_div;

  gen _birapport(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_birapport;

  gen _puissance(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_puissance;

  gen _axe_radical(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_axe_radical;

  gen _polaire(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_polaire;

  gen _pole(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_pole;

  gen _polaire_reciproque(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_polaire_reciproque;

  gen _est_orthogonal(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_est_orthogonal;

  gen _est_conjugue(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_est_conjugue;

  gen _est_faisceau_cercle(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_est_faisceau_cercle;

  gen _est_faisceau_droite(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_est_faisceau_droite;

  gen _enveloppe(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_enveloppe;

  extern bool gnuplot_hidden3d,gnuplot_pm3d;
  void gnuplot_set_hidden3d(bool hidden);
  void gnuplot_set_pm3d(bool b);

  int gnuplot_show_pnt(const symbolic & e,GIAC_CONTEXT);
  int graph_output_type(const giac::gen & g);
  gen put_attributs(const gen & lieu_geo,const vecteur & attributs,GIAC_CONTEXT);
  vecteur seq2vecteur(const gen & g);

  int est_aligne(const gen & a,const gen & b,const gen & c,GIAC_CONTEXT);
  bool est_coplanaire(const gen & a,const gen & b,const gen & c,const gen & d,GIAC_CONTEXT);
  bool est_cocyclique(const gen & a,const gen & b,const gen & c,const gen & d,GIAC_CONTEXT);
  // True if a=coeff*b
  bool est_parallele_vecteur(const vecteur & a,const vecteur &b,gen & coeff,GIAC_CONTEXT);
  bool est_parallele_vecteur(const vecteur & a,const vecteur &b,GIAC_CONTEXT);
  bool est_parallele(const gen & a,const gen & b,GIAC_CONTEXT);
  bool est_perpendiculaire(const gen & a,const gen & b,GIAC_CONTEXT);
  // check if a belongs to b, a must be a complex, b a line or circle or curve
  int est_element(const gen & a_orig,const gen & b_orig,GIAC_CONTEXT);
  bool est_carre(const gen & a,const gen & b,const gen & c,const gen & d,GIAC_CONTEXT);
  int est_isocele(const gen & a,const gen & b,const gen & c,GIAC_CONTEXT);
  bool est_equilateral(const gen & a,const gen & b,const gen & c,GIAC_CONTEXT);
  int est_trianglerect(const gen & a,const gen & b,const gen & c,GIAC_CONTEXT);
  //teste si deux cercles C1 centre c1 rayon R1 et C2  centre c2 rayon R2
  //sont orthogonaux
  bool est_orthogonal(const gen & c1,const gen & R1,const gen & c2,const gen & R2,GIAC_CONTEXT);
  //teste si 4 points forment une division harmonique
  bool est_harmonique(const gen & a,const gen & b,const gen & c,const gen & d,GIAC_CONTEXT);

  gen _vector(const gen & args,GIAC_CONTEXT);
  extern const unary_function_ptr at_vector;

  extern const unary_function_ptr point_sommet_tab_op[];
  extern const unary_function_ptr nosplit_polygon_function[];
  extern const unary_function_ptr measure_functions[];
  extern const unary_function_ptr transformation_functions[];
  /* following obsolete declaration that will be remove in the future
   when all fork/child etc. will be removed */
  extern vecteur plot_instructions;
  // extern int plot_instructionsh,plot_instructionsw;
  extern std::string PICTautoname;
  void PICTautoname_plus_plus();

#ifndef NO_NAMESPACE_GIAC
} // namespace giac
#endif // ndef NO_NAMESPACE_GIAC

#endif // _GIAC_PLOT_H
