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^ھu@ 0#mx(V[]tbnyYrǓҲGNGZZSlt'ؗ|ᷛ~ΐa5յ.y=ݻMӴ,2Fa]bS?x|Ϥ%AK&K޻`OpSSWy-W Bh)2Ҝ9n[Z|gꯇ… 18}M oy vl_r#Iu. C痫X[]UyĜR!쪃ܰa#_]m6v {-;~L}'CSǃOXN|v7}u|ۛP4grMpȟw2夠`Pc($/n{'+3;_JIy25%"h,6ez%#1AҏtVѭ;vO}}56Cr$.vRX͛S wɒ{<6Q='uu|2B$ !i)~3L#6LJ*lӳ秄Y' $qiz3g%Qtj[G~ ]wɂeH; ٹD4E~ӹ)N$06oߞ_%QW<%wbk /()_'}Xu!$I <z~bYcT^g2inE|VwZ`U.,K4MaLb$s {ھqu&IENDB`GraphMonkey-1.7-src/Calculus.cs0000644000175000017500000000436610535344705017357 0ustar lounislounis00000000000000/* * 26/11/2006 - 17:02 * * GraphMonkey - mono based graphing calculator * Copyright (C) 2006 Lounis Bellabes * nolius@users.sourceforge.net * * 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 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. */ using System; public class Calculus { public string phrase; public operation op; public Calculus(string phrase) { this.phrase = phrase; this.op = new operation(this.phrase); this.op.corrige(); } // numerical derivative at the point x public double ndfdx(double x) { double h = x + 0.000001d; double top = op.calculer(h)-op.calculer(x); double bottom = h-x; return Math.Round(top/bottom, 4); } // numerical second derivative at the point x public double n2dfdx(double x) { double h = x + 0.0001d; double h2 = x + 0.0002d; double top = op.calculer(h2) - op.calculer(h) - op.calculer(h) + op.calculer(x); double bottom = (h-x)*(h-x); return Math.Round(top/bottom, 4); } // numerical integral of a function on the interval [a,b] using Simpson's Rule. public double simpsonsrule(double a, double b) { double n = 100.0d; double total = 0; double h = Math.Abs(b-a)/n; double[] l = new double[120]; double x = a; l[0] = op.calculer(x); int count = 1; while (count < n) { x = (double)a + count*h; if (count%2 == 0) { l[count] = 2*op.calculer(x); } else { l[count] = 4*op.calculer(x); } count++; } x = (double)b; l[count] = op.calculer(x); for (int i = 0; i <=count; i++) { total = total + l[i]; } return Math.Round((total*h)/3d, 4); } public double averagevalue(double a, double b) { return Math.Round((simpsonsrule(a,b))/(b-a), 4); } } GraphMonkey-1.7-src/Help_Form.cs0000644000175000017500000001034610535344732017452 0ustar lounislounis00000000000000/* * 26/11/2006 - 17:02 * * GraphMonkey - mono based graphing calculator * Copyright (C) 2006 Lounis Bellabes * nolius@users.sourceforge.net * * 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 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. */ using System; using Gtk; using GtkSharp; public class Help_Form : Window { public Help_Form () : base ("Help") { this.Move(300,100); this.SetDefaultSize (100, 300); this.Resizable = false; Gdk.Pixbuf icon = new Gdk.Pixbuf(null, "gm.png"); this.Icon = icon; Table tableLayout = new Table(1, 3, false); //blank Label label_blank4 = new Label(""); tableLayout.Attach(label_blank4, 0, 1, 0, 1); //GraphMonkey Label label_monkey = new Label("GraphMonkey 1.7"); tableLayout.Attach(label_monkey, 0, 1, 1, 2); //blank Label label_blank = new Label(""); tableLayout.Attach(label_blank, 0, 1, 2, 3); //name Label label_name = new Label(" By Lounis Bellabes "); tableLayout.Attach(label_name, 0, 1, 3, 4); //email Label label_email = new Label(" nolius@users.sourceforge.net "); tableLayout.Attach(label_email, 0, 1, 4, 5); //GPL Label label_gpl = new Label("GPL license"); tableLayout.Attach(label_gpl, 0, 1, 5, 6); //blank2 Label label_blank2 = new Label("-----------------------------"); tableLayout.Attach(label_blank2, 0, 1, 6, 7); //squareroots Label label_squareroots = new Label("square root : sqrt()"); tableLayout.Attach(label_squareroots, 0, 1, 8, 9); //powers square Label label_powerssquare = new Label("powers : ^"); tableLayout.Attach(label_powerssquare , 0, 1, 9, 10); //sine Label label_sine = new Label("sine : sin()"); tableLayout.Attach(label_sine, 0, 1, 10, 11); //cosine Label label_cosine = new Label("cosine : cos()"); tableLayout.Attach(label_cosine, 0, 1, 11, 12); //tangent Label label_tangent = new Label("tangent : tan()"); tableLayout.Attach(label_tangent, 0, 1, 12, 13); //arcsine Label label_arcsine = new Label("arcsine : asin()"); tableLayout.Attach(label_arcsine, 0, 1, 13, 14); //arccosine Label label_arccosine = new Label("arccosine : acos()"); tableLayout.Attach(label_arccosine, 0, 1, 14, 15); //arctangent Label label_arctangent = new Label("arctangent : atan()"); tableLayout.Attach(label_arctangent, 0, 1, 15, 16); //hyperbolic sine Label label_hyperbolicsine = new Label("hyperbolic sine : sinh()"); tableLayout.Attach(label_hyperbolicsine, 0, 1, 16, 17); //hyperbolic cosine Label label_hyperboliccosine = new Label("hyperbolic cosine : cosh()"); tableLayout.Attach(label_hyperboliccosine, 0, 1, 17, 18); //hyperbolic tangent Label label_hyperbolictangent = new Label("hyperbolic tangent : tanh()"); tableLayout.Attach(label_hyperbolictangent, 0, 1, 18, 19); //natural logarithm Label label_logarithm = new Label("natural logarithm: ln()"); tableLayout.Attach(label_logarithm, 0, 1, 19, 20); //base 10 logarithm Label label_logarithm10 = new Label("base 10 logarithm: log()"); tableLayout.Attach(label_logarithm10, 0, 1, 20, 21); //exponential Label label_exponential = new Label("exponential : exp()"); tableLayout.Attach(label_exponential, 0, 1, 21, 22); //absolute value Label label_absolutevalue = new Label("absolute value: abs()"); tableLayout.Attach(label_absolutevalue, 0, 1, 22, 23); //greatest integer Label label_greatestinteger = new Label("greatest integer: int()"); tableLayout.Attach(label_greatestinteger, 0, 1, 23, 24); //blank3 Label label_blank3 = new Label(""); tableLayout.Attach(label_blank3, 0, 1, 24, 25); tableLayout.ShowAll(); this.Add (tableLayout); this.ShowAll (); } } GraphMonkey-1.7-src/GraphMonkey.cs0000644000175000017500000002627410535344717020035 0ustar lounislounis00000000000000/* * 26/11/2006 - 17:02 * * GraphMonkey - mono based graphing calculator * Copyright (C) 2006 Lounis Bellabes * nolius@users.sourceforge.net * * 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 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. */ using System; using Gtk; using Pango; public class GraphMonkey : Window { public Entry entry_eq1; public Entry entry_eq2; public Entry entry_eq3; public Entry entry_x_value; public Entry entry_result; public Entry entry_xmin; public Entry entry_xmax; public Entry entry_ymin; public Entry entry_ymax; public Entry entry_graduation; public double x_min; public double x_max; public double y_min; public double y_max; public double graduation; public Label label_info; public GraphMonkey () : base ("GraphMonkey") { this.Move(100,100); this.SetDefaultSize (400, 300); this.DeleteEvent += new DeleteEventHandler (OnMyWindowDelete); this.Resizable = false; //this.ShowAll (); Gdk.Pixbuf icon = new Gdk.Pixbuf(null, "gm.png"); this.Icon = icon; VBox vbox = new VBox(false,2); // menu /* MenuBar menu = new MenuBar(); Menu file_menu = new Menu(); MenuItem file_item = new MenuItem("_File"); file_item.Submenu = file_menu; menu.Append (file_item); ImageMenuItem exit = new ImageMenuItem("_Quit"); exit.Image = new Gtk.Image(Gtk.Stock.Quit, Gtk.IconSize.Menu); exit_item.Activated += new EventHandler(on_exit); file_menu.Append(exit_item); */ MenuBar bar = new MenuBar (); Menu file_menu = new Menu (); MenuItem file_menu_item = new MenuItem ("_File"); file_menu_item.Submenu = file_menu; ImageMenuItem file_exit = new ImageMenuItem("_Quit"); file_exit.Image = new Gtk.Image(Gtk.Stock.Quit, Gtk.IconSize.Menu); file_exit.Activated += new EventHandler (exit_cb); file_menu.Append (file_exit); bar.Append (file_menu_item); Menu help_menu = new Menu (); MenuItem help_menu_item = new MenuItem ("_Help"); help_menu_item.Submenu = help_menu; ImageMenuItem help_help = new ImageMenuItem("_Help"); help_help.Image = new Gtk.Image(Gtk.Stock.Help, Gtk.IconSize.Menu); help_help.Activated += new EventHandler (help_cb); help_menu.Append (help_help); ImageMenuItem help_about = new ImageMenuItem("_About"); help_about.Image = new Gtk.Image(Gtk.Stock.DialogInfo, Gtk.IconSize.Menu); help_about.Activated += new EventHandler (about_cb); help_menu.Append (help_about); bar.Append (help_menu_item); bar.ShowAll (); vbox.PackStart(bar, true, true, 0); // create a table 6 on 10 Table tableLayout = new Table(6, 10, false); /* Label label_titre = new Label("equations :"); //label_titre.Justify = Gtk.Justification.Left; tableLayout.Attach(label_titre, 0, 6, 0, 1); */ //equation 1 Label label_y1 = new Label("Function 1 : y ="); tableLayout.Attach(label_y1, 0, 1, 0, 1); entry_eq1 = new Entry (""); tableLayout.Attach(entry_eq1, 1, 2, 0, 1); entry_eq1.Activated += new EventHandler(button_trace_click); //equation 2 Label label_y2 = new Label("Function 2 : y ="); tableLayout.Attach(label_y2, 0, 1, 1, 2); entry_eq2 = new Entry (""); tableLayout.Attach(entry_eq2, 1, 2, 1, 2); entry_eq2.Activated += new EventHandler(button_trace_click); //equation 3 Label label_y3 = new Label("Function 3 : y ="); tableLayout.Attach(label_y3, 0, 1, 2, 3); entry_eq3 = new Entry (""); tableLayout.Attach(entry_eq3, 1, 2, 2, 3); entry_eq3.Activated += new EventHandler(button_trace_click); Button button_trace = new Button (" Trace ! "); button_trace.Clicked += new EventHandler (button_trace_click); tableLayout.Attach(button_trace, 3, 4, 0, 3); //------------------------------------------------ // f(x) Label label_x_value = new Label(" x value for Fn 1 : "); tableLayout.Attach(label_x_value, 0, 1, 3, 4); entry_x_value = new Entry (""); tableLayout.Attach(entry_x_value, 1, 2, 3, 4); entry_x_value.Activated += new EventHandler(button_result_click); //Label label_egal = new Label("="); //tableLayout.Attach(label_egal, 3, 4, 1, 2); Button button_result = new Button (" f(x) = "); button_result.Clicked += new EventHandler (button_result_click); tableLayout.Attach(button_result, 2, 3, 3, 4); entry_result = new Entry (""); entry_result.IsEditable = false; tableLayout.Attach(entry_result, 3, 4, 3, 4); //------------------------------------------------ // range Label label_range = new Label(""); tableLayout.Attach(label_range, 0, 1, 4, 5); //xmin Label label_xmin = new Label("Xmin ="); tableLayout.Attach(label_xmin, 0, 1, 5, 6); entry_xmin = new Entry ("-10"); tableLayout.Attach(entry_xmin, 1, 2, 5, 6); entry_xmin.Activated += new EventHandler(button_trace_click); //xmax Label label_xmax = new Label("Xmax ="); tableLayout.Attach(label_xmax, 0, 1, 6, 7); entry_xmax = new Entry ("10"); tableLayout.Attach(entry_xmax, 1, 2, 6, 7); entry_xmax.Activated += new EventHandler(button_trace_click); //ymin Label label_ymin = new Label("Ymin ="); tableLayout.Attach(label_ymin, 0, 1, 7, 8); entry_ymin = new Entry ("-10"); tableLayout.Attach(entry_ymin, 1, 2, 7, 8); entry_ymin.Activated += new EventHandler(button_trace_click); //ymax Label label_ymax = new Label("Ymax ="); tableLayout.Attach(label_ymax, 0, 1, 8, 9); entry_ymax = new Entry ("10"); tableLayout.Attach(entry_ymax, 1, 2, 8, 9); entry_ymax.Activated += new EventHandler(button_trace_click); //graduation Label label_graduation = new Label("Scale ="); tableLayout.Attach(label_graduation, 0, 1, 9, 10); entry_graduation = new Entry ("1"); tableLayout.Attach(entry_graduation, 1, 2, 9, 10); entry_graduation.Activated += new EventHandler(button_trace_click); //initialize range Button button_initialize_range = new Button ("Initialize Range"); button_initialize_range.Clicked += new EventHandler (button_initialize_range_click); tableLayout.Attach(button_initialize_range, 3, 4, 8, 9); //initialize Button button_initialize_all = new Button ("Initialize All"); button_initialize_all.Clicked += new EventHandler (button_initialize_all_click); tableLayout.Attach(button_initialize_all, 3, 4, 7, 8); //help Button button_about = new Button ("Help"); button_about.Clicked += new EventHandler (button_about_click); tableLayout.Attach(button_about, 3, 4, 9, 10); // info label_info = new Label("Ready!"); tableLayout.Attach(label_info, 3, 4, 5, 6); vbox.PackStart(tableLayout,true,true,0); tableLayout.ShowAll(); //this.Add (tableLayout); this.Add(vbox); this.ShowAll (); // range initialization x_min = -10f; x_max = 10f; y_min = -10f; y_max = 10f; graduation = 1f; //Ecran_Form ecran = new Ecran_Form(" ", x_min, x_max, y_min, y_max, graduation); //ecran.equation = "test"; //f.Show(); /* Pango.Layout layout; layout = new Pango.Layout (this.PangoContext); layout.Wrap = Pango.WrapMode.Word; layout.FontDescription = FontDescription.FromString ("Tahoma 16"); layout.SetMarkup ("test"); this.GdkWindow.DrawLayout (this.Style.TextGC (StateType.Normal), 100, 150, layout); this.GdkWindow.DrawLine (this.Style.TextGC (StateType.Normal), 0, 0, 100, 100); //f.GdkWindow.DrawLayout (this.Style.TextGC (StateType.Normal), 100, 150, layout); */ //f.GdkWindow.DrawLine (this.Style.TextGC (StateType.Normal), 0, 0, 500, 500); } void button_result_click (object o, EventArgs args) { try{ string equation = this.entry_eq1.Text; string string_x = entry_x_value.Text; //string_x = string_x.Replace(".", "."); double x; if (equation != ""){ if (string_x != ""){ decimal decimal_x = Convert.ToDecimal(string_x); x = (double) decimal_x; } else{ x = 0f; } operation op =new operation(equation); op.corrige(); //op.decouper(); double res =op.calculer(x); this.entry_result.Text=Convert.ToString(res); double res_verif = res; if(Double.IsNaN(res_verif)){ this.entry_result.Text = "NaN"; label_info.Text = "Error!"; } else{ label_info.Text = "Ready!"; } } } catch(Exception ex) { label_info.Text = "Error!"; this.entry_result.Text = ""; } } void button_trace_click (object o, EventArgs args) { try{ if( ( this.entry_eq1.Text != "" || this.entry_eq2.Text != "" || this.entry_eq3.Text != "") && entry_xmin.Text != "" && entry_xmax.Text != "" && entry_ymin.Text != "" && entry_ymax.Text != "" && entry_graduation.Text != "" ){ decimal decimal_xmin = Convert.ToDecimal(entry_xmin.Text); x_min = (double) decimal_xmin; decimal decimal_xmax = Convert.ToDecimal(entry_xmax.Text); x_max = (double) decimal_xmax; decimal decimal_ymin = Convert.ToDecimal(entry_ymin.Text); y_min = (double) decimal_ymin; decimal decimal_ymax = Convert.ToDecimal(entry_ymax.Text); y_max = (double) decimal_ymax; decimal decimal_graduation = Convert.ToDecimal(entry_graduation.Text); graduation = (double) decimal_graduation; if( x_min < x_max && y_min < y_max && graduation >0){ Ecran_Form ecran = new Ecran_Form(entry_eq1.Text, entry_eq2.Text, entry_eq3.Text, x_min, x_max, y_min, y_max, graduation); label_info.Text = "Ready!"; } else{ label_info.Text = "Range error!"; } } else{ if(this.entry_eq1.Text == "" && this.entry_eq2.Text == "" && this.entry_eq3.Text == ""){ label_info.Text = "No equation!"; } else{ label_info.Text = "Range error!"; } } } catch(Exception ex) { label_info.Text = "Range error!"; } } void button_initialize_range_click (object o, EventArgs args) { entry_xmin.Text = "-10"; entry_xmax.Text = "10"; entry_ymin.Text = "-10"; entry_ymax.Text = "10"; entry_graduation.Text = "1"; } void button_initialize_all_click (object o, EventArgs args) { entry_eq1.Text = ""; entry_eq2.Text = ""; entry_eq3.Text = ""; entry_x_value.Text = ""; entry_result.Text = ""; entry_xmin.Text = "-10"; entry_xmax.Text = "10"; entry_ymin.Text = "-10"; entry_ymax.Text = "10"; entry_graduation.Text = "1"; } void button_about_click (object o, EventArgs args) { Help_Form help = new Help_Form(); help.Show(); } void OnMyWindowDelete (object o, DeleteEventArgs args) { Application.Quit (); } void exit_cb (object o, EventArgs args) { Application.Quit (); } void help_cb (object o, EventArgs args) { Help_Form help = new Help_Form(); help.Show(); } void about_cb (object o, EventArgs args) { About_Form about = new About_Form(); about.Show(); } } GraphMonkey-1.7-src/About_Form.cs0000644000175000017500000000440110535344700017622 0ustar lounislounis00000000000000/* * 26/11/2006 - 17:02 * * GraphMonkey - mono based graphing calculator * Copyright (C) 2006 Lounis Bellabes * nolius@users.sourceforge.net * * 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 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. */ using System; using Gtk; using GtkSharp; public class About_Form : Window { public About_Form () : base ("About") { this.Move(200,200); this.SetDefaultSize (100, 300); this.Resizable = false; Gdk.Pixbuf icon = new Gdk.Pixbuf(null, "gm.png"); this.Icon = icon; Table tableLayout = new Table(3, 1, false); //Logo Gtk.Image im_graphmonkey = new Gtk.Image(new Gdk.Pixbuf(null,"graphmonkey.png")); //Button button_logo = new Button (im_graphmonkey); //button_logo.Relief = Gtk.ReliefStyle.None; //button_logo.Clicked += new EventHandler (button_logo_click); tableLayout.Attach(im_graphmonkey, 0, 1, 0, 1); //blank //Label label_blank4 = new Label(""); //tableLayout.Attach(label_blank4, 0, 1, 1, 2); //blank Label label_blank = new Label(""); tableLayout.Attach(label_blank, 0, 1, 2, 3); //GraphMonkey Label label_monkey = new Label("GraphMonkey 1.7"); tableLayout.Attach(label_monkey, 0, 1, 3, 4); //name Label label_name = new Label(" By Lounis Bellabes "); tableLayout.Attach(label_name, 0, 1, 4, 5); //email Label label_email = new Label(" nolius@users.sourceforge.net "); tableLayout.Attach(label_email, 0, 1, 6, 7); //GPL Label label_gpl = new Label("GPL license"); tableLayout.Attach(label_gpl, 0, 1, 7, 8); tableLayout.ShowAll(); this.Add (tableLayout); this.ShowAll (); } /* void button_logo_click (object o, EventArgs args) { } */ } GraphMonkey-1.7-src/COPYING0000644000175000017500000004313110123125112016257 0ustar lounislounis00000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. GraphMonkey-1.7-src/Ecran_Form.cs0000644000175000017500000006625010535350435017614 0ustar lounislounis00000000000000/* * 26/11/2006 - 17:02 * * GraphMonkey - mono based graphing calculator * Copyright (C) 2006 Lounis Bellabes * nolius@users.sourceforge.net * * 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 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. */ using System; using Gtk; using Pango; class Ecran_Form : DrawingArea { private Gtk.Window win; private HBox hbox; private VBox vbox; //Pango.Layout layout; public string equation; public string equation2; public string equation3; public double x_min; public double x_max; public double y_min; public double y_max; public double graduation; //for color private Gdk.GC gc_red; private Gdk.GC gc_green; private Gdk.GC gc_blue; private Gdk.GC gc_a; private Gdk.GC gc_black; private Gdk.GC gc_white; private Gdk.GC gc_gray; private Gdk.GC gc_cyan; private Gdk.GC gc_orange; // for saving results public bool first_draw = true; private double[] tab_result1_x = new double[501]; private double[] tab_result1_y = new double[501]; private double[] tab_result2_x = new double[501]; private double[] tab_result2_y = new double[501]; private double[] tab_result3_x = new double[501]; private double[] tab_result3_y = new double[501]; private double[] tab_result_derivative_x = new double[501]; private double[] tab_result_derivative_y = new double[501]; private double[] tab_result_secondderivative_x = new double[501]; private double[] tab_result_secondderivative_y = new double[501]; public Label label_coord; //status of options private bool black_screen; private bool grid; // status of calculus private bool simpson; private bool derivative; private bool secondderivative; private bool extension_exist; private bool extension_show; private Statusbar statusbar; public Ecran_Form (string equation1, string equation21, string equation31, double x_min1, double x_max1, double y_min1, double y_max1, double graduation1) { /* Table tableLayout = new Table(10, 3, false); tableLayout.Attach(this, 0, 9, 0, 3); tableLayout.Attach(new Entry(), 9, 10, 0, 3); tableLayout.ShowAll(); */ this.WidthRequest = 501; this.HeightRequest = 501; vbox = new VBox(false,3); MenuBar bar = new MenuBar (); Menu calculus_menu = new Menu (); MenuItem calculus_menu_item = new MenuItem ("_Calculus"); calculus_menu_item.Submenu = calculus_menu; ImageMenuItem simpson_item = new ImageMenuItem("_Net Area Under Fn 1 [Xmin, Xmax]"); simpson_item.Image = new Gtk.Image(Gtk.Stock.GoDown, Gtk.IconSize.Menu); simpson_item.Activated += new EventHandler(simpson_cb); calculus_menu.Append(simpson_item); ImageMenuItem averagevalue_item = new ImageMenuItem("A_verage Value of Fn 1 [Xmin, Xmax]"); averagevalue_item.Image = new Gtk.Image(Gtk.Stock.Index, Gtk.IconSize.Menu); averagevalue_item.Activated += new EventHandler(averagevalue_cb); calculus_menu.Append(averagevalue_item); ImageMenuItem derivative_item = new ImageMenuItem("Graph _Derivative of Fn 1"); derivative_item.Image = new Gtk.Image(Gtk.Stock.Execute,Gtk.IconSize.Menu); derivative_item.Activated += new EventHandler(derivative_cb); calculus_menu.Append(derivative_item); ImageMenuItem secondderivative_item = new ImageMenuItem("Graph _Second Derivative of Fn 1"); secondderivative_item.Image = new Gtk.Image(Gtk.Stock.Execute,Gtk.IconSize.Menu); secondderivative_item.Activated += new EventHandler(secondderivative_cb); calculus_menu.Append(secondderivative_item); /* ImageMenuItem slopefield_item = new ImageMenuItem("Slope _Field of Fn 1 [f(x,y)]"); slopefield_item.Image = new Gtk.Image(Gtk.Stock.Execute,Gtk.IconSize.Menu); //slopefield_item.Activated += new EventHandler(slopefield_cb); calculus_menu.Append(slopefield_item); */ ImageMenuItem clear_item = new ImageMenuItem("_Clear"); clear_item.Image = new Gtk.Image(Gtk.Stock.Clear,Gtk.IconSize.Menu); clear_item.Activated += new EventHandler(clear_cb); calculus_menu.Append(clear_item); bar.Append (calculus_menu_item); Menu option_menu = new Menu (); MenuItem option_menu_item = new MenuItem ("_Options"); option_menu_item.Submenu = option_menu; ImageMenuItem wbscreen_item = new ImageMenuItem("White/Black _screen"); wbscreen_item.Image = new Gtk.Image(Gtk.Stock.Preferences, Gtk.IconSize.Menu); wbscreen_item.Activated += new EventHandler (wbscreen_cb); option_menu.Append (wbscreen_item); ImageMenuItem grid_item = new ImageMenuItem("On/Off _grid"); grid_item.Image = new Gtk.Image(Gtk.Stock.Preferences, Gtk.IconSize.Menu); grid_item.Activated += new EventHandler (grid_cb); option_menu.Append (grid_item); /* ImageMenuItem info_item = new ImageMenuItem("Curves _informations"); info_item.Image = new Gtk.Image(Gtk.Stock.DialogInfo, Gtk.IconSize.Menu); info_item.Activated += new EventHandler (info_cb); option_menu.Append (info_item); */ bar.Append (option_menu_item); bar.ShowAll (); vbox.PackStart(bar,true,true,0); vbox.PackStart(this,true,true,0); //vbox.PackStart(new Entry(),true,true,0); hbox = new HBox(false,5); Image image_GoUp = new Gtk.Image(Gtk.Stock.GoUp , Gtk.IconSize.Button); Button button_zoom_up = new Button (image_GoUp); button_zoom_up.Clicked += new EventHandler (button_zoom_up_click); hbox.PackStart(button_zoom_up,false,false,0); Image image_GoDown = new Gtk.Image(Gtk.Stock.GoDown, Gtk.IconSize.Button); Button button_zoom_down = new Button (image_GoDown); button_zoom_down.Clicked += new EventHandler (button_zoom_down_click); hbox.PackStart(button_zoom_down,false,false,0); Image image_GoBack = new Gtk.Image(Gtk.Stock.GoBack , Gtk.IconSize.Button); Button button_zoom_left = new Button (image_GoBack ); button_zoom_left.Clicked += new EventHandler (button_zoom_left_click); hbox.PackStart(button_zoom_left,false,false,0); Image image_GoForward = new Gtk.Image(Gtk.Stock.GoForward, Gtk.IconSize.Button); Button button_zoom_right = new Button (image_GoForward); button_zoom_right.Clicked += new EventHandler (button_zoom_right_click); hbox.PackStart(button_zoom_right,false,false,0); Image image_ZoomIn = new Gtk.Image(Gtk.Stock.ZoomIn, Gtk.IconSize.Button); Button button_zoom_in = new Button (image_ZoomIn); button_zoom_in.Clicked += new EventHandler (button_zoom_in_click); hbox.PackStart(button_zoom_in,false,false,0); Image image_ZoomOut = new Gtk.Image(Gtk.Stock.ZoomOut, Gtk.IconSize.Button); Button button_zoom_out = new Button (image_ZoomOut); button_zoom_out.Clicked += new EventHandler (button_zoom_out_click); hbox.PackStart(button_zoom_out,false,false,0); Image image_Zoom100 = new Gtk.Image(Gtk.Stock.Zoom100, Gtk.IconSize.Button); Button button_zoom_100 = new Button (image_Zoom100); button_zoom_100.Clicked += new EventHandler (button_zoom_100_click); hbox.PackStart(button_zoom_100,false,false,0); Image image_Save = new Gtk.Image(Gtk.Stock.Save, Gtk.IconSize.Button); Button button_save = new Button (image_Save); button_save.Clicked += new EventHandler (button_save_click); hbox.PackStart(button_save,false,false,0); label_coord = new Label ("( x ; y)"); hbox.PackEnd(label_coord,false,false,0); this.MotionNotifyEvent += new MotionNotifyEventHandler(on_mouse_move_graph); this.LeaveNotifyEvent += new LeaveNotifyEventHandler(on_mouse_leave_graph); this.Events = Gdk.EventMask.ExposureMask | Gdk.EventMask.LeaveNotifyMask | Gdk.EventMask.ButtonPressMask | Gdk.EventMask.PointerMotionMask | Gdk.EventMask.PointerMotionHintMask; vbox.PackStart(hbox,true,true,0); win = new Gtk.Window ("Screen"); Gdk.Pixbuf icon = new Gdk.Pixbuf(null, "gm.png"); win.Icon = icon; //Gdk.GC gc = new Gdk.GC (win); //Gdk.Color red_color = new Gdk.Color (0xff, 0, 0); //gc.Foreground = red_color; win.SetDefaultSize (501, 501); win.Resizable = false; this.ExposeEvent += OnExposed; win.Add (vbox); win.ShowAll (); this.equation = equation1; this.equation2 = equation21; this.equation3 = equation31; this.x_min = x_min1; this.x_max = x_max1; this.y_min = y_min1; this.y_max = y_max1; this.graduation = graduation1; this.black_screen = true; this.grid = false; this.simpson = false; this.derivative = false; this.secondderivative = false; this.extension_exist = false; this.extension_show = false; // color gc_red = new Gdk.GC (this.GdkWindow); gc_green = new Gdk.GC (this.GdkWindow); gc_blue = new Gdk.GC (this.GdkWindow); gc_a = new Gdk.GC (this.GdkWindow); gc_black = new Gdk.GC (this.GdkWindow); gc_white = new Gdk.GC (this.GdkWindow); gc_gray = new Gdk.GC (this.GdkWindow); gc_cyan = new Gdk.GC (this.GdkWindow); gc_orange = new Gdk.GC (this.GdkWindow); Gdk.Color red_color = new Gdk.Color (0xff, 0, 0); Gdk.Color green_color = new Gdk.Color (0 , 0xff, 0); Gdk.Color blue_color = new Gdk.Color (0 , 0, 0xff); Gdk.Color black_color = new Gdk.Color (0 , 0, 0); Gdk.Color a_color = new Gdk.Color (0xff, 0, 0xff); Gdk.Color white_color = new Gdk.Color (0xff, 0xff, 0xff); Gdk.Color gray_color = new Gdk.Color (195, 195, 195); Gdk.Color cyan_color = new Gdk.Color (0, 0xff, 0xff); Gdk.Color orange_color = new Gdk.Color (0xff, 140, 0); Gdk.Colormap colormap = Gdk.Colormap.System; Gdk.Color[] tab_color = new Gdk.Color[100]; tab_color[0] = red_color; tab_color[1] = green_color; tab_color[2] = blue_color; tab_color[3] = a_color; tab_color[4] = black_color; tab_color[5] = white_color; tab_color[6] = gray_color; tab_color[7] = cyan_color; tab_color[8] = orange_color; bool[] tab_bool = new bool[100]; colormap.AllocColors(tab_color, 9, true, true, tab_bool); gc_red.Foreground = tab_color[0]; gc_green.Foreground = tab_color[1]; gc_blue.Foreground = tab_color[2]; gc_a.Foreground = tab_color[3]; gc_black.Foreground = tab_color[4]; gc_white.Foreground = tab_color[5]; gc_gray.Foreground = tab_color[6]; gc_cyan.Foreground = tab_color[7]; gc_orange.Foreground = tab_color[8]; } void OnExposed (object o, ExposeEventArgs args) { trace_all(); } void trace_all() { if(first_draw){ clear_graph(); if(simpson) trace_simpson(); trace_axe(); if(derivative) trace_derivative(); if(secondderivative) trace_secondderivative(); trace_equation(); first_draw = false; } else{ clear_graph(); if(simpson) trace_simpson(); trace_axe(); if(derivative) trace_derivative(); if(secondderivative) trace_secondderivative(); trace_equation_buffer(); } } void clear_graph() { if (this.black_screen) this.GdkWindow.DrawRectangle(gc_black, true, -10, -10, 520, 520); else this.GdkWindow.DrawRectangle(gc_white, true, -10, -10, 520, 520); } // draw axes void trace_axe() { int x0 = (int) Math.Round(trans_x(0f)); int y0 = (int) Math.Round(trans_y(0f)); int xmax = (int) Math.Round(trans_x(x_max)); int xmin = (int) Math.Round(trans_x(x_min)); int ymax = (int) Math.Round(trans_y(y_max)); int ymin = (int) Math.Round(trans_y(y_min)); // graduation for x if (x_max>0){ //0 to max for(double i2=trans_x(0f); i2<=trans_x(x_max); i2=i2+ graduation*500/(x_max - x_min) ){ if (this.grid) this.GdkWindow.DrawLine(gc_gray, (int) Math.Round(i2), ymin, (int) Math.Round(i2), ymax ); this.GdkWindow.DrawLine(gc_blue, (int) Math.Round(i2), y0, (int) Math.Round(i2), y0-5 ); } } if (x_min<0){ //0 to min for(double i2=trans_x(0f); i2>=trans_x(x_min); i2=i2-graduation*500/(x_max - x_min) ){ if (this.grid) this.GdkWindow.DrawLine(gc_gray, (int) Math.Round(i2), ymin, (int) Math.Round(i2), ymax ); this.GdkWindow.DrawLine(gc_blue, (int) Math.Round(i2), y0, (int) Math.Round(i2), y0-5 ); } } // graduation for y if (y_min<0){ //0 to min for(double i2=trans_y(0f); i2<=trans_y(y_min); i2=i2+graduation*500/(y_max - y_min) ){ if (this.grid) this.GdkWindow.DrawLine(gc_gray, xmin, (int) Math.Round(i2), xmax, (int) Math.Round(i2)); this.GdkWindow.DrawLine(gc_blue, x0, (int) Math.Round(i2), x0+5, (int) Math.Round(i2)); } } if (y_max>0){ //0 to max for(double i2=trans_y(0f); i2>=trans_y(y_max); i2=i2-graduation*500/(y_max - y_min) ){ if (this.grid) this.GdkWindow.DrawLine(gc_gray, xmin, (int) Math.Round(i2), xmax,(int) Math.Round(i2)); this.GdkWindow.DrawLine(gc_blue, x0, (int) Math.Round(i2), x0+5,(int) Math.Round(i2)); } } //axe this.GdkWindow.DrawLine(gc_blue, xmin, y0, xmax, y0); this.GdkWindow.DrawLine(gc_blue, x0, ymin, x0, ymax); } // draw 3 functions void trace_equation() { Gdk.GC gc_eq; for(int i_eq=0; i_eq <3; i_eq++){ operation op = new operation(equation); gc_eq = gc_red; if(i_eq==1){ op = new operation(equation2); gc_eq = gc_a; } else if(i_eq==2){ op = new operation(equation3); gc_eq = gc_green; } op.corrige(); try{ double xc_1 = x_min; double yc_1 = op.calculer(x_min); double xc_2; double yc_2; double pitch=(x_max-x_min)/500; double x_1; double y_1; double x_2; double y_2; // save results int i_save = 0; if(i_eq ==0){ tab_result1_x[i_save] = trans_x(xc_1); tab_result1_y[i_save] = trans_y(yc_1); } else if(i_eq ==1){ tab_result2_x[i_save] = trans_x(xc_1); tab_result2_y[i_save] = trans_y(yc_1); } else if(i_eq ==2){ tab_result3_x[i_save] = trans_x(xc_1); tab_result3_y[i_save] = trans_y(yc_1); } for(double i_graph=x_min; i_graph<=x_max; i_graph=i_graph+pitch){ xc_2 = xc_1+pitch; yc_2 = op.calculer(xc_2); x_1 = trans_x(xc_1); y_1 = trans_y(yc_1); x_2 = trans_x(xc_2); y_2 = trans_y(yc_2); // save results i_save++; if(i_eq ==0){ tab_result1_x[i_save] = x_2; tab_result1_y[i_save] = y_2; } else if(i_eq ==1){ tab_result2_x[i_save] = x_2; tab_result2_y[i_save] = y_2; } else if(i_eq ==2){ tab_result3_x[i_save] = x_2; tab_result3_y[i_save] = y_2; } if(!Double.IsNaN(yc_1) && !Double.IsNaN(yc_2)){ if((yc_1>y_min && yc_1y_min && yc_20 && tab_result1_y[i]<500) || (tab_result1_y[i+1]>0 && tab_result1_y[i+1]<500)){ this.GdkWindow.DrawLine(gc_red, (int) Math.Round(tab_result1_x[i]), (int) Math.Round(tab_result1_y[i]), (int) Math.Round(tab_result1_x[i+1]), (int) Math.Round(tab_result1_y[i+1])); } } } for(int i =0; i<500; i++){ if(!Double.IsNaN(tab_result2_y[i]) && !Double.IsNaN(tab_result2_y[i+1])){ if((tab_result2_y[i]>0 && tab_result2_y[i]<500) || (tab_result2_y[i+1]>0 && tab_result2_y[i+1]<500)){ this.GdkWindow.DrawLine(gc_a, (int) Math.Round(tab_result2_x[i]), (int) Math.Round(tab_result2_y[i]), (int) Math.Round(tab_result2_x[i+1]), (int) Math.Round(tab_result2_y[i+1])); } } } for(int i =0; i<500; i++){ if(!Double.IsNaN(tab_result3_y[i]) && !Double.IsNaN(tab_result3_y[i+1])){ if((tab_result3_y[i]>0 && tab_result3_y[i]<500) || (tab_result3_y[i+1]>0 && tab_result3_y[i+1]<500)){ this.GdkWindow.DrawLine(gc_green, (int) Math.Round(tab_result3_x[i]), (int) Math.Round(tab_result3_y[i]), (int) Math.Round(tab_result3_x[i+1]), (int) Math.Round(tab_result3_y[i+1])); } } } } // drawing net aera void trace_simpson() { try{ if (first_draw){ operation op = new operation(equation); double xc_1 = x_min; double yc_1 = op.calculer(x_min); double xc_2; double yc_2; double pitch=(x_max-x_min)/500; double x_1; double y_1; double x_2; double y_2; for(double i_graph=x_min; i_graph<=x_max; i_graph=i_graph+pitch){ xc_2 = xc_1+pitch; yc_2 = op.calculer(xc_2); x_1 = trans_x(xc_1); y_1 = trans_y(yc_1); x_2 = trans_x(xc_2); y_2 = trans_y(yc_2); if(!Double.IsNaN(yc_1) && !Double.IsNaN(yc_2)){ this.GdkWindow.DrawLine(gc_red, (int) Math.Round(x_1), (int) Math.Round(trans_y(0f)), (int) Math.Round(x_1), (int) Math.Round(y_1)); this.GdkWindow.DrawLine(gc_red, (int) Math.Round(x_2), (int) Math.Round(trans_y(0f)), (int) Math.Round(x_2), (int) Math.Round(y_2)); } // next point xc_1=xc_2; yc_1=yc_2; } } else { // using buffer of Fn 1 for(int i =0; i<500; i++){ if(!Double.IsNaN(tab_result1_y[i]) && !Double.IsNaN(tab_result1_y[i+1])){ this.GdkWindow.DrawLine(gc_red, (int) Math.Round(tab_result1_x[i]), (int) Math.Round(trans_y(0f)), (int) Math.Round(tab_result1_x[i]), (int) Math.Round(tab_result1_y[i])); this.GdkWindow.DrawLine(gc_red, (int) Math.Round(tab_result1_x[i+1]), (int) Math.Round(trans_y(0f)), (int) Math.Round(tab_result1_x[i+1]), (int) Math.Round(tab_result1_y[i+1])); } } } } catch(Exception ex) { } } void trace_derivative() { try{ if (first_draw){ Calculus c = new Calculus(equation); double xc_1 = x_min; double yc_1 = c.ndfdx(this.x_min); double xc_2; double yc_2; double pitch=(x_max-x_min)/500; double x_1; double y_1; double x_2; double y_2; // save results int i_save = 0; tab_result_derivative_x[i_save] = trans_x(xc_1); tab_result_derivative_y[i_save] = trans_y(yc_1); for(double i_graph=x_min; i_graph<=x_max; i_graph=i_graph+pitch){ xc_2 = xc_1+pitch; yc_2 = c.ndfdx(xc_2); x_1 = trans_x(xc_1); y_1 = trans_y(yc_1); x_2 = trans_x(xc_2); y_2 = trans_y(yc_2); // save results i_save++; tab_result_derivative_x[i_save] = x_2; tab_result_derivative_y[i_save] = y_2; if(!Double.IsNaN(yc_1) && !Double.IsNaN(yc_2)){ if((yc_1>y_min && yc_1y_min && yc_20 && tab_result_derivative_y[i]<500) || (tab_result_derivative_y[i+1]>0 && tab_result_derivative_y[i+1]<500)){ this.GdkWindow.DrawLine(gc_cyan, (int) Math.Round(tab_result_derivative_x[i]), (int) Math.Round(tab_result_derivative_y[i]), (int) Math.Round(tab_result_derivative_x[i+1]), (int) Math.Round(tab_result_derivative_y[i+1])); } } } } } catch(Exception ex) { } } void trace_secondderivative() { try{ if (first_draw){ Calculus c = new Calculus(equation); double xc_1 = x_min; double yc_1 = c.n2dfdx(this.x_min); double xc_2; double yc_2; double pitch=(x_max-x_min)/500; double x_1; double y_1; double x_2; double y_2; // save results int i_save = 0; tab_result_secondderivative_x[i_save] = trans_x(xc_1); tab_result_secondderivative_y[i_save] = trans_y(yc_1); for(double i_graph=x_min; i_graph<=x_max; i_graph=i_graph+pitch){ xc_2 = xc_1+pitch; yc_2 = c.n2dfdx(xc_2); x_1 = trans_x(xc_1); y_1 = trans_y(yc_1); x_2 = trans_x(xc_2); y_2 = trans_y(yc_2); // save results i_save++; tab_result_secondderivative_x[i_save] = x_2; tab_result_secondderivative_y[i_save] = y_2; if(!Double.IsNaN(yc_1) && !Double.IsNaN(yc_2)){ if((yc_1>y_min && yc_1y_min && yc_20 && tab_result_secondderivative_y[i]<500) || (tab_result_secondderivative_y[i+1]>0 && tab_result_secondderivative_y[i+1]<500)){ this.GdkWindow.DrawLine(gc_orange, (int) Math.Round(tab_result_secondderivative_x[i]), (int) Math.Round(tab_result_secondderivative_y[i]), (int) Math.Round(tab_result_secondderivative_x[i+1]), (int) Math.Round(tab_result_secondderivative_y[i+1])); } } } } } catch(Exception ex) { } } // transformation on x double trans_x(double x){ return (500/(x_max - x_min) * (x - x_min) ); } // transformation on y double trans_y(double y){ return ( -500/(y_max - y_min) * (y - y_max) ); } void button_zoom_up_click (object o, EventArgs args) { first_draw = true; double diff = (y_max-y_min)/10; y_min = y_min+diff; y_max = y_max+diff; this.simpson = false; trace_all(); } void button_zoom_down_click (object o, EventArgs args) { first_draw = true; double diff = (y_max-y_min)/10; y_min = y_min-diff; y_max = y_max-diff; this.simpson = false; trace_all(); } void button_zoom_right_click (object o, EventArgs args) { first_draw = true; double diff = (x_max-x_min)/10; x_min = x_min+diff; x_max = x_max+diff; this.simpson = false; trace_all(); } void button_zoom_left_click (object o, EventArgs args) { first_draw = true; double diff = (x_max-x_min)/10; x_min = x_min-diff; x_max = x_max-diff; this.simpson = false; trace_all(); } void button_zoom_in_click (object o, EventArgs args) { first_draw = true; double diff = (y_max-y_min)/10; y_min = y_min+diff; y_max = y_max-diff; x_min = x_min+diff; x_max = x_max-diff; this.simpson = false; trace_all(); } void button_zoom_out_click (object o, EventArgs args) { first_draw = true; double diff = (y_max-y_min)/10; y_min = y_min-diff; y_max = y_max+diff; x_min = x_min-diff; x_max = x_max+diff; this.simpson = false; trace_all(); } void button_zoom_100_click (object o, EventArgs args) { first_draw = true; y_min = -10; y_max = 10; x_min = -10; x_max = 10; this.simpson = false; trace_all(); } // save graph on PNG file void button_save_click (object o, EventArgs args) { Gdk.Pixbuf dbuf = new Gdk.Pixbuf(Gdk.Colorspace.Rgb,false,8,500,500); dbuf.GetFromImage(this.GdkWindow.GetImage(0,0,500,500), this.Colormap,0,0,0,0,500,500); FileChooserDialog fc = new FileChooserDialog("Save Graph As...", null, FileChooserAction.Save); fc.LocalOnly = false; fc.AddButton (Stock.Cancel, ResponseType.Cancel); fc.AddButton (Stock.Save, ResponseType.Ok); FileFilter fil = new FileFilter(); fil.Name = "PNG Files"; fil.AddPattern("*.png"); fc.AddFilter(fil); fc.DefaultResponse = ResponseType.Ok; int resp = fc.Run(); fc.Hide(); if (resp == (int)ResponseType.Ok) dbuf.Save(fc.Filename,"png"); } void on_mouse_leave_graph(object o, LeaveNotifyEventArgs args) { label_coord.Text = "( x ; y )"; } // display (X,Y) of the mouse point void on_mouse_move_graph(object o, MotionNotifyEventArgs args) { int x=0; int y=0; Gdk.Window window = args.Event.Window; if (args.Event.IsHint) { Gdk.ModifierType s; window.GetPointer (out x, out y, out s); } else { x = (int) args.Event.X; y = (int) args.Event.Y; } label_coord.Text= "( "+Math.Round(x_min+x*((x_max-x_min)/500), 2).ToString() + " ; "+Math.Round((y_max+y*((y_max-y_min)/(-500))), 2).ToString()+" )"; args.RetVal = true; } // change color of screen void wbscreen_cb (object o, EventArgs args) { this.black_screen = !this.black_screen; trace_all(); } // display or not the grid void grid_cb (object o, EventArgs args) { this.grid = !this.grid; trace_all(); } /* void info_cb (object o, EventArgs args) { InfoCurve_Form ic = new InfoCurve_Form(); ic.Show(); } */ // Net Area void simpson_cb (object o, EventArgs args) { if(!extension_exist){ statusbar = new Statusbar(); statusbar.HeightRequest = 25; vbox.PackStart(statusbar,true,true,0); //statusbar.Push(0,"test"); win.ShowAll (); extension_exist = true; extension_show = true; } else if(!extension_show){ statusbar.Show(); extension_show = true; } first_draw = true; this.simpson = true; trace_all(); if(extension_exist){ if (this.equation != ""){ try { Calculus c = new Calculus(this.equation); double s = c.simpsonsrule(x_min, x_max); statusbar.Push(0,"Net Area Under Fn 1 = " + s.ToString()); } catch (Exception ex) { statusbar.Push(0,"Could not calculate area under curve!"); } } else statusbar.Push(0,"Fn 1 does not exist!"); } } // average value void averagevalue_cb (object o, EventArgs args) { if(!extension_exist){ statusbar = new Statusbar(); statusbar.HeightRequest = 25; vbox.PackStart(statusbar,true,true,0); //statusbar.Push(0,"test"); win.ShowAll (); extension_exist = true; extension_show = true; } else if(!extension_show){ statusbar.Show(); extension_show = true; } if(extension_exist) { if (this.equation != ""){ try { Calculus c = new Calculus(this.equation); double s = c.averagevalue(x_min, x_max); statusbar.Push(0,"Average Value of Eq 1 = " + s.ToString()); } catch (Exception ex) { statusbar.Push(0,"Could not calculate the average value!"); } } else statusbar.Push(0,"Fn 1 does not exist!"); } } // draw derivative void derivative_cb (object o, EventArgs args) { first_draw = true; this.derivative = true; trace_all(); } // draw second derivative void secondderivative_cb (object o, EventArgs args) { first_draw = true; this.secondderivative = true; trace_all(); } // clear all calculus void clear_cb (object o, EventArgs args) { if (extension_show) { statusbar.Hide(); extension_show = false; } first_draw = true; this.simpson = false; this.derivative = false; this.secondderivative = false; trace_all(); } } GraphMonkey-1.7-src/graphmonkey0000755000175000017500000000007410400365662017513 0ustar lounislounis00000000000000#!/bin/sh mono /usr/local/share/graphmonkey/GraphMonkey.exe GraphMonkey-1.7-src/HELP0000644000175000017500000000141510535344606015720 0ustar lounislounis00000000000000GraphMonkey - mono based graphing calculator Copyright (C) 2006 Lounis Bellabes nolius@users.sourceforge.net GPL license. GraphMonkey is a mono based graphing calculator. you need mono and gtk-sharp-2. you can use: + , -, *, / square root : sqrt() powers : ^ brackets sine : sin() cosine : cos() tangent : tan() arcsine : asin() arccosine : acos() arctangent : atan() hyperbolic sine : sinh() hyperbolic cosine : cosh() hyperbolic tangent : tan() natural logarithm: ln() base 10 logarithm: log() exponential : exp() absolute value: abs() greatest integer: int() It is also possible to modify the range and to do some calculations. for exemple, you can try: sin(x)*x (sqrt(x)+5)*3 2.3233^5*(x/cos(x)) NOTE: replace "." by "," if you use "," for decimal values in your country GraphMonkey-1.7-src/INSTALL0000644000175000017500000000023010401141423016250 0ustar lounislounis00000000000000Basic Installation ================== 1. make 2. mono GraphMonkey.exe and if you want to install it into your /usr/local/ (as root) : 3. make install GraphMonkey-1.7-src/Main.cs0000644000175000017500000000173710535344727016473 0ustar lounislounis00000000000000/* * 26/11/2006 - 17:02 * * GraphMonkey - mono based graphing calculator * Copyright (C) 2006 Lounis Bellabes * nolius@users.sourceforge.net * * 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 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. */ using System; using Gtk; class MainClass { public static void Main(string[] args) { Application.Init (); new GraphMonkey (); Application.Run (); } } GraphMonkey-1.7-src/Makefile0000755000175000017500000000065010532337451016705 0ustar lounislounis00000000000000CC=mcs EXEC=GraphMonkey.exe SHARE=/usr/local/share BIN=/usr/local/bin all: $(CC) -target:exe -out:"$(EXEC)" -resource:./pixmaps/graphmonkey.png -resource:./pixmaps/gm.png -pkg:gtk-sharp-2.0 ./Main.cs ./GraphMonkey.cs ./Ecran_Form.cs ./operation.cs ./Help_Form.cs ./About_Form.cs ./Calculus.cs clean: rm -rf $(EXEC) install: mkdir -p $(SHARE)/graphmonkey cp -f $(EXEC) $(SHARE)/graphmonkey cp -f graphmonkey $(BIN) GraphMonkey-1.7-src/operation.cs0000644000175000017500000004311410535344761017600 0ustar lounislounis00000000000000/* * 26/11/2006 - 17:02 * * GraphMonkey - mono based graphing calculator * Copyright (C) 2006 Lounis Bellabes * nolius@users.sourceforge.net * * 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 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. */ using System; public class operation : object{ public string phrase; public string operateur; public operation droite; public operation gauche; public operation(string phrase) { this.phrase=phrase; } public void decouper(){ //search a + (the more at rigth) not in Bracket int position_plus=this.phrase.LastIndexOf("+"); bool trouver_bon_plus = false; while (position_plus != -1 && trouver_bon_plus==false ){ if (this.compte_jusqua("(", position_plus) != this.compte_jusqua(")", position_plus) ){ position_plus = this.phrase.LastIndexOf("+", position_plus-1, position_plus); } else{ trouver_bon_plus = true; } } if (trouver_bon_plus == false){ position_plus = -1; } //search a - (the more at rigth) not in Bracket int position_moin=this.phrase.LastIndexOf("-"); bool trouver_bon_moin = false; while (position_moin != -1 && trouver_bon_moin==false ){ if (this.compte_jusqua("(", position_moin) != this.compte_jusqua(")", position_moin) ){ position_moin = this.phrase.LastIndexOf("-", position_moin-1, position_moin); } else{ trouver_bon_moin = true; } } if (trouver_bon_moin == false){ position_moin = -1; } // priority for + and - // initially a + if ( (position_plus!=-1 && position_moin==-1) || (position_plus!=-1 && position_moin!=-1 && position_plus>position_moin) ){ this.operateur = "+"; string phrase_gauche=this.phrase; phrase_gauche = phrase_gauche.Remove(position_plus,phrase_gauche.Length-position_plus); this.gauche = new operation(phrase_gauche); string phrase_droite=this.phrase; phrase_droite = phrase_droite.Remove(0,position_plus+1); this.droite = new operation(phrase_droite); } // initially a - else if ( (position_plus==-1 && position_moin!=-1) || (position_plus!=-1 && position_moin!=-1 && position_moin>position_plus) ){ this.operateur = "-"; string phrase_gauche=this.phrase; phrase_gauche = phrase_gauche.Remove(position_moin,phrase_gauche.Length-position_moin); this.gauche = new operation(phrase_gauche); string phrase_droite=this.phrase; phrase_droite = phrase_droite.Remove(0,position_moin+1); this.droite = new operation(phrase_droite); } // now * et / else { //search a * (the more at rigth) not in Bracket int position_multiplier=this.phrase.LastIndexOf("*"); bool trouver_bon_multiplier = false; while (position_multiplier != -1 && trouver_bon_multiplier==false ){ if (this.compte_jusqua("(", position_multiplier) != this.compte_jusqua(")", position_multiplier) ){ position_multiplier = this.phrase.LastIndexOf("*", position_multiplier-1, position_multiplier); } else{ trouver_bon_multiplier = true; } } if (trouver_bon_multiplier == false){ position_multiplier= -1; } //search a / (the more at rigth) not in Bracket int position_diviser=this.phrase.LastIndexOf("/"); bool trouver_bon_diviser = false; while (position_diviser != -1 && trouver_bon_diviser==false ){ if (this.compte_jusqua("(", position_diviser) != this.compte_jusqua(")", position_diviser) ){ position_diviser = this.phrase.LastIndexOf("/", position_diviser-1, position_diviser); } else{ trouver_bon_diviser = true; } } if (trouver_bon_diviser == false){ position_diviser= -1; } // initially a * if ( (position_multiplier!=-1 && position_diviser==-1) || (position_multiplier!=-1 && position_diviser!=-1 && position_multiplier>position_diviser) ){ // initially a * this.operateur = "*"; string phrase_gauche=this.phrase; phrase_gauche = phrase_gauche.Remove(position_multiplier,phrase_gauche.Length-position_multiplier); this.gauche = new operation(phrase_gauche); string phrase_droite=this.phrase; phrase_droite = phrase_droite.Remove(0,position_multiplier+1); this.droite = new operation(phrase_droite); } // initially a / else if ( (position_multiplier==-1 && position_diviser!=-1) || (position_multiplier!=-1 && position_diviser!=-1 && position_diviser>position_multiplier) ){ // initially a / this.operateur = "/"; string phrase_gauche=this.phrase; phrase_gauche = phrase_gauche.Remove(position_diviser,phrase_gauche.Length-position_diviser); this.gauche = new operation(phrase_gauche); string phrase_droite=this.phrase; phrase_droite = phrase_droite.Remove(0,position_diviser+1); this.droite = new operation(phrase_droite); } // now ^ else{ //search a ^ (the more at rigth) not in Bracket int position_puissance=this.phrase.IndexOf("^"); bool trouver_bon_puissance = false; while (position_puissance != -1 && trouver_bon_puissance==false ){ if (this.compte_jusqua("(", position_puissance) != this.compte_jusqua(")", position_puissance) ){ position_puissance = this.phrase.IndexOf("^", position_puissance+1); } else{ trouver_bon_puissance = true; } } if (trouver_bon_puissance == false){ position_puissance= -1; } if ( (position_puissance!=-1) ){ // there is a ^ this.operateur = "^"; string phrase_gauche=this.phrase; phrase_gauche = phrase_gauche.Remove(position_puissance,phrase_gauche.Length-position_puissance); this.gauche = new operation(phrase_gauche); string phrase_droite=this.phrase; phrase_droite = phrase_droite.Remove(0,position_puissance+1); this.droite = new operation(phrase_droite); } else{ // there is no + - / * or ^ so phrase is like "(2+x-3)" or "2" or "x" or r(2*x)... //if phrase is in bracket (2+x-3), delete bracket if (this.phrase.StartsWith("(")){ this.operateur="()"; string phrase_gauche=this.phrase; phrase_gauche = phrase_gauche.Remove(0,1); //delete "(" in beginning phrase_gauche = phrase_gauche.Remove(phrase_gauche.Length-1,1); //delete ")" in end this.gauche = new operation(phrase_gauche); } else if (this.phrase.StartsWith("sqrt(")){ // root square this.operateur = "sqrt()"; string phrase_gauche = this.phrase; phrase_gauche = phrase_gauche.Remove(0,5); //delete "sqrt(" in beginning phrase_gauche = phrase_gauche.Remove(phrase_gauche.Length-1,1); //delete ")" in end this.gauche = new operation(phrase_gauche); } else if (this.phrase.StartsWith("cos(")){ // cos this.operateur = "cos()"; string phrase_gauche = this.phrase; phrase_gauche = phrase_gauche.Remove(0,4); //delete "cos(" in beginning phrase_gauche = phrase_gauche.Remove(phrase_gauche.Length-1,1); //delete ")" in end this.gauche = new operation(phrase_gauche); } else if (this.phrase.StartsWith("sin(")){ // sin this.operateur = "sin()"; string phrase_gauche = this.phrase; phrase_gauche = phrase_gauche.Remove(0,4); //delete "sin(" in beginning phrase_gauche = phrase_gauche.Remove(phrase_gauche.Length-1,1); //delete ")" in end this.gauche = new operation(phrase_gauche); } else if (this.phrase.StartsWith("tan(")){ // tan this.operateur = "tan()"; string phrase_gauche = this.phrase; phrase_gauche = phrase_gauche.Remove(0,4); //delete "tan(" in beginning phrase_gauche = phrase_gauche.Remove(phrase_gauche.Length-1,1); //delete ")" in end this.gauche = new operation(phrase_gauche); } else if (this.phrase.StartsWith("ln(")){ // ln this.operateur = "ln()"; string phrase_gauche = this.phrase; phrase_gauche = phrase_gauche.Remove(0,3); //delete "ln(" in beginning phrase_gauche = phrase_gauche.Remove(phrase_gauche.Length-1,1); //delete ")" in end this.gauche = new operation(phrase_gauche); } else if (this.phrase.StartsWith("log(")){ // log this.operateur = "log()"; string phrase_gauche = this.phrase; phrase_gauche = phrase_gauche.Remove(0,4); //delete "log(" in beginning phrase_gauche = phrase_gauche.Remove(phrase_gauche.Length-1,1); //delete ")" in end this.gauche = new operation(phrase_gauche); } else if (this.phrase.StartsWith("acos(")){ // acos this.operateur = "acos()"; string phrase_gauche = this.phrase; phrase_gauche = phrase_gauche.Remove(0,5); //delete "acos(" in beginningt phrase_gauche = phrase_gauche.Remove(phrase_gauche.Length-1,1); //delete ")" in end this.gauche = new operation(phrase_gauche); } else if (this.phrase.StartsWith("asin(")){ // asin this.operateur = "asin()"; string phrase_gauche = this.phrase; phrase_gauche = phrase_gauche.Remove(0,5); //delete "asin(" in beginning phrase_gauche = phrase_gauche.Remove(phrase_gauche.Length-1,1); //delete ")" in end this.gauche = new operation(phrase_gauche); } else if (this.phrase.StartsWith("atan(")){ // atan this.operateur = "atan()"; string phrase_gauche = this.phrase; phrase_gauche = phrase_gauche.Remove(0,5); //delete "atan(" in beginning phrase_gauche = phrase_gauche.Remove(phrase_gauche.Length-1,1); //on supprime le ")" de la fin this.gauche = new operation(phrase_gauche); } else if (this.phrase.StartsWith("cosh(")){ // cosh this.operateur = "cosh()"; string phrase_gauche = this.phrase; phrase_gauche = phrase_gauche.Remove(0,5); //delete "cosh(" in beginning phrase_gauche = phrase_gauche.Remove(phrase_gauche.Length-1,1); //delete ")" in end this.gauche = new operation(phrase_gauche); } else if (this.phrase.StartsWith("sinh(")){ // sinh this.operateur = "sinh()"; string phrase_gauche = this.phrase; phrase_gauche = phrase_gauche.Remove(0,5); //delete "sinh(" in beginning phrase_gauche = phrase_gauche.Remove(phrase_gauche.Length-1,1); //delete ")" in end this.gauche = new operation(phrase_gauche); } else if (this.phrase.StartsWith("tanh(")){ // tanh this.operateur = "tanh()"; string phrase_gauche = this.phrase; phrase_gauche = phrase_gauche.Remove(0,5); //delete "tanh(" in beginning phrase_gauche = phrase_gauche.Remove(phrase_gauche.Length-1,1); //delete ")" in end this.gauche = new operation(phrase_gauche); } else if (this.phrase.StartsWith("exp(")){ // exp this.operateur = "exp()"; string phrase_gauche = this.phrase; phrase_gauche = phrase_gauche.Remove(0,4); //delete "exp(" in beginning phrase_gauche = phrase_gauche.Remove(phrase_gauche.Length-1,1); //delete ")" in end this.gauche = new operation(phrase_gauche); } else if (this.phrase.StartsWith("abs(")){ // abs this.operateur = "abs()"; string phrase_gauche = this.phrase; phrase_gauche = phrase_gauche.Remove(0,4); //delete "abs(" in beginning phrase_gauche = phrase_gauche.Remove(phrase_gauche.Length-1,1); //delete ")" in end this.gauche = new operation(phrase_gauche); } else if (this.phrase.StartsWith("int(")){ // int this.operateur = "int()"; string phrase_gauche = this.phrase; phrase_gauche = phrase_gauche.Remove(0,4); //delete "int(" in beginning phrase_gauche = phrase_gauche.Remove(phrase_gauche.Length-1,1); //delete ")" in end this.gauche = new operation(phrase_gauche); } } } } } public void corrige(){ if (this.phrase.StartsWith("-")){ this.phrase = this.phrase.Insert(0, "0"); } this.phrase = this.phrase.Replace("X", "x"); this.phrase = this.phrase.Replace("(-", "(0-"); this.phrase = this.phrase.Replace("x(", "x*("); this.phrase = this.phrase.Replace("0(", "0*("); this.phrase = this.phrase.Replace("1(", "1*("); this.phrase = this.phrase.Replace("2(", "2*("); this.phrase = this.phrase.Replace("3(", "3*("); this.phrase = this.phrase.Replace("4(", "4*("); this.phrase = this.phrase.Replace("5(", "5*("); this.phrase = this.phrase.Replace("6(", "6*("); this.phrase = this.phrase.Replace("7(", "7*("); this.phrase = this.phrase.Replace("8(", "8*("); this.phrase = this.phrase.Replace("9(", "9*("); this.phrase = this.phrase.Replace(")x", ")*x"); this.phrase = this.phrase.Replace("0x", "0*x"); this.phrase = this.phrase.Replace("1x", "1*x"); this.phrase = this.phrase.Replace("2x", "2*x"); this.phrase = this.phrase.Replace("3x", "3*x"); this.phrase = this.phrase.Replace("4x", "4*x"); this.phrase = this.phrase.Replace("5x", "5*x"); this.phrase = this.phrase.Replace("6x", "6*x"); this.phrase = this.phrase.Replace("7x", "7*x"); this.phrase = this.phrase.Replace("8x", "8*x"); this.phrase = this.phrase.Replace("9x", "9*x"); this.phrase = this.phrase.Replace(")(", ")*("); } public double calculer(double x){ double resultat=0; //this.corrige(); this.decouper(); // cas: + - * / ^ if(this.gauche!=null && this.droite!=null){ if(this.operateur=="+"){ resultat=this.gauche.calculer(x)+this.droite.calculer(x); return resultat; } else if(this.operateur=="*"){ resultat=this.gauche.calculer(x)*this.droite.calculer(x); return resultat; } else if(this.operateur=="-"){ resultat=this.gauche.calculer(x)-this.droite.calculer(x); return resultat; } else if(this.operateur=="/"){ resultat=this.gauche.calculer(x)/this.droite.calculer(x); return resultat; } else if(this.operateur=="^"){ double gauche_double = this.gauche.calculer(x); double droite_double = this.droite.calculer(x); resultat = Math.Pow(gauche_double,droite_double); return resultat; } } // case: () r() cos() sin() tan() and n() else if(this.gauche!=null){ if (this.operateur=="()"){ resultat=this.gauche.calculer(x); return resultat; } else if (this.operateur=="sqrt()"){ double gauche_double = this.gauche.calculer(x); resultat = Math.Sqrt(gauche_double); return resultat; } else if (this.operateur=="cos()"){ double gauche_double = this.gauche.calculer(x); resultat = Math.Cos(gauche_double); return resultat; } else if (this.operateur=="sin()"){ double gauche_double = this.gauche.calculer(x); resultat = Math.Sin(gauche_double); return resultat; } else if (this.operateur=="tan()"){ double gauche_double = this.gauche.calculer(x); resultat = Math.Tan(gauche_double); return resultat; } else if (this.operateur=="ln()"){ double gauche_double = this.gauche.calculer(x); resultat = Math.Log(gauche_double); return resultat; } else if (this.operateur=="log()"){ double gauche_double = this.gauche.calculer(x); resultat = Math.Log10(gauche_double); return resultat; } else if (this.operateur=="acos()"){ double gauche_double = this.gauche.calculer(x); resultat = Math.Acos(gauche_double); return resultat; } else if (this.operateur=="asin()"){ double gauche_double = this.gauche.calculer(x); resultat = Math.Asin(gauche_double); return resultat; } else if (this.operateur=="atan()"){ double gauche_double = this.gauche.calculer(x); resultat = Math.Atan(gauche_double); return resultat; } else if (this.operateur=="cosh()"){ double gauche_double = this.gauche.calculer(x); resultat = Math.Cosh(gauche_double); return resultat; } else if (this.operateur=="sinh()"){ double gauche_double = this.gauche.calculer(x); resultat = Math.Sinh(gauche_double); return resultat; } else if (this.operateur=="tanh()"){ double gauche_double = this.gauche.calculer(x); resultat = Math.Tanh(gauche_double); return resultat; } else if (this.operateur=="exp()"){ double gauche_double = this.gauche.calculer(x); resultat = Math.Exp(gauche_double); return resultat; } else if (this.operateur=="abs()"){ double gauche_double = this.gauche.calculer(x); resultat = Math.Abs(gauche_double); return resultat; } else if (this.operateur=="int()"){ double gauche_double = this.gauche.calculer(x); resultat = Math.Floor(gauche_double); return resultat; } } else{ // phrase is like "x" or "2,1213" or "2" if (this.phrase=="x" || this.phrase=="X"){ return x; } else{ decimal res_d = Convert.ToDecimal(this.phrase); double res_f = (double) res_d; resultat=res_f; return resultat; } } return resultat; } // exemple: compte_jusqua("a", 3) for "aaaaaa" =>3 private int compte_jusqua(string ch, int fin){ int pos; int nb=0; bool arreter=false; int i=0; while( (i <= fin) && (arreter == false) && (i <= this.phrase.Length) ){ pos=phrase.IndexOf(ch, i, fin-i); if(pos != -1){ nb++; i=pos+1; } else{ arreter=true; } } return nb; } }